public void abortProcessInstance(long processInstanceId) { ProcessInstance processInstance = getProcessInstance(processInstanceId); if ( processInstance == null ) { throw new IllegalArgumentException( "Could not find process instance for id " + processInstanceId ); } ((org.jbpm.process.instance.ProcessInstance) processInstance).setState( ProcessInstance.STATE_ABORTED ); }
public Object execute(Context context ) { KieSession ksession = ((RegistryContext) context).lookup( KieSession.class ); if (processInstanceId == null) { return null; } ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId); if ( processInstance == null ) { throw new IllegalArgumentException( "Could not find process instance for id " + processInstanceId ); } if ( processInstance.getState() != ProcessInstance.STATE_SUSPENDED ) { throw new IllegalArgumentException( "Process instance with id " + processInstanceId + " in state " + processInstance.getState()); } ((org.jbpm.process.instance.ProcessInstance) processInstance).setState( ProcessInstance.STATE_ACTIVE ); return null; }
public Object execute(Context context ) { KieSession ksession = ((RegistryContext) context).lookup( KieSession.class ); if (processInstanceId == null) { return null; } ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId); if ( processInstance == null ) { throw new IllegalArgumentException( "Could not find process instance for id " + processInstanceId ); } if ( processInstance.getState() != ProcessInstance.STATE_ACTIVE ) { throw new IllegalArgumentException( "Process instance with id " + processInstanceId + " in state " + processInstance.getState()); } ((org.jbpm.process.instance.ProcessInstance) processInstance).setState( ProcessInstance.STATE_SUSPENDED ); return null; }
@Test public void testSubProcessCancel() throws Exception { KieSession workingMemory = createStatefulKnowledgeSessionFromRule(true); org.jbpm.process.instance.ProcessInstance processInstance = ( org.jbpm.process.instance.ProcessInstance ) workingMemory.startProcess("com.sample.ruleflow"); assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState()); assertEquals(2, workingMemory.getProcessInstances().size()); processInstance.setState(ProcessInstance.STATE_ABORTED); assertEquals(1, workingMemory.getProcessInstances().size()); }
@Test public void testIndependentSubProcessCancel() throws Exception { KieSession workingMemory = createStatefulKnowledgeSessionFromRule(false); org.jbpm.process.instance.ProcessInstance processInstance = ( org.jbpm.process.instance.ProcessInstance ) workingMemory.startProcess("com.sample.ruleflow"); assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState()); assertEquals(2, workingMemory.getProcessInstances().size()); processInstance.setState(ProcessInstance.STATE_ABORTED); assertEquals(0, workingMemory.getProcessInstances().size()); }
logger.error("Could not find process {}", processId); logger.error("Aborting process"); ((ProcessInstance) getProcessInstance()).setState(ProcessInstance.STATE_ABORTED); throw new RuntimeException("Could not find process " + processId); } else {
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState()); assertEquals(4, workingMemory.getProcessInstances().size()); processInstance.setState(ProcessInstance.STATE_ABORTED); assertEquals(3, workingMemory.getProcessInstances().size());
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState()); assertEquals(4, workingMemory.getProcessInstances().size()); processInstance.setState(ProcessInstance.STATE_ABORTED); assertEquals(0, workingMemory.getProcessInstances().size());
@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."); } }
public void cancel() { WorkItem workItem = getWorkItem(); if (workItem != null && workItem.getState() != WorkItem.COMPLETED && workItem.getState() != WorkItem.ABORTED) { try { ((WorkItemManager) ((ProcessInstance) getProcessInstance()) .getKnowledgeRuntime().getWorkItemManager()).internalAbortWorkItem(workItemId); } catch (WorkItemHandlerNotFoundException wihnfe) { getProcessInstance().setState(ProcessInstance.STATE_ABORTED); throw wihnfe; } } if (exceptionHandlingProcessInstanceId > -1) { ProcessInstance processInstance = null; KieRuntime kruntime = getKieRuntimeForSubprocess(); processInstance = (ProcessInstance) kruntime.getProcessInstance(exceptionHandlingProcessInstanceId); if (processInstance != null) { processInstance.setState(ProcessInstance.STATE_ABORTED); } } super.cancel(); }
((ProcessInstance) getProcessInstance()).setState(ProcessInstance.STATE_ABORTED, faultName, getFaultData());
public void cancel() { super.cancel(); if (getSubProcessNode() == null || !getSubProcessNode().isIndependent()) { ProcessInstance processInstance = null; InternalKnowledgeRuntime kruntime = ((ProcessInstance) getProcessInstance()).getKnowledgeRuntime(); RuntimeManager manager = (RuntimeManager) kruntime.getEnvironment().get(EnvironmentName.RUNTIME_MANAGER); if (manager != null) { try { org.kie.api.runtime.manager.Context<?> context = ProcessInstanceIdContext.get(processInstanceId); String caseId = (String) kruntime.getEnvironment().get(EnvironmentName.CASE_ID); if (caseId != null) { context = CaseContext.get(caseId); } RuntimeEngine runtime = manager.getRuntimeEngine(context); KieRuntime managedkruntime = (KieRuntime) runtime.getKieSession(); processInstance = (ProcessInstance) managedkruntime.getProcessInstance(processInstanceId); } catch (SessionNotFoundException e) { // in case no session is found for parent process let's skip signal for process instance completion } } else { processInstance = (ProcessInstance) kruntime.getProcessInstance(processInstanceId); } if (processInstance != null) { processInstance.setState(ProcessInstance.STATE_ABORTED); } } }
public void processInstanceCompleted(ProcessInstance processInstance) { removeEventListeners(); handleOutMappings(processInstance); if (processInstance.getState() == ProcessInstance.STATE_ABORTED) { String faultName = processInstance.getOutcome()==null?"":processInstance.getOutcome(); // handle exception as sub process failed with error code ExceptionScopeInstance exceptionScopeInstance = (ExceptionScopeInstance) resolveContextInstance(ExceptionScope.EXCEPTION_SCOPE, faultName); if (exceptionScopeInstance != null) { exceptionScopeInstance.handleException(faultName, processInstance.getFaultData()); if (getSubProcessNode() != null && !getSubProcessNode().isIndependent() && getSubProcessNode().isAbortParent()){ cancel(); } return; } else if (getSubProcessNode() != null && !getSubProcessNode().isIndependent() && getSubProcessNode().isAbortParent()){ ((ProcessInstance) getProcessInstance()).setState(ProcessInstance.STATE_ABORTED, faultName); return; } } // handle dynamic subprocess if (getNode() == null) { setMetaData("NodeType", "SubProcessNode"); } // if there were no exception proceed normally triggerCompleted(); }
WorkItem workItem = handler.getWorkItem(); assertNotNull(workItem); processInstance.setState(ProcessInstance.STATE_ABORTED); assertTrue(handler.isAborted());
public void abortProcessInstance(long processInstanceId) { ProcessInstance processInstance = getProcessInstance(processInstanceId); if ( processInstance == null ) { throw new IllegalArgumentException( "Could not find process instance for id " + processInstanceId ); } ((org.jbpm.process.instance.ProcessInstance) processInstance).setState( ProcessInstance.STATE_ABORTED ); }
public Object execute(Context context ) { KieSession ksession = ((RegistryContext) context).lookup( KieSession.class ); if (processInstanceId == null) { return null; } ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId); if ( processInstance == null ) { throw new IllegalArgumentException( "Could not find process instance for id " + processInstanceId ); } if ( processInstance.getState() != ProcessInstance.STATE_SUSPENDED ) { throw new IllegalArgumentException( "Process instance with id " + processInstanceId + " in state " + processInstance.getState()); } ((org.jbpm.process.instance.ProcessInstance) processInstance).setState( ProcessInstance.STATE_ACTIVE ); return null; }
public Object execute(Context context ) { KieSession ksession = ((RegistryContext) context).lookup( KieSession.class ); if (processInstanceId == null) { return null; } ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId); if ( processInstance == null ) { throw new IllegalArgumentException( "Could not find process instance for id " + processInstanceId ); } if ( processInstance.getState() != ProcessInstance.STATE_ACTIVE ) { throw new IllegalArgumentException( "Process instance with id " + processInstanceId + " in state " + processInstance.getState()); } ((org.jbpm.process.instance.ProcessInstance) processInstance).setState( ProcessInstance.STATE_SUSPENDED ); return null; }
@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."); } }
public void cancel() { WorkItem workItem = getWorkItem(); if (workItem != null && workItem.getState() != WorkItem.COMPLETED && workItem.getState() != WorkItem.ABORTED) { try { ((WorkItemManager) ((ProcessInstance) getProcessInstance()) .getKnowledgeRuntime().getWorkItemManager()).internalAbortWorkItem(workItemId); } catch (WorkItemHandlerNotFoundException wihnfe) { getProcessInstance().setState(ProcessInstance.STATE_ABORTED); throw wihnfe; } } if (exceptionHandlingProcessInstanceId > -1) { ProcessInstance processInstance = null; KieRuntime kruntime = getKieRuntimeForSubprocess(); processInstance = (ProcessInstance) kruntime.getProcessInstance(exceptionHandlingProcessInstanceId); if (processInstance != null) { processInstance.setState(ProcessInstance.STATE_ABORTED); } } super.cancel(); }
public void processInstanceCompleted(ProcessInstance processInstance) { removeEventListeners(); handleOutMappings(processInstance); if (processInstance.getState() == ProcessInstance.STATE_ABORTED) { String faultName = processInstance.getOutcome()==null?"":processInstance.getOutcome(); // handle exception as sub process failed with error code ExceptionScopeInstance exceptionScopeInstance = (ExceptionScopeInstance) resolveContextInstance(ExceptionScope.EXCEPTION_SCOPE, faultName); if (exceptionScopeInstance != null) { exceptionScopeInstance.handleException(faultName, processInstance.getFaultData()); if (getSubProcessNode() != null && !getSubProcessNode().isIndependent() && getSubProcessNode().isAbortParent()){ cancel(); } return; } else if (getSubProcessNode() != null && !getSubProcessNode().isIndependent() && getSubProcessNode().isAbortParent()){ ((ProcessInstance) getProcessInstance()).setState(ProcessInstance.STATE_ABORTED, faultName); return; } } // handle dynamic subprocess if (getNode() == null) { setMetaData("NodeType", "SubProcessNode"); } // if there were no exception proceed normally triggerCompleted(); }