Source:
public List<DocumentMetadata> findDocuments(DocumentQueryParams params) { LOG.debug("Beginning document query"); DocumentQueryParams parameters = params; if (parameters == null) { parameters = new DocumentQueryParams(); } List<DocumentMetadata> documents = new ArrayList<>(); Session sess = null; try { sess = getSession(); if (sess != null) { Criteria criteria = sess.createCriteria(DocumentMetadata.class); String patientId = parameters.getPatientId(); if (patientId != null) { criteria.add(Restrictions.eq("patientId", patientId)); } List<String> statuses = parameters.getStatuses(); if (statuses != null && !statuses.isEmpty()) { LOG.debug("Document query - statuses: {}", statuses); criteria.add(Restrictions.in("status", statuses)); } List<String> documentUniqueIds = parameters.getDocumentUniqueIds(); if (documentUniqueIds != null && !documentUniqueIds.isEmpty()) { LOG.debug("Document query - document unique ids: {}", documentUniqueIds); criteria.add(Restrictions.in("documentUniqueId", documentUniqueIds)); } Boolean onDemand = parameters.getOnDemand(); if (onDemand != null) { LOG.debug("Document query - onDemand: {}", onDemand); criteria.add(Restrictions.eq("onDemand", onDemand)); } populateClassCodeCritera(parameters, criteria); populateServiceDateCriteria(parameters, criteria); populateCreationDateCriteria(parameters, criteria); documents = criteria.list(); LOG.debug("Completed retrieve of document query. results returned.", documents.size()); } else { LOG.error("Failed to obtain a session from the sessionFactory"); } } finally { GenericDBUtils.closeSession(sess); } return documents; }

Target:
public List<DocumentMetadata> findDocuments(DocumentQueryParams params) { LOG.debug("Beginning document query"); DocumentQueryParams parameters = params; if (parameters == null) { parameters = new DocumentQueryParams(); } List<DocumentMetadata> documents = new ArrayList<>(); Session sess = null; try { sess = getSession(); if (sess != null) { Criteria criteria = sess.createCriteria(DocumentMetadata.class); String patientId = parameters.getPatientId(); if (patientId != null) { criteria.add(Restrictions.eq("patientId", patientId)); } List<String> statuses = parameters.getStatuses(); if (CollectionUtils.isNotEmpty(statuses)) { LOG.debug("Document query - statuses: {}", statuses); criteria.add(Restrictions.in("status", statuses)); } List<String> documentUniqueIds = parameters.getDocumentUniqueIds(); if (CollectionUtils.isNotEmpty(documentUniqueIds)) { LOG.debug("Document query - document unique ids: {}", documentUniqueIds); criteria.add(Restrictions.in("documentUniqueId", documentUniqueIds)); } Boolean onDemand = parameters.getOnDemand(); if (onDemand != null) { LOG.debug("Document query - onDemand: {}", onDemand); criteria.add(Restrictions.eq("onDemand", onDemand)); } populateClassCodeCritera(parameters, criteria); populateServiceDateCriteria(parameters, criteria); populateCreationDateCriteria(parameters, criteria); documents = criteria.list(); LOG.debug("Completed retrieve of document query. results returned.", documents.size()); } else { LOG.error("Failed to obtain a session from the sessionFactory"); } } finally { GenericDBUtils.closeSession(sess); } return documents; }