예제 #1
0
 @Override
 public Post getPost(String postId) {
   CassandraPost foundPost = cassandraPostRepository.findOne(UUID.fromString(postId));
   List<CassandraComment> commentsForPost =
       cassandraCommentRepository.findByPostId(foundPost.getId());
   return foundPost.convertToPost(commentsForPost);
 }
예제 #2
0
 @Override
 public List<Post> getExistingPosts() {
   Iterable<CassandraPost> cassandraPosts = cassandraPostRepository.findAll();
   List<CassandraComment> cassandraComments =
       (List<CassandraComment>) cassandraCommentRepository.findAll();
   List<Post> posts = new ArrayList<>();
   for (CassandraPost cassandraPost : cassandraPosts) {
     List<CassandraComment> commentsForPost =
         cassandraComments
             .stream()
             .filter(cc -> cassandraPost.getId().equals(cc.getPostId()))
             .collect(Collectors.toList());
     Post post =
         new Post(
             cassandraPost.getId().toString(),
             cassandraPost.getMessage(),
             CassandraComment.convertToCommentList(commentsForPost));
     posts.add(post);
   }
   return posts;
 }