use of com.odysseusinc.arachne.portal.model.StudyStatus in project ArachneCentralAPI by OHDSI.
the class StudyStatusController method list.
@ApiOperation("List study statuses.")
@RequestMapping(value = "/api/v1/study-management/study-statuses", method = RequestMethod.GET)
public JsonResult<List<StudyStatusDTO>> list() {
JsonResult<List<StudyStatusDTO>> result;
Iterable<StudyStatus> studyStatuses = studyStatusService.list();
result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
List<StudyStatusDTO> studyStatusDTOs = new LinkedList<>();
for (StudyStatus studyStatus : studyStatuses) {
studyStatusDTOs.add(conversionService.convert(studyStatus, StudyStatusDTO.class));
}
result.setResult(studyStatusDTOs);
return result;
}
use of com.odysseusinc.arachne.portal.model.StudyStatus in project ArachneCentralAPI by OHDSI.
the class StudyStatusToStudyStatusDTOConverter method convert.
@Override
public StudyStatusDTO convert(StudyStatus source) {
StudyStatusDTO dto = new StudyStatusDTO(source.getId(), source.getName());
Arrays.asList(StudyState.values()).stream().filter(ss -> ss.getStateName().equals(source.getName())).findFirst().ifPresent(ss -> dto.setAvailableActions(Arrays.stream(ss.getActions()).map(sa -> sa.name()).toArray(String[]::new)));
return dto;
}
use of com.odysseusinc.arachne.portal.model.StudyStatus in project ArachneCentralAPI by OHDSI.
the class StudyStateMachineTest method createStudy.
private Study createStudy(String statusName) {
StudyStatus status = stateMachine.getStateByName(statusName);
Study study = new Study();
study.setStatus(status);
return study;
}
use of com.odysseusinc.arachne.portal.model.StudyStatus 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.model.StudyStatus 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;
}
Aggregations