use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.CreateStudyStatusDTO in project ArachneCentralAPI by OHDSI.
the class StudyStatusController method create.
@ApiOperation(value = "Register new study status.", hidden = true)
@RequestMapping(value = "/api/v1/admin/study-statuses", method = RequestMethod.POST)
public JsonResult<StudyStatusDTO> create(@RequestBody @Valid CreateStudyStatusDTO studyStatusDTO, BindingResult binding) throws NotExistException, NotUniqueException, PermissionDeniedException {
JsonResult<StudyStatusDTO> result;
if (binding.hasErrors()) {
result = new JsonResult<>(JsonResult.ErrorCode.VALIDATION_ERROR);
for (FieldError fieldError : binding.getFieldErrors()) {
result.getValidatorErrors().put(fieldError.getField(), fieldError.getDefaultMessage());
}
} else {
StudyStatus studyStatus = conversionService.convert(studyStatusDTO, StudyStatus.class);
studyStatus = studyStatusService.create(studyStatus);
result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
result.setResult(conversionService.convert(studyStatus, StudyStatusDTO.class));
}
return result;
}
Aggregations