Search in sources :

Example 6 with StudyStatus

use of com.odysseusinc.arachne.portal.model.StudyStatus 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;
}
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 7 with StudyStatus

use of com.odysseusinc.arachne.portal.model.StudyStatus in project ArachneCentralAPI by OHDSI.

the class CreateStudyStatusDTOToStudyStatusConverter method convert.

@Override
public StudyStatus convert(CreateStudyStatusDTO source) {
    StudyStatus studyStatus = new StudyStatus();
    studyStatus.setId(source.getId());
    studyStatus.setName(source.getName());
    return studyStatus;
}
Also used : StudyStatus(com.odysseusinc.arachne.portal.model.StudyStatus)

Example 8 with StudyStatus

use of com.odysseusinc.arachne.portal.model.StudyStatus in project ArachneCentralAPI by OHDSI.

the class StudyStatusDTOToStudyStatusConverter method convert.

@Override
public StudyStatus convert(StudyStatusDTO source) {
    StudyStatus studyStatus = new StudyStatus();
    studyStatus.setId(source.getId());
    studyStatus.setName(source.getName());
    return studyStatus;
}
Also used : StudyStatus(com.odysseusinc.arachne.portal.model.StudyStatus)

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