use of com.odysseusinc.arachne.portal.model.StudyType in project ArachneCentralAPI by OHDSI.
the class StudyTypeController method update.
@ApiOperation(value = "Edit study type.", hidden = true)
@RequestMapping(value = "/api/v1/admin/study-types/{studyTypeId}", method = RequestMethod.PUT)
public JsonResult update(@PathVariable("studyTypeId") Long id, @RequestBody @Valid StudyTypeDTO studyTypeDTO, BindingResult binding) {
JsonResult result = null;
if (binding.hasErrors()) {
result = new JsonResult<>(JsonResult.ErrorCode.VALIDATION_ERROR);
for (FieldError fieldError : binding.getFieldErrors()) {
result.getValidatorErrors().put(fieldError.getField(), fieldError.getDefaultMessage());
}
} else {
try {
StudyType studyType = conversionService.convert(studyTypeDTO, StudyType.class);
studyType = studyTypeService.update(studyType);
result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
result.setResult(studyType);
} catch (ConverterNotFoundException ex) {
log.error(ex.getMessage(), ex);
result = new JsonResult<>(JsonResult.ErrorCode.SYSTEM_ERROR);
result.setErrorMessage(ex.getMessage());
} catch (NotExistException ex) {
log.error(ex.getMessage(), ex);
result = new JsonResult<>(JsonResult.ErrorCode.VALIDATION_ERROR);
result.getValidatorErrors().put("id", "Status with id=" + id + " not found");
result.setErrorMessage(ex.getMessage());
} catch (NotUniqueException ex) {
log.error(ex.getMessage(), ex);
result = new JsonResult<>(JsonResult.ErrorCode.VALIDATION_ERROR);
result.getValidatorErrors().put(ex.getField(), ex.getMessage());
result.setErrorMessage(ex.getMessage());
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
result = new JsonResult<>(JsonResult.ErrorCode.SYSTEM_ERROR);
result.setErrorMessage(ex.getMessage());
}
}
return result;
}
use of com.odysseusinc.arachne.portal.model.StudyType in project ArachneCentralAPI by OHDSI.
the class StudyTypeDTOToStudyTypeConverter method convert.
@Override
public StudyType convert(StudyTypeDTO source) {
StudyType studyType = new StudyType();
studyType.setId(source.getId());
studyType.setName(source.getName());
return studyType;
}
use of com.odysseusinc.arachne.portal.model.StudyType in project ArachneCentralAPI by OHDSI.
the class AnalysisHelperTest method prepareStudy.
private Study prepareStudy(IUser owner) throws NotUniqueException, NotExistException {
List<Study> exists = studyRepository.findByTitle("AnalysisHelperTest#test");
if (!exists.isEmpty()) {
analysisFileRepository.deleteAll();
submissionFileRepository.deleteAll();
studyRepository.delete(exists);
}
Study study = new Study();
study.setTitle("AnalysisHelperTest#test");
StudyType studyType = studyTypeRepository.findAll().iterator().next();
Assert.notNull(studyType);
study.setType(studyType);
return studyService.create(owner, study);
}
Aggregations