use of com.odysseusinc.arachne.portal.model.User in project ArachneCentralAPI by OHDSI.
the class ArachnePermissionEvaluator method addPermissions.
public boolean addPermissions(ArachneUser user, HasArachnePermissions hasPermissionsObj) {
Set<ArachnePermission> allPermissions = getAllPermissions(hasPermissionsObj, user);
hasPermissionsObj.setPermissions(allPermissions);
if (hasPermissionsObj instanceof Analysis) {
final Analysis analysis = (Analysis) hasPermissionsObj;
final List<SubmissionGroup> submissionGroups = analysis.getSubmissionGroups();
if (!CollectionUtils.isEmpty(submissionGroups)) {
submissionGroups.forEach(submissionGroup -> submissionGroup.getSubmissions().forEach(submission -> {
final Set<ArachnePermission> submissionPermissions = getAllPermissions(submission, user);
submission.setPermissions(submissionPermissions);
}));
}
final List<AnalysisFile> files = analysis.getFiles();
if (!CollectionUtils.isEmpty(files)) {
files.forEach(file -> {
final Set<ArachnePermission> filePermissions = getAllPermissions(file, user);
file.setPermissions(filePermissions);
});
}
}
return true;
}
use of com.odysseusinc.arachne.portal.model.User 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<User> 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.User in project ArachneCentralAPI by OHDSI.
the class SearchResultToExpertListSearchResultDTOConverter method buildContent.
protected List<UserProfileDTO> buildContent(SearchResult source) {
List<UserProfileDTO> userProfileDTOList = new ArrayList<>();
for (Object entity : source.getEntityList()) {
User user = (User) entity;
userProfileDTOList.add(conversionService.convert(user, UserProfileDTO.class));
}
return userProfileDTOList;
}
use of com.odysseusinc.arachne.portal.model.User in project ArachneCentralAPI by OHDSI.
the class DataNodeUtils method isDataNodeOwner.
public static boolean isDataNodeOwner(DataNode dataNode, Long userId) {
final User user = new User();
user.setId(userId);
return isDataNodeOwner(dataNode, user);
}
use of com.odysseusinc.arachne.portal.model.User in project ArachneCentralAPI by OHDSI.
the class BaseStudyServiceImpl method addParticipant.
@Override
@PreAuthorize("hasPermission(#studyId, 'Study', " + "T(com.odysseusinc.arachne.portal.security.ArachnePermission).INVITE_CONTRIBUTOR)")
public UserStudy addParticipant(IUser createdBy, Long studyId, Long participantId, ParticipantRole role) throws NotExistException, AlreadyExistException {
Study study = Optional.ofNullable(studyRepository.findOne(studyId)).orElseThrow(() -> new NotExistException(EX_STUDY_NOT_EXISTS, Study.class));
IUser participant = Optional.ofNullable(userService.findOne(participantId)).orElseThrow(() -> new NotExistException(EX_USER_NOT_EXISTS, User.class));
UserStudy studyLink = userStudyRepository.findOneByStudyIdAndUserId(study.getId(), participant.getId());
if (studyLink == null) {
// If user is invited for first time - create new link
studyLink = new UserStudy();
} else if (studyLink.getStatus().isPendingOrApproved()) {
// Otherwise - invitation is pending or was already accepted. Cannot change or recreate
throw new AlreadyExistException(EX_PARTICIPANT_EXISTS);
}
studyLink.setCreatedBy(createdBy);
studyLink.setUser(participant);
studyLink.setStudy(study);
studyLink.setRole(role);
studyLink.setCreated(new Date());
studyLink.setStatus(ParticipantStatus.PENDING);
studyLink.setDeletedAt(null);
studyLink.setComment(null);
studyLink.setToken(UUID.randomUUID().toString().replace("-", ""));
userStudyRepository.save(studyLink);
arachneMailSender.send(new InvitationCollaboratorMailSender(WebSecurityConfig.getDefaultPortalURI(), participant, studyLink));
return studyLink;
}
Aggregations