private void addProcessListener() { getProcessInstance().addEventListener("processInstanceCompleted:" + processInstanceId, this, true); }
@Override public ContextInstance getContextInstance(Context context) { ContextInstanceFactory conf = ContextInstanceFactoryRegistry.INSTANCE.getContextInstanceFactory(context); if (conf == null) { throw new IllegalArgumentException("Illegal context type (registry not found): " + context.getClass()); } ContextInstance contextInstance = (ContextInstance) conf.getContextInstance(context, this, (ProcessInstance) getProcessInstance()); if (contextInstance == null) { throw new IllegalArgumentException("Illegal context type (instance not found): " + context.getClass()); } return contextInstance; }
public void removeEventListeners() { super.removeEventListeners(); getProcessInstance().removeEventListener("processInstanceCompleted:" + processInstanceId, this, true); }
processId = processId.replace("#{" + replacement.getKey() + "}", replacement.getValue()); KieBase kbase = ((ProcessInstance) getProcessInstance()).getKnowledgeRuntime().getKieBase(); 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 { KieRuntime kruntime = ((ProcessInstance) getProcessInstance()).getKnowledgeRuntime(); RuntimeManager manager = (RuntimeManager) kruntime.getEnvironment().get(EnvironmentName.RUNTIME_MANAGER); if (manager != null) { if (((WorkflowProcessInstanceImpl)getProcessInstance()).getCorrelationKey() != null) { businessKeys.add(((WorkflowProcessInstanceImpl)getProcessInstance()).getCorrelationKey()); businessKeys.add(processId); businessKeys.add(String.valueOf(System.currentTimeMillis())); ((ProcessInstanceImpl) processInstance).setMetaData("ParentProcessInstanceId", getProcessInstance().getId()); ((ProcessInstanceImpl) processInstance).setMetaData("ParentNodeInstanceId", getUniqueId()); ((ProcessInstanceImpl) processInstance).setMetaData("ParentNodeId", getSubProcessNode().getUniqueId()); ((ProcessInstanceImpl) processInstance).setParentProcessInstanceId(getProcessInstance().getId()); ((ProcessInstanceImpl) processInstance).setSignalCompletion(getSubProcessNode().isWaitForCompletion());
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(); }
private void addProcessListener() { getProcessInstance().addEventListener("processInstanceCompleted:" + processInstanceId, this, true); }
@Override public ContextInstance getContextInstance(Context context) { ContextInstanceFactory conf = ContextInstanceFactoryRegistry.INSTANCE.getContextInstanceFactory(context); if (conf == null) { throw new IllegalArgumentException("Illegal context type (registry not found): " + context.getClass()); } ContextInstance contextInstance = (ContextInstance) conf.getContextInstance(context, this, (ProcessInstance) getProcessInstance()); if (contextInstance == null) { throw new IllegalArgumentException("Illegal context type (instance not found): " + context.getClass()); } return contextInstance; }
public void removeEventListeners() { super.removeEventListeners(); getProcessInstance().removeEventListener("processInstanceCompleted:" + processInstanceId, this, true); }
processId = processId.replace("#{" + replacement.getKey() + "}", replacement.getValue()); KieBase kbase = ((ProcessInstance) getProcessInstance()).getKnowledgeRuntime().getKieBase(); 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 { KieRuntime kruntime = ((ProcessInstance) getProcessInstance()).getKnowledgeRuntime(); RuntimeManager manager = (RuntimeManager) kruntime.getEnvironment().get(EnvironmentName.RUNTIME_MANAGER); if (manager != null) { if (((WorkflowProcessInstanceImpl)getProcessInstance()).getCorrelationKey() != null) { businessKeys.add(((WorkflowProcessInstanceImpl)getProcessInstance()).getCorrelationKey()); businessKeys.add(processId); businessKeys.add(String.valueOf(System.currentTimeMillis())); ((ProcessInstanceImpl) processInstance).setMetaData("ParentProcessInstanceId", getProcessInstance().getId()); ((ProcessInstanceImpl) processInstance).setMetaData("ParentNodeInstanceId", getUniqueId()); ((ProcessInstanceImpl) processInstance).setMetaData("ParentNodeId", getSubProcessNode().getUniqueId()); ((ProcessInstanceImpl) processInstance).setParentProcessInstanceId(getProcessInstance().getId()); ((ProcessInstanceImpl) processInstance).setSignalCompletion(getSubProcessNode().isWaitForCompletion());
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(); }