Search in sources :

Example 1 with SubmissionInsightSubmissionFile

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

the class SubmissionInsightSubmissionFileToCommentableSubmissionFileDTOConverter method convert.

@Override
public CommentableSubmissionFileDTO convert(SubmissionInsightSubmissionFile submissionInsightSubmissionFile) {
    final CommentableSubmissionFileDTO dto = new CommentableSubmissionFileDTO();
    final SubmissionFile submissionFile = submissionInsightSubmissionFile.getSubmissionFile();
    dto.setLabel(submissionFile.getLabel());
    dto.setUuid(submissionFile.getUuid());
    dto.setName(submissionFile.getRealName());
    dto.setCreated(submissionFile.getCreated());
    dto.setCommentTopicId(submissionInsightSubmissionFile.getCommentTopic().getId());
    dto.setCommentCount(submissionInsightSubmissionFile.getCommentTopic().getCount());
    dto.setAuthor(conversionService.convert(submissionFile.getAuthor(), UserInfoDTO.class));
    dto.setDocType(submissionInsightSubmissionFile.getSubmissionFile().getContentType());
    dto.setFileId(submissionFile.getId());
    return dto;
}
Also used : UserInfoDTO(com.odysseusinc.arachne.portal.api.v1.dto.UserInfoDTO) CommentableSubmissionFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.CommentableSubmissionFileDTO) SubmissionInsightSubmissionFile(com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile) SubmissionFile(com.odysseusinc.arachne.portal.model.SubmissionFile)

Example 2 with SubmissionInsightSubmissionFile

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

the class BaseSubmissionInsightServiceImpl method extractCommentTopics.

private Set<CommentTopic> extractCommentTopics(SubmissionInsight insight) {
    final Stream<CommentTopic> submissionFilesTopics = insight.getSubmissionInsightSubmissionFiles().stream().map(SubmissionInsightSubmissionFile::getCommentTopic);
    final Submission submission = insight.getSubmission();
    final Stream<CommentTopic> resultFileTopics = submission.getResultFiles().stream().map(ResultFile::getCommentTopic);
    return Stream.concat(submissionFilesTopics, resultFileTopics).map(commentTopic -> {
        commentTopic.setComments(new LinkedList<>());
        return commentTopic;
    }).collect(Collectors.toSet());
}
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) SubmissionInsightSubmissionFile(com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) ResultFile(com.odysseusinc.arachne.portal.model.ResultFile) LinkedList(java.util.LinkedList)

Example 3 with SubmissionInsightSubmissionFile

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

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

the class BaseArachneSecureServiceImpl method getRolesByCommentTopic.

@Override
public List<ParticipantRole> getRolesByCommentTopic(ArachneUser user, CommentTopic topic) {
    SubmissionInsightSubmissionFile submissionInsightLink = submissionInsightSubmissionFileRepository.findByCommentTopic(topic);
    SubmissionInsight insight;
    if (submissionInsightLink == null) {
        ResultFile resultFile = resultFileRepository.findByCommentTopic(topic);
        insight = resultFile.getSubmission().getSubmissionInsight();
    } else {
        insight = submissionInsightLink.getSubmissionInsight();
    }
    return getRolesByInsight(user, insight);
}
Also used : SubmissionInsightSubmissionFile(com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile) SubmissionInsight(com.odysseusinc.arachne.portal.model.SubmissionInsight) ResultFile(com.odysseusinc.arachne.portal.model.ResultFile)

Example 5 with SubmissionInsightSubmissionFile

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

Aggregations

SubmissionInsightSubmissionFile (com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile)5 SubmissionInsight (com.odysseusinc.arachne.portal.model.SubmissionInsight)4 CommentTopic (com.odysseusinc.arachne.portal.model.CommentTopic)3 ResultFile (com.odysseusinc.arachne.portal.model.ResultFile)3 EntityGraphUtils (com.cosium.spring.data.jpa.entity.graph.domain.EntityGraphUtils)2 AlreadyExistException (com.odysseusinc.arachne.portal.exception.AlreadyExistException)2 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)2 Submission (com.odysseusinc.arachne.portal.model.Submission)2 SubmissionStatus (com.odysseusinc.arachne.portal.model.SubmissionStatus)2 EXECUTED_PUBLISHED (com.odysseusinc.arachne.portal.model.SubmissionStatus.EXECUTED_PUBLISHED)2 FAILED_PUBLISHED (com.odysseusinc.arachne.portal.model.SubmissionStatus.FAILED_PUBLISHED)2 SubmissionInsightRepository (com.odysseusinc.arachne.portal.repository.SubmissionInsightRepository)2 SubmissionInsightSubmissionFileRepository (com.odysseusinc.arachne.portal.repository.SubmissionInsightSubmissionFileRepository)2 SubmissionResultFileRepository (com.odysseusinc.arachne.portal.repository.SubmissionResultFileRepository)2 CommentService (com.odysseusinc.arachne.portal.service.CommentService)2 SubmissionInsightService (com.odysseusinc.arachne.portal.service.submission.SubmissionInsightService)2 SubmissionService (com.odysseusinc.arachne.portal.service.submission.SubmissionService)2 EntityUtils (com.odysseusinc.arachne.portal.util.EntityUtils)2 BigInteger (java.math.BigInteger)2 Arrays (java.util.Arrays)2