airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1213773 [1/3] - in /incubator/airavata/trunk/modules: commons/utils/src/main/java/org/apache/airavata/common/utils/ xbaya-gui/src/main/java/org/apache/airavata/xbaya/ xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/dynamic/ xba...
Date Tue, 13 Dec 2011 16:35:52 GMT
Author: lahiru
Date: Tue Dec 13 16:35:51 2011
New Revision: 1213773

URL: http://svn.apache.org/viewvc?rev=1213773&view=rev
Log:
adding ogce-xbaya changes to airavata.

Added:
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/util/InterpreterUtil.java
Modified:
    incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/WSConstants.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/XBaya.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/XBayaConfiguration.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/dynamic/GenericSubworkflowPort.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/dynamic/CepPort.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/gui/GraphCanvas.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/impl/PortImpl.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/subworkflow/SubWorkflowNode.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/system/ForEachNode.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/util/GraphUtil.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/SystemComponentInvoker.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpreter.java
    incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/GenericInvoker.java
    incubator/airavata/trunk/modules/xbaya-gui/src/test/java/org/apache/airavata/xbaya/interpreter/WorkflowTest.java

Modified: incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/WSConstants.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/WSConstants.java?rev=1213773&r1=1213772&r2=1213773&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/WSConstants.java (original)
+++ incubator/airavata/trunk/modules/commons/utils/src/main/java/org/apache/airavata/common/utils/WSConstants.java Tue Dec 13 16:35:51 2011
@@ -175,4 +175,14 @@ public interface WSConstants {
      * schemaLocation
      */
     public static final String SCHEMA_LOCATION_ATTRIBUTE = "schemaLocation";
+
+    public static final String LEAD_NS_URI = "http://www.extreme.indiana.edu/lead";
+
+    /**
+     * The any type.
+     */
+    public static final QName LEAD_ANY_TYPE = new QName(LEAD_NS_URI, "any",
+            XSD_NS_PREFIX);
+
+
 }
\ No newline at end of file

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/XBaya.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/XBaya.java?rev=1213773&r1=1213772&r2=1213773&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/XBaya.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/XBaya.java Tue Dec 13 16:35:51 2011
@@ -86,7 +86,7 @@ public class XBaya {
                 + " [-karmaWorkflowInstanceID]" + " [-myProxyPort port]" + " [-myProxyUsername username]"
                 + " [-myProxyLifetime sec]" + " [-loadMyProxy {true,false}]" + " [-messageBoxURL url]"
                 + " [-width width]" + " [-height height]" + " [-exitOnClose false/true]" + "[-enableProvenance false/true]"
-                + "[-enableProvenanceSmartRun false/true]");
+                + "[-enableProvenanceSmartRun false/true]" + "[-runWithCrossProduct true/false]");
     }
 
     private void parseArguments(String[] args) {
@@ -250,6 +250,12 @@ public class XBaya {
                     if ("true".equalsIgnoreCase(exit)) {
                         this.config.setProvenanceSmartRun(true);
                     }
+                }  else if ("-runWithCrossProduct".equalsIgnoreCase(arg)) {
+                    index++;
+                    String exit = args[index];
+                    if ("false".equalsIgnoreCase(exit)) {
+                        this.config.setRunWithCrossProduct(false);
+                    }
                 }
                 else {
                     String message = "Unknown option: " + arg;

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/XBayaConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/XBayaConfiguration.java?rev=1213773&r1=1213772&r2=1213773&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/XBayaConfiguration.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/XBayaConfiguration.java Tue Dec 13 16:35:51 2011
@@ -128,6 +128,8 @@ public class XBayaConfiguration extends 
 
     private boolean provenanceSmartRun = false;
 
+    private boolean runWithCrossProduct = true;
+
     /**
      * Constructs an XwfConfiguration.
      */
@@ -825,4 +827,11 @@ public class XBayaConfiguration extends 
         this.provenanceSmartRun = provenanceSmartRun;
     }
 
+    public void setRunWithCrossProduct(boolean runWithCrossProduct) {
+        this.runWithCrossProduct = runWithCrossProduct;
+    }
+
+    public boolean isRunWithCrossProduct() {
+        return runWithCrossProduct;
+    }
 }
\ No newline at end of file

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/dynamic/GenericSubworkflowPort.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/dynamic/GenericSubworkflowPort.java?rev=1213773&r1=1213772&r2=1213773&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/dynamic/GenericSubworkflowPort.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/component/dynamic/GenericSubworkflowPort.java Tue Dec 13 16:35:51 2011
@@ -29,7 +29,8 @@ public class GenericSubworkflowPort exte
 
     }
 
-    protected void setID(String id) {
+    @Override
+    public void setID(String id) {
         this.id = id;
 
     }

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/dynamic/CepPort.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/dynamic/CepPort.java?rev=1213773&r1=1213772&r2=1213773&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/dynamic/CepPort.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/dynamic/CepPort.java Tue Dec 13 16:35:51 2011
@@ -71,7 +71,7 @@ public class CepPort extends DataPort {
         return WSConstants.XSD_ANY_TYPE;
     }
 
-    protected void setID(String id) {
+    public void setID(String id) {
         this.id = id;
     }
 

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/gui/GraphCanvas.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/gui/GraphCanvas.java?rev=1213773&r1=1213772&r2=1213773&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/gui/GraphCanvas.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/gui/GraphCanvas.java Tue Dec 13 16:35:51 2011
@@ -1244,6 +1244,9 @@ public class GraphCanvas {
 
                 } catch (GraphException e1) {
                     GraphCanvas.this.engine.getErrorWindow().error(e1);
+                }  catch (ComponentException e1) {
+
+                    GraphCanvas.this.engine.getErrorWindow().error(e1);
                 }
 
             }

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/impl/PortImpl.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/impl/PortImpl.java?rev=1213773&r1=1213772&r2=1213773&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/impl/PortImpl.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/impl/PortImpl.java Tue Dec 13 16:35:51 2011
@@ -430,4 +430,8 @@ public abstract class PortImpl implement
         }
         return index;
     }
+
+    public void setID(String id) {
+        this.id = id;
+    }
 }
\ No newline at end of file

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/subworkflow/SubWorkflowNode.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/subworkflow/SubWorkflowNode.java?rev=1213773&r1=1213772&r2=1213773&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/subworkflow/SubWorkflowNode.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/subworkflow/SubWorkflowNode.java Tue Dec 13 16:35:51 2011
@@ -22,6 +22,7 @@
 package org.apache.airavata.xbaya.graph.subworkflow;
 
 import org.apache.airavata.xbaya.component.SubWorkflowComponent;
+import org.apache.airavata.xbaya.graph.DataPort;
 import org.apache.airavata.xbaya.graph.Edge;
 import org.apache.airavata.xbaya.graph.Graph;
 import org.apache.airavata.xbaya.graph.GraphException;
@@ -30,6 +31,8 @@ import org.apache.airavata.xbaya.graph.i
 import org.apache.airavata.xbaya.graph.util.GraphUtil;
 import org.apache.airavata.xbaya.wf.Workflow;
 
+import java.util.List;
+
 public class SubWorkflowNode extends NodeImpl {
 
     private SubWorkflowNodeGUI gui;
@@ -82,4 +85,26 @@ public class SubWorkflowNode extends Nod
         return this.workflow;
     }
 
+     public DataPort assignInputPortID(String id, int index) {
+        List<DataPort> ports = this.getInputPorts();
+        for (DataPort d : ports) {
+            if (null == d.getID()) {
+                d.setID(id);
+            }
+        }
+
+        return ports.get(index);
+    }
+
+    public DataPort assignOutputPortID(String id, int index) {
+        List<DataPort> ports = this.getOutputPorts();
+        for (DataPort d : ports) {
+            if (null == d.getID()) {
+                d.setID(id);
+            }
+        }
+
+        return ports.get(index);
+    }
+
 }
