use of org.kuali.rice.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(SpringContext.getBean(DataDictionaryService.class).getDocumentTypeNameByClass(document));
criteria.setDocumentStatuses(Collections.singletonList(DocumentStatus.fromCode(statusCode)));
DocumentSearchCriteria crit = criteria.build();
int maxResults = SpringContext.getBean(FinancialSystemDocumentService.class).getMaxResultCap(crit);
int iterations = SpringContext.getBean(FinancialSystemDocumentService.class).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 = KewApiServiceLocator.getWorkflowDocumentService().documentSearch(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