private boolean canComplete() { if (nodeInstances.isEmpty()) { return true; } else { int eventSubprocessCounter = 0; for (NodeInstance nodeInstance : nodeInstances) { Node node = nodeInstance.getNode(); if (node instanceof EventSubProcessNode) { if (((EventSubProcessNodeInstance) nodeInstance).getNodeInstances().isEmpty()) { eventSubprocessCounter++; } } else { return false; } } return eventSubprocessCounter == nodeInstances.size(); } }
public void nodeInstanceCompleted(NodeInstance nodeInstance, String outType) { Node nodeInstanceNode = nodeInstance.getNode(); if( nodeInstanceNode != null ) { Object compensationBoolObj = nodeInstanceNode.getMetaData().get("isForCompensation"); boolean isForCompensation = compensationBoolObj == null ? false : ((Boolean) compensationBoolObj); if( isForCompensation ) { return; } } if (nodeInstance instanceof FaultNodeInstance || nodeInstance instanceof EndNodeInstance || nodeInstance instanceof EventSubProcessNodeInstance ) { if (getCompositeNode().isAutoComplete()) { if (nodeInstances.isEmpty()) { triggerCompleted( org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE); } } } else { throw new IllegalArgumentException( "Completing a node instance that has no outgoing connection not supported."); } }
private void updateNodeInstances(NodeInstanceContainer nodeInstanceContainer, Map<String, Long> nodeMapping) { for (NodeInstance nodeInstance: nodeInstanceContainer.getNodeInstances()) { String oldNodeId = ((NodeImpl) ((org.jbpm.workflow.instance.NodeInstance) nodeInstance).getNode()).getUniqueId(); Long newNodeId = nodeMapping.get(oldNodeId); if (newNodeId == null) { newNodeId = nodeInstance.getNodeId(); } ((NodeInstanceImpl) nodeInstance).setNodeId(newNodeId); if (nodeInstance instanceof NodeInstanceContainer) { updateNodeInstances((NodeInstanceContainer) nodeInstance, nodeMapping); } } }
public void nodeInstanceCompleted(NodeInstance nodeInstance, String outType) { Node nodeInstanceNode = nodeInstance.getNode(); if( nodeInstanceNode != null ) { Object compensationBoolObj = nodeInstanceNode.getMetaData().get("isForCompensation"); boolean isForCompensation = compensationBoolObj == null ? false : ((Boolean) compensationBoolObj); if( isForCompensation ) { return; } } if (nodeInstance instanceof FaultNodeInstance || nodeInstance instanceof EndNodeInstance || ((org.jbpm.workflow.core.WorkflowProcess) getWorkflowProcess()).isDynamic() || nodeInstance instanceof CompositeNodeInstance) { if (((org.jbpm.workflow.core.WorkflowProcess) getProcess()).isAutoComplete()) { if (canComplete()) { setState(ProcessInstance.STATE_COMPLETED); } } } else { throw new IllegalArgumentException( "Completing a node instance that has no outgoing connection is not supported."); } }
String oldNodeId = (String) ((NodeImpl) ((org.jbpm.workflow.instance.NodeInstance) nodeInstance).getNode()).getMetaData().get("UniqueId"); String newNodeId = nodeMapping.get(oldNodeId); if (newNodeId == null) { Boolean isHidden = (Boolean) ((NodeImpl) ((org.jbpm.workflow.instance.NodeInstance) nodeInstance).getNode()).getMetaData().get("hidden"); if (isHidden != null && isHidden.booleanValue()) {
private static void updateNodeInstances(NodeInstanceContainer nodeInstanceContainer, Map<String, Long> nodeMapping) { for (NodeInstance nodeInstance : nodeInstanceContainer.getNodeInstances()) { String oldNodeId = ((NodeImpl) ((org.jbpm.workflow.instance.NodeInstance) nodeInstance).getNode()).getUniqueId(); Long newNodeId = nodeMapping.get(oldNodeId); if (newNodeId == null) { newNodeId = nodeInstance.getNodeId(); } // clean up iteration levels for removed (old) nodes Map<String, Integer> iterLevels = ((WorkflowProcessInstanceImpl) nodeInstance.getProcessInstance()).getIterationLevels(); String uniqueId = (String) ((NodeImpl) nodeInstance.getNode()).getMetaData("UniqueId"); iterLevels.remove(uniqueId); // and now set to new node id ((NodeInstanceImpl) nodeInstance).setNodeId(newNodeId); if (nodeInstance instanceof NodeInstanceContainer) { updateNodeInstances((NodeInstanceContainer) nodeInstance, nodeMapping); } } }
public void nodeInstanceCompleted(org.jbpm.workflow.instance.NodeInstance nodeInstance, String outType) { Node nodeInstanceNode = nodeInstance.getNode(); if( nodeInstanceNode != null ) { Object compensationBoolObj = nodeInstanceNode.getMetaData().get("isForCompensation"); boolean isForCompensation = compensationBoolObj == null ? false : ((Boolean) compensationBoolObj); if( isForCompensation ) { return; } } String completionCondition = getDynamicNode().getCompletionExpression(); // TODO what if we reach the end of one branch but others might still need to be created ? // TODO are we sure there will always be node instances left if we are not done yet? if (isTerminated(nodeInstance)) { triggerCompleted(NodeImpl.CONNECTION_DEFAULT_TYPE); } else if (getDynamicNode().isAutoComplete() && getNodeInstances(false).isEmpty()) { triggerCompleted(NodeImpl.CONNECTION_DEFAULT_TYPE); } else if (completionCondition != null && "mvel".equals(getDynamicNode().getLanguage())) { Object value = MVELSafeHelper.getEvaluator().eval(completionCondition, new NodeInstanceResolverFactory(this)); if ( !(value instanceof Boolean) ) { throw new RuntimeException( "Completion condition expression must return boolean values: " + value + " for expression " + completionCondition); } if (((Boolean) value).booleanValue()) { triggerCompleted(NodeImpl.CONNECTION_DEFAULT_TYPE); } } }
public boolean evaluate(NodeInstance instance, Connection connection, Constraint constraint) { WorkflowProcessInstance processInstance = instance.getProcessInstance(); InternalAgenda agenda = (InternalAgenda) ((ProcessInstance) processInstance).getKnowledgeRuntime().getAgenda(); String rule = "RuleFlow-Split-" + processInstance.getProcessId() + "-" + ((Node) instance.getNode()).getUniqueId() + "-" + ((Node) connection.getTo()).getUniqueId() + "-" + connection.getToType(); return agenda.isRuleActiveInRuleFlowGroup( "DROOLS_SYSTEM", rule, processInstance.getId() ); }
private boolean canComplete() { if (nodeInstances.isEmpty()) { return true; } else { int eventSubprocessCounter = 0; for (NodeInstance nodeInstance : nodeInstances) { Node node = nodeInstance.getNode(); if (node instanceof EventSubProcessNode) { if (((EventSubProcessNodeInstance) nodeInstance).getNodeInstances().isEmpty()) { eventSubprocessCounter++; } } else { return false; } } return eventSubprocessCounter == nodeInstances.size(); } }
public void nodeInstanceCompleted(NodeInstance nodeInstance, String outType) { Node nodeInstanceNode = nodeInstance.getNode(); if( nodeInstanceNode != null ) { Object compensationBoolObj = nodeInstanceNode.getMetaData().get("isForCompensation"); boolean isForCompensation = compensationBoolObj == null ? false : ((Boolean) compensationBoolObj); if( isForCompensation ) { return; } } if (nodeInstance instanceof FaultNodeInstance || nodeInstance instanceof EndNodeInstance || nodeInstance instanceof EventSubProcessNodeInstance ) { if (getCompositeNode().isAutoComplete()) { if (nodeInstances.isEmpty()) { triggerCompleted( org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE); } } } else { throw new IllegalArgumentException( "Completing a node instance that has no outgoing connection not supported."); } }
private void updateNodeInstances(NodeInstanceContainer nodeInstanceContainer, Map<String, Long> nodeMapping) { for (NodeInstance nodeInstance: nodeInstanceContainer.getNodeInstances()) { String oldNodeId = ((NodeImpl) ((org.jbpm.workflow.instance.NodeInstance) nodeInstance).getNode()).getUniqueId(); Long newNodeId = nodeMapping.get(oldNodeId); if (newNodeId == null) { newNodeId = nodeInstance.getNodeId(); } ((NodeInstanceImpl) nodeInstance).setNodeId(newNodeId); if (nodeInstance instanceof NodeInstanceContainer) { updateNodeInstances((NodeInstanceContainer) nodeInstance, nodeMapping); } } }
public void nodeInstanceCompleted(NodeInstance nodeInstance, String outType) { Node nodeInstanceNode = nodeInstance.getNode(); if( nodeInstanceNode != null ) { Object compensationBoolObj = nodeInstanceNode.getMetaData().get("isForCompensation"); boolean isForCompensation = compensationBoolObj == null ? false : ((Boolean) compensationBoolObj); if( isForCompensation ) { return; } } if (nodeInstance instanceof FaultNodeInstance || nodeInstance instanceof EndNodeInstance || ((org.jbpm.workflow.core.WorkflowProcess) getWorkflowProcess()).isDynamic() || nodeInstance instanceof CompositeNodeInstance) { if (((org.jbpm.workflow.core.WorkflowProcess) getProcess()).isAutoComplete()) { if (canComplete()) { setState(ProcessInstance.STATE_COMPLETED); } } } else { throw new IllegalArgumentException( "Completing a node instance that has no outgoing connection is not supported."); } }
String oldNodeId = (String) ((NodeImpl) ((org.jbpm.workflow.instance.NodeInstance) nodeInstance).getNode()).getMetaData().get("UniqueId"); String newNodeId = nodeMapping.get(oldNodeId); if (newNodeId == null) { Boolean isHidden = (Boolean) ((NodeImpl) ((org.jbpm.workflow.instance.NodeInstance) nodeInstance).getNode()).getMetaData().get("hidden"); if (isHidden != null && isHidden.booleanValue()) {
private static void updateNodeInstances(NodeInstanceContainer nodeInstanceContainer, Map<String, Long> nodeMapping) { for (NodeInstance nodeInstance : nodeInstanceContainer.getNodeInstances()) { String oldNodeId = ((NodeImpl) ((org.jbpm.workflow.instance.NodeInstance) nodeInstance).getNode()).getUniqueId(); Long newNodeId = nodeMapping.get(oldNodeId); if (newNodeId == null) { newNodeId = nodeInstance.getNodeId(); } // clean up iteration levels for removed (old) nodes Map<String, Integer> iterLevels = ((WorkflowProcessInstanceImpl) nodeInstance.getProcessInstance()).getIterationLevels(); String uniqueId = (String) ((NodeImpl) nodeInstance.getNode()).getMetaData("UniqueId"); iterLevels.remove(uniqueId); // and now set to new node id ((NodeInstanceImpl) nodeInstance).setNodeId(newNodeId); if (nodeInstance instanceof NodeInstanceContainer) { updateNodeInstances((NodeInstanceContainer) nodeInstance, nodeMapping); } } }
public void nodeInstanceCompleted(org.jbpm.workflow.instance.NodeInstance nodeInstance, String outType) { Node nodeInstanceNode = nodeInstance.getNode(); if( nodeInstanceNode != null ) { Object compensationBoolObj = nodeInstanceNode.getMetaData().get("isForCompensation"); boolean isForCompensation = compensationBoolObj == null ? false : ((Boolean) compensationBoolObj); if( isForCompensation ) { return; } } String completionCondition = getDynamicNode().getCompletionExpression(); // TODO what if we reach the end of one branch but others might still need to be created ? // TODO are we sure there will always be node instances left if we are not done yet? if (isTerminated(nodeInstance)) { triggerCompleted(NodeImpl.CONNECTION_DEFAULT_TYPE); } else if (getDynamicNode().isAutoComplete() && getNodeInstances(false).isEmpty()) { triggerCompleted(NodeImpl.CONNECTION_DEFAULT_TYPE); } else if (completionCondition != null && "mvel".equals(getDynamicNode().getLanguage())) { Object value = MVELSafeHelper.getEvaluator().eval(completionCondition, new NodeInstanceResolverFactory(this)); if ( !(value instanceof Boolean) ) { throw new RuntimeException( "Completion condition expression must return boolean values: " + value + " for expression " + completionCondition); } if (((Boolean) value).booleanValue()) { triggerCompleted(NodeImpl.CONNECTION_DEFAULT_TYPE); } } }
public boolean evaluate(NodeInstance instance, Connection connection, Constraint constraint) { WorkflowProcessInstance processInstance = instance.getProcessInstance(); InternalAgenda agenda = (InternalAgenda) ((ProcessInstance) processInstance).getKnowledgeRuntime().getAgenda(); String rule = "RuleFlow-Split-" + processInstance.getProcessId() + "-" + ((Node) instance.getNode()).getUniqueId() + "-" + ((Node) connection.getTo()).getUniqueId() + "-" + connection.getToType(); return agenda.isRuleActiveInRuleFlowGroup( "DROOLS_SYSTEM", rule, processInstance.getId() ); }