예제 #1
0
 @Override
 public int getTopicCount(int projectId) {
   Topic topicExample = new Topic(false);
   topicExample.setProjectId(projectId);
   topicExample.setStick(true);
   return topicMapper.countByExample(new TopicExample(topicExample));
 }
예제 #2
0
  @Override
  public List<Topic> getTopicListByProjectId(int projectId, int start, int limit) {
    Topic topic = new Topic(false);
    topic.setProjectId(projectId);
    topic.setStick(false);
    TopicExample example = new TopicExample(topic);
    example.setLimit(start, limit);
    example.setOrderByClause("updated desc");

    List<Topic> topics = Lists.newArrayList();
    if (start == 0) {
      topics = getCollectedTopics(projectId);
    }
    topics.addAll(topicMapper.selectByExample(example));

    for (Topic t : topics) {
      t.setExcerpt(HtmlTextParser.getPlainText(t.getExcerpt()));
      t.setLastUpdator(userMapper.selectByPrimaryKey(t.getLastUpdatorId()));
      BaseOperateItem identifiable =
          identifiableManager.getIdentifiableByTypeAndId(t.getRefType(), t.getRefId());
      if (identifiable != null) {
        t.setTargetCreator(
            userMapper.selectByPrimaryKey(((BaseProjectItem) identifiable).getCreatorId()));
      }
    }
    return topics;
  }
예제 #3
0
  @Override
  public Topic buildTopicFromComment(Comment comment, int projectId) {
    Topic topic = new Topic();
    topic.setCreated(comment.getCreated());
    topic.setExcerpt(comment.getContent());
    checkTopicExcerptLength(topic);
    topic.setLastUpdatorId(comment.getCreatorId());
    topic.setProjectId(projectId);
    topic.setRefId(comment.getAttachId());
    topic.setRefType(comment.getAttachType());

    Commentable commentable =
        (Commentable)
            identifiableManager.getIdentifiableByTypeAndId(
                comment.getAttachType(), comment.getAttachId());

    if (commentable == null) {
      return null;
    }

    topic.setTitle(commentable.getCommentSubject());
    topic.setUpdated(comment.getUpdated());
    topic.setDeleted(false);
    return topic;
  }
예제 #4
0
  @Override
  public List<Topic> getCollectedTopics(int projectId) {
    Topic topicExample = new Topic(false);
    topicExample.setProjectId(projectId);
    topicExample.setStick(true);

    return Lists.newArrayList(topicMapper.selectByExample(new TopicExample(topicExample)));
  }
예제 #5
0
 @Override
 public Topic buildTopicFromDiscussion(Discussion discussion) {
   Topic topic = new Topic();
   topic.setCreated(discussion.getCreated());
   topic.setExcerpt(discussion.getContent());
   checkTopicExcerptLength(topic);
   topic.setLastUpdatorId(discussion.getCreatorId());
   topic.setProjectId(discussion.getProjectId());
   topic.setRefId(discussion.getId());
   topic.setRefType(discussion.getType());
   topic.setTitle(discussion.getSubject());
   topic.setUpdated(discussion.getUpdated());
   topic.setDeleted(false);
   return topic;
 }