Search in sources :

Example 1 with StudyStatusDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO 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 StudyStatusDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO 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 StudyStatusDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO in project ArachneCentralAPI by OHDSI.

the class StudyControllerTests method testUpdateStudyEndDate.

@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/study/study-before-updating.xml")
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-after-updating-end-date.xml", assertionMode = NON_STRICT) })
public void testUpdateStudyEndDate() throws Exception {
    StudyDTO updatedStudyDTO = new StudyDTO();
    updatedStudyDTO.setId(STUDY_ID);
    updatedStudyDTO.setDescription("description");
    updatedStudyDTO.setEndDate(UPDATED_DATE);
    StudyStatusDTO status = new StudyStatusDTO(STUDY_STATUS_ID, "Initiate");
    updatedStudyDTO.setStatus(status);
    testUpdate(updatedStudyDTO, UPDATED_STUDY_END_DATE_JSON_OBJECT, UPDATED_DATE);
}
Also used : CreateStudyDTO(com.odysseusinc.arachne.portal.api.v1.dto.CreateStudyDTO) StudyDTO(com.odysseusinc.arachne.portal.api.v1.dto.StudyDTO) StudyStatusDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup)

Example 4 with StudyStatusDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO in project ArachneCentralAPI by OHDSI.

the class StudyControllerTests method testUpdateStudyStartDate.

@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/study/study-before-updating.xml")
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-after-updating-start-date.xml", assertionMode = NON_STRICT) })
public void testUpdateStudyStartDate() throws Exception {
    StudyDTO updatedStudyDTO = new StudyDTO();
    updatedStudyDTO.setId(STUDY_ID);
    updatedStudyDTO.setDescription("description");
    updatedStudyDTO.setStartDate(UPDATED_DATE);
    StudyStatusDTO status = new StudyStatusDTO(STUDY_STATUS_ID, "Initiate");
    updatedStudyDTO.setStatus(status);
    testUpdate(updatedStudyDTO, UPDATED_STUDY_START_DATE_JSON_OBJECT, UPDATED_DATE);
}
Also used : CreateStudyDTO(com.odysseusinc.arachne.portal.api.v1.dto.CreateStudyDTO) StudyDTO(com.odysseusinc.arachne.portal.api.v1.dto.StudyDTO) StudyStatusDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup)

Example 5 with StudyStatusDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO in project ArachneCentralAPI by OHDSI.

the class StudyControllerTests method testUpdateStudyTitle.

@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/study/study-before-updating.xml")
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-after-updating-title.xml", assertionMode = NON_STRICT) })
public void testUpdateStudyTitle() throws Exception {
    StudyDTO updatedStudyDTO = new StudyDTO();
    updatedStudyDTO.setId(STUDY_ID);
    updatedStudyDTO.setTitle("Study Title New");
    updatedStudyDTO.setDescription("description");
    StudyTypeDTO type = new StudyTypeDTO(STUDY_TYPE_ID);
    type.setName("type");
    updatedStudyDTO.setType(type);
    StudyStatusDTO status = new StudyStatusDTO(STUDY_STATUS_ID, "Initiate");
    updatedStudyDTO.setStatus(status);
    testUpdate(updatedStudyDTO, UPDATED_STUDY_TITLE_JSON_OBJECT, UPDATED_STUDY_TITLE);
}
Also used : CreateStudyDTO(com.odysseusinc.arachne.portal.api.v1.dto.CreateStudyDTO) StudyDTO(com.odysseusinc.arachne.portal.api.v1.dto.StudyDTO) StudyStatusDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO) StudyTypeDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyTypeDTO) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases) DatabaseSetup(com.github.springtestdbunit.annotation.DatabaseSetup)

Aggregations

StudyStatusDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO)11 DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)6 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)6 CreateStudyDTO (com.odysseusinc.arachne.portal.api.v1.dto.CreateStudyDTO)6 StudyDTO (com.odysseusinc.arachne.portal.api.v1.dto.StudyDTO)6 Test (org.junit.Test)6 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)6 StudyStatus (com.odysseusinc.arachne.portal.model.StudyStatus)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 StudyTypeDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyTypeDTO)3 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 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