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;
}
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()));
}
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();
}
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();
}
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()));
}
Aggregations