public void retractFacts() { Map<String, Object> objects = new HashMap<String, Object>(); KieRuntime kruntime = getProcessInstance().getKnowledgeRuntime(); for (Entry<String, FactHandle> entry : factHandles.entrySet()) { Object object = ((StatefulKnowledgeSession)kruntime).getObject(entry.getValue()); String key = entry.getKey(); key = key.replaceAll(getRuleFlowGroup()+"_", ""); key = key.replaceAll(getProcessInstance().getId()+"_", ""); objects.put(key , object); kruntime.delete(entry.getValue()); } processOutputs(objects); factHandles.clear(); }
protected boolean checkProcessInstance(Activation activation) { final Map<?, ?> declarations = activation.getSubRule().getOuterDeclarations(); for ( Iterator<?> it = declarations.values().iterator(); it.hasNext(); ) { Declaration declaration = (Declaration) it.next(); if ("processInstance".equals(declaration.getIdentifier()) || "org.kie.api.runtime.process.WorkflowProcessInstance".equals(declaration.getTypeName())) { Object value = declaration.getValue( ((StatefulKnowledgeSessionImpl) getProcessInstance().getKnowledgeRuntime()).getInternalWorkingMemory(), ((InternalFactHandle) activation.getTuple().get(declaration)).getObject()); if (value instanceof ProcessInstance) { return ((ProcessInstance) value).getId() == getProcessInstance().getId(); } } } return true; }
((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 Long execute(Context context) { StatefulKnowledgeSession ksession = (StatefulKnowledgeSession) ((RegistryContext) context).lookup(KieSession.class); WorkflowProcessInstance realProcessInstance = (WorkflowProcessInstance) ksession.getProcessInstance(processInstance.getId()); subProcessNodeInstance.setProcessInstance(realProcessInstance); if (dynamicContext == null) { subProcessNodeInstance.setNodeInstanceContainer(realProcessInstance); } else { DynamicNodeInstance realDynamicContext = findDynamicContext(realProcessInstance, dynamicContext.getUniqueId()); subProcessNodeInstance.setNodeInstanceContainer(realDynamicContext); } return executeSubProcess((StatefulKnowledgeSessionImpl) ksession, processId, parameters, processInstance, subProcessNodeInstance); } });
final WorkItemImpl workItem = new WorkItemImpl(); workItem.setState(WorkItem.ACTIVE); workItem.setProcessInstanceId(processInstance.getId()); workItem.setDeploymentId((String) ksession.getEnvironment().get(EnvironmentName.DEPLOYMENT_ID)); workItem.setName(workItemName);
public Void execute(Context context) { StatefulKnowledgeSession ksession = (StatefulKnowledgeSession) ((RegistryContext) context).lookup(KieSession.class); WorkflowProcessInstance realProcessInstance = (WorkflowProcessInstance) ksession.getProcessInstance(processInstance.getId()); workItemNodeInstance.setProcessInstance(realProcessInstance); if (dynamicContext == null) { workItemNodeInstance.setNodeInstanceContainer(realProcessInstance); } else { DynamicNodeInstance realDynamicContext = findDynamicContext(realProcessInstance, dynamicContext.getUniqueId()); workItemNodeInstance.setNodeInstanceContainer(realDynamicContext); } workItemNodeInstance.addEventListeners(); executeWorkItem((StatefulKnowledgeSessionImpl) ksession, workItem, workItemNodeInstance); return null; } });
String inputKey = getRuleFlowGroup() + "_" + getProcessInstance().getId() + "_" + entry.getKey(); addRuleSetListener(); ((InternalAgenda) getProcessInstance().getKnowledgeRuntime().getAgenda()) .activateRuleFlowGroup(getRuleFlowGroup(), getProcessInstance().getId(), getUniqueId()); .activateRuleFlowGroup(getRuleFlowGroup(), getProcessInstance().getId(), getUniqueId());
public void internalTrigger(final NodeInstance from, String type) { super.internalTrigger(from, type); // if node instance was cancelled, abort if (getNodeInstanceContainer().getNodeInstance(getId()) == null) { return; } if (!org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE.equals(type)) { throw new IllegalArgumentException( "A MilestoneNode only accepts default incoming connections!"); } String rule = "RuleFlow-Milestone-" + getProcessInstance().getProcessId() + "-" + getMilestoneNode().getUniqueId(); boolean isActive = ((InternalAgenda) getProcessInstance().getKnowledgeRuntime().getAgenda()) .isRuleActiveInRuleFlowGroup("DROOLS_SYSTEM", rule, getProcessInstance().getId()); if (isActive) { triggerCompleted(); } else { addActivationListener(); } }
public void internalTrigger(final NodeInstance from, String type) { super.internalTrigger(from, type); ExecutorService executorService = (ExecutorService) getProcessInstance().getKnowledgeRuntime().getEnvironment().get("ExecutorService"); if (executorService != null) { RuntimeManager runtimeManager = ((RuntimeManager)getProcessInstance().getKnowledgeRuntime().getEnvironment().get("RuntimeManager")); CommandContext ctx = new CommandContext(); ctx.setData("deploymentId", runtimeManager.getIdentifier()); ctx.setData("processInstanceId", getProcessInstance().getId()); ctx.setData("Signal", getEventType()); ctx.setData("Event", null); executorService.scheduleRequest(AsyncSignalEventCommand.class.getName(), ctx); Node node = getNode(); if (node != null) { String uniqueId = (String) node.getMetaData().get("UniqueId"); if( uniqueId == null ) { uniqueId = ((NodeImpl) node).getUniqueId(); } ((WorkflowProcessInstanceImpl) getProcessInstance()).getIterationLevels().remove(getNode().getMetaData().get("UniqueId")); } } else { logger.warn("No async executor service found continuing as sync operation..."); // if there is no executor service available move as sync node triggerCompleted(); } }
((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());
.isRuleActiveInRuleFlowGroup("DROOLS_SYSTEM", name, getProcessInstance().getId()); if (isActive) { getProcessInstance().getKnowledgeRuntime().signalEvent(name, null);
if (ruleFlowGroup != null && !agenda.getRuleFlowGroup(ruleFlowGroup).isActive()) { agenda.getRuleFlowGroup(ruleFlowGroup).setAutoDeactivate(false); agenda.activateRuleFlowGroup(ruleFlowGroup, getProcessInstance().getId(), getUniqueId()); .isRuleActiveInRuleFlowGroup(getRuleFlowGroupName(), rule, getProcessInstance().getId()); if (isActive) { triggerCompleted();
connection.getToType(); boolean isActive = ((InternalAgenda) getProcessInstance().getKnowledgeRuntime().getAgenda()) .isRuleActiveInRuleFlowGroup("DROOLS_SYSTEM", rule, getProcessInstance().getId()); if (isActive) { selected = connection;
public void retractFacts() { Map<String, Object> objects = new HashMap<String, Object>(); KieRuntime kruntime = getProcessInstance().getKnowledgeRuntime(); for (Entry<String, FactHandle> entry : factHandles.entrySet()) { Object object = ((StatefulKnowledgeSession)kruntime).getObject(entry.getValue()); String key = entry.getKey(); key = key.replaceAll(getRuleFlowGroup()+"_", ""); key = key.replaceAll(getProcessInstance().getId()+"_", ""); objects.put(key , object); kruntime.delete(entry.getValue()); } processOutputs(objects); factHandles.clear(); }
protected boolean checkProcessInstance(Activation activation) { final Map<?, ?> declarations = activation.getSubRule().getOuterDeclarations(); for ( Iterator<?> it = declarations.values().iterator(); it.hasNext(); ) { Declaration declaration = (Declaration) it.next(); if ("processInstance".equals(declaration.getIdentifier()) || "org.kie.api.runtime.process.WorkflowProcessInstance".equals(declaration.getTypeName())) { Object value = declaration.getValue( ((StatefulKnowledgeSessionImpl) getProcessInstance().getKnowledgeRuntime()).getInternalWorkingMemory(), ((InternalFactHandle) activation.getTuple().get(declaration)).getObject()); if (value instanceof ProcessInstance) { return ((ProcessInstance) value).getId() == getProcessInstance().getId(); } } } return true; }
public Long execute(Context context) { StatefulKnowledgeSession ksession = (StatefulKnowledgeSession) ((RegistryContext) context).lookup(KieSession.class); WorkflowProcessInstance realProcessInstance = (WorkflowProcessInstance) ksession.getProcessInstance(processInstance.getId()); subProcessNodeInstance.setProcessInstance(realProcessInstance); if (dynamicContext == null) { subProcessNodeInstance.setNodeInstanceContainer(realProcessInstance); } else { DynamicNodeInstance realDynamicContext = findDynamicContext(realProcessInstance, dynamicContext.getUniqueId()); subProcessNodeInstance.setNodeInstanceContainer(realDynamicContext); } return executeSubProcess((StatefulKnowledgeSessionImpl) ksession, processId, parameters, processInstance, subProcessNodeInstance); } });
public Void execute(Context context) { StatefulKnowledgeSession ksession = (StatefulKnowledgeSession) ((RegistryContext) context).lookup(KieSession.class); WorkflowProcessInstance realProcessInstance = (WorkflowProcessInstance) ksession.getProcessInstance(processInstance.getId()); workItemNodeInstance.setProcessInstance(realProcessInstance); if (dynamicContext == null) { workItemNodeInstance.setNodeInstanceContainer(realProcessInstance); } else { DynamicNodeInstance realDynamicContext = findDynamicContext(realProcessInstance, dynamicContext.getUniqueId()); workItemNodeInstance.setNodeInstanceContainer(realDynamicContext); } workItemNodeInstance.addEventListeners(); executeWorkItem((StatefulKnowledgeSessionImpl) ksession, workItem, workItemNodeInstance); return null; } });
public void internalTrigger(final NodeInstance from, String type) { super.internalTrigger(from, type); // if node instance was cancelled, abort if (getNodeInstanceContainer().getNodeInstance(getId()) == null) { return; } if (!org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE.equals(type)) { throw new IllegalArgumentException( "A MilestoneNode only accepts default incoming connections!"); } String rule = "RuleFlow-Milestone-" + getProcessInstance().getProcessId() + "-" + getMilestoneNode().getUniqueId(); boolean isActive = ((InternalAgenda) getProcessInstance().getKnowledgeRuntime().getAgenda()) .isRuleActiveInRuleFlowGroup("DROOLS_SYSTEM", rule, getProcessInstance().getId()); if (isActive) { triggerCompleted(); } else { addActivationListener(); } }
public void internalTrigger(final NodeInstance from, String type) { super.internalTrigger(from, type); ExecutorService executorService = (ExecutorService) getProcessInstance().getKnowledgeRuntime().getEnvironment().get("ExecutorService"); if (executorService != null) { RuntimeManager runtimeManager = ((RuntimeManager)getProcessInstance().getKnowledgeRuntime().getEnvironment().get("RuntimeManager")); CommandContext ctx = new CommandContext(); ctx.setData("deploymentId", runtimeManager.getIdentifier()); ctx.setData("processInstanceId", getProcessInstance().getId()); ctx.setData("Signal", getEventType()); ctx.setData("Event", null); executorService.scheduleRequest(AsyncSignalEventCommand.class.getName(), ctx); Node node = getNode(); if (node != null) { String uniqueId = (String) node.getMetaData().get("UniqueId"); if( uniqueId == null ) { uniqueId = ((NodeImpl) node).getUniqueId(); } ((WorkflowProcessInstanceImpl) getProcessInstance()).getIterationLevels().remove(getNode().getMetaData().get("UniqueId")); } } else { logger.warn("No async executor service found continuing as sync operation..."); // if there is no executor service available move as sync node triggerCompleted(); } }