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;
}
Aggregations