Search in sources :

Example 1 with ParticipantStatus

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

Example 2 with ParticipantStatus

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

the class BaseUserServiceImpl method processInvitation.

@Override
public UserStudy processInvitation(U user, Long id, Boolean accepted, String comment) {
    UserStudy userStudy = userStudyRepository.findByIdAndUserId(id, user.getId());
    if (userStudy != null) {
        ParticipantStatus status = TRUE.equals(accepted) ? APPROVED : DECLINED;
        userStudy.setStatus(status);
        userStudy.setComment(DECLINED == status ? comment : null);
        userStudyRepository.save(userStudy);
    }
    return userStudy;
}
Also used : ParticipantStatus(com.odysseusinc.arachne.portal.model.ParticipantStatus) UserStudy(com.odysseusinc.arachne.portal.model.UserStudy)

Aggregations

ParticipantStatus (com.odysseusinc.arachne.portal.model.ParticipantStatus)2 RawUser (com.odysseusinc.arachne.portal.model.RawUser)1 Study (com.odysseusinc.arachne.portal.model.Study)1 UserStudy (com.odysseusinc.arachne.portal.model.UserStudy)1 UserStudyExtended (com.odysseusinc.arachne.portal.model.UserStudyExtended)1 Predicate (javax.persistence.criteria.Predicate)1