예제 #1
0
파일: Comment.java 프로젝트: Geneuae/ModReq
 public boolean equalsComment(Comment c) {
   if (c.getCommenter().equals(commenter)) {
     if (c.getComment().equals(comment)) {
       if (c.getDate().equals(date)) {
         return true;
       }
     }
   }
   return false;
 }
예제 #2
0
  private static final void printPostsAndComments(Blog blog) {
    UUID blogId = blog.getId();
    int maxPageToPrint = 3;
    int pageSize = 2; // 2 posts per page
    System.out.println("###################################################");
    System.out.println(blog.getBlogName().toUpperCase() + ":: by " + blog.getAuthor());
    System.out.println("###################################################");
    System.out.println("");

    try (SessionWrapper sessionWrapper = new SessionWrapper()) {
      UUID lastPostId = null;
      for (int i = 1; i <= maxPageToPrint; i++) {
        List<Post> posts = Post.getPosts(blogId, lastPostId, pageSize, sessionWrapper);
        for (Post post : posts) {
          System.out.println(
              post.getTitle().toUpperCase() + "\t" + "" + new Date(post.getPostedOn()).toString());
          PostVotes pvotes = new PostVotes().get(sessionWrapper, post.getId());
          System.out.println("Votes: +" + pvotes.getUpvotes() + "/-" + pvotes.getDownvotes());
          System.out.println("--------------------------------------------");
          System.out.println(post.getContent());
          System.out.println("Tags: " + post.getTags().toString());

          System.out.println("### COMMENTS:\n");

          List<Comment> comments = Comment.getComments(post.getId(), sessionWrapper);
          for (Comment comment : comments) {
            System.out.println("  >> " + comment.getTitle().toUpperCase());
            System.out.println("  " + comment.getContent());
            System.out.println(
                "   -- "
                    + comment.getCommenter()
                    + " on "
                    + new Date(comment.getPostedOn()).toString());
            CommentVotes cvotes = new CommentVotes().get(sessionWrapper, comment.getId());
            System.out.println("  Votes: +" + cvotes.getUpvotes() + "/-" + cvotes.getDownvotes());
            System.out.println("  -.-.-.-.-.-.-");
          }
          System.out.println();
          System.out.println("============================================");
          System.out.println();
        }
        System.out.println("END OF PAGE: " + i);
        System.out.println();
        System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
        System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
        System.out.println();
      }
    }
  }