Search in sources :

Example 1 with StudyMediumDTO

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

Example 2 with StudyMediumDTO

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

the class BasePaperToPaperDTOConverter method convert.

@Override
public PD convert(P paper) {
    final PD paperDTO = createResultObject();
    paperDTO.setId(paper.getId());
    final Study study = paper.getStudy();
    final StudyMediumDTO studyDTO = conversionService.convert(study, StudyMediumDTO.class);
    paperDTO.setStudy(studyDTO);
    paperDTO.setPublishState(paper.getPublishState());
    paperDTO.setPublishedDate(paper.getPublishedDate());
    final List<PaperFileDTO> protocols = paper.getProtocols().stream().map(protocolFile -> conversionService.convert(protocolFile, PaperFileDTO.class)).collect(Collectors.toList());
    paperDTO.setProtocols(protocols);
    final List<PaperFileDTO> paperFileDTOs = paper.getPapers().stream().map(paperFile -> conversionService.convert(paperFile, PaperFileDTO.class)).collect(Collectors.toList());
    paperDTO.setPapers(paperFileDTOs);
    paperDTO.setPermissions(conversionService.convert(paper, PermissionsDTO.class));
    proceedAdditionalFields(paperDTO, paper);
    return paperDTO;
}
Also used : List(java.util.List) Component(org.springframework.stereotype.Component) PaperDTO(com.odysseusinc.arachne.portal.api.v1.dto.PaperDTO) StudyMediumDTO(com.odysseusinc.arachne.portal.api.v1.dto.StudyMediumDTO) Autowired(org.springframework.beans.factory.annotation.Autowired) BaseConversionServiceAwareConverter(com.odysseusinc.arachne.portal.api.v1.dto.converters.BaseConversionServiceAwareConverter) GenericConversionService(org.springframework.core.convert.support.GenericConversionService) PaperFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.PaperFileDTO) PermissionsDTO(com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO) Collectors(java.util.stream.Collectors) Paper(com.odysseusinc.arachne.portal.model.Paper) Study(com.odysseusinc.arachne.portal.model.Study) Study(com.odysseusinc.arachne.portal.model.Study) PaperFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.PaperFileDTO) PermissionsDTO(com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO) StudyMediumDTO(com.odysseusinc.arachne.portal.api.v1.dto.StudyMediumDTO)

Example 3 with StudyMediumDTO

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

the class BasePaperToShortPaperDTOConverter method convert.

@Override
public SPD convert(P paper) {
    final SPD paperDTO = createResultObject();
    paperDTO.setId(paper.getId());
    paperDTO.setPublishState(paper.getPublishState());
    paperDTO.setPublishedDate(paper.getPublishedDate());
    final Study study = paper.getStudy();
    final StudyMediumDTO studyDTO = conversionService.convert(study, StudyMediumDTO.class);
    paperDTO.setStudy(studyDTO);
    proceedAdditionalFields(paperDTO, paper);
    return paperDTO;
}
Also used : Study(com.odysseusinc.arachne.portal.model.Study) StudyMediumDTO(com.odysseusinc.arachne.portal.api.v1.dto.StudyMediumDTO)

Aggregations

StudyMediumDTO (com.odysseusinc.arachne.portal.api.v1.dto.StudyMediumDTO)3 Study (com.odysseusinc.arachne.portal.model.Study)3 BaseConversionServiceAwareConverter (com.odysseusinc.arachne.portal.api.v1.dto.converters.BaseConversionServiceAwareConverter)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 GenericConversionService (org.springframework.core.convert.support.GenericConversionService)2 Component (org.springframework.stereotype.Component)2 DataSourceDTO (com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO)1 PaperDTO (com.odysseusinc.arachne.portal.api.v1.dto.PaperDTO)1 PaperFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.PaperFileDTO)1 ParticipantDTO (com.odysseusinc.arachne.portal.api.v1.dto.ParticipantDTO)1 ParticipantExtendedDTO (com.odysseusinc.arachne.portal.api.v1.dto.ParticipantExtendedDTO)1 PermissionsDTO (com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO)1 StudyStatusDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO)1 Paper (com.odysseusinc.arachne.portal.model.Paper)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 StudyDataSourceLink (com.odysseusinc.arachne.portal.model.StudyDataSourceLink)1