private void addParentChain(List parentChain) { parentChain.add(this); GraphElement parent = getParent(); if (parent != null) parent.addParentChain(parentChain); }
/** * @return the ancestors of this graph element ordered by depth. */ public List getParents() { GraphElement parent = getParent(); if (parent == null) return Collections.EMPTY_LIST; List parents = new ArrayList(); parent.addParentChain(parents); return parents; }
private void addParentChain(List parentChain) { parentChain.add(this); GraphElement parent = getParent(); if (parent != null) parent.addParentChain(parentChain); }
/** * @return the ancestors of this graph element ordered by depth. */ public List getParents() { GraphElement parent = getParent(); if (parent == null) return Collections.EMPTY_LIST; List parents = new ArrayList(); parent.addParentChain(parents); return parents; }
public GraphElement getParent() { if (from != null && to != null) { if (from.equals(to)) return from.getParent(); for (GraphElement fromParent = from; fromParent != null; fromParent = fromParent.getParent()) { for (GraphElement toParent = to; toParent != null; toParent = toParent.getParent()) { if (fromParent.equals(toParent)) return fromParent; } } } return processDefinition; } }
public GraphElement getParent() { if (from != null && to != null) { if (from.equals(to)) return from.getParent(); for (GraphElement fromParent = from; fromParent != null; fromParent = fromParent.getParent()) { for (GraphElement toParent = to; toParent != null; toParent = toParent.getParent()) { if (fromParent.equals(toParent)) return fromParent; } } } return processDefinition; } }
public int hashCode() { GraphElement parent = getParent(); int result = 580399073; if (name != null && parent != null) { result += name.hashCode(); } else if (parent instanceof NodeCollection) { NodeCollection nodeCollection = (NodeCollection) parent; int index = nodeCollection.getNodes().indexOf(this); assert index != -1 : nodeCollection.getNodes(); result += index; } else { return super.hashCode(); } return 345105097 * result + parent.hashCode(); }
public int hashCode() { GraphElement parent = getParent(); int result = 580399073; if (name != null && parent != null) { result += name.hashCode(); } else if (parent instanceof NodeCollection) { NodeCollection nodeCollection = (NodeCollection) parent; int index = nodeCollection.getNodes().indexOf(this); assert index != -1 : nodeCollection.getNodes(); result += index; } else { return super.hashCode(); } return 345105097 * result + parent.hashCode(); }
public static Node findNode(NodeCollection nodeCollection, String hierarchicalName) { String[] nameParts = hierarchicalName.split("/"); if (nameParts.length == 1) { String nodeName = nameParts[0]; return nodeName.length() > 0 ? nodeCollection.getNode(nodeName) : null; } GraphElement currentElement = (GraphElement) nodeCollection; int startIndex = 0; if (nameParts[0].length() == 0) { // hierarchical name started with a '/' currentElement = currentElement.getProcessDefinition(); startIndex = 1; } for (int i = startIndex; i < nameParts.length; i++) { String namePart = nameParts[i]; if ("..".equals(namePart)) { // namePart calls for parent, but current element is absent if (currentElement == null) return null; currentElement = currentElement.getParent(); } else { // namePart calls for child, but current element is not a collection if (!(currentElement instanceof NodeCollection)) return null; NodeCollection currentCollection = (NodeCollection) currentElement; currentElement = currentCollection.getNode(namePart); } } // current element could be the process definition or might be absent return currentElement instanceof Node ? (Node) currentElement : null; }
public static Node findNode(NodeCollection nodeCollection, String hierarchicalName) { String[] nameParts = hierarchicalName.split("/"); if (nameParts.length == 1) { String nodeName = nameParts[0]; return nodeName.length() > 0 ? nodeCollection.getNode(nodeName) : null; } GraphElement currentElement = (GraphElement) nodeCollection; int startIndex = 0; if (nameParts[0].length() == 0) { // hierarchical name started with a '/' currentElement = currentElement.getProcessDefinition(); startIndex = 1; } for (int i = startIndex; i < nameParts.length; i++) { String namePart = nameParts[i]; if ("..".equals(namePart)) { // namePart calls for parent, but current element is absent if (currentElement == null) return null; currentElement = currentElement.getParent(); } else { // namePart calls for child, but current element is not a collection if (!(currentElement instanceof NodeCollection)) return null; NodeCollection currentCollection = (NodeCollection) currentElement; currentElement = currentCollection.getNode(namePart); } } // current element could be the process definition or might be absent return currentElement instanceof Node ? (Node) currentElement : null; }
public boolean equals(Object o) { if (o == this) return true; if (!getClass().isInstance(o)) return false; GraphElement other = (GraphElement) o; if (id != 0 && id == other.getId()) return true; GraphElement parent = getParent(); GraphElement otherParent = other.getParent(); boolean result; if (name != null && parent != null) { result = name.equals(other.getName()); } else if (parent instanceof NodeCollection && otherParent instanceof NodeCollection) { NodeCollection nodeCollection = (NodeCollection) parent; int index = nodeCollection.getNodes().indexOf(this); assert index != -1 : nodeCollection.getNodes(); NodeCollection otherNodeCollection = (NodeCollection) otherParent; int otherIndex = otherNodeCollection.getNodes().indexOf(other); result = index == otherIndex; } else { return false; } return result && parent.equals(otherParent); }
GraphElement parent = getParent(); if (parent != null && !equals(parent)) {
GraphElement parent = getParent(); if (parent != null && !equals(parent)) {
public void fireAndPropagateEvent(String eventType, ExecutionContext executionContext) { // check whether the event was fired on this element // or propagated from another element boolean isPropagated = !equals(executionContext.getEventSource()); // execute static actions Event event = getEvent(eventType); if (event != null) { // update the context executionContext.setEvent(event); // execute the static actions specified in the process definition executeActions(event.getActions(), executionContext, isPropagated); } // execute the runtime actions List runtimeActions = getRuntimeActionsForEvent(executionContext, eventType); executeActions(runtimeActions, executionContext, isPropagated); // remove the event from the context executionContext.setEvent(null); // propagate the event to the parent element GraphElement parent = getParent(); if (parent != null) { parent.fireAndPropagateEvent(eventType, executionContext); } }
public void fireAndPropagateEvent(String eventType, ExecutionContext executionContext) { // check whether the event was fired on this element // or propagated from another element boolean isPropagated = !equals(executionContext.getEventSource()); // execute static actions Event event = getEvent(eventType); if (event != null) { // update the context executionContext.setEvent(event); // execute the static actions specified in the process definition executeActions(event.getActions(), executionContext, isPropagated); } // execute the runtime actions List runtimeActions = getRuntimeActionsForEvent(executionContext, eventType); executeActions(runtimeActions, executionContext, isPropagated); // remove the event from the context executionContext.setEvent(null); // propagate the event to the parent element GraphElement parent = getParent(); if (parent != null) { parent.fireAndPropagateEvent(eventType, executionContext); } }