use of com.odysseusinc.arachne.portal.model.UserStudyExtended 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.UserStudyExtended 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.UserStudyExtended in project ArachneCentralAPI by OHDSI.
the class PaperSpecification method getUserStudyLinkSubquery.
protected Subquery<UserStudyExtended> getUserStudyLinkSubquery(CriteriaQuery<?> query, CriteriaBuilder cb, Path<Long> studyId) {
final Subquery<UserStudyExtended> userStudyExtendedLinkSubquery = query.subquery(UserStudyExtended.class);
final Root<UserStudyExtended> userStudyLinkRoot = userStudyExtendedLinkSubquery.from(UserStudyExtended.class);
userStudyExtendedLinkSubquery.select(userStudyLinkRoot);
final Path<RawUser> linkUser = userStudyLinkRoot.get(UserStudyExtended_.user);
final Path<Study> linkStudy = userStudyLinkRoot.get(UserStudyExtended_.study);
final Path<Long> linkStudyId = linkStudy.get(Study_.id);
final Path<ParticipantStatus> linkStatus = userStudyLinkRoot.get(UserStudyExtended_.status);
Predicate userStudyPredicate = cb.and(cb.equal(linkUser, user), cb.equal(linkStudyId, studyId));
userStudyPredicate = cb.and(userStudyPredicate, cb.notEqual(linkStatus, ParticipantStatus.DELETED));
userStudyExtendedLinkSubquery.where(userStudyPredicate);
return userStudyExtendedLinkSubquery;
}
use of com.odysseusinc.arachne.portal.model.UserStudyExtended in project ArachneCentralAPI by OHDSI.
the class BaseStudyToStudyDTOConverter method convert.
@Override
public DTO convert(final S source) {
final DTO studyDTO = super.convert(source);
final Tenant studyTenant = source.getTenant();
List<UserStudyExtended> sourceParticipants = new ArrayList<>(source.getParticipants());
Comparator<UserStudyExtended> comparator = Comparator.comparing(p -> p.getStatus().ordinal());
sourceParticipants.sort(comparator.thenComparing((p1, p2) -> StringUtils.compare(p1.getUser().getFullName(), p2.getUser().getFullName())));
for (final UserStudyExtended studyUserLink : sourceParticipants) {
final ParticipantDTO participantDTO = conversionService.convert(studyUserLink, ParticipantDTO.class);
if (!studyUserLink.getUser().getTenants().contains(studyTenant)) {
participantDTO.setCanBeRecreated(Boolean.FALSE);
}
studyDTO.getParticipants().add(participantDTO);
}
studyDTO.setStatus(conversionService.convert(source.getStatus(), StudyStatusDTO.class));
studyDTO.setType(conversionService.convert(source.getType(), StudyTypeDTO.class));
studyDTO.setEndDate(source.getEndDate());
studyDTO.setStartDate(source.getStartDate());
studyDTO.setDescription(source.getDescription());
studyDTO.setCreated(source.getCreated());
studyDTO.setUpdated(source.getUpdated());
studyDTO.setPaperId(source.getPaper() == null ? null : source.getPaper().getId());
studyDTO.setPrivacy(source.getPrivacy());
proceedAdditionalFields(studyDTO, source);
return studyDTO;
}
use of com.odysseusinc.arachne.portal.model.UserStudyExtended in project ArachneCentralAPI by OHDSI.
the class BaseStudyToWorkspaceDTOConverter method convert.
@Override
public DTO convert(S source) {
final DTO workspaceDTO = super.convert(source);
if (!source.getParticipants().isEmpty()) {
Optional<UserStudyExtended> leadOptional = source.getParticipants().stream().filter(participant -> participant.getRole().equals(ParticipantRole.LEAD_INVESTIGATOR)).findFirst();
workspaceDTO.setLeadParticipant(conversionService.convert(leadOptional.orElseThrow(() -> {
final String message = "Lead investigator for workspace id = " + workspaceDTO.getId() + " doesn't exist";
return new NotExistException(message, UserStudyExtended.class);
}), ParticipantDTO.class));
}
return workspaceDTO;
}
Aggregations