Search in sources :

Example 1 with FAILED_PUBLISHED

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

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