Search in sources :

Example 6 with DocumentRouteHeaderValue

use of org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue in project cu-kfs by CU-CommunityApps.

the class TransactionRowPdpBuilder method updateTransactionRowsFromWorkflowDocuments.

@Override
void updateTransactionRowsFromWorkflowDocuments(ResultSet rs, T summary) throws SQLException {
    TransactionDetailRow detailRow = summary.transactionDetailRow;
    String documentId;
    String initiatorPrincipalId;
    String initiatorPrincipalName;
    String vendorTaxNumber;
    DocumentRouteHeaderValue document;
    // Perform row updates as needed.
    while (rs.next()) {
        // Only update PDP-related rows.
        if (!DisbursementVoucherConstants.DOCUMENT_TYPE_CODE.equals(rs.getString(detailRow.documentType.index))) {
            // Initialize variables.
            documentId = rs.getString(detailRow.documentNumber.index);
            initiatorPrincipalId = null;
            vendorTaxNumber = rs.getString(detailRow.vendorTaxNumber.index);
            // Retrieve document info.
            document = getWorkflowDocumentForTaxRow(documentId, summary);
            if (document != null) {
                initiatorPrincipalId = document.getInitiatorPrincipalId();
            }
            // Check for null objects as needed, and get the initiator's principal name. (NOTE: Uses temp chart from doc title field.)
            initiatorPrincipalName = checkForEntityAndAccountAndOrgExistence(initiatorPrincipalId, rs.getString(detailRow.documentTitle.index), rs.getString(detailRow.accountNumber.index), summary);
            // If vendor tax number is blank, then replace with a generated value accordingly.
            if (StringUtils.isBlank(vendorTaxNumber)) {
                vendorTaxNumber = getReplacementVendorTaxNumber(rs.getString(detailRow.payeeId.index), summary);
                rs.updateString(detailRow.vendorTaxNumber.index, vendorTaxNumber);
            }
            // Do tax-type-specific updates.
            doTaxSpecificSecondPassRowSetup(rs, summary);
            // Update other fields as needed.
            if (StringUtils.isBlank(documentId)) {
                rs.updateString(detailRow.documentNumber.index, CUTaxConstants.DOC_ID_ZERO);
            }
            rs.updateString(detailRow.documentTitle.index, (document != null && StringUtils.isNotBlank(document.getTitle())) ? document.getTitle() : CUTaxConstants.DOC_TITLE_IF_NOT_FOUND);
            rs.updateString(detailRow.initiatorNetId.index, StringUtils.isNotBlank(initiatorPrincipalName) ? initiatorPrincipalName : CUTaxConstants.NETID_IF_NOT_FOUND);
            // Update the current row.
            rs.updateRow();
        }
    }
}
Also used : TransactionDetailRow(edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.TransactionDetailRow) DocumentRouteHeaderValue(org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue)

Example 7 with DocumentRouteHeaderValue

use of org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue in project cu-kfs by CU-CommunityApps.

the class DocumentOperationAction method queueActionInvocation.

public ActionForward queueActionInvocation(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    try {
        DocumentOperationForm docForm = (DocumentOperationForm) form;
        String principalId = KEWServiceLocator.getIdentityHelperService().getIdForPrincipalName(docForm.getActionInvocationUser());
        ActionInvocation invocation = ActionInvocation.create(ActionType.fromCode(docForm.getActionInvocationActionCode()), docForm.getActionInvocationActionItemId());
        DocumentRouteHeaderValue document = docForm.getRouteHeader();
        ActionInvocationQueue actionInvocationQueue = KewApiServiceLocator.getActionInvocationProcessorService(document.getDocumentId());
        actionInvocationQueue.invokeAction(principalId, docForm.getRouteHeader().getDocumentId(), invocation);
        ActionMessages messages = new ActionMessages();
        messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("general.message", "Action Invocation Processor was successfully scheduled"));
        saveMessages(request, messages);
        return mapping.findForward("basic");
    } catch (Exception e) {
        throw new WorkflowRuntimeException(e);
    }
}
Also used : ActionMessages(org.apache.struts.action.ActionMessages) ActionInvocation(org.kuali.kfs.kew.api.action.ActionInvocation) ActionInvocationQueue(org.kuali.kfs.kew.api.action.ActionInvocationQueue) ActionMessage(org.apache.struts.action.ActionMessage) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) DocumentRouteHeaderValue(org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue) ServletException(javax.servlet.ServletException) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) ParseException(java.text.ParseException) WorkflowServiceErrorException(org.kuali.kfs.kew.exception.WorkflowServiceErrorException) IOException(java.io.IOException)

