コード例 #1
0
ファイル: TopicServiceImpl.java プロジェクト: joynn/onboard
  @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;
  }
コード例 #2
0
ファイル: TopicServiceImpl.java プロジェクト: joynn/onboard
 @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;
 }
コード例 #3
0
ファイル: TopicServiceImpl.java プロジェクト: joynn/onboard
  @Override
  public Topic createOrUpdateTopic(Topic topic) {

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

    Topic t = new Topic();
    t.setRefId(topic.getRefId());
    t.setRefType(topic.getRefType());
    TopicExample example = new TopicExample(t);

    List<Topic> topics = topicMapper.selectByExample(example);
    if (topics.size() == 0) {
      createTopic(topic);
      return topic;
    } else {
      topic.setId(topics.get(0).getId());
      topic.setCreated(null);
      updateTopic(topic);
      return topic;
    }
  }