Search in sources :

Example 1 with DocumentSearchCriteria

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;
}
Also used : DocumentSearchResult(org.kuali.rice.kew.api.document.search.DocumentSearchResult) DocumentSearchCriteria(org.kuali.rice.kew.api.document.search.DocumentSearchCriteria) DocumentSearchResults(org.kuali.rice.kew.api.document.search.DocumentSearchResults) FinancialSystemDocumentService(org.kuali.kfs.sys.document.service.FinancialSystemDocumentService) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 FinancialSystemDocumentService (org.kuali.kfs.sys.document.service.FinancialSystemDocumentService)1 DocumentSearchCriteria (org.kuali.rice.kew.api.document.search.DocumentSearchCriteria)1 DocumentSearchResult (org.kuali.rice.kew.api.document.search.DocumentSearchResult)1 DocumentSearchResults (org.kuali.rice.kew.api.document.search.DocumentSearchResults)1