use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionController method createSubmission.
@ApiOperation("Create and send submission.")
@RequestMapping(value = "/api/v1/analysis-management/{analysisId}/submissions", method = POST)
public JsonResult<List<DTO>> createSubmission(Principal principal, @RequestBody @Validated CreateSubmissionsDTO createSubmissionsDTO, @PathVariable("analysisId") Long analysisId) throws PermissionDeniedException, NotExistException, IOException, NoExecutableFileException, ValidationException {
final JsonResult<List<DTO>> result;
if (principal == null) {
throw new PermissionDeniedException();
}
IUser user = userService.getByEmail(principal.getName());
if (user == null) {
throw new PermissionDeniedException();
}
Analysis analysis = analysisService.getById(analysisId);
final List<Submission> submissions = AnalysisHelper.createSubmission(submissionService, createSubmissionsDTO.getDataSources(), user, analysis);
final List<DTO> submissionDTOs = submissions.stream().map(s -> conversionService.convert(s, getSubmissionDTOClass())).collect(Collectors.toList());
result = new JsonResult<>(NO_ERROR);
result.setResult(submissionDTOs);
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionController method getStatusHistory.
@ApiOperation("Get status history of the submission")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/status-history", method = GET)
public JsonResult<List<SubmissionStatusHistoryElementDTO>> getStatusHistory(@PathVariable("submissionId") Long submissionId) throws NotExistException {
Submission submission = submissionService.getSubmissionById(submissionId);
List<SubmissionStatusHistoryElement> submissionStatusHistory = submissionService.getSubmissionStatusHistory(submission.getSubmissionGroup().getAnalysis().getId(), submissionId);
List<SubmissionStatusHistoryElementDTO> convert = new LinkedList<>();
for (SubmissionStatusHistoryElement submissionStatusHistoryElement : submissionStatusHistory) {
convert.add(conversionService.convert(submissionStatusHistoryElement, SubmissionStatusHistoryElementDTO.class));
}
JsonResult<List<SubmissionStatusHistoryElementDTO>> result = new JsonResult<>(NO_ERROR);
result.setResult(convert);
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method create.
@ApiOperation("Create analysis.")
@RequestMapping(value = "/api/v1/analysis-management/analyses", method = POST)
public JsonResult<D> create(Principal principal, @RequestBody @Valid A_C_DTO analysisDTO, BindingResult bindingResult) throws PermissionDeniedException, NotExistException, NotUniqueException {
JsonResult<D> result;
IUser user = getUser(principal);
if (bindingResult.hasErrors()) {
return setValidationErrors(bindingResult);
} else {
T analysis = conversionService.convert(analysisDTO, getAnalysisClass());
analysis.setAuthor(user);
analysis = analysisService.create(analysis);
afterCreate(analysis, analysisDTO);
result = new JsonResult<>(NO_ERROR);
result.setResult(conversionService.convert(analysis, getAnalysisDTOClass()));
}
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method list.
@ApiOperation("List analyses.")
@RequestMapping(value = "/api/v1/analysis-management/analyses", method = GET)
public JsonResult<List<D>> list(Principal principal, @RequestParam("study-id") Long studyId) throws PermissionDeniedException, NotExistException {
JsonResult<List<D>> result;
IUser user = userService.getByEmail(principal.getName());
if (user == null) {
result = new JsonResult<>(PERMISSION_DENIED);
return result;
}
Iterable<T> analyses = analysisService.list(user, studyId);
result = new JsonResult<>(NO_ERROR);
List<D> analysisDTOs = StreamSupport.stream(analyses.spliterator(), false).map(analysis -> conversionService.convert(analysis, getAnalysisDTOClass())).collect(Collectors.toList());
result.setResult(analysisDTOs);
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method updateCommonEntityInAnalysis.
@ApiOperation("update common entity in analysis")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}/entities/{fileUuid}", method = PUT)
public JsonResult updateCommonEntityInAnalysis(@PathVariable("analysisId") Long analysisId, @PathVariable("fileUuid") String fileUuid, @RequestParam(value = "type", required = false, defaultValue = "COHORT") CommonAnalysisType analysisType, Principal principal) throws IOException, JMSException, PermissionDeniedException, URISyntaxException {
final IUser user = getUser(principal);
final AnalysisFile analysisFile = analysisService.getAnalysisFile(analysisId, fileUuid);
T analysis = (T) analysisFile.getAnalysis();
final DataReference dataReference = analysisFile.getDataReference();
final DataReferenceDTO entityReference = new DataReferenceDTO(dataReference.getDataNode().getId(), dataReference.getGuid());
final List<MultipartFile> entityFiles = getEntityFiles(entityReference, dataReference.getDataNode(), analysisType);
analysisService.findAnalysisFilesByDataReference(analysis, dataReference).forEach(af -> {
analysisService.deleteAnalysisFile(analysis, af);
analysis.getFiles().remove(af);
});
doAddCommonEntityToAnalysis(analysis, dataReference, user, analysisType, entityFiles);
return new JsonResult(NO_ERROR);
}
Aggregations