Search in sources :

Example 1 with CaseListEntryDtoResultTransformer

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

the class CaseService method getEntriesList.

public List<CaseListEntryDto> getEntriesList(Long personId, Integer first, Integer max) {
    if (personId == null) {
        return Collections.emptyList();
    }
    final CriteriaBuilder cb = em.getCriteriaBuilder();
    final CriteriaQuery<Object[]> cq = cb.createQuery(Object[].class);
    final Root<Case> caze = cq.from(Case.class);
    CaseQueryContext caseQueryContext = new CaseQueryContext(cb, cq, caze);
    cq.multiselect(caze.get(Case.UUID), caze.get(Case.REPORT_DATE), caze.get(Case.DISEASE), caze.get(Case.CASE_CLASSIFICATION), JurisdictionHelper.booleanSelector(cb, inJurisdictionOrOwned(caseQueryContext)), caze.get(Case.CHANGE_DATE));
    Predicate filter = cb.equal(caze.get(Case.PERSON_ID), personId);
    filter = CriteriaBuilderHelper.and(cb, filter, cb.isFalse(caze.get(Case.DELETED)));
    cq.where(filter);
    cq.orderBy(cb.desc(caze.get(Case.CHANGE_DATE)));
    cq.distinct(true);
    return createQuery(cq, first, max).unwrap(org.hibernate.query.Query.class).setResultTransformer(new CaseListEntryDtoResultTransformer()).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) CaseListEntryDtoResultTransformer(de.symeda.sormas.backend.caze.transformers.CaseListEntryDtoResultTransformer) Subquery(javax.persistence.criteria.Subquery) AbstractDomainObject(de.symeda.sormas.backend.common.AbstractDomainObject) Predicate(javax.persistence.criteria.Predicate)

Aggregations

CaseListEntryDtoResultTransformer (de.symeda.sormas.backend.caze.transformers.CaseListEntryDtoResultTransformer)1 AbstractDomainObject (de.symeda.sormas.backend.common.AbstractDomainObject)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 Predicate (javax.persistence.criteria.Predicate)1 Subquery (javax.persistence.criteria.Subquery)1