public void addExceptionProcessListener() { if (exceptionHandlingProcessInstanceId > -1) { getProcessInstance().addEventListener("processInstanceCompleted:" + exceptionHandlingProcessInstanceId, this, true); } }
private void addWorkItemListener() { getProcessInstance().addEventListener("workItemCompleted", this, false); getProcessInstance().addEventListener("workItemAborted", this, false); }
@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("workItemCompleted", this, false); getProcessInstance().removeEventListener("workItemAborted", this, false); }
public void removeExceptionProcessListeners() { super.removeEventListeners(); getProcessInstance().removeEventListener("processInstanceCompleted:" + exceptionHandlingProcessInstanceId, this, true); }
public WorkItem getWorkItem() { if (workItem == null && workItemId >= 0) { workItem = ((WorkItemManager) ((ProcessInstance) getProcessInstance()) .getKnowledgeRuntime().getWorkItemManager()).getWorkItem(workItemId); } return workItem; }
@Override public void signalEvent(String type, Object event) { if ("workItemCompleted".equals(type)) { workItemCompleted((WorkItem) event); } else if ("workItemAborted".equals(type)) { workItemAborted((WorkItem) event); } else if (("processInstanceCompleted:" + exceptionHandlingProcessInstanceId).equals(type)) { exceptionHandlingCompleted((ProcessInstance) event, null); } else if (type.equals("RuleFlow-Activate" + getProcessInstance().getProcessId() + "-" + getNode().getMetaData().get("UniqueId"))) { trigger(null, org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE); } else { super.signalEvent(type, event); } }
private void handleAssignment(Assignment assignment) { AssignmentAction action = (AssignmentAction) assignment.getMetaData("Action"); try { ProcessContext context = new ProcessContext(getProcessInstance().getKnowledgeRuntime()); context.setNodeInstance(this); action.execute(getWorkItem(), context); } catch (Exception e) { throw new RuntimeException("unable to execute Assignment", e); } }
((ProcessInstanceImpl) processInstance).setMetaData("ParentProcessInstanceId", getProcessInstance().getId()); ((ProcessInstanceImpl) processInstance).setMetaData("ParentNodeInstanceId", getUniqueId()); ((ProcessInstanceImpl) processInstance).setParentProcessInstanceId(getProcessInstance().getId()); ((ProcessInstanceImpl) processInstance).setSignalCompletion(true);
workItem = new WorkItemImpl(); ((WorkItem) workItem).setName(work.getName()); ((WorkItem) workItem).setProcessInstanceId(getProcessInstance().getId()); ((WorkItem) workItem).setParameters(new HashMap<String, Object>(work.getParameters()));
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(); }
((WorkItemManager) ((ProcessInstance) getProcessInstance()) .getKnowledgeRuntime().getWorkItemManager()).abortWorkItem(getWorkItem().getId()); break; ExceptionScopeInstance exceptionScopeInstance = (ExceptionScopeInstance) resolveContextInstance(ExceptionScope.EXCEPTION_SCOPE, exceptionName); if (exceptionScopeInstance == null) { throw new WorkflowRuntimeException(this, getProcessInstance(), "Unable to execute work item " + handlerException.getMessage(), handlerException.getCause()); ((WorkItemManager) ((ProcessInstance) getProcessInstance()) .getKnowledgeRuntime().getWorkItemManager()).retryWorkItem(getWorkItem().getId(), parameters); break; case COMPLETE: ((WorkItemManager) ((ProcessInstance) getProcessInstance()) .getKnowledgeRuntime().getWorkItemManager()).completeWorkItem(getWorkItem().getId(), ((WorkflowProcessInstanceImpl)processInstance).getVariables());
addWorkItemListener(); String deploymentId = (String) getProcessInstance().getKnowledgeRuntime().getEnvironment().get(EnvironmentName.DEPLOYMENT_ID); ((WorkItem) workItem).setDeploymentId(deploymentId); ((WorkItem) workItem).setNodeInstanceId(this.getId()); ((WorkItem) workItem).setNodeId(getNodeId()); if (isInversionOfControl()) { ((ProcessInstance) getProcessInstance()).getKnowledgeRuntime() .update(((ProcessInstance) getProcessInstance()).getKnowledgeRuntime().getFactHandle(this), this); } else { try { ((WorkItemManager) ((ProcessInstance) getProcessInstance()) .getKnowledgeRuntime().getWorkItemManager()).internalExecuteWorkItem( (org.drools.core.process.instance.WorkItem) workItem); } catch (WorkItemHandlerNotFoundException wihnfe) { getProcessInstance().setState(ProcessInstance.STATE_ABORTED); throw wihnfe; } catch (ProcessWorkItemHandlerException handlerException) { ExceptionScopeInstance exceptionScopeInstance = (ExceptionScopeInstance) resolveContextInstance(ExceptionScope.EXCEPTION_SCOPE, exceptionName); if (exceptionScopeInstance == null) { throw new WorkflowRuntimeException(this, getProcessInstance(), "Unable to execute Action: " + e.getMessage(), e);
protected KieRuntime getKieRuntimeForSubprocess() { KieRuntime kruntime = ((ProcessInstance) getProcessInstance()).getKnowledgeRuntime(); RuntimeManager manager = (RuntimeManager) kruntime.getEnvironment().get(EnvironmentName.RUNTIME_MANAGER); if (manager != null) { org.kie.api.runtime.manager.Context<?> context = ProcessInstanceIdContext.get(); String caseId = (String) kruntime.getEnvironment().get(EnvironmentName.CASE_ID); if (caseId != null) { context = CaseContext.get(caseId); } RuntimeEngine runtime = manager.getRuntimeEngine(context); kruntime = (KieRuntime) runtime.getKieSession(); } return kruntime; }
validateWorkItemResultVariable(getProcessInstance().getProcessName(), workItemNode.getOutAssociations(), workItem); for (Iterator<DataAssociation> iterator = getWorkItemNode().getOutAssociations().iterator(); iterator.hasNext();) { DataAssociation association = iterator.next(); if (variableScopeInstance != null && parameterValue != null) { variableScopeInstance.getVariableScope().validateVariable(getProcessInstance().getProcessName(), association.getTarget(), parameterValue); value = dataType.readValue((String) value); } else { variableScopeInstance.getVariableScope().validateVariable(getProcessInstance().getProcessName(), association.getTarget(), value); KieRuntime kruntime = ((ProcessInstance) getProcessInstance()).getKnowledgeRuntime(); kruntime.update(kruntime.getFactHandle(this), this); } else {
public void addExceptionProcessListener() { if (exceptionHandlingProcessInstanceId > -1) { getProcessInstance().addEventListener("processInstanceCompleted:" + exceptionHandlingProcessInstanceId, this, true); } }
private void addWorkItemListener() { getProcessInstance().addEventListener("workItemCompleted", this, false); getProcessInstance().addEventListener("workItemAborted", this, false); }
@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("workItemCompleted", this, false); getProcessInstance().removeEventListener("workItemAborted", this, false); }
public WorkItem getWorkItem() { if (workItem == null && workItemId >= 0) { workItem = ((WorkItemManager) ((ProcessInstance) getProcessInstance()) .getKnowledgeRuntime().getWorkItemManager()).getWorkItem(workItemId); } return workItem; }