コード例 #1
0
ファイル: Topic.java プロジェクト: h4ck3r88/jcommune
  /**
   * Returns first post that is newer then give time
   *
   * @param time time to looking for newer post
   * @return first post that is newer then give time or first post if there is no post that is newer
   */
  private Post getFirstNewerPost(DateTime time) {
    for (Post post : getPosts()) {
      if (post.getCreationDate().isAfter(time)) {
        return post;
      }
    }

    return getFirstPost();
  }
コード例 #2
0
ファイル: Topic.java プロジェクト: h4ck3r88/jcommune
 /** Get the date of the last modification of posts in the current topic. */
 public DateTime getLastModificationPostDate() {
   DateTime newTopicModificationDate = getFirstPost().getLastTouchedDate();
   for (Post post : posts) {
     if (post.getLastTouchedDate().isAfter(newTopicModificationDate.toInstant())) {
       newTopicModificationDate = post.getLastTouchedDate();
     }
   }
   return newTopicModificationDate;
 }
コード例 #3
0
ファイル: Topic.java プロジェクト: h4ck3r88/jcommune
 /**
  * Calculates modification date of topic taking it as last post in topic creation date. Used after
  * deletion of the post. It is necessary to save the sort order of topics in the future.
  */
 public void recalculateModificationDate() {
   DateTime newTopicModificationDate = getFirstPost().getCreationDate();
   for (Post post : posts) {
     if (post.getCreationDate().isAfter(newTopicModificationDate.toInstant())) {
       newTopicModificationDate = post.getCreationDate();
     }
   }
   modificationDate = newTopicModificationDate;
 }
コード例 #4
0
ファイル: Topic.java プロジェクト: h4ck3r88/jcommune
 /** @return content of the first post of the topic */
 public String getBodyText() {
   Post firstPost = getFirstPost();
   return firstPost.getPostContent();
 }
コード例 #5
0
ファイル: Topic.java プロジェクト: h4ck3r88/jcommune
 /**
  * Add new {@link Post} to the topic. The method sets Posts.topic field to this Topic.
  *
  * @param post post to add
  */
 public void addPost(Post post) {
   post.setTopic(this);
   updateModificationDate();
   this.posts.add(post);
 }