use of com.odysseusinc.arachne.portal.model.ParticipantRole.CONTRIBUTOR in project ArachneCentralAPI by OHDSI.
the class StudyToStudyMediumDTOConverter method convert.
@Override
public StudyMediumDTO convert(Study source) {
final StudyMediumDTO studyDTO = new StudyMediumDTO();
studyDTO.setId(source.getId());
studyDTO.setTitle(source.getTitle());
studyDTO.setDescription(source.getDescription());
studyDTO.setCreated(source.getCreated());
studyDTO.setStartDate(source.getStartDate());
studyDTO.setEndDate(source.getEndDate());
studyDTO.setStatus(conversionService.convert(source.getStatus(), StudyStatusDTO.class));
final Map<ParticipantRole, List<UserStudyExtended>> studyParticipants = source.getParticipants().stream().collect(Collectors.groupingBy(link -> link.getRole() == ParticipantRole.LEAD_INVESTIGATOR ? LEAD_INVESTIGATOR : CONTRIBUTOR));
final List<UserStudyExtended> studyLeads = studyParticipants.get(LEAD_INVESTIGATOR);
if (!CollectionUtils.isEmpty(studyLeads)) {
studyDTO.setStudyLeads(studyLeads.stream().filter(distinctByKey(p -> p.getUser().getId())).map(studyParticipant -> conversionService.convert(studyParticipant, ParticipantDTO.class)).collect(Collectors.toList()));
}
final List<UserStudyExtended> studyContributors = studyParticipants.get(CONTRIBUTOR);
if (!CollectionUtils.isEmpty(studyContributors)) {
studyDTO.setStudyParticipants(studyContributors.stream().filter(distinctByKey(p -> p.getUser().getId())).map(studyParticipant -> conversionService.convert(studyParticipant, ParticipantExtendedDTO.class)).collect(Collectors.toList()));
}
final List<StudyDataSourceLink> studyDataSources = source.getDataSources();
studyDTO.setStudyDataSources(studyDataSources.stream().map(studyDataSource -> conversionService.convert(studyDataSource.getDataSource(), DataSourceDTO.class)).collect(Collectors.toList()));
return studyDTO;
}
Aggregations