1 package org.jbpm.bpel.def; 2 3 import java.util.*; 4 5 import org.jbpm.graph.def.Node; 6 import org.jbpm.graph.def.NodeCollection; 7 import org.jbpm.graph.def.ProcessDefinition; 8 9 import org.jbpm.bpel.data.def.VariableDefinition; 10 import org.jbpm.bpel.service.def.CorrelationSetDefinition; 11 import org.jbpm.bpel.service.def.PartnerLinkDefinition; 12 13 19 public abstract class CompositeActivity extends Activity implements NodeCollection { 20 21 private transient Map nodesMap = null; 22 23 public CompositeActivity() { 24 } 25 26 public CompositeActivity(String name) { 27 super(name); 28 } 29 30 public boolean isChildInitial(Activity activity) { 31 return false; 32 } 33 34 36 public VariableDefinition findVariable(String varName) { 37 CompositeActivity parent = getCompositeActivity(); 38 return parent != null ? parent.findVariable(varName) : null; 39 } 40 41 public CorrelationSetDefinition findCorrelationSet(String csName) { 42 CompositeActivity parent = getCompositeActivity(); 43 return parent != null ? parent.findCorrelationSet(csName) : null; 44 } 45 46 public PartnerLinkDefinition findPartnerLink(String plinkName) { 47 CompositeActivity parent = getCompositeActivity(); 48 return parent != null ? parent.findPartnerLink(plinkName) : null; 49 } 50 51 public Link findLink(String linkName) { 52 CompositeActivity parent = getCompositeActivity(); 53 return parent != null ? parent.findLink(linkName) : null; 54 } 55 56 58 59 public Map getNodesMap() { 60 List nodes = getNodes(); 61 62 if ( nodesMap==null && nodes!=null ) { 63 nodesMap = new HashMap(); 64 Iterator iter = nodes.iterator(); 65 while (iter.hasNext()) { 66 Node node = (Node) iter.next(); 67 nodesMap.put(node.getName(), node); 68 } 69 } 70 return nodesMap; 71 } 72 73 74 public String generateNodeName() { 75 return ProcessDefinition.generateNodeName(getNodes()); 76 } 77 78 79 public Node findNode(String hierarchicalName) { 80 return ProcessDefinition.findNode(this, hierarchicalName); 81 } 82 83 84 public Node getNode(String name) { 85 return (Node) getNodesMap().get(name); 86 } 87 88 89 public boolean hasNode(String name) { 90 return getNodesMap().containsKey(name); 91 } 92 93 94 public Node findChild(String childName) { 95 Node node = getNode(childName); 96 if(node != null) return node; 97 98 for(Iterator it = getNodes().iterator(); it.hasNext();) { 99 Object child = it.next(); 100 if(child instanceof StructuredActivity) { 101 node = ((StructuredActivity)child).findChild(childName); 102 if(node != null) return node; 103 } 104 } 105 return null; 106 } 107 } | Popular Tags |