use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult in project ArachneCentralAPI by OHDSI.
the class ProfessionalTypeController method create.
@ApiOperation(value = "Register new professional type.", hidden = true)
@RequestMapping(value = "/api/v1/admin/professional-types", method = RequestMethod.POST)
public JsonResult<CommonProfessionalTypeDTO> create(@RequestBody @Valid CommonProfessionalTypeDTO professionalTypeDTO, BindingResult binding) throws NotExistException, NotUniqueException, PermissionDeniedException {
JsonResult result;
if (binding.hasErrors()) {
result = new JsonResult<>(JsonResult.ErrorCode.VALIDATION_ERROR);
for (FieldError fieldError : binding.getFieldErrors()) {
result.getValidatorErrors().put(fieldError.getField(), fieldError.getDefaultMessage());
}
} else {
ProfessionalType professionalType = conversionService.convert(professionalTypeDTO, ProfessionalType.class);
professionalType = professionalTypeService.create(professionalType);
result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
result.setResult(conversionService.convert(professionalType, professionalTypeDTO.getClass()));
}
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult in project ArachneCentralAPI by OHDSI.
the class ProfessionalTypeController method remove.
@ApiOperation(value = "Delete professional type.", hidden = true)
@RequestMapping(value = "/api/v1/admin/professional-types/{professionalTypeId}", method = RequestMethod.DELETE)
public JsonResult<Boolean> remove(@PathVariable("professionalTypeId") Long id) throws NotExistException {
JsonResult result = null;
if (id == null) {
result = new JsonResult<>(JsonResult.ErrorCode.VALIDATION_ERROR);
result.getValidatorErrors().put("professionalTypeId", "cannot be null");
} else {
professionalTypeService.delete(id);
result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
result.setResult(Boolean.TRUE);
}
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionController method deleteSubmissionResultsByUuid.
@ApiOperation("Delete manually uploaded submission result file")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/result/{fileUuid}", method = DELETE)
public JsonResult<Boolean> deleteSubmissionResultsByUuid(@PathVariable("submissionId") Long id, @PathVariable("fileUuid") String fileUuid) {
LOGGER.info("deleting result file for submission with id={} having uuid={}", id, fileUuid);
JsonResult.ErrorCode errorCode;
Boolean hasResult;
try {
ResultFile resultFile = submissionService.getResultFileByPath(contentStorageService.getFileByIdentifier(fileUuid).getPath());
hasResult = submissionService.deleteSubmissionResultFile(id, resultFile);
errorCode = JsonResult.ErrorCode.NO_ERROR;
} catch (NotExistException e) {
LOGGER.warn("Submission was not found, id: {}", id);
errorCode = JsonResult.ErrorCode.VALIDATION_ERROR;
hasResult = false;
} catch (ValidationException e) {
LOGGER.warn("Result file was not deleted", e);
errorCode = JsonResult.ErrorCode.VALIDATION_ERROR;
hasResult = false;
}
JsonResult<Boolean> result = new JsonResult<>(errorCode);
result.setResult(hasResult);
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult 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 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;
}
Aggregations