airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shame...@apache.org
Subject [08/14] airavata git commit: Handle ouptprt of application nodes and workflowOutputNodes
Date Wed, 18 Feb 2015 22:05:06 GMT
Handle ouptprt of application nodes and workflowOutputNodes


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/9445b7a1
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/9445b7a1
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/9445b7a1

Branch: refs/heads/new-workflow-design
Commit: 9445b7a10596c509cbe7950a470add94b3deb32a
Parents: e3ce93e
Author: shamrath <shameerainfo@gmail.com>
Authored: Mon Feb 16 11:19:18 2015 -0500
Committer: shamrath <shameerainfo@gmail.com>
Committed: Mon Feb 16 11:19:18 2015 -0500

----------------------------------------------------------------------
 .../workflow/engine/dag/edge/DirectedEdge.java  |   8 +-
 .../engine/dag/nodes/ApplicationNode.java       |   4 +-
 .../engine/dag/nodes/ApplicationNodeImpl.java   |  28 +-
 .../engine/dag/nodes/WorkflowInputNode.java     |   2 +
 .../engine/dag/nodes/WorkflowInputNodeImpl.java |  19 +-
 .../engine/dag/nodes/WorkflowOutputNode.java    |   7 +-
 .../dag/nodes/WorkflowOutputNodeImpl.java       |  26 +-
 .../workflow/engine/dag/port/InputPortIml.java  |  13 +-
 .../workflow/engine/dag/port/OutPortImpl.java   |  21 +-
 .../engine/parser/AiravataDefaultParser.java    |  50 +-
 .../simple/workflow/engine/WorkflowDAGTest.java |   2 +
 .../parser/AiravataDefaultParserTest.java       |  71 +++
 .../src/test/resources/ComplexMathWorkflow.awf  | 465 +++++++++++++++++++
 13 files changed, 664 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/9445b7a1/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/edge/DirectedEdge.java
