Search in sources :

Example 1 with User

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;
}
Also used : Arrays(java.util.Arrays) DomainObjectLoaderFactory(com.odysseusinc.arachne.portal.service.domain.DomainObjectLoaderFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) PermissionDsl.domainObject(com.odysseusinc.arachne.portal.component.PermissionDsl.domainObject) Submission(com.odysseusinc.arachne.portal.model.Submission) Paper(com.odysseusinc.arachne.portal.model.Paper) HashSet(java.util.HashSet) DataSource(com.odysseusinc.arachne.portal.model.DataSource) IDataSource(com.odysseusinc.arachne.portal.model.IDataSource) BaseArachneSecureService(com.odysseusinc.arachne.portal.service.BaseArachneSecureService) ParticipantRole(com.odysseusinc.arachne.portal.model.ParticipantRole) ObjectUtils(org.apache.commons.lang3.ObjectUtils) Analysis(com.odysseusinc.arachne.portal.model.Analysis) Map(java.util.Map) ArachneUser(com.odysseusinc.arachne.portal.model.security.ArachneUser) DELETE_ANALYSIS_FILES(com.odysseusinc.arachne.portal.security.ArachnePermission.DELETE_ANALYSIS_FILES) SubmissionInsight(com.odysseusinc.arachne.portal.model.SubmissionInsight) LinkedList(java.util.LinkedList) PermissionDslPredicates.analysisAuthorIs(com.odysseusinc.arachne.portal.component.PermissionDslPredicates.analysisAuthorIs) HasArachnePermissions(com.odysseusinc.arachne.portal.security.HasArachnePermissions) User(com.odysseusinc.arachne.portal.model.User) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) PermissionDslPredicates.analysisFileAuthorIs(com.odysseusinc.arachne.portal.component.PermissionDslPredicates.analysisFileAuthorIs) PublishState(com.odysseusinc.arachne.portal.model.PublishState) UserStudyGrouped(com.odysseusinc.arachne.portal.model.UserStudyGrouped) Set(java.util.Set) DELETE_DATASOURCE(com.odysseusinc.arachne.portal.security.ArachnePermission.DELETE_DATASOURCE) Page(org.springframework.data.domain.Page) PermissionEvaluator(org.springframework.security.access.PermissionEvaluator) Serializable(java.io.Serializable) Objects(java.util.Objects) AnalysisFile(com.odysseusinc.arachne.portal.model.AnalysisFile) List(java.util.List) Component(org.springframework.stereotype.Component) RawDataSource(com.odysseusinc.arachne.portal.model.RawDataSource) CollectionUtils(org.springframework.util.CollectionUtils) PermissionDslPredicates.userIsLeadInvestigator(com.odysseusinc.arachne.portal.component.PermissionDslPredicates.userIsLeadInvestigator) DataNode(com.odysseusinc.arachne.portal.model.DataNode) PermissionDslPredicates.hasRole(com.odysseusinc.arachne.portal.component.PermissionDslPredicates.hasRole) PermissionDslPredicates.instanceOf(com.odysseusinc.arachne.portal.component.PermissionDslPredicates.instanceOf) Authentication(org.springframework.security.core.Authentication) SubmissionGroup(com.odysseusinc.arachne.portal.model.SubmissionGroup) ArachnePermission(com.odysseusinc.arachne.portal.security.ArachnePermission) Collections(java.util.Collections) Study(com.odysseusinc.arachne.portal.model.Study) HashSet(java.util.HashSet) Set(java.util.Set) SubmissionGroup(com.odysseusinc.arachne.portal.model.SubmissionGroup) Analysis(com.odysseusinc.arachne.portal.model.Analysis) AnalysisFile(com.odysseusinc.arachne.portal.model.AnalysisFile) ArachnePermission(com.odysseusinc.arachne.portal.security.ArachnePermission)

Example 2 with User

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;
}
Also used : Study(com.odysseusinc.arachne.portal.model.Study) IUser(com.odysseusinc.arachne.portal.model.IUser) User(com.odysseusinc.arachne.portal.model.User) ParticipantStatus(com.odysseusinc.arachne.portal.model.ParticipantStatus) UserStudyExtended(com.odysseusinc.arachne.portal.model.UserStudyExtended) Predicate(javax.persistence.criteria.Predicate)

Example 3 with User

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;
}
Also used : User(com.odysseusinc.arachne.portal.model.User) UserProfileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UserProfileDTO) ArrayList(java.util.ArrayList)

Example 4 with User

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);
}
Also used : ArachneUser(com.odysseusinc.arachne.portal.model.security.ArachneUser) DataNodeUser(com.odysseusinc.arachne.portal.model.DataNodeUser) User(com.odysseusinc.arachne.portal.model.User) IUser(com.odysseusinc.arachne.portal.model.IUser)

Example 5 with 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;
}
Also used : UserStudy(com.odysseusinc.arachne.portal.model.UserStudy) Study(com.odysseusinc.arachne.portal.model.Study) FavouriteStudy(com.odysseusinc.arachne.portal.model.FavouriteStudy) User(com.odysseusinc.arachne.portal.model.User) IUser(com.odysseusinc.arachne.portal.model.IUser) DataNodeUser(com.odysseusinc.arachne.portal.model.DataNodeUser) IUser(com.odysseusinc.arachne.portal.model.IUser) InvitationCollaboratorMailSender(com.odysseusinc.arachne.portal.service.mail.InvitationCollaboratorMailSender) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) UserStudy(com.odysseusinc.arachne.portal.model.UserStudy) AlreadyExistException(com.odysseusinc.arachne.portal.exception.AlreadyExistException) Date(java.util.Date) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

User (com.odysseusinc.arachne.portal.model.User)9 IUser (com.odysseusinc.arachne.portal.model.IUser)3 Study (com.odysseusinc.arachne.portal.model.Study)3 ArachneUser (com.odysseusinc.arachne.portal.model.security.ArachneUser)3 DataNodeUser (com.odysseusinc.arachne.portal.model.DataNodeUser)2 ProfessionalType (com.odysseusinc.arachne.portal.model.ProfessionalType)2 Skill (com.odysseusinc.arachne.portal.model.Skill)2 HashSet (java.util.HashSet)2 CommonHealthStatus (com.odysseusinc.arachne.commons.api.v1.dto.CommonHealthStatus)1 DataNodeDTO (com.odysseusinc.arachne.portal.api.v1.dto.DataNodeDTO)1 UserProfileDTO (com.odysseusinc.arachne.portal.api.v1.dto.UserProfileDTO)1 SkillDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.SkillDTO)1 PermissionDsl.domainObject (com.odysseusinc.arachne.portal.component.PermissionDsl.domainObject)1 PermissionDslPredicates.analysisAuthorIs (com.odysseusinc.arachne.portal.component.PermissionDslPredicates.analysisAuthorIs)1 PermissionDslPredicates.analysisFileAuthorIs (com.odysseusinc.arachne.portal.component.PermissionDslPredicates.analysisFileAuthorIs)1 PermissionDslPredicates.hasRole (com.odysseusinc.arachne.portal.component.PermissionDslPredicates.hasRole)1 PermissionDslPredicates.instanceOf (com.odysseusinc.arachne.portal.component.PermissionDslPredicates.instanceOf)1 PermissionDslPredicates.userIsLeadInvestigator (com.odysseusinc.arachne.portal.component.PermissionDslPredicates.userIsLeadInvestigator)1 AlreadyExistException (com.odysseusinc.arachne.portal.exception.AlreadyExistException)1 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)1