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