use of org.obiba.mica.core.domain.Comment in project mica2 by obiba.
the class CommentDtos method fromDto.
@NotNull
Comment fromDto(@NotNull Mica.CommentDtoOrBuilder dto) {
Comment.Builder commentBuilder = //
Comment.newBuilder().id(//
dto.getId()).message(//
dto.getMessage()).resourceId(//
dto.getResourceId()).instanceId(dto.getInstanceId());
if (dto.hasAdmin())
commentBuilder.admin(dto.getAdmin());
Comment comment = commentBuilder.build();
if (dto.hasModifiedBy())
comment.setLastModifiedBy(dto.getModifiedBy());
TimestampsDtos.fromDto(dto.getTimestamps(), comment);
return comment;
}
use of org.obiba.mica.core.domain.Comment 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;
}
use of org.obiba.mica.core.domain.Comment in project mica2 by obiba.
the class DataAccessController method getPrivateComments.
@GetMapping("/data-access-private-comments/{id:.+}")
public ModelAndView getPrivateComments(@PathVariable String id) {
Subject subject = SecurityUtils.getSubject();
if (subject.isAuthenticated()) {
Map<String, Object> params = newParameters(id);
addDataAccessConfiguration(params);
if (!isPermitted("/data-access-request/private-comment", "VIEW"))
checkPermission("/private-comment/data-access-request", "VIEW", null);
List<Comment> comments = commentsService.findPrivateComments("/data-access-request", id);
params.put("comments", comments);
params.put("authors", comments.stream().map(AbstractAuditableDocument::getCreatedBy).distinct().collect(Collectors.toMap(u -> u, u -> userProfileService.getProfileMap(u, true))));
return new ModelAndView("data-access-private-comments", params);
} else {
return new ModelAndView("redirect:../signin?redirect=" + micaConfigService.getContextPath() + "/data-access-private-comments%2F" + id);
}
}
Aggregations