use of com.odysseusinc.arachne.portal.model.SubmissionInsight in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method updateSubmissionInsight.
@ApiOperation("Update submission insight")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/insight", method = PUT)
public JsonResult<SubmissionInsightDTO> updateSubmissionInsight(@PathVariable("submissionId") Long submissionId, @RequestBody SubmissionInsightUpdateDTO insightDTO) throws NotExistException {
final SubmissionInsight insight = conversionService.convert(insightDTO, SubmissionInsight.class);
final SubmissionInsight updatedInsight = submissionInsightService.updateSubmissionInsight(submissionId, insight);
final SubmissionInsightDTO updatedInsightDTO = conversionService.convert(updatedInsight, SubmissionInsightDTO.class);
final JsonResult<SubmissionInsightDTO> result = new JsonResult<>(NO_ERROR);
result.setResult(updatedInsightDTO);
return result;
}
use of com.odysseusinc.arachne.portal.model.SubmissionInsight 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