use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method addSubmissionInsight.
@ApiOperation("Create submission insight")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/insight", method = POST)
public JsonResult<SubmissionInsightDTO> addSubmissionInsight(@PathVariable("submissionId") Long submissionId, @RequestBody @Valid SubmissionInsightDTO insightDTO) throws AlreadyExistException, NotExistException {
final SubmissionInsight insight = conversionService.convert(insightDTO, SubmissionInsight.class);
final SubmissionInsight savedInsight = submissionInsightService.createSubmissionInsight(submissionId, insight);
final SubmissionInsightDTO savedInsightDTO = conversionService.convert(savedInsight, SubmissionInsightDTO.class);
final JsonResult<SubmissionInsightDTO> result = new JsonResult<>(NO_ERROR);
result.setResult(savedInsightDTO);
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method getFileContent.
@ApiOperation("Get analysis code file.")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}/code-files/{fileUuid}", method = GET)
public JsonResult<AnalysisFileDTO> getFileContent(@PathVariable("analysisId") Long analysisId, @RequestParam(defaultValue = "true") Boolean withContent, @PathVariable("fileUuid") String uuid) throws PermissionDeniedException, NotExistException, IOException {
AnalysisFile analysisFile = analysisService.getAnalysisFile(analysisId, uuid);
AnalysisFileDTO analysisFileDTO = conversionService.convert(analysisFile, AnalysisFileDTO.class);
if (withContent) {
analysisFileDTO = (AnalysisFileDTO) FileDtoContentHandler.getInstance(analysisFileDTO, analysisService.getPath(analysisFile).toFile()).withPdfConverter(toPdfConverter::convert).handle();
}
return new JsonResult<>(NO_ERROR, analysisFileDTO);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method update.
@ApiOperation("Update analysis.")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}", method = PUT)
public JsonResult<D> update(@PathVariable("analysisId") Long id, @RequestBody @Valid AnalysisUpdateDTO analysisDTO, BindingResult binding) throws NotExistException, NotUniqueException, ValidationException {
JsonResult<D> result;
if (binding.hasErrors()) {
result = new JsonResult<>(VALIDATION_ERROR);
for (FieldError fieldError : binding.getFieldErrors()) {
result.getValidatorErrors().put(fieldError.getField(), fieldError.getDefaultMessage());
}
} else {
T analysis = conversionService.convert(analysisDTO, getAnalysisClass());
analysis.setId(id);
analysis = analysisService.update(analysis);
result = new JsonResult<>(NO_ERROR);
result.setResult(conversionService.convert(analysis, getAnalysisDTOClass()));
}
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method addCommonEntityToAnalysis.
@ApiOperation("Add common entity to analysis")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}/entities", method = POST)
public JsonResult addCommonEntityToAnalysis(@PathVariable("analysisId") Long analysisId, @RequestBody @Valid DataReferenceDTO entityReference, @RequestParam(value = "type", required = false, defaultValue = "COHORT") CommonAnalysisType analysisType, Principal principal) throws NotExistException, JMSException, IOException, PermissionDeniedException, URISyntaxException {
final IUser user = getUser(principal);
final DataNode dataNode = dataNodeService.getById(entityReference.getDataNodeId());
final T analysis = analysisService.getById(analysisId);
final DataReference dataReference = dataReferenceService.addOrUpdate(entityReference.getEntityGuid(), dataNode);
final List<MultipartFile> entityFiles = getEntityFiles(entityReference, dataNode, analysisType);
doAddCommonEntityToAnalysis(analysis, dataReference, user, analysisType, entityFiles);
return new JsonResult(NO_ERROR);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method uploadFile.
@ApiOperation("Upload file to attach to analysis.")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}/upload", method = POST)
public JsonResult<List<AnalysisFileDTO>> uploadFile(Principal principal, @Valid UploadFileDTO uploadFileDTO, @PathVariable("analysisId") Long id) throws PermissionDeniedException, NotExistException, IOException {
IUser user = getUser(principal);
T analysis = analysisService.getById(id);
JsonResult<List<AnalysisFileDTO>> result = new JsonResult<>(NO_ERROR);
List<AnalysisFileDTO> createdFiles = new ArrayList<>();
if (uploadFileDTO.getFile() != null) {
AnalysisFile createdFile = analysisService.saveFile(uploadFileDTO.getFile(), user, analysis, uploadFileDTO.getLabel(), uploadFileDTO.getExecutable(), null);
createdFiles.add(conversionService.convert(createdFile, AnalysisFileDTO.class));
} else {
if (StringUtils.hasText(uploadFileDTO.getLink())) {
AnalysisFile createdFile = analysisService.saveFile(uploadFileDTO.getLink(), user, analysis, uploadFileDTO.getLabel(), uploadFileDTO.getExecutable());
createdFiles.add(conversionService.convert(createdFile, AnalysisFileDTO.class));
} else {
result.setErrorCode(VALIDATION_ERROR.getCode());
}
}
result.setResult(createdFiles);
return result;
}
Aggregations