Search in sources :

Example 1 with AdHocRouteRecipient

use of org.kuali.kfs.krad.bo.AdHocRouteRecipient in project cu-kfs by CU-CommunityApps.

the class CorporateBilledCorporatePaidCreateDocumentServiceImpl method routeProcurementCardDocuments.

@Override
public boolean routeProcurementCardDocuments() {
    LOG.debug("routeProcurementCardDocuments() started");
    Collection<CorporateBilledCorporatePaidDocument> cbcpDocumentList = retrieveCorporateBilledCorporatePaidDocuments(KewApiConstants.ROUTE_HEADER_SAVED_CD);
    LOG.info("routeProcurementCardDocuments() Number of CBCP documents to Route: " + cbcpDocumentList.size());
    Map<String, String> documentErrors = new HashMap<String, String>();
    List<String> successfulDocuments = new ArrayList<String>();
    for (CorporateBilledCorporatePaidDocument cbcpDocument : cbcpDocumentList) {
        try {
            LOG.info("routeProcurementCardDocuments() Routing CBCP document # " + cbcpDocument.getDocumentNumber() + ".");
            documentService.prepareWorkflowDocument(cbcpDocument);
            documentService.routeDocument(cbcpDocument, "CBCP document automatically routed", new ArrayList<AdHocRouteRecipient>());
            successfulDocuments.add(cbcpDocument.getDocumentNumber());
        } catch (WorkflowException we) {
            documentErrors.put(cbcpDocument.getDocumentNumber(), "Workflow error: " + we.getMessage());
            GlobalVariables.getMessageMap().clearErrorMessages();
            LOG.error("routeProcurementCardDocuments, workflow error routing document # " + cbcpDocument.getDocumentNumber() + " " + we.getMessage(), we);
        } catch (ValidationException ve) {
            documentErrors.put(cbcpDocument.getDocumentNumber(), corporateBilledCorporatePaidRouteStepReportService.buildValidationErrorMessage(ve));
            GlobalVariables.getMessageMap().clearErrorMessages();
            LOG.error("routeProcurementCardDocuments, Error routing document # " + cbcpDocument.getDocumentNumber() + " " + ve.getMessage(), ve);
        }
    }
    createAndEmailReport(cbcpDocumentList, documentErrors, successfulDocuments);
    return true;
}
Also used : CorporateBilledCorporatePaidDocument(edu.cornell.kfs.fp.document.CorporateBilledCorporatePaidDocument) AdHocRouteRecipient(org.kuali.kfs.krad.bo.AdHocRouteRecipient) ValidationException(org.kuali.kfs.krad.exception.ValidationException) HashMap(java.util.HashMap) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) ArrayList(java.util.ArrayList)

Aggregations

CorporateBilledCorporatePaidDocument (edu.cornell.kfs.fp.document.CorporateBilledCorporatePaidDocument)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 AdHocRouteRecipient (org.kuali.kfs.krad.bo.AdHocRouteRecipient)1 ValidationException (org.kuali.kfs.krad.exception.ValidationException)1 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)1