Search in sources :

Example 1 with ParticipantDTO

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

the class ParticipantLinkToParticipantDTOConverter method convert.

@Override
public ParticipantDTO convert(ParticipantLink participantLink) {
    ParticipantDTO participantDTO = new ParticipantDTO();
    ParticipantRole role = participantLink.getRole();
    final IUser user = participantLink.getUser();
    participantDTO.setId(user.getUuid());
    participantDTO.setFullName(user.getFullName());
    participantDTO.setRole(new OptionDTO(role.name(), role.toString()));
    participantDTO.setStatus(participantLink.getStatus().toString());
    if (participantLink instanceof UserStudyExtended) {
        if (DECLINED == participantLink.getStatus() && !isEmpty(((UserStudyExtended) participantLink).getComment())) {
            participantDTO.setComment(((UserStudyExtended) participantLink).getComment());
        }
        if (role.equals(ParticipantRole.DATA_SET_OWNER)) {
            DataSource ownedDataSource = ((UserStudyExtended) participantLink).getDataSource();
            participantDTO = new DataOwnerParticipantDTO(participantDTO, ownedDataSource.getId());
        }
    }
    return participantDTO;
}
Also used : DataOwnerParticipantDTO(com.odysseusinc.arachne.portal.api.v1.dto.DataOwnerParticipantDTO) IUser(com.odysseusinc.arachne.portal.model.IUser) ParticipantDTO(com.odysseusinc.arachne.portal.api.v1.dto.ParticipantDTO) DataOwnerParticipantDTO(com.odysseusinc.arachne.portal.api.v1.dto.DataOwnerParticipantDTO) OptionDTO(com.odysseusinc.arachne.commons.api.v1.dto.OptionDTO) UserStudyExtended(com.odysseusinc.arachne.portal.model.UserStudyExtended) ParticipantRole(com.odysseusinc.arachne.portal.model.ParticipantRole) DataSource(com.odysseusinc.arachne.portal.model.DataSource)

Example 2 with ParticipantDTO

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

the class StudyControllerTests method testUpdateContributorRoleToDatasetOwner.

@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study/study-participant-before-changing-role.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-participant-before-changing-role.xml", assertionMode = NON_STRICT) })
public void testUpdateContributorRoleToDatasetOwner() throws Exception {
    UpdateParticipantDTO participantDTO = new UpdateParticipantDTO();
    participantDTO.setRole(DATA_SET_OWNER.name());
    mvc.perform(put("/api/v1/study-management/studies/" + STUDY_ID + "/participants/" + 2L).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(participantDTO))).andExpect(jsonPath("$.errorCode").value(VALIDATION_ERROR.getCode()));
}
Also used : UpdateParticipantDTO(com.odysseusinc.arachne.portal.api.v1.dto.UpdateParticipantDTO) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases)

Example 3 with ParticipantDTO

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

the class StudyControllerTests method testAddParticipant.

@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study/study-after-updating-description.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-participant-after-add.xml", assertionMode = NON_STRICT) })
public void testAddParticipant() throws Exception {
    AddStudyParticipantDTO participantDTO = new AddStudyParticipantDTO();
    participantDTO.setUserId(USER_2_UUID);
    participantDTO.setRole(CONTRIBUTOR);
    mvc.perform(post("/api/v1/study-management/studies/" + STUDY_ID + "/participants").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(participantDTO))).andExpect(NO_ERROR_CODE).andReturn();
}
Also used : AddStudyParticipantDTO(com.odysseusinc.arachne.portal.api.v1.dto.AddStudyParticipantDTO) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases)

Example 4 with ParticipantDTO

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

the class StudyControllerTests method testUpdateContributorRoleToLeadInvestigator.

@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study/study-participant-before-changing-role.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-participant-with-2-leaders.xml", assertionMode = NON_STRICT) })
public void testUpdateContributorRoleToLeadInvestigator() throws Exception {
    UpdateParticipantDTO participantDTO = new UpdateParticipantDTO();
    participantDTO.setRole(LEAD_INVESTIGATOR.name());
    mvc.perform(put("/api/v1/study-management/studies/" + STUDY_ID + "/participants/" + UserIdUtils.idToUuid(2L)).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(participantDTO))).andExpect(NO_ERROR_CODE).andReturn();
}
Also used : UpdateParticipantDTO(com.odysseusinc.arachne.portal.api.v1.dto.UpdateParticipantDTO) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases)

Example 5 with ParticipantDTO

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

the class StudyControllerTests method testAddExistedParticipant.

@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetups({ @DatabaseSetup("/data/study/study-participant.xml") })
@ExpectedDatabases({ @ExpectedDatabase(value = "/data/study/study-participant.xml", assertionMode = NON_STRICT) })
public void testAddExistedParticipant() throws Exception {
    AddStudyParticipantDTO participantDTO = new AddStudyParticipantDTO();
    participantDTO.setUserId(USER_2_UUID);
    participantDTO.setRole(CONTRIBUTOR);
    mvc.perform(post("/api/v1/study-management/studies/" + STUDY_ID + "/participants").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(participantDTO))).andExpect(jsonPath("$.errorCode").value(ALREADY_EXIST.getCode()));
}
Also used : AddStudyParticipantDTO(com.odysseusinc.arachne.portal.api.v1.dto.AddStudyParticipantDTO) DatabaseSetups(com.github.springtestdbunit.annotation.DatabaseSetups) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails) ExpectedDatabases(com.github.springtestdbunit.annotation.ExpectedDatabases)

Aggregations

DatabaseSetups (com.github.springtestdbunit.annotation.DatabaseSetups)6 ExpectedDatabases (com.github.springtestdbunit.annotation.ExpectedDatabases)6 Test (org.junit.Test)6 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)6 UpdateParticipantDTO (com.odysseusinc.arachne.portal.api.v1.dto.UpdateParticipantDTO)4 OptionDTO (com.odysseusinc.arachne.commons.api.v1.dto.OptionDTO)2 AddStudyParticipantDTO (com.odysseusinc.arachne.portal.api.v1.dto.AddStudyParticipantDTO)2 IUser (com.odysseusinc.arachne.portal.model.IUser)2 ParticipantRole (com.odysseusinc.arachne.portal.model.ParticipantRole)2 DataOwnerParticipantDTO (com.odysseusinc.arachne.portal.api.v1.dto.DataOwnerParticipantDTO)1 ParticipantDTO (com.odysseusinc.arachne.portal.api.v1.dto.ParticipantDTO)1 ParticipantExtendedDTO (com.odysseusinc.arachne.portal.api.v1.dto.ParticipantExtendedDTO)1 DataSource (com.odysseusinc.arachne.portal.model.DataSource)1 UserStudyExtended (com.odysseusinc.arachne.portal.model.UserStudyExtended)1