Example 8 with DocumentRouteHeaderValue

use of org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue in project cu-kfs by CU-CommunityApps.

the class DocumentOperationAction method blanketApproveDocument.

public ActionForward blanketApproveDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    try {
        DocumentOperationForm docForm = (DocumentOperationForm) form;
        String blanketApproverUser = docForm.getBlanketApproveUser();
        if (StringUtils.isBlank(blanketApproverUser)) {
            throw new WorkflowServiceErrorException("No user was provided in the Blanket Approve User field", new WorkflowServiceErrorImpl("No user was provided in the Blanket Approve User field", "docoperation.operation.invalid"));
        }
        String principalId = KimApiServiceLocator.getPersonService().getPersonByPrincipalName(docForm.getBlanketApproveUser()).getPrincipalId();
        Set<String> nodeNames = new HashSet<>();
        if (StringUtils.isNotBlank(docForm.getBlanketApproveNodes())) {
            String[] nodeNameArray = docForm.getBlanketApproveNodes().split(",");
            for (String nodeName : nodeNameArray) {
                nodeNames.add(nodeName.trim());
            }
        }
        DocumentRouteHeaderValue document = docForm.getRouteHeader();
        DocumentOrchestrationQueue blanketApprove = KewApiServiceLocator.getDocumentOrchestrationQueue(document.getDocumentId());
        DocumentOrchestrationConfig documentOrchestrationConfig = DocumentOrchestrationConfig.create(docForm.getBlanketApproveActionTakenId(), nodeNames);
        DocumentProcessingOptions options = DocumentProcessingOptions.createDefault();
        blanketApprove.orchestrateDocument(docForm.getRouteHeader().getDocumentId(), principalId, documentOrchestrationConfig, options);
        ActionMessages messages = new ActionMessages();
        messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("general.message", "Blanket Approve Processor was successfully scheduled"));
        saveMessages(request, messages);
        return mapping.findForward("basic");
    } catch (Exception e) {
        throw new WorkflowRuntimeException(e);
    }
}
Also used : WorkflowServiceErrorImpl(org.kuali.kfs.kew.exception.WorkflowServiceErrorImpl) WorkflowServiceErrorException(org.kuali.kfs.kew.exception.WorkflowServiceErrorException) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) DocumentOrchestrationQueue(org.kuali.kfs.kew.api.document.DocumentOrchestrationQueue) DocumentRouteHeaderValue(org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue) ServletException(javax.servlet.ServletException) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) ParseException(java.text.ParseException) WorkflowServiceErrorException(org.kuali.kfs.kew.exception.WorkflowServiceErrorException) IOException(java.io.IOException) DocumentProcessingOptions(org.kuali.kfs.kew.api.document.DocumentProcessingOptions) ActionMessages(org.apache.struts.action.ActionMessages) ActionMessage(org.apache.struts.action.ActionMessage) DocumentOrchestrationConfig(org.kuali.kfs.kew.api.document.DocumentOrchestrationConfig) HashSet(java.util.HashSet)

Example 9 with DocumentRouteHeaderValue

use of org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue in project cu-kfs by CU-CommunityApps.

the class DocumentOperationAction method moveDocument.

