Search in sources :

Example 6 with CommentTopic

use of com.odysseusinc.arachne.portal.model.CommentTopic 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 7 with CommentTopic

use of com.odysseusinc.arachne.portal.model.CommentTopic in project ArachneCentralAPI by OHDSI.

the class CommentServiceImpl method addComment.

@CacheEvict(cacheNames = "comments", allEntries = true)
@Override
@PreAuthorize("hasPermission(#topicId, 'CommentTopic', " + "T(com.odysseusinc.arachne.portal.security.ArachnePermission).EDIT_INSIGHT)")
public Comment addComment(Long topicId, Long parentId, Comment comment) {
    comment.setId(null);
    comment.setDate(new Date());
    final CommentTopic topic = commentTopicRepository.getOne(topicId);
    comment.setTopic(topic);
    if (parentId != null) {
        final Comment parent = commentRepository.findOne(parentId);
        comment.setParent(parent);
    }
    return commentRepository.save(comment);
}
Also used : Comment(com.odysseusinc.arachne.portal.model.Comment) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) Date(java.util.Date) CacheEvict(org.springframework.cache.annotation.CacheEvict) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 8 with CommentTopic

use of com.odysseusinc.arachne.portal.model.CommentTopic in project ArachneCentralAPI by OHDSI.

the class BaseSubmissionInsightServiceImpl method createSubmissionInsight.

