You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sa...@apache.org on 2012/05/17 19:12:21 UTC

svn commit: r1339718 [4/10] - in /incubator/airavata/trunk: ./ modules/airavata-client/ modules/distribution/ modules/distribution/src/main/assembly/ modules/workflow-model/ modules/workflow-model/src/ modules/workflow-model/src/main/ modules/workflow-...

Added: incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/gpel/script/WorkflowWSDL.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/gpel/script/WorkflowWSDL.java?rev=1339718&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/gpel/script/WorkflowWSDL.java (added)
+++ incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/gpel/script/WorkflowWSDL.java Thu May 17 17:12:15 2012
@@ -0,0 +1,735 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.workflow.model.gpel.script;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.common.exception.UtilsException;
+import org.apache.airavata.common.utils.WSConstants;
+import org.apache.airavata.common.utils.WSDLUtil;
+import org.apache.airavata.common.utils.XMLUtil;
+import org.apache.airavata.workflow.model.component.ws.WSComponentPort;
+import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException;
+import org.apache.airavata.workflow.model.graph.DataPort;
+import org.apache.airavata.workflow.model.graph.GraphException;
+import org.apache.airavata.workflow.model.graph.Node;
+import org.apache.airavata.workflow.model.graph.system.InputNode;
+import org.apache.airavata.workflow.model.graph.system.OutputNode;
+import org.apache.airavata.workflow.model.graph.system.ParameterNode;
+import org.apache.airavata.workflow.model.graph.system.ReceiveNode;
+import org.apache.airavata.workflow.model.graph.system.SystemDataPort;
+import org.apache.airavata.workflow.model.graph.util.GraphUtil;
+import org.apache.airavata.workflow.model.graph.ws.WSGraph;
+import org.apache.airavata.workflow.model.utils.WorkflowConstants;
+import org.apache.airavata.workflow.model.utils.ApplicationVersion;
+import org.apache.airavata.workflow.model.wf.Workflow;
+import org.xmlpull.infoset.XmlComment;
+import org.xmlpull.infoset.XmlElement;
+import org.xmlpull.infoset.XmlNamespace;
+
+import xsul5.XmlConstants;
+import xsul5.wsdl.WsdlDefinitions;
+import xsul5.wsdl.WsdlDocumentation;
+import xsul5.wsdl.WsdlMessage;
+import xsul5.wsdl.WsdlPortType;
+import xsul5.wsdl.WsdlPortTypeOperation;
+import xsul5.wsdl.plnk.PartnerLinkRole;
+import xsul5.wsdl.plnk.PartnerLinkType;
+
+public class WorkflowWSDL {
+
+    /**
+     * Run
+     */
+    private String workflowOperationName;
+
+    private static final String INPUT_MESSAGE_ELEMENT_SUFFIX = "";
+
+    private static final String OUTPUT_MESSAGE_ELEMENT_SUFFIX = "Response";
+
+    /**
+     * Run
+     */
+    private String workflowInputMessageElelmentName;
+
+    /**
+     * RunOutput
+     */
+    private String workflowOutputMessageElementName;
+
+    private static final String INPUT_MESSAGE_SUFFIX = "InputMessage";
+
+    private static final String OUTPUT_MESSAGE_SUFFIX = "OutputMessage";
+
+    /**
+     * RunInputMessage
+     */
+    private String workflowInputMessageName;
+
+    /**
+     * RunOutputMessage
+     */
+    private String workflowOutputMessageName;
+
+    /**
+     * input
+     */
+    public static final String INPUT_PART_NAME = "input";
+
+    /**
+     * output
+     */
+    public static final String OUTPUT_PART_NAME = "output";
+
+    private static final String TARGET_NS_NAME_PREFIX = WorkflowConstants.NS_URI_XBAYA;
+
+    private static final String TYPE_SUFFIX = "Type";
+
+    private Workflow workflow;
+
+    private WSGraph graph;
+
+    private WsdlDefinitions definitions;
+
+    private XmlNamespace targetNamespace;
+
+    private XmlNamespace typesNamespace;
+
+    private QName portTypeQName;
+
+    private Map<QName, PartnerLinkRole> partnerLinkRoleMap;
+
+    /**
+     * Constructs a WorkflowWsdl.
+     * 
+     * @param workflow
+     * @param operationName
+     */
+    public WorkflowWSDL(Workflow workflow, String operationName) {
+        this.workflow = workflow;
+        this.graph = workflow.getGraph();
+        this.partnerLinkRoleMap = new HashMap<QName, PartnerLinkRole>();
+        workflowOperationName = operationName;
+
+        workflowInputMessageElelmentName = workflowOperationName + INPUT_MESSAGE_ELEMENT_SUFFIX;
+
+        workflowOutputMessageElementName = workflowOperationName + OUTPUT_MESSAGE_ELEMENT_SUFFIX;
+
+        workflowInputMessageName = workflowOperationName + INPUT_MESSAGE_SUFFIX;
+
+        workflowOutputMessageName = workflowOperationName + OUTPUT_MESSAGE_SUFFIX;
+    }
+
+    /**
+     * @return the WSLD definitions
+     */
+    public WsdlDefinitions getWsdlDefinitions() {
+        return this.definitions;
+    }
+
+    /**
+     * @return The target namespace.
+     */
+    public XmlNamespace getTargetNamespace() {
+        return this.targetNamespace;
+    }
+
+    /**
+     * @return The types namespace. typens:"http://..../xsd/"
+     */
+    public XmlNamespace getTypesNamespace() {
+        return this.typesNamespace;
+    }
+
+    /**
+     * @return The portType QName.
+     */
+    public QName getPortTypeQName() {
+        return this.portTypeQName;
+    }
+
+    /**
+     * Creates WSDL.
+     * 
+     * @throws GraphException
+     */
+    public void create() throws GraphException {
+
+        try {
+            String targetNSName = TARGET_NS_NAME_PREFIX + this.graph.getID() + "/";
+            this.targetNamespace = XmlConstants.BUILDER.newNamespace(WSConstants.TARGET_NS_PREFIX, targetNSName);
+            String typesNSName = targetNSName + "xsd/";
+            this.typesNamespace = XmlConstants.BUILDER.newNamespace(WSConstants.TYPE_NS_PREFIX, typesNSName);
+
+            this.definitions = new WsdlDefinitions(targetNSName);
+            this.definitions.xml().setAttributeValue(WSConstants.NAME_ATTRIBUTE, this.graph.getID());
+
+            this.definitions.xml().declareNamespace(this.targetNamespace);
+            this.definitions.xml().declareNamespace(this.typesNamespace);
+            this.definitions.xml().declareNamespace(WSConstants.XSD_NS);
+            this.definitions.xml().declareNamespace(PartnerLinkType.NS);
+            addDocumentation();
+            addTypes();
+            WsdlMessage inputMessage = createInputMessage();
+            WsdlMessage outputMessage = createOutputMessage();
+            createPortType(inputMessage, outputMessage);
+            addComment();
+        } catch (RuntimeException e) {
+            throw new GraphException(e);
+        }
+    }
+
+    /**
+     * @param servicePortTypeQName
+     * @return PartnerLinkRole
+     */
+    public PartnerLinkRole getPartnerRoll(QName servicePortTypeQName) {
+        return this.partnerLinkRoleMap.get(servicePortTypeQName);
+    }
+
+    /**
+     * Adds a partnerLinkType.
+     * 
+     * This method is called by BPELScript.
+     * 
+     * @param partnerLinkTypeName
+     * @param partnerRollName
+     * @param servicePortTypeQName
+     * @return PartnerLinkRole
+     */
+    public PartnerLinkRole addPartnerLinkTypeAndRoll(String partnerLinkTypeName, String partnerRollName,
+            QName servicePortTypeQName) {
+        PartnerLinkType partnerLinkType = new PartnerLinkType(partnerLinkTypeName);
+        PartnerLinkRole partnerRoll = new PartnerLinkRole(partnerRollName, servicePortTypeQName);
+        partnerLinkType.addRole(partnerRoll);
+
+        declareNamespaceIfNecessary("p", servicePortTypeQName.getNamespaceURI(), true);
+        this.definitions.xml().addElement(partnerLinkType.xml());
+
+        this.partnerLinkRoleMap.put(servicePortTypeQName, partnerRoll);
+        return partnerRoll;
+    }
+
+    /**
+     * @param operationName
+     * @param receiveNode
+     * @return The portType added.
+     */
+    public WsdlPortType addReceivePortType(String operationName, ReceiveNode receiveNode) {
+        //
+        // <types>
+        //
+
+        // <types> and <schema> have been defined.
+        XmlElement types = this.definitions.getTypes();
+        XmlElement schema = types.element(WSConstants.SCHEMA_TAG);
+
+        XmlElement sequence = setupParameterType(operationName, null, schema);
+        for (DataPort outputPort : receiveNode.getOutputPorts()) {
+            addParameter(receiveNode, (SystemDataPort) outputPort, sequence, schema);
+        }
+
+        //
+        // <message>
+        //
+        String messageName = operationName + INPUT_MESSAGE_SUFFIX;
+        String partName = INPUT_PART_NAME;
+        String messageElementName = operationName + INPUT_MESSAGE_ELEMENT_SUFFIX;
+        WsdlMessage inputMessage = createMessage(messageName, partName, messageElementName);
+
+        String portTypeName = operationName;
+        WsdlPortType portType = createPortType(portTypeName, operationName, inputMessage, null);
+        return portType;
+    }
+
+    private void addComment() {
+        XmlComment comment = this.definitions.xml().newComment(
+                "\nThis document is automatically generated by " + WorkflowConstants.APPLICATION_NAME + " "
+                        + ApplicationVersion.VERSION + ".\n");
+        this.definitions.xml().insertChild(0, "\n");
+        this.definitions.xml().insertChild(0, comment);
+        this.definitions.xml().insertChild(0, "\n");
+    }
+
+    /**
+     * Sets the documentation element.
+     */
+    private void addDocumentation() {
+        String description = this.workflow.getDescription();
+        if (description != null) {
+            WsdlDocumentation documentation = new WsdlDocumentation(description);
+            this.definitions.setDocumentation(documentation);
+        }
+    }
+
+    /**
+     * Adds the types element.
+     * 
+     * @return The types element
+     */
+    private XmlElement addTypes() {
+        XmlElement types = this.definitions.getOrCreateTypes();
+
+        XmlElement schema = types.addElement(WSConstants.SCHEMA_TAG);
+        schema.setAttributeValue(WSConstants.TARGET_NAMESPACE_ATTRIBUTE, this.typesNamespace.getName());
+        schema.setAttributeValue(WSConstants.XMLNS, WSConstants.XSD_NS_URI);
+        schema.setAttributeValue(WSConstants.ELEMENT_FORM_DEFAULT_ATTRIBUTE, WSConstants.UNQUALIFIED_VALUE);
+        List<InputNode> inputNodes = GraphUtil.getInputNodes(this.graph);
+        XmlElement inputMetadata = this.graph.getInputMetadata();
+        addParameters(workflowInputMessageElelmentName, inputMetadata, inputNodes, schema);
+
+        List<OutputNode> outputNodes = GraphUtil.getOutputNodes(this.graph);
+        XmlElement outputMetadata = this.graph.getOutputMetadata();
+        addParameters(workflowOutputMessageElementName, outputMetadata, outputNodes, schema);
+
+        return types;
+    }
+
+    private void addParameters(String name, XmlElement appinfo, List<? extends ParameterNode> nodes, XmlElement schema) {
+        XmlElement sequence = setupParameterType(name, appinfo, schema);
+        for (ParameterNode node : nodes) {
+            addParameter(node, sequence, schema);
+        }
+    }
+
+    /**
+     * @param name
+     * @param appinfo
+     * @param schema
+     * @return The sequence element.
+     */
+    private XmlElement setupParameterType(String name, XmlElement appinfo, XmlElement schema) {
+        XmlElement element = schema.addElement(WSConstants.ELEMENT_TAG);
+        element.setAttributeValue(WSConstants.NAME_ATTRIBUTE, name);
+        String type = name + TYPE_SUFFIX;
+        element.setAttributeValue(WSConstants.TYPE_ATTRIBUTE, WSConstants.TYPE_NS_PREFIX + ":" + type);
+
+        // add metadata
+        if (appinfo != null) {
+            XmlElement annotation = element.addElement(WSConstants.ANNOTATION_TAG);
+            try {
+                annotation.addElement(XMLUtil.deepClone(appinfo));
+            } catch (UtilsException e) {
+                e.printStackTrace();
+            }
+        }
+
+        XmlElement complex = schema.addElement(WSConstants.COMPLEX_TYPE_TAG);
+        complex.setAttributeValue(WSConstants.NAME_ATTRIBUTE, type);
+
+        XmlElement sequence = complex.addElement(WSConstants.SEQUENCE_TAG);
+        return sequence;
+    }
+
+    /**
+     * Adds the parameter element.
+     * 
+     * @param node
+     * @param sequence
+     * @param schema
+     * @return The parameter element
+     */
+    private XmlElement addParameter(ParameterNode node, XmlElement sequence, XmlElement schema) {
+        XmlElement element;
+        SystemDataPort port = node.getPort();
+        element = addParameter(node, port, sequence, schema);
+
+        //
+        // Annotation
+        //
+        String description = node.getDescription();
+        XmlElement appinfo = node.getMetadata();
+
+        // description
+        if (description != null && description.trim().length() != 0) {
+            XmlElement annotation = element.element(null, WSConstants.ANNOTATION_TAG, true);
+            XmlElement documentation = annotation.addElement(WSConstants.DOCUMENTATION_TAG);
+            documentation.setText(node.getDescription());
+        }
+
+        // appinfo
+        if (appinfo != null) {
+            XmlElement annotation = element.element(null, WSConstants.ANNOTATION_TAG, true);
+            try {
+                annotation.addElement(XMLUtil.deepClone(appinfo));
+            } catch (UtilsException e) {
+                e.printStackTrace();
+            }
+        }
+
+        //
+        // Add default value if it's input.
+        //
+        if (node instanceof InputNode) {
+            InputNode inputNode = (InputNode) node;
+            Object value = inputNode.getDefaultValue();
+            if (value instanceof String) {
+                element.setAttributeValue(WSConstants.DEFAULT_ATTRIBUTE, (String) value);
+            } else if (value instanceof XmlElement) {
+                // Add the default value in <annotation><default> because there
+                // is no standard way.
+                XmlElement valueElement = null;
+                try {
+                    valueElement = XMLUtil.deepClone((XmlElement) value);
+                } catch (UtilsException e) {
+                    e.printStackTrace();
+                }
+                XmlElement annotation = element.element(null, WSConstants.ANNOTATION_TAG, true);
+                XmlElement defaultElement = annotation.addElement(WSComponentPort.DEFAULT);
+                defaultElement.addElement(valueElement);
+            }
+        }
+
+        return element;
+    }
+
+    private XmlElement addParameter(Node node, SystemDataPort port, XmlElement sequence, XmlElement schema) {
+        XmlElement element = sequence.addElement(WSConstants.ELEMENT_TAG);
+        element.setAttributeValue(WSConstants.NAME_ATTRIBUTE, node.getID());
+
+        //
+        // type
+        //
+        QName type = port.getType();
+        WSComponentPort componentPort = port.getWSComponentPort();
+        WsdlDefinitions wsdl = null;
+        if (componentPort != null) {
+            wsdl = componentPort.getComponent().getWSDL();
+            type = declareTypeIfNecessary(wsdl, type);
+        }
+        int arrayDimension = port.getArrayDimension();
+        if (arrayDimension == 1) {
+            String typeName = declareArrayType(schema, type, wsdl);
+            type = new QName(this.typesNamespace.getName(), typeName);
+        } else if (arrayDimension > 1) {
+            // TODO
+            throw new WorkflowRuntimeException("multi-dimentional arrays are not supported yet.");
+        }
+
+        if (WSConstants.XSD_ANY_TYPE.equals(type) && componentPort != null) {
+            XmlElement elementElement = componentPort.getElement();
+            if (elementElement == null) {
+                // Types are not defined anywhare. Leave it as xsd:any.
+                setTypeAttribute(element, type);
+            } else {
+                // Copy the embedded type defition.
+                XmlElement clonedElementElement = null;
+                try {
+                    clonedElementElement = XMLUtil.deepClone(elementElement);
+                } catch (UtilsException e) {
+                    e.printStackTrace();
+                }
+                String typeString = clonedElementElement.attributeValue(WSConstants.TYPE_ATTRIBUTE);
+                if (typeString == null) {
+                    for (Object child : clonedElementElement.children()) {
+                        if (child instanceof XmlElement) {
+                            ((XmlElement) child).setParent(null);
+                        }
+                        element.addChild(child);
+                    }
+                } else {
+                    // The case when type is really xsd:any
+                    setTypeAttribute(element, type);
+                }
+            }
+        } else {
+            // The normal case.
+            setTypeAttribute(element, type);
+        }
+        return element;
+    }
+
+    private void setTypeAttribute(XmlElement element, QName type) {
+        String namespaceURI = type.getNamespaceURI();
+        XmlNamespace namespace = element.lookupNamespaceByName(namespaceURI);
+        element.setAttributeValue(WSConstants.TYPE_ATTRIBUTE, namespace.getPrefix() + ":" + type.getLocalPart());
+
+    }
+
+    /**
+     * @param serviceWSDL
+     * @param paramType
+     * @return The QName of the type. This QName always has prefix.
+     */
+    private QName declareTypeIfNecessary(WsdlDefinitions serviceWSDL, QName paramType) {
+        if (WSConstants.XSD_NS_URI.equals(paramType.getNamespaceURI())) {
+            // No need to define
+            return new QName(WSConstants.XSD_NS_URI, paramType.getLocalPart(), WSConstants.XSD_NS_PREFIX);
+        }
+
+        // check if this type already exists in the workflow WSDL.
+        XmlElement typeDefinition = null;
+        try {
+            typeDefinition = WSDLUtil.getTypeDefinition(this.definitions, paramType);
+
+            if (typeDefinition == null) {
+
+                // now lets check whether there is an import in the service wsdl schema
+                // that would import this type,
+                // if so we would be done by just importing that schema
+
+                typeDefinition = WSDLUtil.findTypeDefinitionInImports(serviceWSDL, paramType);
+                if (typeDefinition != null) {
+                    XmlElement importEle = WSDLUtil.getImportContainingTypeDefinition(serviceWSDL, paramType);
+                    addImportIfNecessary(importEle);
+                    String prefix = declareNamespaceIfNecessary(paramType.getPrefix(), paramType.getNamespaceURI(),
+                            false);
+                    return new QName(paramType.getNamespaceURI(), paramType.getLocalPart(), prefix);
+                }
+
+                // copy the type defition and use it.
+
+                // Need to copy the whole schema because it might have different
+                // targetNamespace.
+                XmlElement newSchema = WSDLUtil.getSchema(serviceWSDL, paramType);
+                if (newSchema == null) {
+                    // This should have been caught in WSComponent
+                    throw new WorkflowRuntimeException("could not find definition for type " + paramType + " in "
+                            + WSDLUtil.getWSDLQName(serviceWSDL));
+                }
+                this.definitions.getTypes().addChild(XMLUtil.deepClone(newSchema));
+
+                String prefix = declareNamespaceIfNecessary(paramType.getPrefix(), paramType.getNamespaceURI(), false);
+                return new QName(paramType.getNamespaceURI(), paramType.getLocalPart(), prefix);
+            } else {
+                XmlNamespace namespace = this.definitions.xml().lookupNamespaceByName(paramType.getNamespaceURI());
+                return new QName(paramType.getNamespaceURI(), paramType.getLocalPart(), namespace.getPrefix());
+            }
+        } catch (UtilsException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    private void addImportIfNecessary(XmlElement importEle) {
+        XmlElement schema = this.definitions.getTypes().element(WSConstants.SCHEMA_TAG);
+        Iterable<XmlElement> imports = schema.elements(null, WSConstants.IMPORT_TAG);
+        for (XmlElement importElement : imports) {
+            if (importElement.attributeValue("namespace").equals(importEle.attributeValue("namespace"))
+                    && importElement.attributeValue("schemaLocation")
+                            .equals(importEle.attributeValue("schemaLocation"))) {
+                return;
+            }
+        }
+        schema.addChild(0, importEle);
+    }
+
+    private String declareArrayType(XmlElement schema, QName valueType, WsdlDefinitions serviceWSDL) {
+        XmlElement complexType = schema.addElement(WSConstants.COMPLEX_TYPE_TAG);
+        String typeName = valueType.getLocalPart() + "ArrayType";
+        // TODO check if this typeName is already used.
+        complexType.setAttributeValue(WSConstants.NAME_ATTRIBUTE, typeName);
+        XmlElement sequence = complexType.addElement(WSConstants.SEQUENCE_TAG);
+        XmlElement element = sequence.addElement(WSConstants.ELEMENT_TAG);
+        element.setAttributeValue(WSConstants.MIN_OCCURS_ATTRIBUTE, "0");
+        element.setAttributeValue(WSConstants.MAX_OCCURS_ATTRIBUTE, WSConstants.UNBOUNDED_VALUE);
+        element.setAttributeValue(WSConstants.NAME_ATTRIBUTE, "value");
+        valueType = declareTypeIfNecessary(serviceWSDL, valueType);
+        element.setAttributeValue(WSConstants.TYPE_ATTRIBUTE, valueType.getPrefix() + ":" + valueType.getLocalPart());
+        return typeName;
+    }
+
+    /**
+     * Creates the input message.
+     * 
+     * @return The input message
+     */
+    private WsdlMessage createInputMessage() {
+        return createMessage(workflowInputMessageName, INPUT_PART_NAME, workflowInputMessageElelmentName);
+    }
+
+    /**
+     * Creates the output message.
+     * 
+     * @return The output message
+     */
+    private WsdlMessage createOutputMessage() {
+        return createMessage(workflowOutputMessageName, OUTPUT_PART_NAME, workflowOutputMessageElementName);
+    }
+
+    private WsdlMessage createMessage(String messageName, String partName, String messageElementName) {
+        WsdlMessage outMessage = this.definitions.addMessage(messageName);
+        outMessage.addPartWithElement(partName, new QName(this.typesNamespace.getName(), messageElementName,
+                this.typesNamespace.getPrefix()));
+        return outMessage;
+    }
+
+    /**
+     * Creates the portType.
+     * 
+     * @param inputMessage
+     * @param outputMessage
+     * @return The portType
+     */
+    private WsdlPortType createPortType(WsdlMessage inputMessage, WsdlMessage outputMessage) {
+        String portTypeName = this.graph.getID();
+        this.portTypeQName = new QName(this.targetNamespace.getName(), portTypeName);
+        return createPortType(this.graph.getID(), workflowOperationName, inputMessage, outputMessage);
+    }
+
+    private WsdlPortType createPortType(String portTypeName, String operationName, WsdlMessage inputMessage,
+            WsdlMessage outputMessage) {
+        WsdlPortType portType = this.definitions.addPortType(portTypeName);
+        WsdlPortTypeOperation operation = portType.addOperation(operationName);
+        if (inputMessage != null) {
+            operation.setInput(inputMessage);
+        }
+        if (outputMessage != null) {
+            operation.setOutput(outputMessage);
+        }
+        return portType;
+    }
+
+    private String declareNamespaceIfNecessary(String prefixCandidate, String uri, boolean alwaysUseSuffix) {
+        XmlNamespace namespace = this.definitions.xml().lookupNamespaceByName(uri);
+        if (namespace == null) {
+            return declareNamespace(prefixCandidate, uri, alwaysUseSuffix);
+        } else {
+            return namespace.getPrefix();
+        }
+    }
+
+    /**
+     * @param prefixCandidate
+     * @param uri
+     * @param alwaysUseSuffix
+     * @return The prefix actually used.
+     */
+    private String declareNamespace(String prefixCandidate, String uri, boolean alwaysUseSuffix) {
+        if (prefixCandidate == null || prefixCandidate.length() == 0) {
+            prefixCandidate = "a";
+        }
+        String prefix = prefixCandidate;
+        if (alwaysUseSuffix) {
+            prefix += "0";
+        }
+        if (this.definitions.xml().lookupNamespaceByPrefix(prefix) != null) {
+            int i = 1;
+            prefix = prefixCandidate + i;
+            while (this.definitions.xml().lookupNamespaceByPrefix(prefix) != null) {
+                i++;
+            }
+        }
+        this.definitions.xml().declareNamespace(prefix, uri);
+        return prefix;
+    }
+
+    /**
+     * Returns the workflowOperationName.
+     * 
+     * @return The workflowOperationName
+     */
+    public String getWorkflowOperationName() {
+        return this.workflowOperationName;
+    }
+
+    /**
+     * Sets workflowOperationName.
+     * 
+     * @param workflowOperationName
+     *            The workflowOperationName to set.
+     */
+    public void setWorkflowOperationName(String workflowOperationName) {
+        this.workflowOperationName = workflowOperationName;
+    }
+
+    /**
+     * Returns the workflowInputMessageName.
+     * 
+     * @return The workflowInputMessageName
+     */
+    public String getWorkflowInputMessageName() {
+        return this.workflowInputMessageName;
+    }
+
+    /**
+     * Sets workflowInputMessageName.
+     * 
+     * @param workflowInputMessageName
+     *            The workflowInputMessageName to set.
+     */
+    public void setWorkflowInputMessageName(String workflowInputMessageName) {
+        this.workflowInputMessageName = workflowInputMessageName;
+    }
+
+    /**
+     * Returns the workflowOutputMessageName.
+     * 
+     * @return The workflowOutputMessageName
+     */
+    public String getWorkflowOutputMessageName() {
+        return this.workflowOutputMessageName;
+    }
+
+    /**
+     * Sets workflowOutputMessageName.
+     * 
+     * @param workflowOutputMessageName
+     *            The workflowOutputMessageName to set.
+     */
+    public void setWorkflowOutputMessageName(String workflowOutputMessageName) {
+        this.workflowOutputMessageName = workflowOutputMessageName;
+    }
+
+    /**
+     * Returns the workflowInputMessageElelmentName.
+     * 
+     * @return The workflowInputMessageElelmentName
+     */
+    public String getWorkflowInputMessageElelmentName() {
+        return this.workflowInputMessageElelmentName;
+    }
+
+    /**
+     * Sets workflowInputMessageElelmentName.
+     * 
+     * @param workflowInputMessageElelmentName
+     *            The workflowInputMessageElelmentName to set.
+     */
+    public void setWorkflowInputMessageElelmentName(String workflowInputMessageElelmentName) {
+        this.workflowInputMessageElelmentName = workflowInputMessageElelmentName;
+    }
+
+    /**
+     * Returns the workflowOutputMessageElementName.
+     * 
+     * @return The workflowOutputMessageElementName
+     */
+    public String getWorkflowOutputMessageElementName() {
+        return this.workflowOutputMessageElementName;
+    }
+
+    /**
+     * Sets workflowOutputMessageElementName.
+     * 
+     * @param workflowOutputMessageElementName
+     *            The workflowOutputMessageElementName to set.
+     */
+    public void setWorkflowOutputMessageElementName(String workflowOutputMessageElementName) {
+        this.workflowOutputMessageElementName = workflowOutputMessageElementName;
+    }
+
+}
\ No newline at end of file

Added: incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/ControlEdge.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/ControlEdge.java?rev=1339718&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/ControlEdge.java (added)
+++ incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/ControlEdge.java Thu May 17 17:12:15 2012
@@ -0,0 +1,55 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.workflow.model.graph;
+
+import org.apache.airavata.workflow.model.graph.impl.EdgeImpl;
+import org.xmlpull.infoset.XmlElement;
+
+public class ControlEdge extends EdgeImpl {
+
+    /**
+     * Constructs a ControlEdge.
+     * 
+     */
+    public ControlEdge() {
+        super();
+    }
+
+    /**
+     * Constructs a ControlEdge.
+     * 
+     * @param edgeXml
+     */
+    public ControlEdge(XmlElement edgeXml) {
+        super(edgeXml);
+    }
+
+    /**
+     * @see org.apache.airavata.workflow.model.graph.impl.EdgeImpl#toXML()
+     */
+    @Override
+    protected XmlElement toXML() {
+        XmlElement edgeElement = super.toXML();
+        edgeElement.setAttributeValue(GraphSchema.NS, GraphSchema.EDGE_TYPE_ATTRIBUTE, GraphSchema.EDGE_TYPE_CONTROL);
+        return edgeElement;
+    }
+}
\ No newline at end of file

Added: incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/ControlPort.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/ControlPort.java?rev=1339718&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/ControlPort.java (added)
+++ incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/ControlPort.java Thu May 17 17:12:15 2012
@@ -0,0 +1,74 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.workflow.model.graph;
+
+import org.apache.airavata.workflow.model.graph.impl.PortImpl;
+import org.xmlpull.infoset.XmlElement;
+
+public class ControlPort extends PortImpl {
+
+    private boolean allow;
+
+    /**
+     * Constructs a ControlPort.
+     * 
+     */
+    public ControlPort() {
+        super();
+    }
+
+    /**
+     * Constructs a ControlPort.
+     * 
+     * @param portElement
+     */
+    public ControlPort(XmlElement portElement) {
+        super(portElement);
+    }
+
+    /**
+     * @see org.apache.airavata.workflow.model.graph.impl.PortImpl#toXML()
+     */
+    @Override
+    protected XmlElement toXML() {
+        XmlElement portElement = super.toXML();
+        portElement.setAttributeValue(GraphSchema.NS, GraphSchema.PORT_TYPE_ATTRIBUTE, GraphSchema.PORT_TYPE_CONTROL);
+        return portElement;
+    }
+
+    /**
+     * Set if this port condition is met, flow will execute throw this port
+     * 
+     * @param condition
+     */
+    public void setConditionMet(boolean condition) {
+        this.allow = condition;
+    }
+
+    /**
+     * 
+     * @return true if execution flow can be run on this port
+     */
+    public boolean isConditionMet() {
+        return this.allow;
+    }
+}
\ No newline at end of file

Added: incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/DataEdge.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/DataEdge.java?rev=1339718&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/DataEdge.java (added)
+++ incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/DataEdge.java Thu May 17 17:12:15 2012
@@ -0,0 +1,71 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.workflow.model.graph;
+
+import org.apache.airavata.workflow.model.graph.impl.EdgeImpl;
+import org.xmlpull.infoset.XmlElement;
+
+public class DataEdge extends EdgeImpl {
+
+    /**
+     * Constructs a WSEdge.
+     * 
+     */
+    public DataEdge() {
+        super();
+    }
+
+    /**
+     * Constructs a WSEdge.
+     * 
+     * @param edgeElement
+     */
+    public DataEdge(XmlElement edgeElement) {
+        super(edgeElement);
+    }
+
+    /**
+     * @see org.apache.airavata.workflow.model.graph.impl.EdgeImpl#getFromPort()
+     */
+    @Override
+    public DataPort getFromPort() {
+        return (DataPort) super.getFromPort();
+    }
+
+    /**
+     * @see org.apache.airavata.workflow.model.graph.impl.EdgeImpl#getToPort()
+     */
+    @Override
+    public DataPort getToPort() {
+        return (DataPort) super.getToPort();
+    }
+
+    /**
+     * @see org.apache.airavata.workflow.model.graph.impl.EdgeImpl#toXML()
+     */
+    @Override
+    protected XmlElement toXML() {
+        XmlElement edgeElement = super.toXML();
+        edgeElement.setAttributeValue(GraphSchema.NS, GraphSchema.EDGE_TYPE_ATTRIBUTE, GraphSchema.EDGE_TYPE_DATA);
+        return edgeElement;
+    }
+}
\ No newline at end of file

Added: incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/DataPort.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/DataPort.java?rev=1339718&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/DataPort.java (added)
+++ incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/DataPort.java Thu May 17 17:12:15 2012
@@ -0,0 +1,69 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.workflow.model.graph;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.workflow.model.graph.impl.PortImpl;
+import org.xmlpull.infoset.XmlElement;
+
+public abstract class DataPort extends PortImpl {
+
+    /**
+     * Constructs a DataPort.
+     * 
+     */
+    public DataPort() {
+        super();
+    }
+
+    /**
+     * Constructs a DataPort.
+     * 
+     * @param portElement
+     */
+    public DataPort(XmlElement portElement) {
+        super(portElement);
+    }
+
+    /**
+     * @see org.apache.airavata.workflow.model.graph.impl.PortImpl#getEdges()
+     */
+    @SuppressWarnings("unchecked")
+    @Override
+    public List<DataEdge> getEdges() {
+        return (List<DataEdge>) super.getEdges();
+    }
+
+    /**
+     * @return The type QName.
+     */
+    public abstract QName getType();
+
+    /**
+     * @param port
+     * @throws GraphException
+     */
+    public abstract void copyType(DataPort port) throws GraphException;
+}
\ No newline at end of file

Added: incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/EPRPort.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/EPRPort.java?rev=1339718&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/EPRPort.java (added)
+++ incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/EPRPort.java Thu May 17 17:12:15 2012
@@ -0,0 +1,73 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.workflow.model.graph;
+
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.common.utils.WSConstants;
+import org.xmlpull.infoset.XmlElement;
+
+public class EPRPort extends DataPort {
+
+    /**
+     * Constructs a ControlPort.
+     * 
+     */
+    public EPRPort() {
+        super();
+    }
+
+    /**
+     * Constructs a ControlPort.
+     * 
+     * @param portElement
+     */
+    public EPRPort(XmlElement portElement) {
+        super(portElement);
+    }
+
+    /**
+     * @see org.apache.airavata.workflow.model.graph.impl.PortImpl#toXML()
+     */
+    @Override
+    protected XmlElement toXML() {
+        XmlElement portElement = super.toXML();
+        portElement.setAttributeValue(GraphSchema.NS, GraphSchema.PORT_TYPE_ATTRIBUTE, GraphSchema.PORT_TYPE_EPR);
+        return portElement;
+    }
+
+    /**
+     * @see org.apache.airavata.workflow.model.graph.DataPort#getType()
+     */
+    @Override
+    public QName getType() {
+        return WSConstants.XSD_ANY_TYPE;
+    }
+
+    /**
+     * @see org.apache.airavata.workflow.model.graph.DataPort#copyType(org.apache.airavata.workflow.model.graph.DataPort)
+     */
+    @Override
+    public void copyType(DataPort port) {
+        // TODO Auto-generated method stub
+    }
+}
\ No newline at end of file

Added: incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/Edge.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/Edge.java?rev=1339718&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/Edge.java (added)
+++ incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/Edge.java Thu May 17 17:12:15 2012
@@ -0,0 +1,52 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.workflow.model.graph;
+
+
+public interface Edge extends GraphPiece {
+
+    /**
+     * @return the port that the edget connected from
+     */
+    public Port getFromPort();
+
+    /**
+     * @return the port that the edget connected to
+     */
+    public Port getToPort();
+
+    /**
+     * Label for Stream edge
+     * 
+     * @return
+     */
+    public String getLabel();
+
+    /**
+     * Sets label.
+     * 
+     * @param label
+     *            The label to set.
+     */
+    public void setLabel(String label);
+
+}
\ No newline at end of file

Added: incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/ForEachExecutableNode.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/ForEachExecutableNode.java?rev=1339718&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/ForEachExecutableNode.java (added)
+++ incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/ForEachExecutableNode.java Thu May 17 17:12:15 2012
@@ -0,0 +1,24 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.workflow.model.graph;
+
+public interface ForEachExecutableNode extends Node {
+}

Added: incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/Graph.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/Graph.java?rev=1339718&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/Graph.java (added)
+++ incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/Graph.java Thu May 17 17:12:15 2012
@@ -0,0 +1,189 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.workflow.model.graph;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.xmlpull.infoset.XmlElement;
+
+public interface Graph extends GraphPiece {
+    
+    /**
+     * Returns if the graph should be editable
+     * @return
+     */
+    public boolean isEditable();
+
+    /**
+     * set if graph can be edited
+     * @param editable
+     */
+    public void setEditable(boolean editable);
+    
+    /**
+     * Returns the ID of this graph.
+     * 
+     * @return The ID of this graph
+     */
+    public String getID();
+
+    /**
+     * Sets the name of this graph.
+     * 
+     * @param name
+     *            The name to set
+     */
+    public void setName(String name);
+
+    /**
+     * Returns the name of this graph.
+     * 
+     * @return The name
+     */
+    public String getName();
+
+    /**
+     * Returns the description of this graph.
+     * 
+     * @return The description.
+     */
+    public String getDescription();
+
+    /**
+     * Sets the description of this graph.
+     * 
+     * @param description
+     *            The description to set.
+     */
+    public void setDescription(String description);
+
+    /**
+     * Returns the list of the nodes of this graph.
+     * 
+     * It's a list because the order of input nodes matters.
+     * 
+     * @return the list of the nodes
+     */
+    public List<? extends Node> getNodes();
+
+    /**
+     * Returns the list of the ports of this graph.
+     * 
+     * @return the list of the ports
+     */
+    public Collection<? extends Port> getPorts();
+
+    /**
+     * Returns the list of edges of this graph.
+     * 
+     * @return the list of edges
+     */
+    public Collection<? extends Edge> getEdges();
+
+    /**
+     * Removes a specified node from this graph.
+     * 
+     * @param node
+     *            the node to delete
+     * @throws GraphException
+     *             If the specified node does not exist in the graph
+     */
+    public void removeNode(Node node) throws GraphException;
+
+    /**
+     * Returns a node with a specified ID.
+     * 
+     * @param nodeID
+     *            The specified ID.
+     * @return The node with the specified ID if exists; null otherwise
+     */
+    public Node getNode(String nodeID);
+
+    /**
+     * Returns a port with a specified ID.
+     * 
+     * @param portID
+     *            The specified ID.
+     * @return The port with the specified ID if exists; null otherwise
+     */
+    public Port getPort(String portID);
+
+    /**
+     * Adds an edge between two ports specified. If the edge already exists between two ports, it returns null without
+     * creating a new one.
+     * 
+     * @param fromPort
+     *            The port the edge is connected from
+     * @param toPort
+     *            The port the edge is connected to
+     * @return The edge added
+     * @throws GraphException
+     */
+    public Edge addEdge(Port fromPort, Port toPort) throws GraphException;
+
+    /**
+     * Removes a specified edge.
+     * 
+     * @param edge
+     *            The edge to remove.
+     * @throws GraphException
+     */
+    public void removeEdge(Edge edge) throws GraphException;
+
+    /**
+     * Removes an Edge between two specified ports.
+     * 
+     * @param fromPort
+     * @param toPort
+     * @throws GraphException
+     */
+    public void removeEdge(Port fromPort, Port toPort) throws GraphException;
+
+    /**
+     * Checks if an Edge exist between two specified ports.
+     * 
+     * @param fromPort
+     * @param toPort
+     * @return true if an Edge exists; false otherwise;
+     */
+    public boolean containsEdge(Port fromPort, Port toPort);
+
+    /**
+     * Imports a Graph to this Graph.
+     * 
+     * @param graph
+     *            the Graph to import
+     * @throws GraphException
+     */
+    public void importGraph(Graph graph) throws GraphException;
+
+    /**
+     * @return The graph XML
+     */
+    public XmlElement toXML();
+
+    /**
+     * @param multipleSelectedNodes
+     * @throws GraphException
+     */
+}
\ No newline at end of file

Added: incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/GraphException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/GraphException.java?rev=1339718&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/GraphException.java (added)
+++ incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/GraphException.java Thu May 17 17:12:15 2012
@@ -0,0 +1,63 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.workflow.model.graph;
+
+import org.apache.airavata.workflow.model.exceptions.WorkflowException;
+
+/**
+ * The GraphException class represents an Exception related to a Graph. Mostly, it is thrown when parsing a graph XML.
+ * 
+ */
+public class GraphException extends WorkflowException {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     *  
+     */
+    public GraphException() {
+        super();
+    }
+
+    /**
+     * @param message
+     */
+    public GraphException(String message) {
+        super(message);
+    }
+
+    /**
+     * @param cause
+     */
+    public GraphException(Throwable cause) {
+        super(cause);
+    }
+
+    /**
+     * @param message
+     * @param cause
+     */
+    public GraphException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+}
\ No newline at end of file

Added: incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/GraphFactory.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/GraphFactory.java?rev=1339718&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/GraphFactory.java (added)
+++ incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/GraphFactory.java Thu May 17 17:12:15 2012
@@ -0,0 +1,65 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.workflow.model.graph;
+
+import org.apache.airavata.workflow.model.graph.impl.EdgeImpl;
+import org.apache.airavata.workflow.model.graph.impl.NodeImpl;
+import org.apache.airavata.workflow.model.graph.impl.PortImpl;
+import org.xmlpull.infoset.XmlElement;
+
+public interface GraphFactory {
+
+    /**
+     * Creates a Node.
+     * 
+     * @param nodeElement
+     * @return The node created
+     * @throws GraphException
+     */
+    public NodeImpl createNode(XmlElement nodeElement) throws GraphException;
+
+    /**
+     * Creates a Port.
+     * 
+     * @param portElement
+     * @return the port created
+     */
+    public PortImpl createPort(XmlElement portElement);
+
+    /**
+     * Creates a Edge.
+     * 
+     * @param fromPort
+     * @param toPort
+     * @return The edge created
+     */
+    public EdgeImpl createEdge(Port fromPort, Port toPort);
+
+    /**
+     * Creates an Edge.
+     * 
+     * @param edgeXml
+     * @return the edge created
+     */
+    public EdgeImpl createEdge(XmlElement edgeXml);
+
+}
\ No newline at end of file

Added: incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/GraphPiece.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/GraphPiece.java?rev=1339718&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/GraphPiece.java (added)
+++ incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/GraphPiece.java Thu May 17 17:12:15 2012
@@ -0,0 +1,27 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.workflow.model.graph;
+
+
+public interface GraphPiece {
+
+}
\ No newline at end of file

Added: incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/GraphSchema.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/GraphSchema.java?rev=1339718&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/GraphSchema.java (added)
+++ incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/GraphSchema.java Thu May 17 17:12:15 2012
@@ -0,0 +1,378 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.workflow.model.graph;
+
+import org.apache.airavata.common.utils.XMLUtil;
+import org.apache.airavata.workflow.model.utils.WorkflowConstants;
+import org.xmlpull.infoset.XmlNamespace;
+
+public class GraphSchema {
+
+    /**
+     * Namespace prefix
+     */
+    public static final String NS_PREFIX_XGR = "xgr";
+
+    /**
+     * Namespace URI
+     */
+    public static final String NS_URI_XGR = WorkflowConstants.NS_URI_XBAYA + "graph";
+
+    /**
+     * Namespace
+     */
+    public static final XmlNamespace NS = XMLUtil.BUILDER.newNamespace(GraphSchema.NS_PREFIX_XGR,
+            GraphSchema.NS_URI_XGR);
+
+    /**
+     * The attribute for the version of the XBaya that creates the workflow.
+     */
+    public static final String XBAYA_VERSION_ATTRIBUTE = "version";
+
+    /**
+     * GRAPH_TAG
+     */
+    public static final String GRAPH_TAG = "graph";
+
+    /**
+     * GRAPH_TYPE_ATTRIBUTE
+     */
+    public static final String GRAPH_TYPE_ATTRIBUTE = "type";
+
+    /**
+     * GRAPH_TYPE_WS
+     */
+    public static final String GRAPH_TYPE_WS = "ws";
+
+    /**
+     * The tag for the ID of a graph.
+     */
+    public static final String GRAPH_ID_TAG = "id";
+
+    /**
+     * The tag for the name of a graph.
+     */
+    public static final String GRAPH_NAME_TAG = "name";
+
+    /**
+     * The tag for the description of a graph.
+     */
+    public static final String GRAPH_DESCRIPTION_TAG = "description";
+
+    /**
+     * GRAPH_METADATA_TAG
+     */
+    public static final String GRAPH_METADATA_TAG = "metadata";
+
+    /**
+     * GRAPH_INPUT_METADATA_TAG
+     */
+    public static final String GRAPH_INPUT_METADATA_TAG = "inputMetadata";
+
+    /**
+     * GRAPH_OUTPUT_METADATA_TAG
+     */
+    public static final String GRAPH_OUTPUT_METADATA_TAG = "outputMetadata";
+
+    // Tags for Node
+
+    /**
+     * The tag for a node.
+     */
+    public static final String NODE_TAG = "node";
+
+    /**
+     * type
+     */
+    public static final String NODE_TYPE_ATTRIBUTE = "type";
+
+    /**
+     * ws
+     */
+    public static final String NODE_TYPE_WS = "ws";
+
+    /**
+     * StreamSource
+     */
+    public static final String NODE_TYPE_STREAM_SOURCE = "streamsource";
+
+    /**
+     * CEP
+     */
+    public static final String NODE_TYPE_CEP = "cep";
+
+    /**
+     * workflow
+     */
+    public static final String NODE_TYPE_WORKFLOW = "workflow";
+
+    /**
+     * Input parameter node
+     */
+    public static final String NODE_TYPE_INPUT = "input";
+
+    /**
+     * Output parameter node
+     */
+    public static final String NODE_TYPE_OUTPUT = "output";
+
+    /**
+     * constant
+     */
+    public static final String NODE_TYPE_CONSTANT = "constant";
+
+    /**
+     * split
+     */
+    public static final String NODE_TYPE_SPLIT = "split";
+
+    /**
+     * merge
+     */
+    public static final String NODE_TYPE_MERGE = "merge";
+
+    /**
+     * if
+     */
+    public static final String NODE_TYPE_IF = "if";
+
+    /**
+     * endif
+     */
+    public static final String NODE_TYPE_ENDIF = "endif";
+
+    /**
+     * block
+     */
+    public static final String NODE_TYPE_BLOCK = "block";
+
+    /**
+     * endBlock
+     */
+    public static final String NODE_TYPE_EXIT = "exit";
+
+    /**
+     * endBlock
+     */
+    public static final String NODE_TYPE_ENDBLOCK = "endBlock";
+
+    /**
+     * receive
+     */
+    public static final String NODE_TYPE_RECEIVE = "receive";
+
+    /**
+     * memo
+     */
+    public static final String NODE_TYPE_MEMO = "memo";
+
+    /**
+     * Instance
+     */
+    public static final String NODE_TYPE_INSTANCE = "instance";
+
+    /**
+     * Terminate Instance
+     */
+    public static final String NODE_TYPE_TERMINATE = "terminate";
+
+    /**
+     * Tag for the ID of a node ID. It is unique among a graph.
+     */
+    public static final String NODE_ID_TAG = "id";
+
+    /**
+     * Tag for the name of a node name. A node name is same as the component name.
+     */
+    public static final String NODE_NAME_TAG = "name";
+
+    /**
+     * Tag for wsdl QName.
+     */
+    public static final String NODE_WSDL_QNAME_TAG = "wsdl";
+
+    /**
+     * portType
+     */
+    public static final String NODE_WSDL_PORT_TYPE_TAG = "portType";
+
+    /**
+     * operationType
+     */
+    public static final String NODE_WSDL_OPERATION_TAG = "operation";
+
+    /**
+     * templateID
+     */
+    public static final String NODE_TEMPLATE_ID_TAG = "templateID";
+
+    /**
+     * Tag for a component (Not used since the introduction of .xwf)
+     */
+    public static final String NODE_COMPONENT_TAG = "component";
+
+    /**
+     * The tag used for the configuration of a node.
+     */
+    public static final String NODE_CONFIG_TAG = "config";
+
+    /**
+     * memo
+     */
+    public static final String NODE_MEMO_TAG = "memo";
+
+    /**
+     * Tag for input port
+     */
+    public static final String NODE_INPUT_PORT_TAG = "inputPort";
+
+    /**
+     * Tag for output port
+     */
+    public static final String NODE_OUTPUT_PORT_TAG = "outputPort";
+
+    /**
+     * controlInPort
+     */
+    public static final String NODE_CONTROL_IN_PORT_TAG = "controlInPort";
+
+    /**
+     * controlOutPort
+     */
+    public static final String NODE_CONTROL_OUT_PORT_TAG = "controlOutPort";
+
+    /**
+     * eprPort
+     */
+    public static final String NODE_EPR_PORT_TAG = "eprPort";
+
+    /**
+     * Tag for x-coordinate
+     */
+    public static final String NODE_X_LOCATION_TAG = "x";
+
+    /**
+     * Tag for y-coordinate
+     */
+    public static final String NODE_Y_LOCATION_TAG = "y";
+
+    // Tags for Port
+
+    /**
+     * The tag for a port.
+     */
+    public static final String PORT_TAG = "port";
+
+    /**
+     * type
+     */
+    public static final String PORT_TYPE_ATTRIBUTE = "type";
+
+    /**
+     * ws
+     */
+    public static final String PORT_TYPE_WS_DATA = "ws";
+
+    /**
+     * cep
+     */
+    public static final String PORT_TYPE_CEP = "cep";
+
+    /**
+     * dynamicData
+     */
+    public static final String PORT_TYPE_SYSTEM_DATA = "systemData";
+
+    /**
+     * control
+     */
+    public static final String PORT_TYPE_CONTROL = "control";
+
+    /**
+     * epr
+     */
+    public static final String PORT_TYPE_EPR = "epr";
+
+    /**
+     * Instance
+     */
+    public static final String PORT_TYPE_INSTANCE = "instanceData";
+
+    /**
+     * Tag for the ID of a port
+     */
+    public static final String PORT_ID_TAG = "id";
+
+    /**
+     * Tag for the name of a port
+     */
+    public static final String PORT_NAME_TAG = "name";
+
+    /**
+     * Tag for the data type of a port
+     */
+    public static final String PORT_DATA_TYPE_TAG = "dataType";
+
+    /**
+     * Tag for a node that a port belongs to.
+     */
+    public static final String PORT_NODE_TAG = "node";
+
+    // Tags for Edge
+
+    /**
+     * The tag for an edge
+     */
+    public static final String EDGE_TAG = "edge";
+
+    /**
+     * Tag for the ID of from port of an edge.
+     */
+    public static final String EDGE_FROM_PORT_TAG = "fromPort";
+
+    /**
+     * Tag for the ID of from port of an edge.
+     */
+    public static final String EDGE_TO_PORT_TAG = "toPort";
+
+    /**
+     * type
+     */
+    public static final String EDGE_TYPE_ATTRIBUTE = "type";
+
+    /**
+     * data
+     */
+    public static final String EDGE_TYPE_DATA = "data";
+
+    /**
+     * control
+     */
+    public static final String EDGE_TYPE_CONTROL = "control";
+
+    public static final String PORT_TYPE_UUID = "uuid";
+
+    public static final String NODE_STREAM_LABEL_TAG = "streamlabel";
+
+	public static final String NODE_TYPE_DIFFERED_INPUT = "Differed Input";
+
+}
\ No newline at end of file

Added: incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/Node.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/Node.java?rev=1339718&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/Node.java (added)
+++ incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/Node.java Thu May 17 17:12:15 2012
@@ -0,0 +1,197 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.workflow.model.graph;
+
+import java.awt.Point;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.airavata.workflow.model.component.Component;
+
+public interface Node extends GraphPiece {
+
+    /**
+     * Returns the ID of the node.
+     * 
+     * @return the ID of the node
+     */
+    public String getID();
+
+    /**
+     * Returns the name of the node.
+     * 
+     * @return the name of the node
+     */
+    public String getName();
+
+    /**
+     * Sets the name of the node.
+     * 
+     * @param name
+     *            The name of the node
+     */
+    public void setName(String name);
+
+    /**
+     * Returns the component.
+     * 
+     * @return The component
+     */
+    public Component getComponent();
+
+    /**
+     * Sets the component.
+     * 
+     * @param component
+     *            The component to set.
+     */
+    public void setComponent(Component component);
+
+    /**
+     * @return The graph
+     */
+    public Graph getGraph();
+
+    /**
+     * Returns the List of input ports.
+     * 
+     * @return the List of input ports
+     */
+    public List<DataPort> getInputPorts();
+
+    /**
+     * Returns the List of output ports.
+     * 
+     * @return the List of output ports
+     */
+    public List<DataPort> getOutputPorts();
+
+    /**
+     * Returns the input port of the specified index.
+     * 
+     * @param index
+     *            The specified index
+     * @return the input port of the specified index
+     */
+    public DataPort getInputPort(int index);
+
+    /**
+     * Returns the output port of the specified index.
+     * 
+     * @param index
+     *            The specified index
+     * @return the uses port of the specified index
+     */
+    public Port getOutputPort(int index);
+
+    /**
+     * @return The controlInPort.
+     */
+    public ControlPort getControlInPort();
+
+    /**
+     * @return The List of controlOutPorts.
+     */
+    public List<? extends ControlPort> getControlOutPorts();
+
+    /**
+     * @return The EPR (End Point Reference) Port.
+     */
+    public Port getEPRPort();
+
+    /**
+     * Returns all ports that belong to this node.
+     * 
+     * @return All ports that belong to this node.
+     */
+    public Collection<? extends Port> getAllPorts();
+
+    /**
+     * Checks if this node contains a specified port.
+     * 
+     * @param port
+     *            The specified port
+     * @return true if this node contains port; false otherwise
+     */
+    public boolean containsPort(Port port);
+
+    /**
+     * Sets the position of the node.
+     * 
+     * @param point
+     *            The position
+     */
+    public void setPosition(Point point);
+
+    /**
+     * Gets the position of the node.
+     * 
+     * @return The position of the node.
+     */
+    public Point getPosition();
+
+    /**
+     * Gets whether this node has a break point set in it.
+     * 
+     * @return Whether execution should pause at this node
+     */
+    public boolean isBreak();
+
+    /**
+     * Sets or removes a break point in this node
+     * 
+     * @param breakVal
+     *            whether to add or remove a break point
+     */
+    public void setBreak(boolean breakVal);
+
+    /**
+     * Check to see if all the input pors are already connected
+     * 
+     * @return
+     */
+    public boolean isAllInPortsConnected();
+
+    /**
+     * @param fromPortID
+     */
+    public DataPort getOutputPort(String fromPortID);
+
+    /**
+     * @param id
+     */
+    public DataPort getInputPort(String id);
+
+   
+  
+
+    /**
+     * @param b
+     */
+    public void setRequireJoin(boolean b);
+
+    /**
+     * @return
+     */
+    public boolean getRequireJoin();
+
+}
\ No newline at end of file

Added: incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/Port.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/Port.java?rev=1339718&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/Port.java (added)
+++ incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/Port.java Thu May 17 17:12:15 2012
@@ -0,0 +1,162 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.workflow.model.graph;
+
+import java.util.Collection;
+
+import org.apache.airavata.workflow.model.component.ComponentPort;
+
+public interface Port extends GraphPiece {
+
+    /**
+     * Kinds of ports
+     */
+    public enum Kind {
+        /**
+         * Output port
+         */
+        DATA_OUT,
+
+        /**
+         * Input port
+         */
+        DATA_IN,
+
+        /**
+         * CONTROL_OUT
+         */
+        CONTROL_OUT,
+
+        /**
+         * CONTROL_IN
+         */
+        CONTROL_IN,
+
+        /**
+         * EPR
+         */
+        EPR,
+    }
+
+    /**
+     * Returns an ID that can be used to distinguish a port, and also can be used as a variable name in scripts
+     * 
+     * @return the ID
+     */
+    public String getID();
+
+    /**
+     * @return the name
+     */
+    public String getName();
+
+    /**
+     * @param name
+     */
+    public void setName(String name);
+
+    /**
+     * @return the node that this port belongs to
+     */
+    public Node getNode();
+
+    /**
+     * Returns the Collection of Edges that this Port is connected.
+     * 
+     * @return The Collection of Edges; an empty Collection if there is no edges.
+     */
+    public Collection<? extends Edge> getEdges();
+
+    /**
+     * Returns the Edge with a specified index.
+     * 
+     * @param index
+     *            The specified index
+     * @return The Edge with the specified index.
+     */
+    public Edge getEdge(int index);
+
+    /**
+     * Returns the kind of the port.
+     * 
+     * @return The kind of the port.
+     */
+    public Kind getKind();
+
+    /**
+     * Returns the Collection of Ports that this Port is connected from.
+     * 
+     * @return The Collection of Ports; an empty Collection if there are no Ports.
+     */
+    public Collection<Port> getFromPorts();
+
+    /**
+     * Returns the Port that this port is connected from.
+     * 
+     * @return The Port; null if there is no Port.
+     */
+    public Port getFromPort();
+
+    /**
+     * Returns the Collection of Nodes that this Port is connected from.
+     * 
+     * @return The Collection of Nodes if any; an empty Collection if there are no Nodes.
+     */
+    public Collection<Node> getFromNodes();
+
+    /**
+     * Returns the Nord that this port is connected from.
+     * 
+     * @return The Nort; null if there is no Nort.
+     */
+    public Node getFromNode();
+
+    /**
+     * Returns the Collection of Ports this Port is connected to.
+     * 
+     * @return The Collection of Ports if any; an epty Collection if there are no Ports.
+     */
+    public Collection<Port> getToPorts();
+
+    /**
+     * Returns the Collection of Nodes that this Port is connected to.
+     * 
+     * @return The Collection of Nodes if any; an empty Collection if there are no Nodes.
+     */
+    public Collection<Node> getToNodes();
+
+    /**
+     * Sets a ComponentPort.
+     * 
+     * @param componentPort
+     *            The ComponentPort to set
+     */
+    public void setComponentPort(ComponentPort componentPort);
+
+    /**
+     * Returns the ComponentPort.
+     * 
+     * @return The ComponentPort
+     */
+    public ComponentPort getComponentPort();
+
+}
\ No newline at end of file

Added: incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/amazon/InstanceDataPort.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/amazon/InstanceDataPort.java?rev=1339718&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/amazon/InstanceDataPort.java (added)
+++ incubator/airavata/trunk/modules/workflow-model/src/main/java/org/apache/airavata/workflow/model/graph/amazon/InstanceDataPort.java Thu May 17 17:12:15 2012
@@ -0,0 +1,85 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.workflow.model.graph.amazon;
+
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.common.utils.WSConstants;
+import org.apache.airavata.workflow.model.graph.DataPort;
+import org.apache.airavata.workflow.model.graph.GraphException;
+import org.apache.airavata.workflow.model.graph.GraphSchema;
+import org.xmlpull.infoset.XmlElement;
+
+public class InstanceDataPort extends DataPort {
+
+    /**
+     * String
+     */
+    public static final QName STRING_TYPE = new QName(WSConstants.XSD_NS_URI, "string", WSConstants.XSD_NS_PREFIX);
+
+    /**
+     * 
+     * Constructs a InstanceDataPort.
+     * 
+     */
+    public InstanceDataPort() {
+        super();
+    }
+
+    /**
+     * 
+     * Constructs a InstanceDataPort.
+     * 
+     * @param portElement
+     */
+    public InstanceDataPort(XmlElement portElement) {
+        super(portElement);
+    }
+
+    /**
+     * @see org.apache.airavata.workflow.model.graph.DataPort#getType()
+     */
+    @Override
+    public QName getType() {
+        return STRING_TYPE;
+    }
+
+    /**
+     * 
+     * @see org.apache.airavata.workflow.model.graph.impl.PortImpl#toXML()
+     */
+    @Override
+    protected XmlElement toXML() {
+        XmlElement portElement = super.toXML();
+        portElement.setAttributeValue(GraphSchema.NS, GraphSchema.PORT_TYPE_ATTRIBUTE, GraphSchema.PORT_TYPE_INSTANCE);
+        return portElement;
+    }
+
+    /**
+     * @see org.apache.airavata.workflow.model.graph.DataPort#copyType(org.apache.airavata.workflow.model.graph.DataPort)
+     */
+    @Override
+    public void copyType(DataPort port) throws GraphException {
+        // left blank
+
+    }
+}
\ No newline at end of file