public ActionForward moveDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    try {
        DocumentOperationForm docForm = (DocumentOperationForm) form;
        String principalId = KEWServiceLocator.getIdentityHelperService().getIdForPrincipalName(docForm.getBlanketApproveUser());
        Set<String> nodeNames = new HashSet<>();
        if (StringUtils.isNotBlank(docForm.getBlanketApproveNodes())) {
            String[] nodeNameArray = docForm.getBlanketApproveNodes().split(",");
            for (String nodeName : nodeNameArray) {
                nodeNames.add(nodeName.trim());
            }
        }
        DocumentRouteHeaderValue document = docForm.getRouteHeader();
        DocumentOrchestrationQueue orchestrationQueue = KewApiServiceLocator.getDocumentOrchestrationQueue(document.getDocumentId());
        DocumentOrchestrationConfig documentOrchestrationConfig = DocumentOrchestrationConfig.create(docForm.getBlanketApproveActionTakenId(), nodeNames);
        DocumentProcessingOptions options = DocumentProcessingOptions.create(true, true, false);
        orchestrationQueue.orchestrateDocument(docForm.getDocumentId(), principalId, documentOrchestrationConfig, options);
        ActionMessages messages = new ActionMessages();
        messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("general.message", "Move Document Processor was successfully scheduled"));
        saveMessages(request, messages);
        return mapping.findForward("basic");
    } catch (Exception e) {
        throw new WorkflowRuntimeException(e);
    }
}
Also used : WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) DocumentOrchestrationQueue(org.kuali.kfs.kew.api.document.DocumentOrchestrationQueue) DocumentRouteHeaderValue(org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue) ServletException(javax.servlet.ServletException) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) ParseException(java.text.ParseException) WorkflowServiceErrorException(org.kuali.kfs.kew.exception.WorkflowServiceErrorException) IOException(java.io.IOException) DocumentProcessingOptions(org.kuali.kfs.kew.api.document.DocumentProcessingOptions) ActionMessages(org.apache.struts.action.ActionMessages) ActionMessage(org.apache.struts.action.ActionMessage) DocumentOrchestrationConfig(org.kuali.kfs.kew.api.document.DocumentOrchestrationConfig) HashSet(java.util.HashSet)

Example 10 with DocumentRouteHeaderValue

use of org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue in project cu-kfs by CU-CommunityApps.

the class DocumentOperationAction method queueDocument.

public ActionForward queueDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    try {
        DocumentOperationForm docForm = (DocumentOperationForm) form;
        DocumentRouteHeaderValue document = docForm.getRouteHeader();
        DocumentProcessingQueue documentProcessingQueue = KewApiServiceLocator.getDocumentProcessingQueue(document.getDocumentId());
        documentProcessingQueue.process(docForm.getDocumentId());
        ActionMessages messages = new ActionMessages();
        messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("general.message", "Document was successfully queued"));
        saveMessages(request, messages);
        return mapping.findForward("basic");
    } catch (Exception e) {
        throw new WorkflowRuntimeException(e);
    }
}
Also used : ActionMessages(org.apache.struts.action.ActionMessages) ActionMessage(org.apache.struts.action.ActionMessage) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) DocumentRouteHeaderValue(org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue) ServletException(javax.servlet.ServletException) WorkflowRuntimeException(org.kuali.kfs.kew.api.WorkflowRuntimeException) ParseException(java.text.ParseException) WorkflowServiceErrorException(org.kuali.kfs.kew.exception.WorkflowServiceErrorException) IOException(java.io.IOException) DocumentProcessingQueue(org.kuali.kfs.kew.api.document.DocumentProcessingQueue)

Aggregations

DocumentRouteHeaderValue (org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue)16 ParseException (java.text.ParseException)5 ActionMessage (org.apache.struts.action.ActionMessage)5 ActionMessages (org.apache.struts.action.ActionMessages)5 WorkflowRuntimeException (org.kuali.kfs.kew.api.WorkflowRuntimeException)5 WorkflowServiceErrorException (org.kuali.kfs.kew.exception.WorkflowServiceErrorException)5 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 ServletException (javax.servlet.ServletException)4 TransactionDetailRow (edu.cornell.kfs.tax.dataaccess.impl.TaxTableRow.TransactionDetailRow)3 HashSet (java.util.HashSet)3 DocumentStatus (org.kuali.kfs.kew.api.document.DocumentStatus)3 Iterator (java.util.Iterator)2 List (java.util.List)2 DocumentOrchestrationConfig (org.kuali.kfs.kew.api.document.DocumentOrchestrationConfig)2 DocumentOrchestrationQueue (org.kuali.kfs.kew.api.document.DocumentOrchestrationQueue)2 DocumentProcessingOptions (org.kuali.kfs.kew.api.document.DocumentProcessingOptions)2 DocumentSearchCriteria (org.kuali.kfs.kew.api.document.search.DocumentSearchCriteria)2 DocumentSearchResult (org.kuali.kfs.kew.api.document.search.DocumentSearchResult)2 DocumentSearchResults (org.kuali.kfs.kew.api.document.search.DocumentSearchResults)2