public NodeImpl addNode(NodeImpl node) { node.setParentNode(this); super.addNode(node); return node; }
/** * creates a nested node. Also the nested node's parent pointer will be set * appropriatly. */ public Node createNode() { return createNode(null); }
public Node findNode(String nodeName) { if (nodeName==null) { if (name==null) { return this; } } else if (nodeName.equals(name)) { return this; } return super.findNode(nodeName); }
/** declares a local variable. {@link #scope()} is automatically implied. */ public ProcessFactory variable(String key) { if (node!=null) { scope(); } VariableDefinitionImpl variableDefinition = compositeElement.createVariableDefinition(); variableDefinition.setKey(key); return this; }
/** the first nested node with the given name or null of no * such node exists. */ public NodeImpl getNode(String nodeName) { return (getNodesMap()!=null ? nodesMap.get(nodeName) : null); }
protected void initializeVariables(CompositeElementImpl scope, ExecutionImpl outerExecution) { // loop over all variable definitions List<VariableDefinitionImpl> variableDefinitions = scope.getVariableDefinitions(); if (!variableDefinitions.isEmpty()){ if (log.isTraceEnabled()) { log.trace("initializing variables in scope "+scope); } variables = new HashMap<String, Variable>(); for (VariableDefinitionImpl variableDefinition: variableDefinitions) { String key = variableDefinition.getKey(); Object value = variableDefinition.getSourceValue(outerExecution); Type type = variableDefinition.getType(); createVariable(key, value, type); } } }
protected void initializeTimers(CompositeElementImpl scope) { // initialize the timers Set<TimerDefinitionImpl> timerDefinitions = scope.getTimerDefinitions(); if (!timerDefinitions.isEmpty()) { timers = new HashSet<TimerImpl>(); for (TimerDefinitionImpl timerDefinition: timerDefinitions) { createTimer( timerDefinition.getEventName(), timerDefinition.getSignalName(), timerDefinition.getDueDateDescription(), timerDefinition.getDueDate(), timerDefinition.getRepeat(), timerDefinition.isExclusive(), timerDefinition.getRetries() ); } } }
protected ProcessFactory timer(String dueDateDescription, Date dueDate, String signalName, String repeat) { if (node!=null && scope==null) { scope(); } TimerDefinitionImpl timerDefinition = scope.createTimerDefinition(); if (dueDate!=null) { timerDefinition.setDueDate(dueDate); } else { timerDefinition.setDueDateDescription(dueDateDescription); } timerDefinition.setSignalName(signalName); timerDefinition.setRepeat(repeat); return this; }
public void parseActivities(Element element, Parse parse, CompositeElementImpl compositeElement) { List<Element> elements = XmlUtil.elements(element); for (Element nestedElement : elements) { String tagName = nestedElement.getLocalName(); String name = XmlUtil.attribute(nestedElement, "name"); String id = XmlUtil.attribute(nestedElement, "id", parse); TagBinding activityBinding = (TagBinding) getBinding(nestedElement, CATEGORY_ACTIVITY); if (activityBinding == null) { if (!"sequenceFlow".equals(tagName)) { log.debug("unrecognized activity: " + tagName); } continue; } ActivityImpl activity = compositeElement.createActivity(); parse.contextStackPush(activity); try { activity.setType(activityBinding.getTagName()); activity.setName(id); activity.setDescription(name); if (log.isDebugEnabled()) { log.debug("Parsing Activity: " + name + "(id=" + id + ")"); } ActivityBehaviour activityBehaviour = (ActivityBehaviour) activityBinding.parse(nestedElement, parse, this); activity.setActivityBehaviour(activityBehaviour); } finally { parse.contextStackPop(); } } }
public ExecutionImpl createScope(CompositeElementImpl scope) { ExecutionImpl child = createExecution(scope.getName()); // copy the current state from the child execution to the parent execution child.setNode(getNode()); child.setTransition(getTransition()); child.setPropagation(getPropagation()); child.setTransitionOrigin(getTransitionOrigin()); child.setPreviousTransition(getPreviousTransition()); child.setPreviousNode(getPreviousNode()); child.initializeVariables(scope, this); child.initializeTimers(scope); return child; }
protected static void createVariableDefinitionsFromDataFields(CompositeElementImpl element, Collection<DataFieldDefinition> dataFields, Set<String> participantIds) { if (dataFields != null && !dataFields.isEmpty()) { for (DataFieldDefinition dataField : dataFields) { VariableDefinitionImpl variable = element.createVariableDefinition(); variable.setKey(dataField.getDataFieldId()); variable.setSourceDescriptor(getInitialValueDescriptor(dataField, participantIds)); } } }
/** is this node present ? */ public boolean hasNode(String nodeName) { return ((getNodesMap()!=null) && (nodesMap.containsKey(nodeName))); }
protected void destroyVariables(CompositeElementImpl scope, ExecutionImpl outerExecution) { // loop over all variable definitions List<VariableDefinitionImpl> variableDefinitions = scope.getVariableDefinitions(); if (variableDefinitions!=null) { if (log.isTraceEnabled()) { log.trace("destroying var scope "+scope); } for (VariableDefinitionImpl variableDefinition: variableDefinitions) { String destination = variableDefinition.getDestination(); if (destination!=null) { String key = variableDefinition.getKey(); Object value = variableDefinition.getDestinationValue(this); outerExecution.setVariable(key, value); } } } }
/** declares a local variable. {@link #scope()} is automatically implied. */ public ProcessFactory variable(Descriptor sourceDescriptor) { if (node!=null && scope==null) { scope(); } VariableDefinitionImpl variableDefinition = scope.createVariableDefinition(); variableDefinition.setKey(sourceDescriptor.getName()); variableDefinition.setSourceDescriptor(sourceDescriptor); return this; }
/** creates a named node. * The current parent is either the process definition or a composite node * in case method {@link #compositeNode(String)} was called previously. */ public ProcessFactory node(String nodeName) { if (exceptionHandler!=null) { exceptionHandler.setNodeName(nodeName); } else { node = compositeElement.createNode(nodeName); scope = null; observableElement = node; event = null; eventListenerReference = null; transition = null; exceptionHandler = null; } return this; }
/** * creates a nested node with the given name. Also the nested node's parent pointer will be set * appropriatly. * @param nodeName may be null. */ public NodeImpl createNode(String nodeName) { NodeImpl node = new NodeImpl(); node.setName(nodeName); addNode(node); return node; }