Search in sources :

Example 1 with DocumentOrchestrationConfig

use of org.kuali.kfs.kew.api.document.DocumentOrchestrationConfig 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 2 with DocumentOrchestrationConfig

use of org.kuali.kfs.kew.api.document.DocumentOrchestrationConfig 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)

Aggregations

IOException (java.io.IOException)2 ParseException (java.text.ParseException)2 HashSet (java.util.HashSet)2 ServletException (javax.servlet.ServletException)2 ActionMessage (org.apache.struts.action.ActionMessage)2 ActionMessages (org.apache.struts.action.ActionMessages)2 WorkflowRuntimeException (org.kuali.kfs.kew.api.WorkflowRuntimeException)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 WorkflowServiceErrorException (org.kuali.kfs.kew.exception.WorkflowServiceErrorException)2 DocumentRouteHeaderValue (org.kuali.kfs.kew.routeheader.DocumentRouteHeaderValue)2 WorkflowServiceErrorImpl (org.kuali.kfs.kew.exception.WorkflowServiceErrorImpl)1