Search in sources :

Example 1 with CommentUpdatedEvent

use of org.obiba.mica.core.event.CommentUpdatedEvent in project mica2 by obiba.

the class CommentsService method save.

public Comment save(Comment comment, MailNotification<Comment> mailNotification) {
    if (comment.getMessage().isEmpty())
        throw new IllegalArgumentException("Comment message cannot be empty");
    Comment saved = comment;
    if (!comment.isNew()) {
        saved = commentsRepository.findOne(comment.getId());
        if (saved == null) {
            saved = comment;
        } else {
            BeanUtils.copyProperties(comment, saved, "id", "classId", "createdDate");
        }
        saved.setLastModifiedDate(DateTime.now());
    }
    if (mailNotification != null)
        mailNotification.send(saved);
    commentsRepository.save(saved);
    eventBus.post(new CommentUpdatedEvent(comment));
    return saved;
}
Also used : Comment(org.obiba.mica.core.domain.Comment) CommentUpdatedEvent(org.obiba.mica.core.event.CommentUpdatedEvent)

Aggregations

Comment (org.obiba.mica.core.domain.Comment)1 CommentUpdatedEvent (org.obiba.mica.core.event.CommentUpdatedEvent)1