Search in sources :

Example 1 with ParticipantRole

use of com.odysseusinc.arachne.portal.model.ParticipantRole 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 ParticipantRole

use of com.odysseusinc.arachne.portal.model.ParticipantRole 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 3 with ParticipantRole

use of com.odysseusinc.arachne.portal.model.ParticipantRole in project ArachneCentralAPI by OHDSI.

the class BaseArachneSecureServiceImpl method getRolesByAnalysis.

@Override
public List<ParticipantRole> getRolesByAnalysis(ArachneUser user, Analysis analysis) {
    List<ParticipantRole> result = new LinkedList<>();
    if (analysis != null) {
        if (analysis.getStudy() != null) {
            result = getRolesByStudy(user, analysis.getStudy());
        } else {
            Analysis byId = analysisRepository.findOne(analysis.getId());
            result = byId != null ? getRolesByStudy(user, byId.getStudy()) : result;
        }
        if (analysis.getAuthor().getId().equals(user.getId())) {
            result.add(ParticipantRole.ANALYSIS_OWNER);
        }
    }
    return result;
}
Also used : Analysis(com.odysseusinc.arachne.portal.model.Analysis) LinkedList(java.util.LinkedList) ParticipantRole(com.odysseusinc.arachne.portal.model.ParticipantRole)

Example 4 with ParticipantRole

use of com.odysseusinc.arachne.portal.model.ParticipantRole in project ArachneCentralAPI by OHDSI.

the class BaseArachneSecureServiceImpl method getRolesBySubmissionGroup.

@Override
public List<ParticipantRole> getRolesBySubmissionGroup(ArachneUser user, SubmissionGroup submissionGroup) {
    List<ParticipantRole> result = new LinkedList<>();
    Optional.ofNullable(submissionGroup).ifPresent(sg -> {
        Analysis analysis = submissionGroup.getAnalysis();
        if (analysis != null && analysis.getStudy() != null) {
            result.addAll(getRolesByStudy(user, analysis.getStudy()));
        }
    });
    return result;
}
Also used : Analysis(com.odysseusinc.arachne.portal.model.Analysis) LinkedList(java.util.LinkedList) ParticipantRole(com.odysseusinc.arachne.portal.model.ParticipantRole)

Example 5 with ParticipantRole

use of com.odysseusinc.arachne.portal.model.ParticipantRole in project ArachneCentralAPI by OHDSI.

the class BaseArachneSecureServiceImpl method getRolesBySubmission.

@Override
public List<ParticipantRole> getRolesBySubmission(ArachneUser user, Submission submission) {
    List<ParticipantRole> result = new LinkedList<>();
    if (submission != null) {
        Analysis analysis = submission.getSubmissionGroup().getAnalysis();
        result = getRolesByAnalysis(user, analysis);
        final DataNode dataNode = submission.getDataSource().getDataNode();
        if (!DataNodeUtils.isDataNodeOwner(dataNode, user.getId())) {
            // There can be many DATA_SET_OWNER-s in a single study, owning different data sources
            // But in case of Submission, we are interested, whether current user is owner of the submission's DS
            result.removeIf(ParticipantRole.DATA_SET_OWNER::equals);
        }
    }
    return result;
}
Also used : Analysis(com.odysseusinc.arachne.portal.model.Analysis) DataNode(com.odysseusinc.arachne.portal.model.DataNode) LinkedList(java.util.LinkedList) ParticipantRole(com.odysseusinc.arachne.portal.model.ParticipantRole)

Aggregations

ParticipantRole (com.odysseusinc.arachne.portal.model.ParticipantRole)7 Analysis (com.odysseusinc.arachne.portal.model.Analysis)3 LinkedList (java.util.LinkedList)3 OptionDTO (com.odysseusinc.arachne.commons.api.v1.dto.OptionDTO)2 ParticipantDTO (com.odysseusinc.arachne.portal.api.v1.dto.ParticipantDTO)2 ParticipantExtendedDTO (com.odysseusinc.arachne.portal.api.v1.dto.ParticipantExtendedDTO)2 IUser (com.odysseusinc.arachne.portal.model.IUser)2 UserStudyExtended (com.odysseusinc.arachne.portal.model.UserStudyExtended)2 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)1 DataOwnerParticipantDTO (com.odysseusinc.arachne.portal.api.v1.dto.DataOwnerParticipantDTO)1 DataSourceDTO (com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO)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 DataNode (com.odysseusinc.arachne.portal.model.DataNode)1 DataSource (com.odysseusinc.arachne.portal.model.DataSource)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