Search in sources :

Example 1 with CaseJurisdictionPredicateValidator

use of de.symeda.sormas.backend.caze.CaseJurisdictionPredicateValidator in project SORMAS-Project by hzi-braunschweig.

the class UserFacadeEjb method getUsersHavingCaseInJurisdiction.

@Override
public List<UserReferenceDto> getUsersHavingCaseInJurisdiction(CaseReferenceDto caseReferenceDto) {
    return getUsersHavingEntityInJurisdiction((cb, cq, userRoot) -> {
        final Subquery<Case> caseJurisdictionSubquery = cq.subquery(Case.class);
        final Root<Case> caseRoot = caseJurisdictionSubquery.from(Case.class);
        final CaseJurisdictionPredicateValidator caseJurisdictionPredicateValidator = CaseJurisdictionPredicateValidator.of(new CaseQueryContext(cb, cq, caseRoot), userRoot);
        caseJurisdictionSubquery.select(caseRoot).where(cb.and(cb.equal(caseRoot.get(Case.UUID), caseReferenceDto.getUuid()), cb.isTrue(caseJurisdictionPredicateValidator.inJurisdictionOrOwned()), cb.or(cb.isNull(userRoot.get(User.LIMITED_DISEASE)), cb.equal(userRoot.get(User.LIMITED_DISEASE), caseRoot.get(Case.DISEASE)))));
        return caseJurisdictionSubquery;
    });
}
Also used : CaseQueryContext(de.symeda.sormas.backend.caze.CaseQueryContext) Case(de.symeda.sormas.backend.caze.Case) CaseJurisdictionPredicateValidator(de.symeda.sormas.backend.caze.CaseJurisdictionPredicateValidator)

Aggregations

Case (de.symeda.sormas.backend.caze.Case)1 CaseJurisdictionPredicateValidator (de.symeda.sormas.backend.caze.CaseJurisdictionPredicateValidator)1 CaseQueryContext (de.symeda.sormas.backend.caze.CaseQueryContext)1