use of de.symeda.sormas.backend.contact.transformers.ContactListEntryDtoResultTransformer in project SORMAS-Project by hzi-braunschweig.
the class ContactService method getEntriesList.
public List<ContactListEntryDto> 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<Contact> contact = cq.from(Contact.class);
ContactQueryContext contactQueryContext = new ContactQueryContext(cb, cq, contact);
cq.multiselect(contact.get(Contact.UUID), contact.get(Contact.CONTACT_STATUS), contact.get(Contact.DISEASE), contact.get(Contact.CONTACT_CLASSIFICATION), contact.get(Contact.CONTACT_CATEGORY), JurisdictionHelper.booleanSelector(cb, inJurisdictionOrOwned(contactQueryContext)), contact.get(Contact.CHANGE_DATE));
Predicate filter = cb.equal(contact.get(Contact.PERSON_ID), personId);
filter = CriteriaBuilderHelper.and(cb, filter, cb.isFalse(contact.get(Contact.DELETED)));
cq.where(filter);
cq.orderBy(cb.desc(contact.get(Contact.CHANGE_DATE)));
cq.distinct(true);
return createQuery(cq, first, max).unwrap(org.hibernate.query.Query.class).setResultTransformer(new ContactListEntryDtoResultTransformer()).getResultList();
}
Aggregations