Search in sources :

Example 1 with StudyStatus

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;
}
Also used : StudyStatus(com.odysseusinc.arachne.portal.model.StudyStatus) StudyStatusDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO) CreateStudyStatusDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.CreateStudyStatusDTO) List(java.util.List) LinkedList(java.util.LinkedList) LinkedList(java.util.LinkedList) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with StudyStatus

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;
}
Also used : StudyStatusDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO) Arrays(java.util.Arrays) Component(org.springframework.stereotype.Component) StudyState(com.odysseusinc.arachne.portal.model.statemachine.study.StudyState) BaseConversionServiceAwareConverter(com.odysseusinc.arachne.portal.api.v1.dto.converters.BaseConversionServiceAwareConverter) StudyStatus(com.odysseusinc.arachne.portal.model.StudyStatus) StudyStatusDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO)

Example 3 with StudyStatus

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;
}
Also used : Study(com.odysseusinc.arachne.portal.model.Study) StudyStatus(com.odysseusinc.arachne.portal.model.StudyStatus)

Example 4 with StudyStatus

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;
}
Also used : StudyStatusDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO) CreateStudyStatusDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.CreateStudyStatusDTO) StudyStatus(com.odysseusinc.arachne.portal.model.StudyStatus) FieldError(org.springframework.validation.FieldError) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with StudyStatus

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;
}
Also used : StudyStatus(com.odysseusinc.arachne.portal.model.StudyStatus) StudyStatusDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO) CreateStudyStatusDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.CreateStudyStatusDTO) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

StudyStatus (com.odysseusinc.arachne.portal.model.StudyStatus)8 StudyStatusDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO)5 CreateStudyStatusDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.CreateStudyStatusDTO)4 ApiOperation (io.swagger.annotations.ApiOperation)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 FieldError (org.springframework.validation.FieldError)2 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)1 BaseConversionServiceAwareConverter (com.odysseusinc.arachne.portal.api.v1.dto.converters.BaseConversionServiceAwareConverter)1 Study (com.odysseusinc.arachne.portal.model.Study)1 StudyState (com.odysseusinc.arachne.portal.model.statemachine.study.StudyState)1 Arrays (java.util.Arrays)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Component (org.springframework.stereotype.Component)1