use of org.kuali.kfs.kew.api.document.search.DocumentSearchCriteria in project cu-kfs by CU-CommunityApps.
the class CuElectronicInvoiceHelperServiceImpl method retrieveDocumentsToRoute.
/**
* Returns a list of all initiated but not yet routed payment request or reject documents, using the KualiWorkflowInfo service.
* @return a list of payment request or eirt documents to route
*/
protected Collection<String> retrieveDocumentsToRoute(String statusCode, Class<?> document) throws WorkflowException, RemoteException {
// This is very much from pcardserviceimpl
Set<String> documentIds = new HashSet<String>();
DocumentSearchCriteria.Builder criteria = DocumentSearchCriteria.Builder.create();
criteria.setDocumentTypeName(getDataDictionaryService().getDocumentTypeNameByClass(document));
criteria.setDocumentStatuses(Collections.singletonList(DocumentStatus.fromCode(statusCode)));
DocumentSearchCriteria crit = criteria.build();
int maxResults = financialSystemDocumentService.getMaxResultCap(crit);
int iterations = financialSystemDocumentService.getFetchMoreIterationLimit();
for (int i = 0; i < iterations; i++) {
LOG.debug("Fetch Iteration: " + i);
criteria.setStartAtIndex(maxResults * i);
crit = criteria.build();
LOG.debug("Max Results: " + criteria.getStartAtIndex());
DocumentSearchResults results = KEWServiceLocator.getDocumentSearchService().lookupDocuments(GlobalVariables.getUserSession().getPrincipalId(), crit);
if (results.getSearchResults().isEmpty()) {
break;
}
for (DocumentSearchResult resultRow : results.getSearchResults()) {
documentIds.add(resultRow.getDocument().getDocumentId());
LOG.debug(resultRow.getDocument().getDocumentId());
}
}
return documentIds;
}
Aggregations