use of com.odysseusinc.arachne.portal.model.Submission in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionController method downloadSubmissionGroupFileBySubmission.
@ApiOperation("Download query file of the submission group by submission.")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/files/{fileId}/download", method = GET)
public void downloadSubmissionGroupFileBySubmission(@PathVariable("submissionId") Long submissionId, @PathVariable("fileId") Long fileId, HttpServletResponse response) throws PermissionDeniedException, NotExistException, IOException {
Submission submission = submissionService.getSubmissionById(submissionId);
downloadSubmissionGroupFile(submission.getSubmissionGroup().getId(), fileId, response);
}
use of com.odysseusinc.arachne.portal.model.Submission in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionController method approveSubmissionResult.
@ApiOperation("Approve submission results for show to owner")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/approveresult", method = POST)
public JsonResult<DTO> approveSubmissionResult(Principal principal, @PathVariable("submissionId") Long submissionId, @RequestBody @Valid ApproveDTO approveDTO) throws PermissionDeniedException, NotExistException {
// ToDo remove after front will be changed
approveDTO.setIsSuccess(true);
Submission updatedSubmission = submissionService.approveSubmissionResult(submissionId, approveDTO, userService.getByEmail(principal.getName()));
DTO submissionDTO = conversionService.convert(updatedSubmission, getSubmissionDTOClass());
return new JsonResult<>(NO_ERROR, submissionDTO);
}
use of com.odysseusinc.arachne.portal.model.Submission in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionController method downloadAllSubmissionResultFiles.
@ApiOperation("Download all result files of the submission.")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/results/all", method = GET)
public void downloadAllSubmissionResultFiles(Principal principal, @PathVariable("submissionId") Long submissionId, HttpServletResponse response) throws PermissionDeniedException, NotExistException, IOException {
String archiveName = "submission_result_" + submissionId + "_" + Long.toString(System.currentTimeMillis()) + ".zip";
String contentType = "application/zip, application/octet-stream";
response.setContentType(contentType);
response.setHeader("Content-type", contentType);
response.setHeader("Content-Disposition", "attachment; filename=" + archiveName);
Submission submission = submissionService.getSubmissionById(submissionId);
IUser user = userService.getByEmail(principal.getName());
submissionService.getSubmissionResultAllFiles(user, submission.getSubmissionGroup().getAnalysis().getId(), submissionId, archiveName, response.getOutputStream());
response.flushBuffer();
}
use of com.odysseusinc.arachne.portal.model.Submission 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;
}
use of com.odysseusinc.arachne.portal.model.Submission in project ArachneCentralAPI by OHDSI.
the class AnalysisHelper method createSubmission.
public static List<Submission> createSubmission(BaseSubmissionService submissionService, List<Long> datasourceIds, IUser user, Analysis analysis) throws IOException, NotExistException, NoExecutableFileException, ValidationException {
final List<Submission> submissions = new LinkedList<>();
// removes datasourceId duplicates
Set<Long> datasourceIdSet = new HashSet<>(datasourceIds);
SubmissionGroup submissionGroup = submissionService.createSubmissionGroup(user, analysis);
for (Long datasourceId : datasourceIdSet) {
submissions.add(submissionService.createSubmission(user, analysis, datasourceId, submissionGroup));
}
return submissions;
}
Aggregations