\ No newline at end of file

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/system/ForEachNode.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/system/ForEachNode.java?rev=1213773&r1=1213772&r2=1213773&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/system/ForEachNode.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/system/ForEachNode.java Tue Dec 13 16:35:51 2011
@@ -44,11 +44,13 @@ import org.xmlpull.infoset.XmlElement;
 
 public class ForEachNode extends SystemNode {
 
+    // private static final MLogger logger = MLogger.getLogger();
+
     private ForEachNodeGUI gui;
 
     /**
      * Creates a InputNode.
-     * 
+     *
      * @param graph
      */
     public ForEachNode(Graph graph) {
@@ -57,7 +59,7 @@ public class ForEachNode extends SystemN
 
     /**
      * Constructs a InputNode.
-     * 
+     *
      * @param nodeElement
      * @throws GraphException
      */
@@ -66,9 +68,11 @@ public class ForEachNode extends SystemN
     }
 
     /**
-     * @see org.apache.airavata.xbaya.graph.Node#getGUI()
+     *
+     * @return
      */
-    public NodeGUI getGUI() {
+    @Override
+	public NodeGUI getGUI() {
         if (this.gui == null) {
             this.gui = new ForEachNodeGUI(this);
         }
@@ -76,7 +80,8 @@ public class ForEachNode extends SystemN
     }
 
     /**
-     * @see org.apache.airavata.xbaya.graph.impl.NodeImpl#getComponent()
+     *
+     * @return
      */
     @Override
     public ForEachComponent getComponent() {
@@ -99,11 +104,16 @@ public class ForEachNode extends SystemN
         addInputPort(port);
     }
 
-    /**
-     * Removes the last input port.
-     * 
-     * @throws GraphException
-     */
+    public DataPort addInputPortAndReturn() {
+        ForEachComponent component = getComponent();
+        ComponentDataPort input = component.getInputPort();
+        DataPort port = input.createPort();
+        addInputPort(port);
+        return port;
+    }
+
+
+
     public void removeInputPort() throws GraphException {
         List<DataPort> inputPorts = getInputPorts();
         // Remove the last one.
@@ -111,6 +121,9 @@ public class ForEachNode extends SystemN
         removeInputPort(inputPort);
     }
 
+
+
+
     /**
      * Adds additional output port.
      */
@@ -123,7 +136,7 @@ public class ForEachNode extends SystemN
 
     /**
      * Removes the last output port.
-     * 
+     *
      * @throws GraphException
      */
     public void removeOutputPort() throws GraphException {
@@ -133,10 +146,13 @@ public class ForEachNode extends SystemN
         removeOutputPort(outputPort);
     }
 
+
     /**
+     *
+     * @param edge
      * @throws GraphException
-     * @see org.apache.airavata.xbaya.graph.impl.NodeImpl#edgeWasAdded(org.apache.airavata.xbaya.graph.Edge)
      */
+
     @Override
     protected void edgeWasAdded(Edge edge) throws GraphException {
         // XXX cannot detect if the type is array or not from WSDL at this
@@ -162,7 +178,8 @@ public class ForEachNode extends SystemN
                     fromDataPort.copyType(toDataPort);
                 }
             } else if (toDataPort.getNode() == this) {
-                if (!(fromType == null || fromType.equals(WSConstants.XSD_ANY_TYPE))) {
+                if (!(fromType == null || fromType
+                        .equals(WSConstants.XSD_ANY_TYPE))) {
                     toDataPort.copyType(fromDataPort);
                 }
             } else {
@@ -172,8 +189,11 @@ public class ForEachNode extends SystemN
     }
 
     /**
-     * @see org.apache.airavata.xbaya.graph.system.SystemNode#portTypeChanged(org.apache.airavata.xbaya.graph.system.SystemDataPort)
+     *
+     * @param port
+     * @throws GraphException
      */
+
     @Override
     protected void portTypeChanged(SystemDataPort port) throws GraphException {
         super.portTypeChanged(port);
@@ -206,7 +226,7 @@ public class ForEachNode extends SystemN
         if (port == inputPort) {
             // input -> output
             if (outputType.equals(WSConstants.XSD_ANY_TYPE)) {
-                outputPort.copyType(port, -1);
+              //  outputPort.copyType(port, -1);
             } else if (outputType.equals(portType)) {
                 // Do nothing.
             } else {
@@ -221,7 +241,7 @@ public class ForEachNode extends SystemN
         } else if (port == outputPort) {
             // output -> input1
             if (inputType.equals(WSConstants.XSD_ANY_TYPE)) {
-                inputPort.copyType(port, 1);
+               // inputPort.copyType(port, 1);
             } else if (inputType.equals(portType)) {
                 // Do nothing.
             } else {
@@ -237,6 +257,50 @@ public class ForEachNode extends SystemN
         }
     }
 
+    public DataPort getFreeInPort() {
+        List<DataPort> inputPorts = this.getInputPorts();
+        for (DataPort dataPort : inputPorts) {
+            if (null == dataPort.getFromNode()) {
+                return dataPort;
+            }
+        }
+        addOutputPort();
+        return addInputPortAndReturn();
+    }
+
+
+    public void removeLastDynamicallyAddedInPort() throws GraphException {
+
+        List<DataPort> inputPorts = this.getInputPorts();
+        List<DataPort> outputPorts = this.getOutputPorts();
+        if (inputPorts.size() == 1) {
+            //This is the initial port, so leave it alone
+            return;
+        }
+        if (outputPorts.size() == 1) {
+            return;
+        }
+        DataPort portToBeRemoved = null;
+        for (DataPort dataPort : inputPorts) {
+            if (null == dataPort.getFromNode()) {
+                removeInputPort(dataPort);
+                portToBeRemoved = dataPort;
+                break;
+            }
+        }
+
+        if(outputPorts.size() == this.getInputPorts().size()){
+            return;
+        }
+        for (DataPort dataPort : outputPorts) {
+            if (0 == dataPort.getToNodes().size()) {
+                removeOutputPort(dataPort);
+                portToBeRemoved = dataPort;
+                break;
+            }
+        }
+    }
+
     @Override
     protected void parseConfiguration(XmlElement configElement) {
         super.parseConfiguration(configElement);
@@ -245,13 +309,15 @@ public class ForEachNode extends SystemN
     @Override
     protected XmlElement toXML() {
         XmlElement nodeElement = super.toXML();
-        nodeElement.setAttributeValue(GraphSchema.NS, GraphSchema.NODE_TYPE_ATTRIBUTE, GraphSchema.NODE_TYPE_SPLIT);
+        nodeElement.setAttributeValue(GraphSchema.NS,
+                GraphSchema.NODE_TYPE_ATTRIBUTE, GraphSchema.NODE_TYPE_SPLIT);
         return nodeElement;
     }
 
     @Override
     protected XmlElement addConfigurationElement(XmlElement nodeElement) {
-        XmlElement configElement = nodeElement.addElement(GraphSchema.NS, GraphSchema.NODE_CONFIG_TAG);
+        XmlElement configElement = nodeElement.addElement(GraphSchema.NS,
+                GraphSchema.NODE_CONFIG_TAG);
         return configElement;
     }
 }
\ No newline at end of file

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/util/GraphUtil.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/util/GraphUtil.java?rev=1213773&r1=1213772&r2=1213773&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/util/GraphUtil.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/graph/util/GraphUtil.java Tue Dec 13 16:35:51 2011
@@ -22,23 +22,16 @@
 package org.apache.airavata.xbaya.graph.util;
 
 import java.awt.Point;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.Map.Entry;
-import java.util.Set;
 
 import javax.xml.namespace.QName;
 
 import org.apache.airavata.common.utils.Pair;
 import org.apache.airavata.xbaya.XBayaEngine;
 import org.apache.airavata.xbaya.XBayaRuntimeException;
+import org.apache.airavata.xbaya.component.ComponentException;
+import org.apache.airavata.xbaya.component.SubWorkflowComponent;
 import org.apache.airavata.xbaya.component.dynamic.GenericSubWorkflowComponent;
 import org.apache.airavata.xbaya.graph.ControlEdge;
 import org.apache.airavata.xbaya.graph.ControlPort;
@@ -53,6 +46,7 @@ import org.apache.airavata.xbaya.graph.P
 import org.apache.airavata.xbaya.graph.dynamic.CepNode;
 import org.apache.airavata.xbaya.graph.gui.GraphCanvas;
 import org.apache.airavata.xbaya.graph.impl.NodeImpl;
+import org.apache.airavata.xbaya.graph.subworkflow.SubWorkflowNode;
 import org.apache.airavata.xbaya.graph.system.InputNode;
 import org.apache.airavata.xbaya.graph.system.OutputNode;
 import org.apache.airavata.xbaya.graph.system.gui.StreamSourceNode;
@@ -64,624 +58,695 @@ import org.apache.airavata.common.utils.
 import org.apache.airavata.xbaya.wf.Workflow;
 
 public class GraphUtil {
+	// private static final MLogger logger = MLogger.getLogger();
 
-    /**
-     * Returns the WSNodes included in a specified graph.
-     * 
-     * @param graph
-     *            The specified graph.
-     * @return The WSNodes.
-     */
-    public static Collection<WSNode> getWSNodes(Graph graph) {
-        return getNodes(graph, WSNode.class);
-    }
-
-    /**
-     * Returns a List of InputNodes from a specified graph.
-     * 
-     * @param graph
-     *            the specified graph
-     * @return The List of InputNodes.
-     */
-    public static List<InputNode> getInputNodes(Graph graph) {
-        return getNodes(graph, InputNode.class);
-    }
-
-    /**
-     * Returns a List of OutputNodes from a specified graph.
-     * 
-     * @param graph
-     *            the specified graph
-     * @return The List of OutputNodes.
-     */
-    public static List<OutputNode> getOutputNodes(Graph graph) {
-        return getNodes(graph, OutputNode.class);
-    }
-
-    /**
-     * Returns a List of nodes of specific subclass of Node from a specified graph.
-     * 
-     * @param <N>
-     *            One of the subclass of the Node.
-     * @param graph
-     *            The specified graph.
-     * @param klass
-     *            The specified subclass of Node.
-     * @return The list of T
-     */
-    @SuppressWarnings("unchecked")
-    public static <N extends Node> List<N> getNodes(Graph graph, Class<N> klass) {
-        List<N> nodes = new LinkedList<N>();
-        for (Node node : graph.getNodes()) {
-            if (klass.isInstance(node)) {
-                nodes.add((N) node);
-            }
-        }
-        return nodes;
-    }
-
-    /**
-     * @param node
-     * @return The output nodes.
-     */
-    public static List<Node> getOutputNodes(Node node) {
-        List<Node> outputNodes = new ArrayList<Node>();
-        for (Port port : node.getOutputPorts()) {
-            Collection<Node> toNodes = port.getToNodes();
-            outputNodes.addAll(toNodes);
-        }
-        return outputNodes;
-    }
-
-    /**
-     * Returns next nodes connected to a specified node.
-     * 
-     * @param node
-     *            The specified node.
-     * @return The next nodes.
-     */
-    public static List<Node> getNextNodes(Node node) {
-        List<Node> nextNodes = getOutputNodes(node);
-        for (Port port : node.getControlOutPorts()) {
-            Collection<Node> toNodes = port.getToNodes();
-            nextNodes.addAll(toNodes);
-        }
-        return nextNodes;
-    }
-
-    /**
-     * Sorts the nodes alphabetically by their names.
-     * 
-     * @param <T>
-     * @param nodes
-     * @return The list of nodes sorted.
-     */
-    public static <T extends Node> List<T> sortByName(Collection<T> nodes) {
-        List<T> nodeList = new LinkedList<T>(nodes);
-        Comparator<Node> nameComparator = new Comparator<Node>() {
-            public int compare(Node node1, Node node2) {
-                String name1 = node1.getName();
-                String name2 = node2.getName();
-                return name1.compareToIgnoreCase(name2);
-            }
-        };
-        Collections.sort(nodeList, nameComparator);
-        return nodeList;
-    }
-
-    /**
-     * @param graph
-     * @param kind
-     * @return The ports of specified kind.
-     */
-    public static Collection<Port> getPorts(Graph graph, Port.Kind kind) {
-        Collection<Port> ports = new ArrayList<Port>();
-        for (Port port : graph.getPorts()) {
-            if (port.getKind() == kind) {
-                ports.add(port);
-            }
-        }
-        return ports;
-    }
-
-    /**
-     * @param <P>
-     * @param graph
-     * @param klass
-     * @return The ports
-     */
-    @SuppressWarnings("unchecked")
-    public static <P extends Port> List<P> getPorts(Graph graph, Class<P> klass) {
-        List<P> ports = new LinkedList<P>();
-        for (Port port : graph.getPorts()) {
-            if (klass.isInstance(port)) {
-                ports.add((P) port);
-            }
-        }
-        return ports;
-    }
-
-    private enum Color {
-        /**
-         * This node hasn't been visited.
-         */
-        WHITE,
-        /**
-         * This node has been visited.
-         */
-        GRAY,
-        /**
-         * This not is not in cycle.
-         */
-        BLACK;
-    }
-
-    /**
-     * @param graph
-     * @return true if there is a cycle in the graph; false otherwise.
-     */
-    public static boolean containsCycle(Graph graph) {
-        Map<Node, Color> coloredNodes = new HashMap<Node, Color>();
-        for (Node node : graph.getNodes()) {
-            coloredNodes.put(node, Color.WHITE);
-        }
-
-        for (Node node : graph.getNodes()) {
-            if (coloredNodes.get(node) == Color.WHITE) {
-                if (visit(node, coloredNodes)) {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-    private static boolean visit(Node node, Map<Node, Color> coloredNodes) {
-        coloredNodes.put(node, Color.GRAY);
-        for (Node nextNode : getNextNodes(node)) {
-            Color nextNodeColor = coloredNodes.get(nextNode);
-            if (nextNodeColor == Color.GRAY) {
-                return true;
-            } else if (nextNodeColor == Color.WHITE) {
-                if (visit(nextNode, coloredNodes)) {
-                    return true;
-                }
-            }
-        }
-        coloredNodes.put(node, Color.BLACK);
-        return false;
-    }
-
-    /**
-     * @param edge
-     * @throws GraphException
-     */
-    public static void validateConnection(Edge edge) throws GraphException {
-        Port fromPort = edge.getFromPort();
-        Port toPort = edge.getToPort();
-        if (edge instanceof ControlEdge) {
-            if (!(fromPort instanceof ControlPort && toPort instanceof ControlPort)) {
-                throw new GraphException(ErrorMessages.UNEXPECTED_ERROR);
-            }
-        } else if (edge instanceof DataEdge) {
-            if (fromPort instanceof EPRPort) {
-                // TODO
-                return;
-            }
-            if (!(fromPort instanceof DataPort || fromPort instanceof EPRPort) || !(toPort instanceof DataPort)) {
-                throw new GraphException(ErrorMessages.UNEXPECTED_ERROR);
-            }
-
-            DataPort fromDataPort = (DataPort) fromPort;
-            DataPort toDataPort = (DataPort) toPort;
-
-            QName fromType = fromDataPort.getType();
-            QName toType = toDataPort.getType();
-
-            if (toDataPort.getEdges().size() > 1) {
-                throw new GraphException(ErrorMessages.MORE_THAN_ONE_CONNECTIONS);
-            }
-
-            // if connection came from the CEP register component it should be
-            // ok
-            if (fromPort.getNode() instanceof WSNode) {
-                if ("registerStream".equals(((WSNode) fromPort.getNode()).getOperationName())) {
-                    return;
-                }
-            }
-
-            if (!(fromType == null || fromType.equals(WSConstants.XSD_ANY_TYPE)
-                    || fromType.equals(new QName(WSConstants.XSD_NS_URI, "anyType")) || toType == null
-                    || toType.equals(WSConstants.XSD_ANY_TYPE)
-                    || toType.equals(new QName(WSConstants.XSD_NS_URI, "anyType")) || fromType.equals(toType))) {
-                throw new GraphException("Cannot connect ports with different types:" + " \nfrom=\t" + fromType
-                        + " \nto=\t" + toType + "");
-            }
-        }
-    }
-
-    /**
-     * @param graph
-     * @throws GraphException
-     */
-    public static void propagateTypes(Graph graph) throws GraphException {
-        List<WSPort> wsPorts = getPorts(graph, WSPort.class);
-        for (WSPort wsPort : wsPorts) {
-            List<DataEdge> edges = wsPort.getEdges();
-            for (DataEdge edge : edges) {
-                DataPort fromPort = edge.getFromPort();
-
-                DataPort toPort = edge.getToPort();
-                if (fromPort == wsPort) {
-                    toPort.copyType(wsPort);
-                } else if (toPort == wsPort) {
-                    fromPort.copyType(wsPort);
-                } else {
-                    throw new XBayaRuntimeException();
-                }
-            }
-        }
-
-    }
+	/**
+	 * Returns the WSNodes included in a specified graph.
+	 *
+	 * @param graph
+	 *            The specified graph.
+	 * @return The WSNodes.
+	 */
+	public static Collection<WSNode> getWSNodes(Graph graph) {
+		return getNodes(graph, WSNode.class);
+	}
+
+	/**
+	 * Returns a List of InputNodes from a specified graph.
+	 *
+	 * @param graph
+	 *            the specified graph
+	 * @return The List of InputNodes.
+	 */
+	public static List<InputNode> getInputNodes(Graph graph) {
+		return getNodes(graph, InputNode.class);
+	}
+
+	/**
+	 * Returns a List of OutputNodes from a specified graph.
+	 *
+	 * @param graph
+	 *            the specified graph
+	 * @return The List of OutputNodes.
+	 */
+	public static List<OutputNode> getOutputNodes(Graph graph) {
+		return getNodes(graph, OutputNode.class);
+	}
+
+	/**
+	 * Returns a List of nodes of specific subclass of Node from a specified
+	 * graph.
+	 *
+	 * @param <N>
+	 *            One of the subclass of the Node.
+	 * @param graph
+	 *            The specified graph.
+	 * @param klass
+	 *            The specified subclass of Node.
+	 * @return The list of T
+	 */
+	@SuppressWarnings("unchecked")
+	public static <N extends Node> List<N> getNodes(Graph graph, Class<N> klass) {
+		List<N> nodes = new LinkedList<N>();
+		for (Node node : graph.getNodes()) {
+			if (klass.isInstance(node)) {
+				nodes.add((N) node);
+			}
+		}
+		return nodes;
+	}
+
+	/**
+	 * @param node
+	 * @return The output nodes.
+	 */
+	public static List<Node> getOutputNodes(Node node) {
+		List<Node> outputNodes = new ArrayList<Node>();
+		for (Port port : node.getOutputPorts()) {
+			Collection<Node> toNodes = port.getToNodes();
+			outputNodes.addAll(toNodes);
+		}
+		return outputNodes;
+	}
+
+	/**
+	 * Returns next nodes connected to a specified node.
+	 *
+	 * @param node
+	 *            The specified node.
+	 * @return The next nodes.
+	 */
+	public static List<Node> getNextNodes(Node node) {
+		List<Node> nextNodes = getOutputNodes(node);
+		for (Port port : node.getControlOutPorts()) {
+			Collection<Node> toNodes = port.getToNodes();
+			nextNodes.addAll(toNodes);
+		}
+		return nextNodes;
+	}
+
+	/**
+	 * Sorts the nodes alphabetically by their names.
+	 *
+	 * @param <T>
+	 * @param nodes
+	 * @return The list of nodes sorted.
+	 */
+	public static <T extends Node> List<T> sortByName(Collection<T> nodes) {
+		List<T> nodeList = new LinkedList<T>(nodes);
+		Comparator<Node> nameComparator = new Comparator<Node>() {
+			@Override
+			public int compare(Node node1, Node node2) {
+				String name1 = node1.getName();
+				String name2 = node2.getName();
+				return name1.compareToIgnoreCase(name2);
+			}
+		};
+		Collections.sort(nodeList, nameComparator);
+		return nodeList;
+	}
+
+	/**
+	 * @param graph
+	 * @param kind
+	 * @return The ports of specified kind.
+	 */
+	public static Collection<Port> getPorts(Graph graph, Port.Kind kind) {
+		Collection<Port> ports = new ArrayList<Port>();
+		for (Port port : graph.getPorts()) {
+			if (port.getKind() == kind) {
+				ports.add(port);
+			}
+		}
+		return ports;
+	}
+
+	/**
+	 * @param <P>
+	 * @param graph
+	 * @param klass
+	 * @return The ports
+	 */
+	@SuppressWarnings("unchecked")
+	public static <P extends Port> List<P> getPorts(Graph graph, Class<P> klass) {
+		List<P> ports = new LinkedList<P>();
+		for (Port port : graph.getPorts()) {
+			if (klass.isInstance(port)) {
+				ports.add((P) port);
+			}
+		}
+		return ports;
+	}
+
+	private enum Color {
+		/**
+		 * This node hasn't been visited.
+		 */
+		WHITE,
+		/**
+		 * This node has been visited.
+		 */
+		GRAY,
+		/**
+		 * This not is not in cycle.
+		 */
+		BLACK;
+	}
+
+	/**
+	 * @param graph
+	 * @return true if there is a cycle in the graph; false otherwise.
+	 */
+	public static boolean containsCycle(Graph graph) {
+		Map<Node, Color> coloredNodes = new HashMap<Node, Color>();
+		for (Node node : graph.getNodes()) {
+			coloredNodes.put(node, Color.WHITE);
+		}
+
+		for (Node node : graph.getNodes()) {
+			if (coloredNodes.get(node) == Color.WHITE) {
+				if (visit(node, coloredNodes)) {
+					return true;
+				}
+			}
+		}
+		return false;
+	}
+
+	private static boolean visit(Node node, Map<Node, Color> coloredNodes) {
+		coloredNodes.put(node, Color.GRAY);
+		for (Node nextNode : getNextNodes(node)) {
+			Color nextNodeColor = coloredNodes.get(nextNode);
+			if (nextNodeColor == Color.GRAY) {
+				return true;
+			} else if (nextNodeColor == Color.WHITE) {
+				if (visit(nextNode, coloredNodes)) {
+					return true;
+				}
+			}
+		}
+		coloredNodes.put(node, Color.BLACK);
+		return false;
+	}
+
+	/**
+	 * @param edge
+	 * @throws GraphException
+	 */
+	public static void validateConnection(Edge edge) throws GraphException {
+		Port fromPort = edge.getFromPort();
+		Port toPort = edge.getToPort();
+		if (edge instanceof ControlEdge) {
+			if (!(fromPort instanceof ControlPort && toPort instanceof ControlPort)) {
+				throw new GraphException(ErrorMessages.UNEXPECTED_ERROR);
+			}
+		} else if (edge instanceof DataEdge) {
+			if (fromPort instanceof EPRPort) {
+				// TODO
+				return;
+			}
+			if (!(fromPort instanceof DataPort || fromPort instanceof EPRPort)
+					|| !(toPort instanceof DataPort)) {
+				throw new GraphException(ErrorMessages.UNEXPECTED_ERROR);
+			}
+
+			DataPort fromDataPort = (DataPort) fromPort;
+			DataPort toDataPort = (DataPort) toPort;
+
+			QName fromType = fromDataPort.getType();
+			QName toType = toDataPort.getType();
+
+			if (toDataPort.getEdges().size() > 1) {
+				throw new GraphException(
+						ErrorMessages.MORE_THAN_ONE_CONNECTIONS);
+			}
+
+			// if connection came from the CEP register component it should be
+			// ok
+			if (fromPort.getNode() instanceof WSNode) {
+				if ("registerStream".equals(((WSNode) fromPort.getNode())
+						.getOperationName())) {
+					return;
+				}
+			}
+
+			if (!(fromType == null
+					|| fromType.equals(WSConstants.XSD_ANY_TYPE)
+					|| fromType.equals(new QName(WSConstants.XSD_NS_URI,
+							"anyType"))
+					|| toType == null
+					|| toType.equals(WSConstants.XSD_ANY_TYPE)
+					|| toType.equals(new QName(WSConstants.XSD_NS_URI,
+							"anyType")) || fromType.equals(toType)) && (fromType == null
+					|| fromType.equals(WSConstants.LEAD_ANY_TYPE)
+					|| fromType.equals(new QName(WSConstants.LEAD_NS_URI,
+							"anyType"))
+					|| toType == null
+					|| toType.equals(WSConstants.LEAD_ANY_TYPE)
+					|| toType.equals(new QName(WSConstants.LEAD_NS_URI,
+							"anyType")) || fromType.equals(toType))) {
+				throw new GraphException(
+						"Cannot connect ports with different types:"
+								+ " \nfrom=\t" + fromType + " \nto=\t" + toType
+								+ "");
+			}
+		}
+	}
+
+	/**
+	 * @param graph
+	 * @throws GraphException
+	 */
+	public static void propagateTypes(Graph graph) throws GraphException {
+		List<WSPort> wsPorts = getPorts(graph, WSPort.class);
+		for (WSPort wsPort : wsPorts) {
+			List<DataEdge> edges = wsPort.getEdges();
+			for (DataEdge edge : edges) {
+				DataPort fromPort = edge.getFromPort();
+
+				DataPort toPort = edge.getToPort();
+				if (fromPort == wsPort) {
+					toPort.copyType(wsPort);
+				} else if (toPort == wsPort) {
+					fromPort.copyType(wsPort);
+				} else {
+					throw new XBayaRuntimeException();
+				}
+			}
+		}
+
+	}
+
+	/**
+	 * @param graph
+	 * @return
+	 */
+	public static LinkedList<NodeImpl> getGenericSubWorkflowNodes(WSGraph graph) {
+		final List<NodeImpl> nodes = graph.getNodes();
+		final LinkedList<NodeImpl> ret = new LinkedList<NodeImpl>();
+		for (NodeImpl nodeImpl : nodes) {
+			if (nodeImpl.getComponent() instanceof GenericSubWorkflowComponent) {
+				ret.add(nodeImpl);
+
+			}
+		}
+		return ret;
+	}
 
     /**
+     *
      * @param graph
      * @return
      */
-    public static LinkedList<NodeImpl> getGenericSubWorkflowNodes(WSGraph graph) {
-        final List<NodeImpl> nodes = graph.getNodes();
-        final LinkedList<NodeImpl> ret = new LinkedList<NodeImpl>();
-        for (NodeImpl nodeImpl : nodes) {
-            if (nodeImpl.getComponent() instanceof GenericSubWorkflowComponent) {
-                ret.add(nodeImpl);
-
-            }
-        }
-        return ret;
-    }
-
-    /**
-     * @param wsGraph
-     * @return
-     */
-    public static LinkedList<StreamSourceNode> getStreamSourceNodes(WSGraph graph) {
-        List<NodeImpl> nodes = graph.getNodes();
-        LinkedList<StreamSourceNode> ret = new LinkedList<StreamSourceNode>();
-        for (NodeImpl nodeImpl : nodes) {
-            if (nodeImpl instanceof StreamSourceNode) {
-                ret.add((StreamSourceNode) nodeImpl);
-            }
-        }
-        return ret;
-    }
+	public static LinkedList<StreamSourceNode> getStreamSourceNodes(
+			WSGraph graph) {
+		List<NodeImpl> nodes = graph.getNodes();
+		LinkedList<StreamSourceNode> ret = new LinkedList<StreamSourceNode>();
+		for (NodeImpl nodeImpl : nodes) {
+			if (nodeImpl instanceof StreamSourceNode) {
+				ret.add((StreamSourceNode) nodeImpl);
+			}
+		}
+		return ret;
+	}
+
+	/**
+	 * @param node
+	 * @return null if not the same
+	 */
+	public static String isSameLabeledInput(Node node) {
+		if (!isAllInputsConnected(node)) {
+			throw new XBayaRuntimeException("Node inputs not connected" + node);
+		}
+		if (!isAllInputsLabeled(node)) {
+			throw new XBayaRuntimeException(
+					"Some or all of the node inputs not labeled" + node);
+		}
+		List<DataPort> inputPorts = node.getInputPorts();
+		String label = inputPorts.get(0).getEdge(0).getLabel();
+		for (DataPort dataPort : inputPorts) {
+			// 0 because its got only one
+			if (!label.equals(dataPort.getEdge(0).getLabel())) {
+				return null;
+			}
+		}
+		return label;
+	}
+
+	/**
+	 * @param node
+	 * @return
+	 */
+	public static boolean isAllInputsLabeled(Node node) {
+		List<DataPort> inputPorts = node.getInputPorts();
+		for (DataPort dataPort : inputPorts) {
+			// 0 because its got only one
+			Edge edge = dataPort.getEdge(0);
+			if (edge == null || edge.getLabel() == null) {
+				return false;
+			}
+		}
+		return true;
+	}
+
+	/**
+	 * @param node
+	 * @return
+	 */
+	public static boolean isAllInputsConnected(Node node) {
+		List<DataPort> inputPorts = node.getInputPorts();
+		for (DataPort dataPort : inputPorts) {
+			// 0 because its got only one
+			Edge edge = dataPort.getEdge(0);
+			if (edge == null) {
+				return false;
+			}
+		}
+		return true;
+	}
 
     /**
+     *
      * @param node
-     * @return null if not the same
-     */
-    public static String isSameLabeledInput(Node node) {
-        if (!isAllInputsConnected(node)) {
-            throw new XBayaRuntimeException("Node inputs not connected" + node);
-        }
-        if (!isAllInputsLabeled(node)) {
-            throw new XBayaRuntimeException("Some or all of the node inputs not labeled" + node);
-        }
-        List<DataPort> inputPorts = node.getInputPorts();
-        String label = inputPorts.get(0).getEdge(0).getLabel();
-        for (DataPort dataPort : inputPorts) {
-            // 0 because its got only one
-            if (!label.equals(dataPort.getEdge(0).getLabel())) {
-                return null;
-            }
-        }
-        return label;
-    }
-
-    /**
-     * @param node
-     * @return
-     */
-    public static boolean isAllInputsLabeled(Node node) {
-        List<DataPort> inputPorts = node.getInputPorts();
-        for (DataPort dataPort : inputPorts) {
-            // 0 because its got only one
-            Edge edge = dataPort.getEdge(0);
-            if (edge == null || edge.getLabel() == null) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /**
-     * @param node
-     * @return
-     */
-    public static boolean isAllInputsConnected(Node node) {
-        List<DataPort> inputPorts = node.getInputPorts();
-        for (DataPort dataPort : inputPorts) {
-            // 0 because its got only one
-            Edge edge = dataPort.getEdge(0);
-            if (edge == null) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /**
-     * @param processingNode
-     * @return
-     */
-    public static boolean isRegulerNode(Node node) {
-        if (node instanceof WSNode) {
-            return true;
-        }
-        return false;
-    }
-
-    /**
-     * @param processingNode
-     * @return
-     */
-    public static String getEncodedInputLabels(Node node) {
-        if (!isAllInputsConnected(node)) {
-            throw new XBayaRuntimeException("Node inputs not connected" + node);
-        }
-        if (!isAllInputsLabeled(node)) {
-            throw new XBayaRuntimeException("Some or all of the node inputs not labeled" + node);
-        }
-        List<DataPort> inputPorts = node.getInputPorts();
-        String label = "";
-        for (DataPort dataPort : inputPorts) {
-            label += "#" + dataPort.getEdge(0).getLabel();
-        }
-        return label;
-
-    }
-
-    /**
-     * @param wsGraph
-     * @return
-     */
-    public static List<Node> getJoinRequiredNodes(WSGraph wsGraph) {
-        List<NodeImpl> nodes = wsGraph.getNodes();
-        List<Node> ret = new LinkedList<Node>();
-        for (NodeImpl node : nodes) {
-            if (node.getRequireJoin()) {
-                ret.add(node);
-            }
-        }
-        return ret;
-    }
-
-    /**
-     * @param processingNode
-     * @return
-     */
-    public static boolean isCEPNode(Node processingNode) {
-        return processingNode instanceof CepNode;
-    }
-
-    /**
-     * @param node
-     * @param newCEPJoinNode
-     * @param wsGraph
-     * @return
-     */
-    public static String introduceDynamicNode(Node node, CepNode newCEPJoinNode, WSGraph wsGraph) {
-
-        List<DataPort> inputPorts = node.getInputPorts();
-        for (DataPort dataPort : inputPorts) {
-            DataEdge edge = dataPort.getEdges().get(0);
-
-            Pair<DataPort, DataPort> oldEdge = new Pair<DataPort, DataPort>(edge.getFromPort(), edge.getToPort());
-            try {
-                String inEdgeLabel = edge.getLabel();
-                wsGraph.removeEdge(edge);
-                Edge inEdge = wsGraph.addEdge(oldEdge.getLeft(), newCEPJoinNode.getFreeInPort());
-                inEdge.setLabel(inEdgeLabel);
-                wsGraph.addEdge(newCEPJoinNode.getFreeOutPort(), oldEdge.getRight());
-            } catch (GraphException e) {
-                throw new XBayaRuntimeException(e);
-            }
-        }
-        String nodeLabel = GraphUtil.getEncodedInputLabels(newCEPJoinNode) + "#join";
-        newCEPJoinNode.inventLabel(nodeLabel);
-        return nodeLabel;
-    }
-
-    /**
-     * @param wsGraph
      * @return
      */
-    public static HashMap<String, LinkedList<Node>> partitionGraphOnLabel(WSGraph wsGraph) {
-        HashMap<String, LinkedList<Node>> returnMap = new HashMap<String, LinkedList<Node>>();
-        List<NodeImpl> nodes = wsGraph.getNodes();
-        for (NodeImpl node : nodes) {
-            if (!isInputOutputNode(node)) {
-                LinkedList<Node> list = returnMap.get(node.getLabel());
-                if (null == list) {
-                    list = new LinkedList<Node>();
-                    returnMap.put(node.getLabel(), list);
-                }
-                list.add(node);
-            }
-        }
-        return returnMap;
-    }
+	public static boolean isRegulerNode(Node node) {
+		if (node instanceof WSNode) {
+			return true;
+		}
+		return false;
+	}
 
     /**
+     *
      * @param node
      * @return
      */
-    private static boolean isInputOutputNode(NodeImpl node) {
-        return node instanceof InputNode || node instanceof StreamSourceNode || node instanceof OutputNode;
-    }
-
-    public static void createSubworkflow(Workflow parentWorkflow, List<Node> nodeSet, XBayaEngine engine,
-            String subworkflowName) throws GraphException {
-        Workflow subWorkflow = Workflow.getWorkflow(parentWorkflow, nodeSet, subworkflowName);
-
-        GraphCanvas newGraphCanvas = engine.getGUI().newGraphCanvas(false);
-        newGraphCanvas.setWorkflow(subWorkflow);
-
-        Node newNode = parentWorkflow.addNode(new GenericSubWorkflowComponent(subWorkflow));
-
-        List<Node> removeList = nodeSet;
-        HashMap<Node, Node> lookupMap = new HashMap<Node, Node>();
-        for (Node node : removeList) {
-            lookupMap.put(node, node);
-        }
-        for (Node node : removeList) {
-            List<DataPort> inputPorts = node.getInputPorts();
-            for (DataPort dataPort : inputPorts) {
-                if (null == lookupMap.get(dataPort.getFromNode())) {
-                    // not in this set
-                    final Port fromPort = dataPort.getFromPort();
-                    parentWorkflow.getGraph().removeEdge(fromPort, dataPort);
-                    parentWorkflow.getGraph().addEdge(fromPort, newNode.getInputPort(dataPort.getID()));
-
-                }
-            }
-
-            List<DataPort> outputPorts = node.getOutputPorts();
-            for (int i = 0; i < outputPorts.size(); ++i) {
-
-                DataPort dataPort = outputPorts.get(i);
-                List<Port> toNodes = dataPort.getToPorts();
-                for (Port toPort : toNodes) {
-                    if (null == lookupMap.get(toPort.getNode())) {
-                        // not in this set
-                        parentWorkflow.getGraph().removeEdge(dataPort, toPort);
-                        parentWorkflow.getGraph().addEdge(newNode.getOutputPort(dataPort.getID()), toPort);
-                    }
-                }
-            }
-        }
-        newNode.setPosition(new Point(removeList.get(0).getPosition()));
-        for (Node node : removeList) {
-            parentWorkflow.removeNode(node);
-        }
-    }
-
-    /**
-     * @param nodeSets
-     */
-    public static void clusterCEPSubGraph(HashMap<String, LinkedList<Node>> nodeSets) {
-        Set<String> keys = nodeSets.keySet();
-        for (String key : keys) {
-            LinkedList<Node> subGraph = nodeSets.get(key);
-            if (subGraph != null && subGraph.size() > 0 && isAllCEPNodes(subGraph)) {
-                LinkedList<Node> workQueue = new LinkedList<Node>(subGraph);
-                while (workQueue.size() > 0) {
-                    Node currentNode = workQueue.remove();
-                    List<DataPort> outputPorts = currentNode.getOutputPorts();
-                    for (DataPort dataPort : outputPorts) {
-                        List<Node> nextNodes = dataPort.getToNodes();
-                        for (Node nextNode : nextNodes) {
-                            if (isCEPNode(nextNode) && nodeSets.get(nextNode.getLabel()) != null) {
-                                // it wasnt consumed
-                                LinkedList<Node> adjoiningNodeSet = nodeSets.get(nextNode.getLabel());
-                                if (isAllCEPNodes(adjoiningNodeSet) && !key.equals(nextNode.getLabel())) {
-                                    // consume
-                                    nodeSets.put(nextNode.getLabel(), null);
-                                    // add to this list
-                                    subGraph.addAll(adjoiningNodeSet);
-                                    // add thses for work queue;
-                                    workQueue.addAll(adjoiningNodeSet);
-                                }
-                            }
-                        }
-                    }
+	public static String getEncodedInputLabels(Node node) {
+		if (!isAllInputsConnected(node)) {
+			throw new XBayaRuntimeException("Node inputs not connected" + node);
+		}
+		if (!isAllInputsLabeled(node)) {
+			throw new XBayaRuntimeException(
+					"Some or all of the node inputs not labeled" + node);
+		}
+		List<DataPort> inputPorts = node.getInputPorts();
+		String label = "";
+		for (DataPort dataPort : inputPorts) {
+			label += "#" + dataPort.getEdge(0).getLabel();
+		}
+		return label;
+
+	}
+
+	/**
+	 * @param wsGraph
+	 * @return
+	 */
+	public static List<Node> getJoinRequiredNodes(WSGraph wsGraph) {
+		List<NodeImpl> nodes = wsGraph.getNodes();
+		List<Node> ret = new LinkedList<Node>();
+		for (NodeImpl node : nodes) {
+			if (node.getRequireJoin()) {
+				ret.add(node);
+			}
+		}
+		return ret;
+	}
+
+	/**
+	 * @param processingNode
+	 * @return
+	 */
+	public static boolean isCEPNode(Node processingNode) {
+		return processingNode instanceof CepNode;
+	}
+
+	/**
+	 * @param node
+	 * @param newCEPJoinNode
+	 * @param wsGraph
+	 * @return
+	 */
+	public static String introduceDynamicNode(Node node,
+			CepNode newCEPJoinNode, WSGraph wsGraph) {
+
+		List<DataPort> inputPorts = node.getInputPorts();
+		for (DataPort dataPort : inputPorts) {
+			DataEdge edge = dataPort.getEdges().get(0);
+
+			Pair<DataPort, DataPort> oldEdge = new Pair<DataPort, DataPort>(
+					edge.getFromPort(), edge.getToPort());
+			try {
+				String inEdgeLabel = edge.getLabel();
+				wsGraph.removeEdge(edge);
+				Edge inEdge = wsGraph.addEdge(oldEdge.getLeft(),
+						newCEPJoinNode.getFreeInPort());
+				inEdge.setLabel(inEdgeLabel);
+				wsGraph.addEdge(newCEPJoinNode.getFreeOutPort(),
+						oldEdge.getRight());
+			} catch (GraphException e) {
+				throw new XBayaRuntimeException(e);
+			}
+		}
+		String nodeLabel = GraphUtil.getEncodedInputLabels(newCEPJoinNode)
+				+ "#join";
+		newCEPJoinNode.inventLabel(nodeLabel);
+		return nodeLabel;
+	}
+
+	/**
+	 * @param wsGraph
+	 * @return
+	 */
+	public static HashMap<String, LinkedList<Node>> partitionGraphOnLabel(
+			WSGraph wsGraph) {
+		HashMap<String, LinkedList<Node>> returnMap = new HashMap<String, LinkedList<Node>>();
+		List<NodeImpl> nodes = wsGraph.getNodes();
+		for (NodeImpl node : nodes) {
+			if (!isInputOutputNode(node)) {
+				LinkedList<Node> list = returnMap.get(node.getLabel());
+				if (null == list) {
+					list = new LinkedList<Node>();
+					returnMap.put(node.getLabel(), list);
+				}
+				list.add(node);
+			}
+		}
+		return returnMap;
+	}
+
+	/**
+	 * @param node
+	 * @return
+	 */
+	private static boolean isInputOutputNode(NodeImpl node) {
+		return node instanceof InputNode || node instanceof StreamSourceNode
+				|| node instanceof OutputNode;
+	}
+
+	public static void createSubworkflow(Workflow parentWorkflow,
+			List<Node> nodeSet, XBayaEngine engine, String subworkflowName)
+            throws GraphException, ComponentException {
+		Workflow subWorkflow = Workflow.getWorkflow(parentWorkflow, nodeSet,
+				subworkflowName);
+
+//		GraphCanvas newGraphCanvas = engine.getGUI().newGraphCanvas(false);
+//		newGraphCanvas.setWorkflow(subWorkflow);
+
+		SubWorkflowNode newNode = (SubWorkflowNode) parentWorkflow.addNode( SubWorkflowComponent.getInstance(
+                subWorkflow));
+
+		List<Node> removeList = nodeSet;
+		Set<Node> lookupMap = new HashSet<Node>();
+		for (Node node : removeList) {
+			lookupMap.add(node);
+		}
+
+        List<DataPort> newNodeInputs = newNode.getInputPorts();
+        List<DataPort> newNodeOutputs = newNode.getOutputPorts();
+        int inPortCount = 0;
+        int outPortCount = 0;
+
+        /* replace the subworkflow components with newNode and change the original  workflow*/
+		for (Node node : removeList) {
+			List<DataPort> inputPorts = node.getInputPorts();
+			for (DataPort dataPort : inputPorts) {
+				if (!lookupMap.contains(dataPort.getFromNode())) {
+					// not in this set
+					final Port fromPort = dataPort.getFromPort();
+                    Object defaultValue = null;
+                    if(fromPort.getNode() instanceof InputNode) {
+                        defaultValue = ((InputNode) fromPort.getNode()).getDefaultValue();
 
-                    List<DataPort> inputPorts = currentNode.getInputPorts();
-                    for (DataPort dataPort : inputPorts) {
-                        Node fromNode = dataPort.getFromNode();
-                        if (isCEPNode(fromNode) && nodeSets.get(fromNode.getLabel()) != null) {
-                            // it wasnt consumed
-                            LinkedList<Node> adjoiningNodeSet = nodeSets.get(fromNode.getLabel());
-                            if (isAllCEPNodes(adjoiningNodeSet) && !key.equals(fromNode.getLabel())) {
-                                // consume
-                                nodeSets.put(fromNode.getLabel(), null);
-                                // add to this list
-                                subGraph.addAll(adjoiningNodeSet);
-                                // add thses for work queue;
-                                workQueue.addAll(adjoiningNodeSet);
-                            }
-                        }
                     }
-
-                }
-            }
-
-        }
-        Iterator<Entry<String, LinkedList<Node>>> iterator = nodeSets.entrySet().iterator();
-        while (iterator.hasNext()) {
-            Map.Entry<String, LinkedList<Node>> entry = iterator.next();
-            if (entry.getValue() == null) {
-                iterator.remove();
-            }
-        }
-    }
-
-    /**
-     * @param subGraph
-     * @return
-     */
-    private static boolean isAllCEPNodes(LinkedList<Node> subGraph) {
-        for (Node node : subGraph) {
-            if (!isCEPNode(node)) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /**
-     * @param wsGraph
-     * @return
-     */
-    public static LinkedList<CepNode> getCEPNodes(WSGraph wsGraph) {
-        List<NodeImpl> nodes = wsGraph.getNodes();
-        LinkedList<CepNode> ret = new LinkedList<CepNode>();
-        for (NodeImpl nodeImpl : nodes) {
-            if (nodeImpl instanceof CepNode) {
-                ret.add((CepNode) nodeImpl);
-            }
-        }
-        return ret;
-    }
-
-    /**
-     * @param name
-     * @param nodeList
-     * @param key
-     * @return
-     */
-    public static String getSubWorkflowName(String name, LinkedList<Node> nodeList, String key) {
-        String ret = name + "_subworkflow";
-        for (Node node : nodeList) {
-            ret += node.getID();
-
-        }
-
-        if (ret.length() > 40) {
-            ret = ret.substring(0, 40);
-        }
-        // TODO Auto-generated method stub
-        return ret;
-    }
+					parentWorkflow.getGraph().removeEdge(fromPort, dataPort);
+                    DataPort newtoPort  = newNode.assignInputPortID(dataPort.getID(), inPortCount);
+					parentWorkflow.getGraph().addEdge(fromPort,
+                            newtoPort);
+                    // we do this because if the edge is removed, the input node value gets reset. So we need to save
+                    // it and set it again.
+                     if(fromPort.getNode() instanceof InputNode) {
+                        ((InputNode) fromPort.getNode()).setDefaultValue(defaultValue);
+                     }
+                    ++inPortCount;
+
+				}
+			}
+
+			List<DataPort> outputPorts = node.getOutputPorts();
+			for (int i = 0; i < outputPorts.size(); ++i) {
+
+				DataPort dataPort = outputPorts.get(i);
+				List<Port> toNodes = dataPort.getToPorts();
+				for (Port toPort : toNodes) {
+					if (! lookupMap.contains(toPort.getNode())) {
+						// not in this set
+						parentWorkflow.getGraph().removeEdge(dataPort, toPort);
+                        DataPort newFromPort = newNode.assignOutputPortID(dataPort.getID(), outPortCount) ;
+						parentWorkflow.getGraph().addEdge(newFromPort,
+                                toPort);
+
+                        ++outPortCount;
+					}
+				}
+			}
+		}
+		newNode.setPosition(new Point(removeList.get(0).getPosition()));
+		for (Node node : removeList) {
+			parentWorkflow.removeNode(node);
+		}
+	}
+
+	/**
+	 * @param nodeSets
+	 */
+	public static void clusterCEPSubGraph(
+			HashMap<String, LinkedList<Node>> nodeSets) {
+		Set<String> keys = nodeSets.keySet();
+		for (String key : keys) {
+			LinkedList<Node> subGraph = nodeSets.get(key);
+			if (subGraph != null && subGraph.size() > 0
+					&& isAllCEPNodes(subGraph)) {
+				LinkedList<Node> workQueue = new LinkedList<Node>(subGraph);
+				while (workQueue.size() > 0) {
+					Node currentNode = workQueue.remove();
+					List<DataPort> outputPorts = currentNode.getOutputPorts();
+					for (DataPort dataPort : outputPorts) {
+						List<Node> nextNodes = dataPort.getToNodes();
+						for (Node nextNode : nextNodes) {
+							if (isCEPNode(nextNode)
+									&& nodeSets.get(nextNode.getLabel()) != null) {
+								// it wasnt consumed
+								LinkedList<Node> adjoiningNodeSet = nodeSets
+										.get(nextNode.getLabel());
+								if (isAllCEPNodes(adjoiningNodeSet)
+										&& !key.equals(nextNode.getLabel())) {
+									// consume
+									nodeSets.put(nextNode.getLabel(), null);
+									// add to this list
+									subGraph.addAll(adjoiningNodeSet);
+									// add thses for work queue;
+									workQueue.addAll(adjoiningNodeSet);
+								}
+							}
+						}
+					}
+
+					List<DataPort> inputPorts = currentNode.getInputPorts();
+					for (DataPort dataPort : inputPorts) {
+						Node fromNode = dataPort.getFromNode();
+						if (isCEPNode(fromNode)
+								&& nodeSets.get(fromNode.getLabel()) != null) {
+							// it wasnt consumed
+							LinkedList<Node> adjoiningNodeSet = nodeSets
+									.get(fromNode.getLabel());
+							if (isAllCEPNodes(adjoiningNodeSet)
+									&& !key.equals(fromNode.getLabel())) {
+								// consume
+								nodeSets.put(fromNode.getLabel(), null);
+								// add to this list
+								subGraph.addAll(adjoiningNodeSet);
+								// add thses for work queue;
+								workQueue.addAll(adjoiningNodeSet);
+							}
+						}
+					}
+
+				}
+			}
+
+		}
+		Iterator<Entry<String, LinkedList<Node>>> iterator = nodeSets
+				.entrySet().iterator();
+		while (iterator.hasNext()) {
+			Map.Entry<String, LinkedList<Node>> entry = iterator.next();
+			if (entry.getValue() == null) {
+				iterator.remove();
+			}
+		}
+	}
+
+	/**
+	 * @param subGraph
+	 * @return
+	 */
+	private static boolean isAllCEPNodes(LinkedList<Node> subGraph) {
+		for (Node node : subGraph) {
+			if (!isCEPNode(node)) {
+				return false;
+			}
+		}
+		return true;
+	}
+
+	/**
+	 * @param wsGraph
+	 * @return
+	 */
+	public static LinkedList<CepNode> getCEPNodes(WSGraph wsGraph) {
+		List<NodeImpl> nodes = wsGraph.getNodes();
+		LinkedList<CepNode> ret = new LinkedList<CepNode>();
+		for (NodeImpl nodeImpl : nodes) {
+			if (nodeImpl instanceof CepNode) {
+				ret.add((CepNode) nodeImpl);
+			}
+		}
+		return ret;
+	}
+
+	/**
+	 * @param name
+	 * @param nodeList
+	 * @param key
+	 * @return
+	 */
+	public static String getSubWorkflowName(String name,
+			LinkedList<Node> nodeList, String key) {
+		String ret = name + "_subworkflow";
+		for (Node node : nodeList) {
+			ret += node.getID();
+
+		}
+
+		if(ret.length()>40){
+			ret = ret.substring(0, 40);
+		}
+		// TODO Auto-generated method stub
+		return ret;
+	}
 
     /**
+     *
      * @param multipleSelectedNodes
-     * @param string
+     * @param label
      */
-    public static void setLabelsToNodes(List<Node> multipleSelectedNodes, String label) {
+	public static void setLabelsToNodes(List<Node> multipleSelectedNodes,
+			String label) {
 
-        for (Node node : multipleSelectedNodes) {
-            node.setLabel(label);
-        }
+		for (Node node : multipleSelectedNodes) {
+			node.setLabel(label);
+		}
 
-    }
+	}
 }
\ No newline at end of file

Modified: incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/SystemComponentInvoker.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/SystemComponentInvoker.java?rev=1213773&r1=1213772&r2=1213773&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/SystemComponentInvoker.java (original)
+++ incubator/airavata/trunk/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/SystemComponentInvoker.java Tue Dec 13 16:35:51 2011
@@ -44,7 +44,7 @@ public class SystemComponentInvoker impl
     }
 
     /**
-     * @see org.apache.airavata.xbaya.invoker.WorkflowInvoker#getOutput(java.lang.String)
+     * @see org.apache.airavata.xbaya.invoker.Invoker#getOutput(java.lang.String)
      */
     @Override
     public Object getOutput(String name) {
@@ -61,7 +61,7 @@ public class SystemComponentInvoker impl
     }
 
     /**
-     * @see org.apache.airavata.xbaya.invoker.WorkflowInvoker#getOutputs()
+     * @see org.apache.airavata.xbaya.invoker.Invoker#getOutputs()
      */
     @Override
     public WSIFMessage getOutputs() {
@@ -69,7 +69,7 @@ public class SystemComponentInvoker impl
     }
 
     /**
-     * @see org.apache.airavata.xbaya.invoker.WorkflowInvoker#invoke()
+     * @see org.apache.airavata.xbaya.invoker.Invoker#invoke()
      */
     @Override
     public boolean invoke() {
@@ -77,21 +77,21 @@ public class SystemComponentInvoker impl
     }
 
     /**
-     * @see org.apache.airavata.xbaya.invoker.WorkflowInvoker#setInput(java.lang.String, java.lang.Object)
+     * @see org.apache.airavata.xbaya.invoker.Invoker#setInput(java.lang.String, java.lang.Object)
      */
     @Override
     public void setInput(String name, Object value) {
     }
 
     /**
-     * @see org.apache.airavata.xbaya.wXPath Operatorsorkflow.WorkflowInvoker#setOperation(java.lang.String)
+     * @see org.apache.airavata.xbaya.wXPath Operatorsorkflow.Invoker#setOperation(java.lang.String)
      */
     @Override
     public void setOperation(String operationName) {
     }
 
     /**
-     * @see org.apache.airavata.xbaya.invoker.WorkflowInvoker#setup()
+     * @see org.apache.airavata.xbaya.invoker.Invoker#setup()
      */
     @Override
     public void setup() {



Mime
View raw message