Search in sources :

Example 1 with WorkflowDocumentService

use of org.kuali.kfs.krad.workflow.service.WorkflowDocumentService in project cu-kfs by CU-CommunityApps.

the class CuElectronicInvoiceHelperServiceImpl method routeEIRTDocuments.

protected boolean routeEIRTDocuments() {
    Collection<String> documentIdList = null;
    try {
        documentIdList = retrieveDocumentsToRoute(KewApiConstants.ROUTE_HEADER_SAVED_CD, ElectronicInvoiceRejectDocument.class);
    } catch (WorkflowException e1) {
        LOG.error("Error retrieving eirt documents for routing: " + e1.getMessage(), e1);
        throw new RuntimeException(e1.getMessage(), e1);
    } catch (RemoteException re) {
        LOG.error("Error retrieving eirt documents for routing: " + re.getMessage(), re);
        throw new RuntimeException(re.getMessage(), re);
    }
    // Collections.reverse(documentIdList);
    LOG.info("EIRTs to Route: " + documentIdList);
    DocumentService documentService = SpringContext.getBean(DocumentService.class);
    WorkflowDocumentService workflowDocumentService = SpringContext.getBean(WorkflowDocumentService.class);
    for (String eirtDocumentId : documentIdList) {
        try {
            LOG.info("Retrieving EIRT document # " + eirtDocumentId + ".");
            ElectronicInvoiceRejectDocument eirtDocument = (ElectronicInvoiceRejectDocument) documentService.getByDocumentHeaderId(eirtDocumentId);
            LOG.info("Routing EIRT document # " + eirtDocumentId + ".");
            documentService.prepareWorkflowDocument(eirtDocument);
            LOG.info("EIRT document # " + eirtDocumentId + " prepared for workflow.");
            // calling workflow service to bypass business rule checks
            workflowDocumentService.route(eirtDocument.getDocumentHeader().getWorkflowDocument(), "Routed by electronic invoice batch job", null);
            LOG.info("EIRT document # " + eirtDocumentId + " routed.");
        } catch (WorkflowException e) {
            LOG.error("Error routing document # " + eirtDocumentId + " " + e.getMessage());
            throw new RuntimeException(e.getMessage(), e);
        }
    }
    return true;
}
Also used : ElectronicInvoiceRejectDocument(org.kuali.kfs.module.purap.document.ElectronicInvoiceRejectDocument) CuElectronicInvoiceRejectDocument(edu.cornell.kfs.module.purap.document.CuElectronicInvoiceRejectDocument) WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) WorkflowDocumentService(org.kuali.kfs.krad.workflow.service.WorkflowDocumentService) RemoteException(java.rmi.RemoteException) WorkflowDocumentService(org.kuali.kfs.krad.workflow.service.WorkflowDocumentService) DocumentService(org.kuali.kfs.krad.service.DocumentService) FinancialSystemDocumentService(org.kuali.kfs.sys.document.service.FinancialSystemDocumentService)

Example 2 with WorkflowDocumentService

use of org.kuali.kfs.krad.workflow.service.WorkflowDocumentService in project cu-kfs by CU-CommunityApps.

the class CuElectronicInvoiceHelperServiceImpl method routePREQDocuments.

/**
 * @return
 */
protected boolean routePREQDocuments() {
    Collection<String> documentIdList = null;
    try {
        documentIdList = retrieveDocumentsToRoute(KewApiConstants.ROUTE_HEADER_SAVED_CD, PaymentRequestDocument.class);
    } catch (WorkflowException e1) {
        LOG.error("Error retrieving preq documents for routing: " + e1.getMessage(), e1);
        throw new RuntimeException(e1.getMessage(), e1);
    } catch (RemoteException re) {
        LOG.error("Error retrieving preq documents for routing: " + re.getMessage(), re);
        throw new RuntimeException(re.getMessage(), re);
    }
    // Collections.reverse(documentIdList);
    LOG.info("PREQs to Route: " + documentIdList);
    DocumentService documentService = SpringContext.getBean(DocumentService.class);
    WorkflowDocumentService workflowDocumentService = SpringContext.getBean(WorkflowDocumentService.class);
    for (String preqDocumentId : documentIdList) {
        try {
            LOG.info("Retrieving PREQ document # " + preqDocumentId + ".");
            PaymentRequestDocument preqDocument = (PaymentRequestDocument) documentService.getByDocumentHeaderId(preqDocumentId);
            LOG.info("Routing PREQ document # " + preqDocumentId + ".");
            if (preqDocument.getPaymentRequestElectronicInvoiceIndicator()) {
                documentService.prepareWorkflowDocument(preqDocument);
                LOG.info("PREQ document # " + preqDocumentId + " prepared for workflow.");
                // calling workflow service to bypass business rule checks
                workflowDocumentService.route(preqDocument.getDocumentHeader().getWorkflowDocument(), "Routed by electronic invoice batch job", null);
                LOG.info("PREQ document # " + preqDocumentId + " routed.");
            }
        } catch (WorkflowException e) {
            LOG.error("Error routing document # " + preqDocumentId + " " + e.getMessage());
            throw new RuntimeException(e.getMessage(), e);
        }
    }
    return true;
}
Also used : WorkflowException(org.kuali.rice.kew.api.exception.WorkflowException) CuPaymentRequestDocument(edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument) PaymentRequestDocument(org.kuali.kfs.module.purap.document.PaymentRequestDocument) WorkflowDocumentService(org.kuali.kfs.krad.workflow.service.WorkflowDocumentService) RemoteException(java.rmi.RemoteException) WorkflowDocumentService(org.kuali.kfs.krad.workflow.service.WorkflowDocumentService) DocumentService(org.kuali.kfs.krad.service.DocumentService) FinancialSystemDocumentService(org.kuali.kfs.sys.document.service.FinancialSystemDocumentService)

Aggregations

RemoteException (java.rmi.RemoteException)2 DocumentService (org.kuali.kfs.krad.service.DocumentService)2 WorkflowDocumentService (org.kuali.kfs.krad.workflow.service.WorkflowDocumentService)2 FinancialSystemDocumentService (org.kuali.kfs.sys.document.service.FinancialSystemDocumentService)2 WorkflowException (org.kuali.rice.kew.api.exception.WorkflowException)2 CuElectronicInvoiceRejectDocument (edu.cornell.kfs.module.purap.document.CuElectronicInvoiceRejectDocument)1 CuPaymentRequestDocument (edu.cornell.kfs.module.purap.document.CuPaymentRequestDocument)1 ElectronicInvoiceRejectDocument (org.kuali.kfs.module.purap.document.ElectronicInvoiceRejectDocument)1 PaymentRequestDocument (org.kuali.kfs.module.purap.document.PaymentRequestDocument)1