@Override
@PreAuthorize("hasPermission(#submissionId,  'Submission', " + "T(com.odysseusinc.arachne.portal.security.ArachnePermission).EDIT_ANALYSIS)")
public SubmissionInsight createSubmissionInsight(Long submissionId, SubmissionInsight insight) throws AlreadyExistException, NotExistException {
    LOGGER.info(CREATING_INSIGHT_LOG, submissionId);
    final SubmissionInsight submissionInsight = submissionInsightRepository.findOneBySubmissionId(submissionId);
    if (submissionInsight != null) {
        final String message = String.format(INSIGHT_ALREADY_EXISTS_EXCEPTION, submissionId);
        throw new AlreadyExistException(message);
    }
    final List<SubmissionStatus> allowedStatuses = Arrays.asList(EXECUTED_PUBLISHED, FAILED_PUBLISHED);
    final Submission submission = submissionService.getSubmissionByIdAndStatus(submissionId, allowedStatuses);
    throwNotExistExceptionIfNull(submission, submissionId);
    insight.setId(null);
    insight.setCreated(new Date());
    insight.setSubmission(submission);
    final SubmissionInsight savedInsight = submissionInsightRepository.save(insight);
    final List<SubmissionInsightSubmissionFile> submissionInsightSubmissionFiles = submission.getSubmissionGroup().getFiles().stream().map(sf -> new SubmissionInsightSubmissionFile(savedInsight, sf, new CommentTopic())).collect(Collectors.toList());
    submissionInsightSubmissionFileRepository.save(submissionInsightSubmissionFiles);
    final List<ResultFile> resultFiles = submission.getResultFiles();
    resultFiles.forEach(resultFile -> resultFile.setCommentTopic(new CommentTopic()));
    submissionResultFileRepository.save(resultFiles);
    return savedInsight;
}
Also used : Arrays(java.util.Arrays) Date(java.util.Date) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResultFile(com.odysseusinc.arachne.portal.model.ResultFile) EntityGraphUtils(com.cosium.spring.data.jpa.entity.graph.domain.EntityGraphUtils) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) EXECUTED_PUBLISHED(com.odysseusinc.arachne.portal.model.SubmissionStatus.EXECUTED_PUBLISHED) Submission(com.odysseusinc.arachne.portal.model.Submission) FAILED_PUBLISHED(com.odysseusinc.arachne.portal.model.SubmissionStatus.FAILED_PUBLISHED) Map(java.util.Map) BigInteger(java.math.BigInteger) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) SubmissionInsight(com.odysseusinc.arachne.portal.model.SubmissionInsight) LinkedList(java.util.LinkedList) CommentService(com.odysseusinc.arachne.portal.service.CommentService) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) Logger(org.slf4j.Logger) AlreadyExistException(com.odysseusinc.arachne.portal.exception.AlreadyExistException) SubmissionResultFileRepository(com.odysseusinc.arachne.portal.repository.SubmissionResultFileRepository) Set(java.util.Set) PostAuthorize(org.springframework.security.access.prepost.PostAuthorize) SubmissionInsightSubmissionFile(com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) SubmissionInsightRepository(com.odysseusinc.arachne.portal.repository.SubmissionInsightRepository) SubmissionService(com.odysseusinc.arachne.portal.service.submission.SubmissionService) List(java.util.List) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) EntityUtils(com.odysseusinc.arachne.portal.util.EntityUtils) Stream(java.util.stream.Stream) SubmissionInsightService(com.odysseusinc.arachne.portal.service.submission.SubmissionInsightService) SubmissionInsightSubmissionFileRepository(com.odysseusinc.arachne.portal.repository.SubmissionInsightSubmissionFileRepository) SubmissionStatus(com.odysseusinc.arachne.portal.model.SubmissionStatus) Submission(com.odysseusinc.arachne.portal.model.Submission) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) SubmissionInsight(com.odysseusinc.arachne.portal.model.SubmissionInsight) ResultFile(com.odysseusinc.arachne.portal.model.ResultFile) Date(java.util.Date) SubmissionStatus(com.odysseusinc.arachne.portal.model.SubmissionStatus) SubmissionInsightSubmissionFile(com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile) AlreadyExistException(com.odysseusinc.arachne.portal.exception.AlreadyExistException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 9 with CommentTopic

use of com.odysseusinc.arachne.portal.model.CommentTopic in project ArachneCentralAPI by OHDSI.

the class CommentTopicToCommentTopicDTOConverter method convert.

@Override
public CommentTopicDTO convert(CommentTopic source) {
    final CommentTopicDTO commentTopicDTO = new CommentTopicDTO();
    final List<CommentDTO> commentDTOS = source.getComments().stream().map(c -> conversionService.convert(c, CommentDTO.class)).collect(Collectors.toList());
    commentTopicDTO.setId(source.getId());
    commentTopicDTO.setComments(commentDTOS);
    return commentTopicDTO;
}
Also used : List(java.util.List) Component(org.springframework.stereotype.Component) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) CommentTopicDTO(com.odysseusinc.arachne.portal.api.v1.dto.CommentTopicDTO) Autowired(org.springframework.beans.factory.annotation.Autowired) BaseConversionServiceAwareConverter(com.odysseusinc.arachne.portal.api.v1.dto.converters.BaseConversionServiceAwareConverter) GenericConversionService(org.springframework.core.convert.support.GenericConversionService) CommentDTO(com.odysseusinc.arachne.portal.api.v1.dto.CommentDTO) Collectors(java.util.stream.Collectors) CommentTopicDTO(com.odysseusinc.arachne.portal.api.v1.dto.CommentTopicDTO) CommentDTO(com.odysseusinc.arachne.portal.api.v1.dto.CommentDTO)

Aggregations

CommentTopic (com.odysseusinc.arachne.portal.model.CommentTopic)9 SubmissionInsight (com.odysseusinc.arachne.portal.model.SubmissionInsight)5 Sort (org.springframework.data.domain.Sort)4 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)3 Comment (com.odysseusinc.arachne.portal.model.Comment)3 SubmissionInsightSubmissionFile (com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile)3 ApiOperation (io.swagger.annotations.ApiOperation)3 Date (java.util.Date)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Pageable (org.springframework.data.domain.Pageable)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 EntityGraphUtils (com.cosium.spring.data.jpa.entity.graph.domain.EntityGraphUtils)2 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)2 CommentTopicDTO (com.odysseusinc.arachne.portal.api.v1.dto.CommentTopicDTO)2 Commentable (com.odysseusinc.arachne.portal.api.v1.dto.Commentable)2 SubmissionInsightDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO)2 AlreadyExistException (com.odysseusinc.arachne.portal.exception.AlreadyExistException)2 ResultFile (com.odysseusinc.arachne.portal.model.ResultFile)2