Search in sources :

Example 1 with CommentNodeView

use of org.ambraproject.rhino.view.comment.CommentNodeView in project rhino by PLOS.

the class CommentCrudServiceImpl method getCommentsCreatedOn.

@Override
public ServiceResponse<Collection<CommentNodeView>> getCommentsCreatedOn(LocalDate date) {
    Collection<CommentNodeView> views = hibernateTemplate.execute(session -> {
        Query query = session.createQuery("FROM Comment WHERE DATE(created) = :date");
        query.setParameter("date", java.sql.Date.valueOf(date));
        Collection<Comment> comments = query.list();
        return comments.stream().map(commentNodeViewFactory::create).collect(Collectors.toList());
    });
    return ServiceResponse.serveView(views);
}
Also used : Comment(org.ambraproject.rhino.model.Comment) Query(org.hibernate.Query) CommentNodeView(org.ambraproject.rhino.view.comment.CommentNodeView)

Aggregations

Comment (org.ambraproject.rhino.model.Comment)1 CommentNodeView (org.ambraproject.rhino.view.comment.CommentNodeView)1 Query (org.hibernate.Query)1