Package org.osforce.connect.entity.commons

Examples of org.osforce.connect.entity.commons.Statistic


      page = postService.getPostPage(page, codes);
    } else if(project!=null) {
      page = postService.getPostPage(page, project.getId(), null);
    }
    for(Post post : page.getResult()) {
      Statistic statistic = statisticService.getStatistic(Statistic.TYPE_VIEW, post.getId(), Post.NAME);
      if(statistic!=null) {
        post.setViews(statistic.getCount());
      }
    }
    model.addAttribute(AttributeKeys.PAGE_KEY_READABLE, page);
    return "blog/post-recent";
  }
View Full Code Here


  public String doListView(@RequestParam(required=false) Long categoryId,
      @RequestAttr Project project, Page<Post> page,  Model model) {
    page = postService.getPostPage(page, project.getId(), categoryId);
    for(Post post : page.getResult()) {
      // views
      Statistic statistic = statisticService.getStatistic(Statistic.TYPE_VIEW, post.getId(), Post.NAME);
      if(statistic!=null) {
        post.setViews(statistic.getCount());
      }
      // count comment
      Long commentNumber = commentService.countComment(post.getId(), Post.NAME);
      post.setCommentNumber(commentNumber);
      // favorite
View Full Code Here

  private void associateLinkedEntity(Page<Link> page) {
    for(Link link : page.getResult()) {
      Object entity = null;
      if(StringUtils.equals(link.getEntity(), Question.NAME)) {
        entity = questionService.getQuestion(link.getToId());
        Statistic statistic = statisticService.getStatistic(Statistic.TYPE_VIEW, link.getToId(), Question.NAME);
        Long views = statistic!=null ? statistic.getCount() : 0L;
        ((Question)entity).setViews(views);
      } else if (StringUtils.equals(link.getEntity(), Post.NAME)) {
        entity = postService.getPost(link.getToId());
        Statistic statistic = statisticService.getStatistic(Statistic.TYPE_VIEW, link.getToId(), Post.NAME);
        Long views = statistic!=null ? statistic.getCount() : 0L;
        ((Post)entity).setViews(views);
      } else if (StringUtils.equals(link.getEntity(), Topic.NAME)) {
        entity = topicService.getTopic(link.getToId());
        Statistic statistic = statisticService.getStatistic(Statistic.TYPE_VIEW, link.getToId(), Topic.NAME);
        Long views = statistic!=null ? statistic.getCount() : 0L;
        ((Topic)entity).setViews(views);
      } else if (StringUtils.equals(link.getEntity(), Photo.NAME)) {
        entity = photoService.getPhoto(link.getToId());
      } else if (StringUtils.equals(link.getEntity(), File.NAME)) {
        entity = fileService.getFile(link.getToId());
View Full Code Here

  public String doListView(@SessionParam String questionOrder,
      Page<Question> page, @RequestAttr Project project, Model model) {
    page = questionService.getQuestionPage(page, project, questionOrder);
    for(Question question : page.getResult()) {
      // views count
      Statistic statistic = statisticService.getStatistic(Statistic.TYPE_VIEW, question.getId(), Question.NAME);
      question.setViews(statistic!=null ? statistic.getCount() : 0);
      // tags
      List<Tag> tags = tagService.getTagList(question.getId(), Question.NAME);
      question.setTagList(tags);
    }
    model.addAttribute(AttributeKeys.PAGE_KEY_READABLE, page);
View Full Code Here

      page = topicService.getTopicPage(page, codes);
    } else if(project!=null) {
      page = topicService.getTopicPage(page, project);
    }
    for(Topic topic : page.getResult()) {
      Statistic statistic = statisticService.getStatistic(Statistic.TYPE_VIEW, topic.getId(), Topic.NAME);
      if(statistic!=null) {
        topic.setViews(statistic.getCount());
      }
    }
    model.addAttribute(AttributeKeys.PAGE_KEY_READABLE, page);
    return "discussion/topic-recent";
  }
View Full Code Here

  @Permission({"topic-view"})
  public String doListView(@RequestParam Long forumId,
      Page<Topic> page,  Model model) {
    page = topicService.getTopicPage(page, forumId);
    for(Topic topic : page.getResult()) {
      Statistic statistic = statisticService.getStatistic(Statistic.TYPE_VIEW, topic.getId(), Topic.NAME);
      if(statistic!=null) {
        topic.setViews(statistic.getCount());
      }
    }
    model.addAttribute(AttributeKeys.PAGE_KEY_READABLE, page);
    return "discussion/topic-list";
  }
View Full Code Here

      @RequestAttr Project project, Model model) {
    List<Forum> forums = forumService.getForumList(project);
    for(Forum forum : forums) {
      page = topicService.getTopicPage(page, forum.getId());
      for(Topic topic : page.getResult()) {
        Statistic statistic = statisticService.getStatistic(Statistic.TYPE_VIEW, topic.getId(), Topic.NAME);
        if(statistic!=null) {
          topic.setViews(statistic.getCount());
        }
      }
      forum.setTopics(page.getResult());
    }
    model.addAttribute(AttributeKeys.FORUM_LIST_KEY_READABLE, forums);
View Full Code Here

 
  @Override
  protected void doTask(Map<Object, Object> context) throws Exception {
    Long questionId = (Long) context.get("questionId");
    Question question = questionService.getQuestion(questionId);
    Statistic statistic = statisticService.getStatistic(Statistic.TYPE_VIEW, questionId, Question.NAME);
    if(statistic==null) {
      statistic = new Statistic(Statistic.TYPE_VIEW, questionId, Question.NAME);
    }
    Long views = statistic.countAdd();
    statistic.setProjectId(question.getProjectId());
    statisticService.createStatistic(statistic);
    //
    question.setViews(views);
    questionService.updateQuestion(question);
  }
View Full Code Here

 
  @Override
  protected void doTask(Map<Object, Object> context) throws Exception {
    Long postId = (Long) context.get("postId");
    Post post = postService.getPost(postId);
    Statistic statistic = statisticService.getStatistic(Statistic.TYPE_VIEW, postId, Post.NAME);
    if(statistic==null) {
      statistic = new Statistic(Statistic.TYPE_VIEW, postId, Post.NAME);
    }
    statistic.countAdd();
    statistic.setProjectId(post.getProjectId());
    statisticService.createStatistic(statistic);
  }
View Full Code Here

 
  @Override
  protected void doTask(Map<Object, Object> context) throws Exception {
    Long topicId = (Long) context.get("topicId");
    Topic topic = topicService.getTopic(topicId);
    Statistic statistic = statisticService.getStatistic(Statistic.TYPE_VIEW, topicId, Topic.NAME);
    if(statistic==null) {
      statistic = new Statistic(Statistic.TYPE_VIEW, topicId, Topic.NAME);
    }
    statistic.countAdd();
    statistic.setProjectId(topic.getForum().getProject().getId());
    statisticService.createStatistic(statistic);
  }
View Full Code Here

TOP

Related Classes of org.osforce.connect.entity.commons.Statistic

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.