----------------------------------------------------------------------
diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/edge/DirectedEdge.java
b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/edge/DirectedEdge.java
index 4b05740..000cd06 100644
--- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/edge/DirectedEdge.java
+++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/edge/DirectedEdge.java
@@ -11,21 +11,21 @@ public class DirectedEdge implements Edge {
 
     @Override
     public InPort getToPort() {
-        return null; // TODO: Auto generated method body.
+        return inPort;
     }
 
     @Override
     public void setToPort(InPort inPort) {
-        // TODO: Auto generated method body.
+        this.inPort = inPort;
     }
 
     @Override
     public OutPort getFromPort() {
-        return null; // TODO: Auto generated method body.
+        return outPort;
     }
 
     @Override
     public void setFromPort(OutPort outPort) {
-        // TODO: Auto generated method body.
+        this.outPort = outPort;
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/9445b7a1/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/ApplicationNode.java
----------------------------------------------------------------------
diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/ApplicationNode.java
b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/ApplicationNode.java
index cd2a955..6ab5754 100644
--- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/ApplicationNode.java
+++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/ApplicationNode.java
@@ -30,11 +30,11 @@ public interface ApplicationNode extends WorkflowNode {
 
     public String getApplicationId();
 
-//    public void addInputPort(InPort inPort);
+    public void addInPort(InPort inPort);
 
     public List<InPort> getInputPorts();
 
-//    public void addOutputPort(OutPort outPort);
+    public void addOutPort(OutPort outPort);
 
     public List<OutPort> getOutputPorts();
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/9445b7a1/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/ApplicationNodeImpl.java
----------------------------------------------------------------------
diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/ApplicationNodeImpl.java
b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/ApplicationNodeImpl.java
index 9388c43..fd7e3c7 100644
--- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/ApplicationNodeImpl.java
+++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/ApplicationNodeImpl.java
@@ -26,6 +26,7 @@ package org.apache.ariavata.simple.workflow.engine.dag.nodes;
 import org.apache.ariavata.simple.workflow.engine.dag.port.InPort;
 import org.apache.ariavata.simple.workflow.engine.dag.port.OutPort;
 
+import java.util.ArrayList;
 import java.util.List;
 
 public class ApplicationNodeImpl implements ApplicationNode {
@@ -33,6 +34,8 @@ public class ApplicationNodeImpl implements ApplicationNode {
     private final String nodeId;
     private NodeState myState = NodeState.WAITING;
     private String applicationId;
+    private List<InPort> inPorts = new ArrayList<InPort>();
+    private List<OutPort> outPorts = new ArrayList<OutPort>();
 
     public ApplicationNodeImpl(String nodeId) {
         this(nodeId, null);
@@ -50,7 +53,7 @@ public class ApplicationNodeImpl implements ApplicationNode {
 
     @Override
     public String getNodeName() {
-        return null; // TODO: Auto generated method body.
+        return this.getNodeName();
     }
 
     @Override
@@ -71,21 +74,36 @@ public class ApplicationNodeImpl implements ApplicationNode {
 
     @Override
     public boolean isSatisfy() {
-        return false; // TODO: Auto generated method body.
+        for (InPort inPort : getInputPorts()) {
+            if (!inPort.isSatisfy()) {
+                return false;
+            }
+        }
+        return true;
     }
 
     @Override
     public String getApplicationId() {
-        return null; // TODO: Auto generated method body.
+        return this.applicationId;
+    }
+
+    @Override
+    public void addInPort(InPort inPort) {
+        this.inPorts.add(inPort);
     }
 
     @Override
     public List<InPort> getInputPorts() {
-        return null; // TODO: Auto generated method body.
+        return this.inPorts;
+    }
+
+    @Override
+    public void addOutPort(OutPort outPort) {
+        this.outPorts.add(outPort);
     }
 
     @Override
     public List<OutPort> getOutputPorts() {
-        return null; // TODO: Auto generated method body.
+        return this.outPorts;
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/9445b7a1/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowInputNode.java
----------------------------------------------------------------------
diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowInputNode.java
b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowInputNode.java
index 8d24c96..b27fdea 100644
--- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowInputNode.java
+++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowInputNode.java
@@ -35,4 +35,6 @@ public interface WorkflowInputNode extends WorkflowNode {
 
     public OutPort getOutPort();
 
+    public void setOutPort(OutPort outPort);
+
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/9445b7a1/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowInputNodeImpl.java
----------------------------------------------------------------------
diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowInputNodeImpl.java
b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowInputNodeImpl.java
index 31bd6b0..0f6ea92 100644
--- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowInputNodeImpl.java
+++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowInputNodeImpl.java
@@ -30,6 +30,8 @@ public class WorkflowInputNodeImpl implements WorkflowInputNode {
     private NodeState myState = NodeState.READY;
     private final String nodeId;
     private String nodeName;
+    private OutPort outPort;
+    private InputDataObjectType inputDataObjectType;
 
     public WorkflowInputNodeImpl(String nodeId) {
         this(nodeId, null);
@@ -42,12 +44,12 @@ public class WorkflowInputNodeImpl implements WorkflowInputNode {
 
     @Override
     public String getNodeId() {
-        return null;
+        return this.nodeId;
     }
 
     @Override
     public String getNodeName() {
-        return null; // TODO: Auto generated method body.
+        return this.nodeName;
     }
 
     @Override
@@ -68,22 +70,27 @@ public class WorkflowInputNodeImpl implements WorkflowInputNode {
 
     @Override
     public boolean isSatisfy() {
-        return false; // TODO: Auto generated method body.
+        return inputDataObjectType.getValue() != null && !inputDataObjectType.getValue().equals("");
     }
 
     @Override
     public InputDataObjectType getInputObject() {
-        return null; // TODO: Auto generated method body.
+        return this.inputDataObjectType;
     }
 
     @Override
     public void setInputObject(InputDataObjectType inputObject) {
-        // TODO: Auto generated method body.
+        this.inputDataObjectType = inputObject;
     }
 
     @Override
     public OutPort getOutPort() {
-        return null; // TODO: Auto generated method body.
+        return this.outPort;
+    }
+
+    @Override
+    public void setOutPort(OutPort outPort) {
+        this.outPort = outPort;
     }
 
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/9445b7a1/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowOutputNode.java
----------------------------------------------------------------------
diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowOutputNode.java
b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowOutputNode.java
index 55e1268..a1ff6d4 100644
--- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowOutputNode.java
+++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowOutputNode.java
@@ -23,11 +23,16 @@ package org.apache.ariavata.simple.workflow.engine.dag.nodes;
 
 import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType;
 import org.apache.ariavata.simple.workflow.engine.dag.edge.Edge;
+import org.apache.ariavata.simple.workflow.engine.dag.port.InPort;
 
 public interface WorkflowOutputNode extends WorkflowNode {
 
     public OutputDataObjectType getOutputObject();
 
-    public Edge getInputLink();
+    public void setOutputObject(OutputDataObjectType outputObject);
+
+    public InPort getInPort();
+
+    public void setInPort(InPort inPort);
 
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/9445b7a1/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowOutputNodeImpl.java
----------------------------------------------------------------------
diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowOutputNodeImpl.java
b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowOutputNodeImpl.java
index 36ab1f6..ec3a1ea 100644
--- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowOutputNodeImpl.java
+++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/nodes/WorkflowOutputNodeImpl.java
@@ -25,12 +25,15 @@ package org.apache.ariavata.simple.workflow.engine.dag.nodes;
 
 import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType;
 import org.apache.ariavata.simple.workflow.engine.dag.edge.Edge;
+import org.apache.ariavata.simple.workflow.engine.dag.port.InPort;
 
 public class WorkflowOutputNodeImpl implements WorkflowOutputNode {
 
     private NodeState myState = NodeState.WAITING;
     private final String nodeId;
     private String nodeName;
+    private OutputDataObjectType outputDataObjectType;
+    private InPort inPort;
 
     public WorkflowOutputNodeImpl(String nodeId) {
         this(nodeId, null);
@@ -43,12 +46,12 @@ public class WorkflowOutputNodeImpl implements WorkflowOutputNode {
 
     @Override
     public String getNodeId() {
-        return null;
+        return this.nodeId;
     }
 
     @Override
     public String getNodeName() {
-        return null; // TODO: Auto generated method body.
+        return this.nodeName;
     }
 
     @Override
@@ -69,17 +72,28 @@ public class WorkflowOutputNodeImpl implements WorkflowOutputNode {
 
     @Override
     public boolean isSatisfy() {
-        return false; // TODO: Auto generated method body.
+        return this.outputDataObjectType.getValue() != null && !this.outputDataObjectType.getValue().equals("");
     }
 
     @Override
     public OutputDataObjectType getOutputObject() {
-        return null; // TODO: Auto generated method body.
+        return this.outputDataObjectType;
     }
 
     @Override
-    public Edge getInputLink() {
-        return null; // TODO: Auto generated method body.
+    public void setOutputObject(OutputDataObjectType outputObject) {
+        this.outputDataObjectType = outputObject;
     }
+
+    @Override
+    public InPort getInPort() {
+        return this.inPort;
+    }
+
+    @Override
+    public void setInPort(InPort inPort) {
+        this.inPort = inPort;
+    }
+
 }
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/9445b7a1/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/InputPortIml.java
----------------------------------------------------------------------
diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/InputPortIml.java
b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/InputPortIml.java
index b33b91b..629a832 100644
--- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/InputPortIml.java
+++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/InputPortIml.java
@@ -30,6 +30,7 @@ public class InputPortIml implements InPort {
     private boolean isSatisfy = false;
     private String portId;
     private Edge edge;
+    private WorkflowNode node;
 
     public InputPortIml(String portId) {
         this.portId = portId;
@@ -37,12 +38,12 @@ public class InputPortIml implements InPort {
 
     @Override
     public void setInputObject(InputDataObjectType inputObject) {
-        // TODO: Auto generated method body.
+        this.inputDataObjectType = inputObject;
     }
 
     @Override
     public InputDataObjectType getInputObject() {
-        return null; // TODO: Auto generated method body.
+        return this.inputDataObjectType;
     }
 
     @Override
@@ -57,22 +58,22 @@ public class InputPortIml implements InPort {
 
     @Override
     public boolean isSatisfy() {
-        return false; // TODO: Auto generated method body.
+        return inputDataObjectType.getValue() != null && !inputDataObjectType.getValue().equals("");
     }
 
     @Override
     public WorkflowNode getNode() {
-        return null; // TODO: Auto generated method body.
+        return this.node;
     }
 
     @Override
     public void setNode(WorkflowNode workflowNode) {
-        // TODO: Auto generated method body.
+        this.node = workflowNode;
     }
 
     @Override
     public String getId() {
-        return null; // TODO: Auto generated method body.
+        return this.portId;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/9445b7a1/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/OutPortImpl.java
----------------------------------------------------------------------
diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/OutPortImpl.java
b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/OutPortImpl.java
index bc7628f..35b8c3b 100644
--- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/OutPortImpl.java
+++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/dag/port/OutPortImpl.java
@@ -4,6 +4,7 @@ import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType;
 import org.apache.ariavata.simple.workflow.engine.dag.edge.Edge;
 import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowNode;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -12,9 +13,10 @@ import java.util.List;
 public class OutPortImpl implements OutPort {
 
     private OutputDataObjectType outputDataObjectType;
-    private List<Edge> outEdges;
+    private List<Edge> outEdges = new ArrayList<Edge>();
     private boolean isSatisfy = false;
     private String portId;
+    private WorkflowNode node;
 
     public OutPortImpl(String portId) {
         this.portId = portId;
@@ -22,41 +24,42 @@ public class OutPortImpl implements OutPort {
 
     @Override
     public void setOutputObject(OutputDataObjectType outputObject) {
-        // TODO: Auto generated method body.
+        this.outputDataObjectType = outputObject;
     }
 
     @Override
     public OutputDataObjectType getOutputObject() {
-        return null; // TODO: Auto generated method body.
+        return this.outputDataObjectType;
     }
 
     @Override
     public List<Edge> getOutEdges() {
-        return null; // TODO: Auto generated method body.
+        return this.outEdges;
     }
 
     @Override
     public void addEdge(Edge edge) {
-        // TODO: Auto generated method body.
+        this.outEdges.add(edge);
     }
 
     @Override
     public boolean isSatisfy() {
-        return false; // TODO: Auto generated method body.
+        return this.outputDataObjectType.getValue() != null
+                && !this.outputDataObjectType.getValue().equals("");
     }
 
     @Override
     public WorkflowNode getNode() {
-        return null; // TODO: Auto generated method body.
+        return this.node;
     }
 
     @Override
     public void setNode(WorkflowNode workflowNode) {
-        // TODO: Auto generated method body.
+        this.node = workflowNode;
     }
 
     @Override
     public String getId() {
-        return null; // TODO: Auto generated method body.
+        return portId;
     }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/9445b7a1/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/parser/AiravataDefaultParser.java
----------------------------------------------------------------------
diff --git a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/parser/AiravataDefaultParser.java
b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/parser/AiravataDefaultParser.java
index 92e9811..d2095c8 100644
--- a/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/parser/AiravataDefaultParser.java
+++ b/modules/simple-workflow/src/main/java/org/apache/ariavata/simple/workflow/engine/parser/AiravataDefaultParser.java
@@ -3,6 +3,7 @@ package org.apache.ariavata.simple.workflow.engine.parser;
 import org.airavata.appcatalog.cpi.AppCatalogException;
 import org.airavata.appcatalog.cpi.WorkflowCatalog;
 import org.apache.aiaravata.application.catalog.data.impl.AppCatalogFactory;
+import org.apache.aiaravata.application.catalog.data.model.WorkflowOutput;
 import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType;
 import org.apache.airavata.model.appcatalog.appinterface.OutputDataObjectType;
 import org.apache.airavata.model.workspace.experiment.Experiment;
@@ -31,6 +32,8 @@ import org.apache.ariavata.simple.workflow.engine.dag.nodes.ApplicationNodeImpl;
 import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowInputNode;
 import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowInputNodeImpl;
 import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowNode;
+import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowOutputNode;
+import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowOutputNodeImpl;
 import org.apache.ariavata.simple.workflow.engine.dag.port.InPort;
 import org.apache.ariavata.simple.workflow.engine.dag.port.InputPortIml;
 import org.apache.ariavata.simple.workflow.engine.dag.port.OutPort;
@@ -51,8 +54,14 @@ public class AiravataDefaultParser implements WorkflowParser {
     private String experimentId;
     private String credentialToken ;
     private Workflow workflow;
+
+    // TODO : remove this setter method
+    public void setExperiment(Experiment experiment) {
+        this.experiment = experiment;
+    }
+
     private Experiment experiment;
-    private Map<String, ApplicationNode> wfNodes = new HashMap<String, ApplicationNode>();
+    private Map<String, WorkflowNode> wfNodes = new HashMap<String, WorkflowNode>();
 
 
     public AiravataDefaultParser(String experimentId, String credentialToken) {
@@ -66,7 +75,7 @@ public class AiravataDefaultParser implements WorkflowParser {
         return parseWorkflow(getWorkflowFromExperiment());
     }
 
-    private List<WorkflowInputNode> parseWorkflow(Workflow workflow) {
+    public List<WorkflowInputNode> parseWorkflow(Workflow workflow) {
         List<Node> gNodes = getInputNodes(workflow);
         List<WorkflowInputNode> wfInputNodes = new ArrayList<WorkflowInputNode>();
         List<PortContainer> portContainers = new ArrayList<PortContainer>();
@@ -85,7 +94,8 @@ public class AiravataDefaultParser implements WorkflowParser {
             if (wfInputNode.getInputObject() == null) {
                 // TODO: throw an error and exit.
             }
-            for (DataPort dataPort : gNode.getInputPorts()) {
+            portContainers.addAll(processOutPorts(gNode, wfInputNode));
+/*            for (DataPort dataPort : gNode.getOutputPorts()) {
                 outPort = new OutPortImpl(dataPort.getID());
                 for (DataEdge dataEdge : dataPort.getEdges()) {
                     edge = new DirectedEdge();
@@ -96,8 +106,8 @@ public class AiravataDefaultParser implements WorkflowParser {
                     inPort.addEdge(edge);
                     portContainers.add(new PortContainer(dataEdge.getToPort(), inPort));
                 }
-                outPort.setOutputObject(getOutputDataObject(wfInputNode.getInputObject()));
-            }
+//                outPort.setOutputObject(getOutputDataObject(wfInputNode.getInputObject()));
+            }*/
             wfInputNodes.add(wfInputNode);
         }
 
@@ -114,7 +124,8 @@ public class AiravataDefaultParser implements WorkflowParser {
         }
         DataPort dataPort = null;
         InPort inPort = null;
-        WorkflowNode wfNode = null;
+        ApplicationNode wfApplicationNode = null;
+        WorkflowOutputNode wfOutportNode = null;
         List<PortContainer> nextPortContainerList = new ArrayList<PortContainer>();
         for (PortContainer portContainer : portContainerList) {
             dataPort = portContainer.getDataPort();
@@ -123,17 +134,21 @@ public class AiravataDefaultParser implements WorkflowParser {
             inPort.setInputObject(getInputDataObject(dataPort));
             if (node instanceof WSNode) {
                 WSNode wsNode = (WSNode) node;
-                wfNode = wfNodes.get(wsNode.getID());
-                if (wfNode == null) {
-                    wfNode = new ApplicationNodeImpl(wsNode.getID(),
+                wfApplicationNode = (ApplicationNode) wfNodes.get(wsNode.getID());
+                if (wfApplicationNode == null) {
+                    wfApplicationNode = new ApplicationNodeImpl(wsNode.getID(),
                             wsNode.getComponent().getApplication().getApplicationId());
-                    nextPortContainerList.addAll(processOutPorts(wsNode, wfNode));
+                    wfNodes.put(wfApplicationNode.getNodeId(), wfApplicationNode);
+                    nextPortContainerList.addAll(processOutPorts(wsNode, wfApplicationNode));
                 }
+                inPort.setNode(wfApplicationNode);
+                wfApplicationNode.addInPort(inPort);
+
             }else if (node instanceof OutputNode) {
                 OutputNode oNode = (OutputNode) node;
-                wfNode = new WorkflowInputNodeImpl(oNode.getID(), oNode.getName());
+                wfOutportNode = new WorkflowOutputNodeImpl(oNode.getID(), oNode.getName());
+                wfOutportNode.setInPort(inPort);
             }
-            inPort.setNode(wfNode);
             buildModel(nextPortContainerList);
             // set the workflow node to inPort
             // if require check the types of inputs and output ports,
@@ -148,7 +163,7 @@ public class AiravataDefaultParser implements WorkflowParser {
     private List<PortContainer> processOutPorts(Node node, WorkflowNode wfNode) {
         OutPort outPort ;
         Edge edge;
-        InPort inPort;
+        InPort inPort = null;
         List<PortContainer> portContainers = new ArrayList<PortContainer>();
         for (DataPort dataPort : node.getOutputPorts()) {
             outPort = new OutPortImpl(dataPort.getID());
@@ -161,6 +176,15 @@ public class AiravataDefaultParser implements WorkflowParser {
                 inPort.addEdge(edge);
                 portContainers.add(new PortContainer(dataEdge.getToPort(), inPort));
             }
+            outPort.setNode(wfNode);
+            if (wfNode instanceof WorkflowInputNode) {
+                WorkflowInputNode workflowInputNode = (WorkflowInputNode) wfNode;
+                workflowInputNode.setOutPort(outPort);
+            }else if (wfNode instanceof ApplicationNode) {
+                ApplicationNode applicationNode = ((ApplicationNode) wfNode);
+                applicationNode.addOutPort(outPort);
+                applicationNode.addInPort(inPort);
+            }
         }
         return portContainers;
     }

http://git-wip-us.apache.org/repos/asf/airavata/blob/9445b7a1/modules/simple-workflow/src/test/java/org/apache/ariavata/simple/workflow/engine/WorkflowDAGTest.java
----------------------------------------------------------------------
diff --git a/modules/simple-workflow/src/test/java/org/apache/ariavata/simple/workflow/engine/WorkflowDAGTest.java
b/modules/simple-workflow/src/test/java/org/apache/ariavata/simple/workflow/engine/WorkflowDAGTest.java
index 4e3a120..645af42 100644
--- a/modules/simple-workflow/src/test/java/org/apache/ariavata/simple/workflow/engine/WorkflowDAGTest.java
+++ b/modules/simple-workflow/src/test/java/org/apache/ariavata/simple/workflow/engine/WorkflowDAGTest.java
@@ -21,5 +21,7 @@ public class WorkflowDAGTest {
     @Test
     public void testWorkflowDAG() throws Exception {
 
+
+
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/9445b7a1/modules/simple-workflow/src/test/java/org/apache/ariavata/simple/workflow/engine/parser/AiravataDefaultParserTest.java
----------------------------------------------------------------------
diff --git a/modules/simple-workflow/src/test/java/org/apache/ariavata/simple/workflow/engine/parser/AiravataDefaultParserTest.java
b/modules/simple-workflow/src/test/java/org/apache/ariavata/simple/workflow/engine/parser/AiravataDefaultParserTest.java
new file mode 100644
index 0000000..0d56aa4
--- /dev/null
+++ b/modules/simple-workflow/src/test/java/org/apache/ariavata/simple/workflow/engine/parser/AiravataDefaultParserTest.java
@@ -0,0 +1,71 @@
+package org.apache.ariavata.simple.workflow.engine.parser;
+
+import junit.framework.Assert;
+import org.apache.airavata.model.appcatalog.appinterface.DataType;
+import org.apache.airavata.model.appcatalog.appinterface.InputDataObjectType;
+import org.apache.airavata.model.workspace.experiment.Experiment;
+import org.apache.airavata.workflow.model.wf.Workflow;
+import org.apache.ariavata.simple.workflow.engine.dag.nodes.WorkflowInputNode;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.List;
+
+public class AiravataDefaultParserTest {
+
+    @Before
+    public void setUp() throws Exception {
+
+    }
+
+    @After
+    public void tearDown() throws Exception {
+
+    }
+
+    @Test
+    public void testWorkflowParse() throws Exception {
+        File jsonWfFile = new File("modules/simple-workflow/src/test/resources/ComplexMathWorkflow.awf");
+        BufferedReader br = new BufferedReader(new FileReader(jsonWfFile));
+        StringBuffer sb = new StringBuffer();
+        String nextLine = br.readLine();
+        while (nextLine != null) {
+            sb.append(nextLine);
+            nextLine = br.readLine();
+        }
+
+        Workflow workflow = new Workflow(sb.toString());
+        AiravataDefaultParser parser = new AiravataDefaultParser("testExperimentId", "testCredentialId");
+        Experiment experiment = new Experiment();
+        InputDataObjectType x = new InputDataObjectType();
+        x.setValue("6");
+        x.setType(DataType.STRING);
+        x.setName("x");
+
+        InputDataObjectType y = new InputDataObjectType();
+        y.setValue("8");
+        y.setType(DataType.STRING);
+        y.setName("y");
+
+        InputDataObjectType z = new InputDataObjectType();
+        z.setValue("10");
+        z.setType(DataType.STRING);
+        z.setName("y_2");
+
+        List<InputDataObjectType> inputs = new ArrayList<InputDataObjectType>();
+        inputs.add(x);
+        inputs.add(y);
+        inputs.add(z);
+        experiment.setExperimentInputs(inputs);
+        parser.setExperiment(experiment);
+        List<WorkflowInputNode> workflowInputNodes = parser.parseWorkflow(workflow);
+        Assert.assertNotNull(workflowInputNodes);
+        Assert.assertEquals(3, workflowInputNodes.size());
+
+    }
+}
\ No newline at end of file


Mime
View raw message