use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO in project ArachneCentralAPI by OHDSI.
the class StudyStatusController method update.
@ApiOperation(value = "Edit study status.", hidden = true)
@RequestMapping(value = "/api/v1/admin/study-statuses/{studyStatusId}", method = RequestMethod.PUT)
public JsonResult<StudyStatusDTO> update(@PathVariable("studyStatusId") Long id, @RequestBody @Valid StudyStatusDTO studyStatusDTO, BindingResult binding) throws NotExistException, NotUniqueException, ValidationException {
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.update(studyStatus);
result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
result.setResult(conversionService.convert(studyStatus, StudyStatusDTO.class));
}
return result;
}
use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO in project ArachneCentralAPI by OHDSI.
the class StudyStatusController method get.
@ApiOperation("Get study status.")
@RequestMapping(value = "/api/v1/study-management/study-statuses/{studyStatusId}", method = RequestMethod.GET)
public JsonResult<StudyStatusDTO> get(@PathVariable("studyStatusId") Long id) throws NotExistException {
StudyStatus studyStatus = studyStatusService.getById(id);
JsonResult<StudyStatusDTO> result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
result.setResult(conversionService.convert(studyStatus, StudyStatusDTO.class));
return result;
}
use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO 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;
}
use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO in project ArachneCentralAPI by OHDSI.
the class StudyControllerTests method testUpdateStudyType.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/study/study-before-updating.xml")
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-after-updating-type.xml", assertionMode = NON_STRICT_UNORDERED) })
public void testUpdateStudyType() throws Exception {
StudyDTO updatedStudyDTO = new StudyDTO();
updatedStudyDTO.setId(STUDY_ID);
updatedStudyDTO.setDescription("description");
StudyTypeDTO type = new StudyTypeDTO(1L);
type.setName("type1");
updatedStudyDTO.setType(type);
StudyStatusDTO status = new StudyStatusDTO(STUDY_STATUS_ID, "Initiate");
updatedStudyDTO.setStatus(status);
testUpdate(updatedStudyDTO, UPDATED_STUDY_TYPE_JSON_OBJECT, "type1");
}
use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO in project ArachneCentralAPI by OHDSI.
the class StudyControllerTests method testUpdateStudyStatus.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/study/study-before-updating.xml")
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-after-updating-status.xml", assertionMode = NON_STRICT_UNORDERED) })
public void testUpdateStudyStatus() throws Exception {
StudyDTO updatedStudyDTO = new StudyDTO();
updatedStudyDTO.setId(STUDY_ID);
updatedStudyDTO.setDescription("description");
StudyTypeDTO type = new StudyTypeDTO(STUDY_TYPE_ID);
type.setName("type1");
updatedStudyDTO.setType(type);
StudyStatusDTO status = new StudyStatusDTO(2L, "Active");
updatedStudyDTO.setStatus(status);
testUpdate(updatedStudyDTO, UPDATED_STUDY_STATUS_JSON_OBJECT, "Active");
}
Aggregations