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();
}
Aggregations