@Override public void nodeInstanceCompleted(org.jbpm.workflow.instance.NodeInstance nodeInstance, String outType) { if (nodeInstance instanceof EndNodeInstance) { if (getCompositeNode().isKeepActive()) { StartNode startNode = getCompositeNode().findStartNode(); triggerCompleted(true); if (startNode.isInterrupting()) { String faultName = getProcessInstance().getOutcome()==null?"":getProcessInstance().getOutcome(); if (startNode.getMetaData("FaultCode") != null) { faultName = (String) startNode.getMetaData("FaultCode"); } if (getNodeInstanceContainer() instanceof ProcessInstance) { ((ProcessInstance) getProcessInstance()).setState(ProcessInstance.STATE_ABORTED, faultName); } else { ((NodeInstanceContainer) getNodeInstanceContainer()).setState( ProcessInstance.STATE_ABORTED); } } } } else { throw new IllegalArgumentException( "Completing a node instance that has no outgoing connection not supported."); } }
@Test public void testEventSubProcessErrorWithScript() throws Exception { KieBase kbase = createKnowledgeBase("BPMN2-EventSubProcessErrorWithScript.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.getWorkItemManager().registerWorkItemHandler("Request Handler", new SignallingTaskHandlerDecorator(ExceptionOnPurposeHandler.class, "Error-90277")); ksession.getWorkItemManager().registerWorkItemHandler("Error Handler", new SystemOutWorkItemHandler()); ProcessInstance processInstance = ksession.startProcess("com.sample.process"); assertProcessInstanceAborted(processInstance); assertEquals("90277", ((WorkflowProcessInstance) processInstance).getOutcome()); }
@Override public void nodeInstanceCompleted(org.jbpm.workflow.instance.NodeInstance nodeInstance, String outType) { if (nodeInstance instanceof EndNodeInstance) { if (getCompositeNode().isKeepActive()) { StartNode startNode = getCompositeNode().findStartNode(); triggerCompleted(true); if (startNode.isInterrupting()) { String faultName = getProcessInstance().getOutcome()==null?"":getProcessInstance().getOutcome(); if (startNode.getMetaData("FaultCode") != null) { faultName = (String) startNode.getMetaData("FaultCode"); } if (getNodeInstanceContainer() instanceof ProcessInstance) { ((ProcessInstance) getProcessInstance()).setState(ProcessInstance.STATE_ABORTED, faultName); } else { ((NodeInstanceContainer) getNodeInstanceContainer()).setState( ProcessInstance.STATE_ABORTED); } } } } else { throw new IllegalArgumentException( "Completing a node instance that has no outgoing connection not supported."); } }
@Test public void testEventSubProcessErrorWithScript() throws Exception { KieBase kbase = createKnowledgeBase("BPMN2-EventSubProcessErrorWithScript.bpmn2"); ksession = createKnowledgeSession(kbase); ksession.getWorkItemManager().registerWorkItemHandler("Request Handler", new SignallingTaskHandlerDecorator(ExceptionOnPurposeHandler.class, "Error-90277")); ksession.getWorkItemManager().registerWorkItemHandler("Error Handler", new SystemOutWorkItemHandler()); ProcessInstance processInstance = ksession.startProcess("com.sample.process"); assertProcessInstanceAborted(processInstance); assertEquals("90277", ((WorkflowProcessInstance) processInstance).getOutcome()); }