Search in sources :

Example 1 with LEAD_INVESTIGATOR

use of com.odysseusinc.arachne.portal.model.ParticipantRole.LEAD_INVESTIGATOR 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;
}
Also used : LEAD_INVESTIGATOR(com.odysseusinc.arachne.portal.model.ParticipantRole.LEAD_INVESTIGATOR) StudyStatusDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO) CONTRIBUTOR(com.odysseusinc.arachne.portal.model.ParticipantRole.CONTRIBUTOR) ParticipantDTO(com.odysseusinc.arachne.portal.api.v1.dto.ParticipantDTO) Predicate(java.util.function.Predicate) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) GenericConversionService(org.springframework.core.convert.support.GenericConversionService) DataSourceDTO(com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) List(java.util.List) Component(org.springframework.stereotype.Component) UserStudyExtended(com.odysseusinc.arachne.portal.model.UserStudyExtended) ParticipantRole(com.odysseusinc.arachne.portal.model.ParticipantRole) CollectionUtils(org.springframework.util.CollectionUtils) StudyMediumDTO(com.odysseusinc.arachne.portal.api.v1.dto.StudyMediumDTO) Map(java.util.Map) BaseConversionServiceAwareConverter(com.odysseusinc.arachne.portal.api.v1.dto.converters.BaseConversionServiceAwareConverter) StudyDataSourceLink(com.odysseusinc.arachne.portal.model.StudyDataSourceLink) ParticipantExtendedDTO(com.odysseusinc.arachne.portal.api.v1.dto.ParticipantExtendedDTO) Study(com.odysseusinc.arachne.portal.model.Study) StudyDataSourceLink(com.odysseusinc.arachne.portal.model.StudyDataSourceLink) ParticipantDTO(com.odysseusinc.arachne.portal.api.v1.dto.ParticipantDTO) UserStudyExtended(com.odysseusinc.arachne.portal.model.UserStudyExtended) StudyMediumDTO(com.odysseusinc.arachne.portal.api.v1.dto.StudyMediumDTO) DataSourceDTO(com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO) StudyStatusDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO) List(java.util.List) ParticipantExtendedDTO(com.odysseusinc.arachne.portal.api.v1.dto.ParticipantExtendedDTO) ParticipantRole(com.odysseusinc.arachne.portal.model.ParticipantRole)

Aggregations

DataSourceDTO (com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO)1 ParticipantDTO (com.odysseusinc.arachne.portal.api.v1.dto.ParticipantDTO)1 ParticipantExtendedDTO (com.odysseusinc.arachne.portal.api.v1.dto.ParticipantExtendedDTO)1 StudyMediumDTO (com.odysseusinc.arachne.portal.api.v1.dto.StudyMediumDTO)1 BaseConversionServiceAwareConverter (com.odysseusinc.arachne.portal.api.v1.dto.converters.BaseConversionServiceAwareConverter)1 StudyStatusDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO)1 ParticipantRole (com.odysseusinc.arachne.portal.model.ParticipantRole)1 CONTRIBUTOR (com.odysseusinc.arachne.portal.model.ParticipantRole.CONTRIBUTOR)1 LEAD_INVESTIGATOR (com.odysseusinc.arachne.portal.model.ParticipantRole.LEAD_INVESTIGATOR)1 Study (com.odysseusinc.arachne.portal.model.Study)1 StudyDataSourceLink (com.odysseusinc.arachne.portal.model.StudyDataSourceLink)1 UserStudyExtended (com.odysseusinc.arachne.portal.model.UserStudyExtended)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Function (java.util.function.Function)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 GenericConversionService (org.springframework.core.convert.support.GenericConversionService)1