use of com.odysseusinc.arachne.portal.model.Comment in project ArachneCentralAPI by OHDSI.
the class CommentServiceImpl method getTopic.
// @Cacheable("comments") broken code here
@Override
public CommentTopic getTopic(Long id) throws NotExistException {
final CommentTopic commentTopic = commentTopicRepository.getOne(id);
if (commentTopic == null) {
final String message = String.format(TOPIC_NOT_EXIST_EXCEPTION, id);
throw new NotExistException(message, CommentTopic.class);
}
final List<Comment> comments = commentRepository.getAllByTopicIdAndParentIsNull(id);
comments.forEach(c -> Hibernate.initialize(c.getAuthor().getRoles()));
commentTopic.setComments(comments);
return commentTopic;
}
use of com.odysseusinc.arachne.portal.model.Comment in project ArachneCentralAPI by OHDSI.
the class CommentServiceImpl method list.
@Override
public Set<CommentTopic> list(Set<CommentTopic> topics, Integer size, Sort sort) {
Pageable pageable = PageRequest.of(0, size, sort);
final Page<Comment> page = commentRepository.getAllByTopicIn(topics, pageable);
final List<Comment> comments = page.getContent();
comments.forEach(comment -> connectToTopic(topics, comment));
return comments.stream().map(Comment::getTopic).collect(Collectors.toCollection(LinkedHashSet::new));
}
use of com.odysseusinc.arachne.portal.model.Comment in project ArachneCentralAPI by OHDSI.
the class BaseAdminServiceImpl method deleteSubmissionInsight.
private void deleteSubmissionInsight(SB submission) {
SubmissionInsight insight = submission.getSubmissionInsight();
if (insight == null) {
return;
}
List<SubmissionInsightSubmissionFile> submissionInsightSubmissionFiles = insight.getSubmissionInsightSubmissionFiles();
for (SubmissionInsightSubmissionFile link : submissionInsightSubmissionFiles) {
CommentTopic topic = link.getCommentTopic();
List<Comment> comments = topic.getComments();
commentService.deleteComments(comments);
commentService.deleteTopic(topic);
}
submissionInsightService.deleteSubmissionInsightSubmissionFileLinks(submissionInsightSubmissionFiles);
submissionInsightService.tryDeleteSubmissionInsight(insight.getId());
}
use of com.odysseusinc.arachne.portal.model.Comment in project ArachneCentralAPI by OHDSI.
the class CommentController method addComment.
@ApiOperation(value = "Add new comment")
@RequestMapping(value = "/api/v1/comments/{topicId}", method = RequestMethod.POST)
public JsonResult<CommentDTO> addComment(@PathVariable("topicId") Long topicId, @Validated @RequestBody CommentDTO commentDTO, Principal principal) throws PermissionDeniedException {
final IUser user = getUser(principal);
final Comment comment = conversionService.convert(commentDTO, Comment.class);
comment.setAuthor(user);
final Comment saved = commentService.addComment(topicId, commentDTO.getParentId(), comment);
JsonResult<CommentDTO> result = new JsonResult<>(NO_ERROR);
result.setResult(conversionService.convert(saved, CommentDTO.class));
return result;
}
use of com.odysseusinc.arachne.portal.model.Comment in project ArachneCentralAPI by OHDSI.
the class CommentDTOToCommentConverter method convert.
@Override
public Comment convert(CommentDTO source) {
final Comment comment = new Comment();
comment.setComment(source.getComment());
return comment;
}
Aggregations