Search in sources :

Example 1 with Comment

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;
}
Also used : Comment(com.odysseusinc.arachne.portal.model.Comment) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException)

Example 2 with Comment

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));
}
Also used : Comment(com.odysseusinc.arachne.portal.model.Comment) Pageable(org.springframework.data.domain.Pageable)

Example 3 with Comment

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());
}
Also used : Comment(com.odysseusinc.arachne.portal.model.Comment) SubmissionInsightSubmissionFile(com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) SubmissionInsight(com.odysseusinc.arachne.portal.model.SubmissionInsight)

Example 4 with Comment

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;
}
Also used : Comment(com.odysseusinc.arachne.portal.model.Comment) IUser(com.odysseusinc.arachne.portal.model.IUser) CommentDTO(com.odysseusinc.arachne.portal.api.v1.dto.CommentDTO) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with Comment

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;
}
Also used : Comment(com.odysseusinc.arachne.portal.model.Comment)

Aggregations

Comment (com.odysseusinc.arachne.portal.model.Comment)6 CommentTopic (com.odysseusinc.arachne.portal.model.CommentTopic)3 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)1 CommentDTO (com.odysseusinc.arachne.portal.api.v1.dto.CommentDTO)1 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)1 IUser (com.odysseusinc.arachne.portal.model.IUser)1 SubmissionInsight (com.odysseusinc.arachne.portal.model.SubmissionInsight)1 SubmissionInsightSubmissionFile (com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile)1 ApiOperation (io.swagger.annotations.ApiOperation)1 Date (java.util.Date)1 CacheEvict (org.springframework.cache.annotation.CacheEvict)1 Pageable (org.springframework.data.domain.Pageable)1 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1