Search in sources :

Example 1 with StudyTypeDTO

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

the class StudyTypeController method list.

@ApiOperation("List study types.")
@RequestMapping(value = "/api/v1/study-management/study-types", method = RequestMethod.GET)
public JsonResult<List<StudyTypeDTO>> list() {
    JsonResult result;
    try {
        Iterable<StudyType> studyTypees = studyTypeService.list();
        result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
        List<StudyTypeDTO> studyTypeDTOs = new LinkedList<>();
        for (StudyType studyType : studyTypees) {
            studyTypeDTOs.add(conversionService.convert(studyType, StudyTypeDTO.class));
        }
        result.setResult(studyTypeDTOs);
    } catch (Exception ex) {
        log.error(ex.getMessage(), ex);
        result = new JsonResult<>(JsonResult.ErrorCode.SYSTEM_ERROR);
        result.setErrorMessage(ex.getMessage());
    }
    return result;
}
Also used : StudyType(com.odysseusinc.arachne.portal.model.StudyType) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) CreateStudyTypeDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.CreateStudyTypeDTO) StudyTypeDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyTypeDTO) LinkedList(java.util.LinkedList) NotUniqueException(com.odysseusinc.arachne.portal.exception.NotUniqueException) ConverterNotFoundException(org.springframework.core.convert.ConverterNotFoundException) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with StudyTypeDTO

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

Example 3 with StudyTypeDTO

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

the class StudyTypeToStudyTypeDTOConverter method convert.

@Override
public StudyTypeDTO convert(StudyType source) {
    StudyTypeDTO dto = new StudyTypeDTO(source.getId());
    dto.setName(source.getName());
    return dto;
}
Also used : StudyTypeDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyTypeDTO)

Example 4 with StudyTypeDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyTypeDTO 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");
}
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)

Example 5 with StudyTypeDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyTypeDTO 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");
}
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

StudyTypeDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyTypeDTO)6 DatabaseSetup (com.github.springtestdbunit.annotation.DatabaseSetup)4 Test (org.junit.Test)4 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)3 CreateStudyDTO (com.odysseusinc.arachne.portal.api.v1.dto.CreateStudyDTO)3 StudyDTO (com.odysseusinc.arachne.portal.api.v1.dto.StudyDTO)3 StudyStatusDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO)3 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)3 CreateStudyTypeDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.CreateStudyTypeDTO)2 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)1 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)1 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)1 NotUniqueException (com.odysseusinc.arachne.portal.exception.NotUniqueException)1 StudyType (com.odysseusinc.arachne.portal.model.StudyType)1 ApiOperation (io.swagger.annotations.ApiOperation)1 LinkedList (java.util.LinkedList)1 ConverterNotFoundException (org.springframework.core.convert.ConverterNotFoundException)1 MvcResult (org.springframework.test.web.servlet.MvcResult)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1