You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by st...@apache.org on 2018/07/05 10:45:51 UTC

[01/13] incubator-taverna-language git commit: First commit, Add YAML file parser

Repository: incubator-taverna-language
Updated Branches:
  refs/heads/cwlparser e5547ef8c -> 48f7dd9f7


First commit, Add YAML file parser


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/commit/30910928
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/30910928
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/30910928

Branch: refs/heads/cwlparser
Commit: 309109286ee0ef07c5744de67c3f83463eb6713b
Parents: e5547ef
Author: Majdi Haouech <m....@criteo.com>
Authored: Mon May 21 15:26:57 2018 +0200
Committer: Majdi Haouech <m....@criteo.com>
Committed: Mon May 21 15:26:57 2018 +0200

----------------------------------------------------------------------
 taverna-scufl2-cwl/pom.xml                      | 43 ++++++++++++++++++++
 .../org/apache/taverna/scufl2/cwl/Parser.java   | 41 +++++++++++++++++++
 2 files changed, 84 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/30910928/taverna-scufl2-cwl/pom.xml
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/pom.xml b/taverna-scufl2-cwl/pom.xml
new file mode 100644
index 0000000..7a897bd
--- /dev/null
+++ b/taverna-scufl2-cwl/pom.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.taverna.language</groupId>
+    <artifactId>apache-taverna-language</artifactId>
+    <version>0.16.0-incubating-SNAPSHOT</version>
+  </parent>
+  <artifactId>taverna-scufl2-cwl</artifactId>
+  <packaging>bundle</packaging>
+  <name>Apache Taverna Scufl 2 CWL parser</name>
+  <description>Parser for .cwl file format</description>
+  <dependencies>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>taverna-scufl2-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+      <version>${commons.io.version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/30910928/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
new file mode 100644
index 0000000..544d3d4
--- /dev/null
+++ b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
@@ -0,0 +1,41 @@
+package org.apache.taverna.scufl2.cwl;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+
+public class Parser {
+
+    private String yamlLine;
+    private int fileLength;
+
+    private Map<Integer, String> yamlFile = null;
+
+    public Parser(File file) {
+        int counter = 0;
+
+        yamlFile = new HashMap<>();
+
+        FileReader yamlFileDescriptor = null;
+
+
+        try {
+            yamlFileDescriptor = new FileReader(file);
+            BufferedReader bufferedReader = new BufferedReader(yamlFileDescriptor);
+            String parent = null;
+            int parentDepth = 0;
+            while((yamlLine = bufferedReader.readLine()) != null) {
+
+                yamlFile.put(counter, yamlLine);
+                counter = counter + 1;
+            }
+
+            bufferedReader.close();
+            fileLength = counter;
+        } catch (IOException e) {
+            System.err.println("Parser init error: " + e );
+        }
+    }
+}


[08/13] incubator-taverna-language git commit: Split CWL parser and converter

Posted by st...@apache.org.
Split CWL parser and converter


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/commit/881a4096
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/881a4096
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/881a4096

Branch: refs/heads/cwlparser
Commit: 881a409608e4fd8d6b820b8e9e54f1eb5e3c6d16
Parents: ee6b282
Author: Majdi Haouech <m....@criteo.com>
Authored: Mon Jun 11 16:51:06 2018 +0200
Committer: Majdi Haouech <m....@criteo.com>
Committed: Mon Jun 11 16:51:06 2018 +0200

----------------------------------------------------------------------
 .../apache/taverna/scufl2/cwl/CWLParser.java    |  81 +++++++++++++
 .../apache/taverna/scufl2/cwl/Converter.java    |  75 ++++++++++++
 .../org/apache/taverna/scufl2/cwl/Parser.java   | 114 -------------------
 3 files changed, 156 insertions(+), 114 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/881a4096/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/CWLParser.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/CWLParser.java b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/CWLParser.java
new file mode 100644
index 0000000..a2007ad
--- /dev/null
+++ b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/CWLParser.java
@@ -0,0 +1,81 @@
+/*
+ * 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.taverna.scufl2.cwl;
+
+import java.util.*;
+
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.core.Processor;
+
+import org.apache.taverna.scufl2.api.port.InputWorkflowPort;
+import org.apache.taverna.scufl2.api.port.OutputWorkflowPort;
+import org.apache.taverna.scufl2.api.port.InputProcessorPort;
+import org.apache.taverna.scufl2.api.port.OutputProcessorPort;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+public class CWLParser {
+
+    private JsonNode cwlFile;
+    private YAMLHelper yamlHelper;
+
+    public CWLParser(JsonNode cwlFile) {
+        this.cwlFile = cwlFile;
+        this.yamlHelper = new YAMLHelper();
+    }
+
+    public Set<Step> parseSteps() {
+        return yamlHelper.processSteps(cwlFile);
+    }
+
+    public Set<PortDetail> parseInputs() {
+        Map<String, PortDetail> inputs = yamlHelper.processInputDetails(cwlFile);
+        Map<String, Integer> inputDepths = yamlHelper.processInputDepths(cwlFile);
+
+        if(inputs == null || inputDepths == null) {
+            return null;
+        }
+        Set<PortDetail> result = new HashSet<PortDetail>();
+        for(String id: inputs.keySet()) {
+            PortDetail port = inputs.get(id);
+            port.setId(id);
+            int depth = inputDepths.get(id);
+            port.setDepth(depth);
+            result.add(port);
+        }
+
+        return result;
+    }
+
+    public Set<PortDetail> parseOutputs() {
+        Map<String, PortDetail> inputs = yamlHelper.processOutputDetails(cwlFile);
+
+        if(inputs == null) {
+            return null;
+        }
+        Set<PortDetail> result = new HashSet<PortDetail>();
+        for(String id: inputs.keySet()) {
+            PortDetail port = inputs.get(id);
+            result.add(port);
+        }
+
+        return result;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/881a4096/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Converter.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Converter.java b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Converter.java
new file mode 100644
index 0000000..8be949a
--- /dev/null
+++ b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Converter.java
@@ -0,0 +1,75 @@
+/*
+ * 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.taverna.scufl2.cwl;
+
+import java.util.*;
+
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.core.Processor;
+
+import org.apache.taverna.scufl2.api.port.InputWorkflowPort;
+import org.apache.taverna.scufl2.api.port.OutputWorkflowPort;
+import org.apache.taverna.scufl2.api.port.InputProcessorPort;
+import org.apache.taverna.scufl2.api.port.OutputProcessorPort;
+
+import com.fasterxml.jackson.databind.JsonNode;
+
+public class Converter {
+
+    public Converter() {
+
+    }
+
+    public InputWorkflowPort convertInputWorkflowPort(PortDetail input) {
+        InputWorkflowPort port = new InputWorkflowPort();
+        port.setName(input.getId());
+        port.setDepth(input.getDepth());
+
+        return port;
+    }
+
+    public OutputWorkflowPort convertOutputWorkflowPort(PortDetail input) {
+        OutputWorkflowPort port = new OutputWorkflowPort();
+        port.setName(input.getId());
+
+        return port;
+    }
+
+    public Processor convertStepToProcessor(Step step) {
+        Processor processor = new Processor(null, step.getId());
+        // Convert input ports
+        Set<InputProcessorPort> processorInputs = new HashSet<>();
+        Set<StepInput> inputs = step.getInputs();
+        for(StepInput input: inputs) {
+            InputProcessorPort port = new InputProcessorPort(processor, input.getId());
+            processorInputs.add(port);
+        }
+        processor.setInputPorts(processorInputs);
+        // Convert output ports
+        Set<OutputProcessorPort> processorOutputs = new HashSet<>();
+        Set<StepOutput> outputs = step.getOutputs();
+        for(StepOutput output: outputs) {
+            OutputProcessorPort port = new OutputProcessorPort(processor, output.getId());
+            processorOutputs.add(port);
+        }
+        processor.setOutputPorts(processorOutputs);
+
+        return processor;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/881a4096/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
deleted file mode 100644
index c0ef438..0000000
--- a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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.taverna.scufl2.cwl;
-
-import java.util.*;
-
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.core.Processor;
-
-import org.apache.taverna.scufl2.api.port.InputWorkflowPort;
-import org.apache.taverna.scufl2.api.port.OutputWorkflowPort;
-import org.apache.taverna.scufl2.api.port.InputProcessorPort;
-import org.apache.taverna.scufl2.api.port.OutputProcessorPort;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-public class Parser {
-
-    private JsonNode cwlFile;
-    private YAMLHelper yamlHelper;
-    private Workflow workflow;
-
-    public Parser(JsonNode cwlFile) {
-        this.cwlFile = cwlFile;
-        this.yamlHelper = new YAMLHelper();
-        this.workflow = new Workflow();
-        this.workflow.setInputPorts(parseInputs());
-        this.workflow.setOutputPorts(parseOutputs());
-    }
-
-    public Workflow getWorkflow() {
-        return this.workflow;
-    }
-
-    public Set<Step> parseSteps() {
-        return yamlHelper.processSteps(cwlFile);
-    }
-
-    public Processor convertStepToProcessor(Step step) {
-        Processor processor = new Processor(null, step.getId());
-        // Convert input ports
-        Set<InputProcessorPort> processorInputs = new HashSet<>();
-        Set<StepInput> inputs = step.getInputs();
-        for(StepInput input: inputs) {
-            InputProcessorPort port = new InputProcessorPort(processor, input.getId());
-            processorInputs.add(port);
-        }
-        processor.setInputPorts(processorInputs);
-        // Convert output ports
-        Set<OutputProcessorPort> processorOutputs = new HashSet<>();
-        Set<StepOutput> outputs = step.getOutputs();
-        for(StepOutput output: outputs) {
-            OutputProcessorPort port = new OutputProcessorPort(processor, output.getId());
-            processorOutputs.add(port);
-        }
-        processor.setOutputPorts(processorOutputs);
-
-        return processor;
-    }
-
-    public Set<InputWorkflowPort> parseInputs() {
-        Map<String, PortDetail> inputs = yamlHelper.processInputDetails(cwlFile);
-        Map<String, Integer> inputDepths = yamlHelper.processInputDepths(cwlFile);
-
-        if(inputs == null || inputDepths == null) {
-            return null;
-        }
-        Set<InputWorkflowPort> result = new HashSet<InputWorkflowPort>();
-        for(String id: inputs.keySet()) {
-            PortDetail detail = inputs.get(id);
-            int depth = inputDepths.get(id);
-            InputWorkflowPort port = new InputWorkflowPort();
-            port.setName(id);
-            port.setDepth(depth);
-            result.add(port);
-        }
-
-        return result;
-    }
-
-    public Set<OutputWorkflowPort> parseOutputs() {
-        Map<String, PortDetail> inputs = yamlHelper.processOutputDetails(cwlFile);
-
-        if(inputs == null) {
-            return null;
-        }
-        Set<OutputWorkflowPort> result = new HashSet<OutputWorkflowPort>();
-        for(String id: inputs.keySet()) {
-            PortDetail detail = inputs.get(id);
-            OutputWorkflowPort port = new OutputWorkflowPort();
-            port.setName(id);
-            result.add(port);
-        }
-
-        return result;
-    }
-
-}


[06/13] incubator-taverna-language git commit: Add jackson and snackyaml dependencies

Posted by st...@apache.org.
Add jackson and snackyaml dependencies


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/commit/ba294139
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/ba294139
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/ba294139

Branch: refs/heads/cwlparser
Commit: ba2941396dd0bc724d40d9b73589575aca246677
Parents: 6d6dc20
Author: Majdi Haouech <m....@criteo.com>
Authored: Mon Jun 4 10:38:01 2018 +0100
Committer: Majdi Haouech <m....@criteo.com>
Committed: Mon Jun 4 10:38:01 2018 +0100

----------------------------------------------------------------------
 taverna-scufl2-cwl/pom.xml | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/ba294139/taverna-scufl2-cwl/pom.xml
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/pom.xml b/taverna-scufl2-cwl/pom.xml
index 7a897bd..3b11dff 100644
--- a/taverna-scufl2-cwl/pom.xml
+++ b/taverna-scufl2-cwl/pom.xml
@@ -27,6 +27,7 @@
   <name>Apache Taverna Scufl 2 CWL parser</name>
   <description>Parser for .cwl file format</description>
   <dependencies>
+
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>taverna-scufl2-api</artifactId>
@@ -39,5 +40,18 @@
       <version>${commons.io.version}</version>
       <scope>test</scope>
     </dependency>
+
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-databind</artifactId>
+      <version>${jackson.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.yaml</groupId>
+      <artifactId>snakeyaml</artifactId>
+      <version>1.17</version>
+    </dependency>
+
   </dependencies>
 </project>


[03/13] incubator-taverna-language git commit: Parse inputs, add tests

Posted by st...@apache.org.
Parse inputs, add tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/commit/4d324890
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/4d324890
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/4d324890

Branch: refs/heads/cwlparser
Commit: 4d32489097c032f9a6c0786af2f033767811acc3
Parents: 252e3d8
Author: Majdi Haouech <m....@criteo.com>
Authored: Mon May 21 15:37:15 2018 +0200
Committer: Majdi Haouech <m....@criteo.com>
Committed: Mon May 21 15:37:15 2018 +0200

----------------------------------------------------------------------
 .../org/apache/taverna/scufl2/cwl/Parser.java   | 92 ++++++++++++++++++++
 .../apache/taverna/scufl2/cwl/TestParser.java   | 84 ++++++++++++++++++
 .../src/test/resources/1st-tool.cwl             | 10 +++
 .../src/test/resources/int_input.cwl            |  6 ++
 .../src/test/resources/simple_string_input.cwl  |  2 +
 .../src/test/resources/worklflow2.cwl           | 27 ++++++
 6 files changed, 221 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/4d324890/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
index 8cc6655..65844b9 100644
--- a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
+++ b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
@@ -77,8 +77,100 @@ public class Parser {
         }
     }
 
+    public ArrayList<InputField> parseInputs() {
+        int startIndex = 0;
+        int endIndex = -1;
+        int depth = -1;
+
+        /**
+         * Search for start and end of inputs section
+         */
+        for(Map.Entry<Integer, String> entry: yamlFile.entrySet()) {
+            int index = entry.getKey();
+            String line = entry.getValue();
+            String key = getKeyFromLine(line);
+            if(key.equals("inputs")) {
+                startIndex = index;
+                endIndex = index;
+                depth = getDepth(line);
+            } else if(!line.equals("") && getDepth(line) <= depth) {
+                break;
+            } else {
+                endIndex++;
+            }
+        }
+        /**
+         * Parse each input
+         */
+        ArrayList<InputField> result = new ArrayList<>();
+        for(int i = startIndex+1; i <= endIndex; i++) {
+            int curDepth = getDepth(yamlFile.get(i));
+            // If current element is a child of inputs key
+            if(curDepth == depth + 1) {
+                result.add(parseInputField(i));
+            }
+        }
+
+        return result;
+    }
+
+    public InputField parseInputField(int startIndex) {
+        String line = yamlFile.get(startIndex);
+        int depth = getDepth(line);
+        String id = getKeyFromLine(line);
+        String value = getValueFromLine(line);
 
+        if(!value.equals("")) {
+            return new InputField(id, value);
+        }
+
+        InputField field = new InputField(id);
+        for(int i = startIndex+1; i < length; i++) {
+            String curLine = yamlFile.get(i);
+            if(curLine.equals("")) {
+                // Ignore empty lines
+                continue;
+            }
+            if(getDepth(curLine) <= depth) {
+                // Out of input section
+                break;
+            }
+            String key = getKeyFromLine(curLine);
+            value = getValueFromLine(curLine);
+
+            if(key.trim().equals("type")) {
+                field.type = value;
+            } else if(key.trim().equals("inputBinding")) {
+                
+                int curDepth = getDepth(curLine);
+                int nextIndex = getNextLineIndex(i);
+                String nextLine = yamlFile.get(nextIndex);
+                String nextKey = getKeyFromLine(nextLine);
+                String nextValue = getValueFromLine(nextLine);
+
+                if(nextKey.equals("position")){
+                    field.position = Integer.parseInt(nextValue);
+                } else if(nextKey.equals("prefix")){
+                    field.prefix = nextValue;
+                }
+
+                // Check if we have another inputBinding property
+                nextIndex = getNextLineIndex(nextIndex);
+                nextLine = yamlFile.get(nextIndex);
+                if(getDepth(nextLine) == curDepth + 1) {
+                    nextKey = getKeyFromLine(nextLine);
+                    nextValue = getValueFromLine(nextLine);
+                    if(nextKey.equals("position")){
+                        field.position = Integer.parseInt(nextValue);
+                    } else if(nextKey.equals("prefix")){
+                        field.prefix = nextValue.trim();
+                    }
+                }
+            }
+        }
 
+        return field;
+    }
 
     private int getNextLineIndex(int index) {
         index++;

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/4d324890/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java b/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
new file mode 100644
index 0000000..01b5bc2
--- /dev/null
+++ b/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
@@ -0,0 +1,84 @@
+package org.apache.taverna.scufl2.cwl;
+
+import java.io.*;
+import java.util.ArrayList;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import org.apache.commons.io.FileUtils;
+
+import org.apache.taverna.scufl2.cwl.Parser;
+import org.apache.taverna.scufl2.cwl.InputField;
+
+public class TestParser {
+
+    private static final String SIMPLE_STRING_INPUT = "/simple_string_input.cwl";
+    private static final String INT_INPUT = "/int_input.cwl";
+
+    @Test
+    public void testGetDepth() throws Exception {
+
+        assert Parser.getDepth("  test") == 1;
+        assert Parser.getDepth("test") == 0;
+        assert Parser.getDepth("    test") == 2;
+    }
+
+    @Test
+    public void testGetKey() throws Exception {
+
+        assert Parser.getKeyFromLine("  test: test_value").equals("test");
+        assert Parser.getKeyFromLine("test: 1 ").equals("test");
+        assert Parser.getKeyFromLine("    test:").equals("test");
+    }
+
+    @Test
+    public void testGetValue() throws Exception {
+
+        assert Parser.getValueFromLine("  test: test_value").equals("test_value");
+        assert Parser.getValueFromLine("test: 1 ").equals("1");
+        assert Parser.getValueFromLine("    test:").equals("");
+    }
+
+    @Test
+    public void testSimpleInput() throws Exception {
+        File yaml = FileUtils.getFile("src", "test", "resources", SIMPLE_STRING_INPUT);
+
+        Parser parser = new Parser(yaml);
+
+        ArrayList<InputField> inputs = parser.parseInputs();
+
+        assertEquals(1, inputs.size());
+        assertEquals("example_string", inputs.get(0).key);
+    }
+
+    @Test
+    public void testIntInput() throws Exception {
+        File yaml = FileUtils.getFile("src", "test", "resources", INT_INPUT);
+
+        Parser parser = new Parser(yaml);
+
+        ArrayList<InputField> inputs = parser.parseInputs();
+
+        assertEquals(1, inputs.size());
+        assertEquals("example_int", inputs.get(0).key);
+        assertEquals("int", inputs.get(0).type);
+        assertEquals(2, inputs.get(0).position);
+        assertEquals("-i", inputs.get(0).prefix);
+    }
+
+    void printFile(File yaml) throws Exception {
+        /**
+         * Print file
+         */
+        FileReader fdesc = new FileReader(yaml);
+        BufferedReader bufferedReader = new BufferedReader(fdesc);
+        String yamlLine;
+        while((yamlLine = bufferedReader.readLine()) != null) {
+            System.out.println(yamlLine);
+        }
+
+        System.out.println("*************************");
+        bufferedReader.close();
+        /*****/
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/4d324890/taverna-scufl2-cwl/src/test/resources/1st-tool.cwl
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/test/resources/1st-tool.cwl b/taverna-scufl2-cwl/src/test/resources/1st-tool.cwl
new file mode 100644
index 0000000..e292134
--- /dev/null
+++ b/taverna-scufl2-cwl/src/test/resources/1st-tool.cwl
@@ -0,0 +1,10 @@
+cwlVersion: v1.0
+class: CommandLineTool
+baseCommand: echo
+inputs:
+  message:
+    type: string
+
+    inputBinding:
+      position: 1
+outputs: []
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/4d324890/taverna-scufl2-cwl/src/test/resources/int_input.cwl
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/test/resources/int_input.cwl b/taverna-scufl2-cwl/src/test/resources/int_input.cwl
new file mode 100644
index 0000000..ffb79e6
--- /dev/null
+++ b/taverna-scufl2-cwl/src/test/resources/int_input.cwl
@@ -0,0 +1,6 @@
+inputs:
+  example_int:
+    type: int
+    inputBinding:
+      position: 2
+      prefix: -i

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/4d324890/taverna-scufl2-cwl/src/test/resources/simple_string_input.cwl
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/test/resources/simple_string_input.cwl b/taverna-scufl2-cwl/src/test/resources/simple_string_input.cwl
new file mode 100644
index 0000000..c075b22
--- /dev/null
+++ b/taverna-scufl2-cwl/src/test/resources/simple_string_input.cwl
@@ -0,0 +1,2 @@
+inputs:
+  example_string: string
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/4d324890/taverna-scufl2-cwl/src/test/resources/worklflow2.cwl
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/test/resources/worklflow2.cwl b/taverna-scufl2-cwl/src/test/resources/worklflow2.cwl
new file mode 100644
index 0000000..43f164c
--- /dev/null
+++ b/taverna-scufl2-cwl/src/test/resources/worklflow2.cwl
@@ -0,0 +1,27 @@
+#!/usr/bin/env cwl-runner
+cwlVersion: v1.0
+class: Workflow
+
+inputs:
+  message: string
+
+outputs:
+  download:
+    type: File
+    outputSource:  "#step1/curl"
+
+steps:
+  step1:
+    run:
+      class: CommandLineTool
+      baseCommand: echo
+      inputs:
+        text:
+          type: string
+          inputBinding:
+            position: 1
+      outputs: []
+    in:
+      text: message
+
+    out: [curl]


[09/13] incubator-taverna-language git commit: Add main parser that parses the structure of a CWL workflow

Posted by st...@apache.org.
Add main parser that parses the structure of a CWL workflow


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/commit/4ee2f5bc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/4ee2f5bc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/4ee2f5bc

Branch: refs/heads/cwlparser
Commit: 4ee2f5bc021c236aea248b0917a57d00b4d6ae66
Parents: 881a409
Author: Majdi Haouech <m....@criteo.com>
Authored: Mon Jun 11 16:52:26 2018 +0200
Committer: Majdi Haouech <m....@criteo.com>
Committed: Mon Jun 11 16:52:26 2018 +0200

----------------------------------------------------------------------
 .../taverna/scufl2/cwl/WorkflowParser.java      | 232 +++++++++++++++++++
 .../scufl2/cwl/components/PortDetail.java       |  12 +-
 2 files changed, 243 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/4ee2f5bc/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/WorkflowParser.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/WorkflowParser.java b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/WorkflowParser.java
new file mode 100644
index 0000000..f0f6b2a
--- /dev/null
+++ b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/WorkflowParser.java
@@ -0,0 +1,232 @@
+/*
+ * 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.taverna.scufl2.cwl;
+
+import java.io.*;
+import java.util.*;
+
+import java.lang.NullPointerException;
+
+import org.yaml.snakeyaml.Yaml;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.core.Processor;
+import org.apache.taverna.scufl2.api.core.DataLink;
+
+import org.apache.taverna.scufl2.api.port.InputWorkflowPort;
+import org.apache.taverna.scufl2.api.port.OutputWorkflowPort;
+import org.apache.taverna.scufl2.api.port.InputProcessorPort;
+import org.apache.taverna.scufl2.api.port.OutputProcessorPort;
+import org.apache.taverna.scufl2.api.port.SenderPort;
+import org.apache.taverna.scufl2.api.port.ReceiverPort;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+
+import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
+import org.apache.taverna.scufl2.api.io.WriterException;
+
+public class WorkflowParser {
+
+    private static final String FILE_NAME = "/hello_world.cwl";
+    private CWLParser cwlParser;
+    private Converter converter;
+
+    private Map<String, InputWorkflowPort> workflowInputs;
+    private Map<String, OutputWorkflowPort> workflowOutputs;
+    private Map<String, Processor> workflowProcessors;
+    private Map<String, InputProcessorPort> processorInputs;
+    private Map<String, OutputProcessorPort> processorOutputs;
+    private Set<DataLink> dataLinks;
+
+    public WorkflowParser() {
+        Yaml reader = new Yaml();
+        ObjectMapper mapper = new ObjectMapper();
+        JsonNode cwlFile = mapper.valueToTree(reader.load(WorkflowParser.class.getResourceAsStream(FILE_NAME)));
+        this.cwlParser = new CWLParser(cwlFile);
+        this.converter = new Converter();
+    }
+
+    public WorkflowParser(JsonNode cwlFile) {
+        this.cwlParser = new CWLParser(cwlFile);
+        this.converter = new Converter();
+        workflowInputs = new HashMap<>();
+        workflowOutputs = new HashMap<>();
+        workflowProcessors = new HashMap<>();
+        processorInputs = new HashMap<>();
+        processorOutputs = new HashMap<>();
+        dataLinks = new HashSet<DataLink>();
+    }
+
+    public Workflow buildWorkflow() {
+        parseInputs();
+        parseOutputs();
+        Set<Step> cwlSteps = cwlParser.parseSteps();
+        parseProcessors(cwlSteps);
+        parseDataLinks(cwlSteps);
+
+        Workflow workflow = new Workflow();
+        Set<InputWorkflowPort> inputs = new HashSet<>(workflowInputs.values());
+        Set<OutputWorkflowPort> outputs = new HashSet<>(workflowOutputs.values());
+        Set<Processor> processors = new HashSet<>(workflowProcessors.values());
+
+        workflow.setInputPorts(inputs);
+        workflow.setOutputPorts(outputs);
+        workflow.setProcessors(processors);
+        workflow.setDataLinks(dataLinks);
+
+//        writeWorkflowToFile(workflow);
+
+        return workflow;
+    }
+
+    public void writeWorkflowToFile(Workflow workflow) {
+        try {
+            WorkflowBundleIO io = new WorkflowBundleIO();
+            File scufl2File = new File("workflow.wfbundle");
+            WorkflowBundle bundle = io.createBundle();
+            Set<Workflow> workflowSet = new HashSet<>();
+            workflowSet.add(workflow);
+            bundle.setWorkflows(workflowSet);
+            bundle.setMainWorkflow(workflow);
+            io.writeBundle(bundle, scufl2File, "application/vnd.taverna.scufl2.workflow-bundle");
+        } catch(WriterException e) {
+            System.out.println("Exception writing the workflow bundle");
+        } catch(IOException e) {
+            System.out.println("IOException");
+        }
+    }
+
+    public void parseInputs() {
+        Set<PortDetail> cwlInputs = cwlParser.parseInputs();
+        if(cwlInputs != null) {
+            for (PortDetail port : cwlInputs) {
+                String portId = port.getId();
+                InputWorkflowPort workflowPort = converter.convertInputWorkflowPort(port);
+                workflowInputs.put(portId, workflowPort);
+            }
+        }
+    }
+
+    public void parseOutputs() {
+        Set<PortDetail> cwlOutputs = cwlParser.parseOutputs();
+        for(PortDetail port: cwlOutputs) {
+            String portId = port.getId();
+            OutputWorkflowPort workflowPort = converter.convertOutputWorkflowPort(port);
+            workflowOutputs.put(portId, workflowPort);
+        }
+    }
+
+    public void parseProcessors(Set<Step> cwlSteps) {
+        for(Step step: cwlSteps) {
+            Processor processor = converter.convertStepToProcessor(step);
+            workflowProcessors.put(step.getId(), processor);
+
+            DataLink datalink = new DataLink();
+            for(StepInput stepInput: step.getInputs()) {
+                InputProcessorPort processorPort = new InputProcessorPort(processor, stepInput.getId());
+                processorInputs.put(stepInput.getId(), processorPort);
+            }
+            for(StepOutput stepOutput: step.getOutputs()) {
+                OutputProcessorPort processorPort = new OutputProcessorPort(processor, stepOutput.getId());
+                processorOutputs.put(stepOutput.getId(), processorPort);
+            }
+        }
+    }
+
+    public void parseDataLinks(Set<Step> cwlSteps) {
+        for(Step step: cwlSteps) {
+            for(StepInput stepInput: step.getInputs()) {
+                String[] sourcePath = stepInput.getSource().split("/");
+                String source = sourcePath[sourcePath.length-1];
+                source = source.replace("#", "");
+
+                DataLink dataLink = new DataLink();
+                SenderPort sender = workflowInputs.get(source);
+                if(sender == null) {
+                    sender = processorOutputs.get(source);
+                }
+                if(sender == null) {
+                    throw new NullPointerException("Cannot find sender port with name: " + source);
+                }
+                String receiverId = stepInput.getId();
+                ReceiverPort receiver = workflowOutputs.get(receiverId);
+                if(receiver == null) {
+                    receiver = processorInputs.get(receiverId);
+                }
+                if(receiver == null) {
+                    throw new NullPointerException("Cannot find receiver port with name: " + receiverId);
+                }
+                dataLink.setSendsTo(receiver);
+                dataLink.setReceivesFrom(sender);
+                dataLinks.add(dataLink);
+            }
+        }
+    }
+
+    public Map<String, InputWorkflowPort> getWorkflowInputs() {
+        return workflowInputs;
+    }
+
+    public void setWorkflowInputs(Map<String, InputWorkflowPort> workflowInputs) {
+        this.workflowInputs = workflowInputs;
+    }
+
+    public Map<String, OutputWorkflowPort> getWorkflowOutputs() {
+        return workflowOutputs;
+    }
+
+    public void setWorkflowOutputs(Map<String, OutputWorkflowPort> workflowOutputs) {
+        this.workflowOutputs = workflowOutputs;
+    }
+
+    public Map<String, Processor> getWorkflowProcessors() {
+        return workflowProcessors;
+    }
+
+    public void setWorkflowProcessors(Map<String, Processor> workflowProcessors) {
+        this.workflowProcessors = workflowProcessors;
+    }
+
+    public Map<String, InputProcessorPort> getProcessorInputs() {
+        return processorInputs;
+    }
+
+    public void setProcessorInputs(Map<String, InputProcessorPort> processorInputs) {
+        this.processorInputs = processorInputs;
+    }
+
+    public Map<String, OutputProcessorPort> getProcessorOutputs() {
+        return processorOutputs;
+    }
+
+    public void setProcessorOutputs(Map<String, OutputProcessorPort> processorOutputs) {
+        this.processorOutputs = processorOutputs;
+    }
+
+    public Set<DataLink> getDataLinks() {
+        return dataLinks;
+    }
+
+    public void setDataLinks(Set<DataLink> dataLinks) {
+        this.dataLinks = dataLinks;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/4ee2f5bc/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/PortDetail.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/PortDetail.java b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/PortDetail.java
index 563c76f..53604e7 100644
--- a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/PortDetail.java
+++ b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/PortDetail.java
@@ -25,11 +25,21 @@ import java.util.ArrayList;
 public class PortDetail {
 
 
-    private String label;
 
+    private String id;
+    private String label;
     private int depth;
     private String description;
     private ArrayList<String> format;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
     public int getDepth() {
         return depth;
     }


[12/13] incubator-taverna-language git commit: Fix test equality for ports and add Apache header

Posted by st...@apache.org.
Fix test equality for ports and add Apache header


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/commit/d39a8a2f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/d39a8a2f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/d39a8a2f

Branch: refs/heads/cwlparser
Commit: d39a8a2fa3f4137458b247a8d37989af47c3d72a
Parents: 289583c
Author: Majdi Haouech <m....@criteo.com>
Authored: Fri Jun 22 12:39:54 2018 +0200
Committer: Majdi Haouech <m....@criteo.com>
Committed: Fri Jun 22 12:42:31 2018 +0200

----------------------------------------------------------------------
 .../apache/taverna/scufl2/cwl/TestParser.java   | 38 ++++++++++++++++----
 .../src/test/resources/1st-tool.cwl             | 16 +++++++++
 .../src/test/resources/hello_world.cwl          | 18 ++++++++++
 .../src/test/resources/int_input.cwl            | 16 +++++++++
 .../src/test/resources/simple_string_input.cwl  | 16 +++++++++
 .../src/test/resources/worklflow2.cwl           | 17 +++++++++
 6 files changed, 114 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/d39a8a2f/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java b/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
index 89c81ba..4e3e69e 100644
--- a/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
+++ b/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
@@ -1,3 +1,21 @@
+/*
+ * 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.taverna.scufl2.cwl;
 
 
@@ -48,9 +66,12 @@ public class TestParser {
     @Test
     public void testParseInputs() throws Exception {
 
+        workflow.setParent(null);
         NamedSet<InputWorkflowPort> workflowInputs = workflow.getInputPorts();
-        NamedSet<InputWorkflowPort> expectedInputs = new NamedSet<>();
-        expectedInputs.add(new InputWorkflowPort(workflow, "name"));
+
+        Workflow expectedWorkflow = new Workflow(workflow.getName());
+        NamedSet<InputWorkflowPort> expectedInputs = expectedWorkflow.getInputPorts();
+        expectedInputs.add(new InputWorkflowPort(expectedWorkflow, "name"));
 
         assertEquals(expectedInputs, workflowInputs);
     }
@@ -67,9 +88,12 @@ public class TestParser {
     @Test
     public void testParseProcessors() throws Exception {
 
+        workflow.setParent(null);
         NamedSet<Processor> workflowProcessors = workflow.getProcessors();
-        NamedSet<Processor> expectedProcessors = new NamedSet<>();
-        expectedProcessors.add(new Processor(workflow, "step1"));
+
+        Workflow expectedWorkflow = new Workflow(workflow.getName());
+        NamedSet<Processor> expectedProcessors = expectedWorkflow.getProcessors();
+        expectedProcessors.add(new Processor(expectedWorkflow, "step1"));
 
         assertEquals(expectedProcessors, workflowProcessors);
     }
@@ -79,10 +103,9 @@ public class TestParser {
 
         Set<DataLink> workflowDataLinks = workflow.getDataLinks();
         Set<DataLink> expectedDataLinks = new HashSet<>();
-        Set<Processor> processorSet = workflow.getProcessors();
+        NamedSet<Processor> processorSet = workflow.getProcessors();
         // processorSet has one processor
-        Processor processor = processorSet.iterator().next();
-
+        Processor processor = processorSet.getByName("step1");
         expectedDataLinks.add(
                 new DataLink(
                         workflow,
@@ -91,6 +114,7 @@ public class TestParser {
                 )
         );
 
+        assertEquals(1, workflowDataLinks.size());
         assertEquals(expectedDataLinks, workflowDataLinks);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/d39a8a2f/taverna-scufl2-cwl/src/test/resources/1st-tool.cwl
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/test/resources/1st-tool.cwl b/taverna-scufl2-cwl/src/test/resources/1st-tool.cwl
index e292134..be272f2 100644
--- a/taverna-scufl2-cwl/src/test/resources/1st-tool.cwl
+++ b/taverna-scufl2-cwl/src/test/resources/1st-tool.cwl
@@ -1,3 +1,19 @@
+#  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.
 cwlVersion: v1.0
 class: CommandLineTool
 baseCommand: echo

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/d39a8a2f/taverna-scufl2-cwl/src/test/resources/hello_world.cwl
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/test/resources/hello_world.cwl b/taverna-scufl2-cwl/src/test/resources/hello_world.cwl
index d716812..2172578 100644
--- a/taverna-scufl2-cwl/src/test/resources/hello_world.cwl
+++ b/taverna-scufl2-cwl/src/test/resources/hello_world.cwl
@@ -1,4 +1,22 @@
 #!/usr/bin/env cwl-runner
+
+#  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.
+
 cwlVersion: v1.0
 class: Workflow
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/d39a8a2f/taverna-scufl2-cwl/src/test/resources/int_input.cwl
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/test/resources/int_input.cwl b/taverna-scufl2-cwl/src/test/resources/int_input.cwl
index ffb79e6..f2041da 100644
--- a/taverna-scufl2-cwl/src/test/resources/int_input.cwl
+++ b/taverna-scufl2-cwl/src/test/resources/int_input.cwl
@@ -1,3 +1,19 @@
+#  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.
 inputs:
   example_int:
     type: int

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/d39a8a2f/taverna-scufl2-cwl/src/test/resources/simple_string_input.cwl
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/test/resources/simple_string_input.cwl b/taverna-scufl2-cwl/src/test/resources/simple_string_input.cwl
index b474f9d..059338f 100644
--- a/taverna-scufl2-cwl/src/test/resources/simple_string_input.cwl
+++ b/taverna-scufl2-cwl/src/test/resources/simple_string_input.cwl
@@ -1,3 +1,19 @@
+#  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.
 inputs:
   example_string: string
 steps:

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/d39a8a2f/taverna-scufl2-cwl/src/test/resources/worklflow2.cwl
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/test/resources/worklflow2.cwl b/taverna-scufl2-cwl/src/test/resources/worklflow2.cwl
index 43f164c..fc5e846 100644
--- a/taverna-scufl2-cwl/src/test/resources/worklflow2.cwl
+++ b/taverna-scufl2-cwl/src/test/resources/worklflow2.cwl
@@ -1,4 +1,21 @@
 #!/usr/bin/env cwl-runner
+
+#  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.
 cwlVersion: v1.0
 class: Workflow
 


[11/13] incubator-taverna-language git commit: Fix wild card imports

Posted by st...@apache.org.
Fix wild card imports


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/commit/289583c8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/289583c8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/289583c8

Branch: refs/heads/cwlparser
Commit: 289583c8e692d7531ca853a354eaeb6be0948c15
Parents: 62c3615
Author: Majdi Haouech <m....@criteo.com>
Authored: Mon Jun 11 17:01:24 2018 +0200
Committer: Majdi Haouech <m....@criteo.com>
Committed: Mon Jun 11 17:01:24 2018 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/taverna/scufl2/cwl/CWLParser.java   | 4 +++-
 .../main/java/org/apache/taverna/scufl2/cwl/Converter.java   | 3 ++-
 .../java/org/apache/taverna/scufl2/cwl/WorkflowParser.java   | 8 ++++++--
 .../test/java/org/apache/taverna/scufl2/cwl/TestParser.java  | 3 ++-
 4 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/289583c8/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/CWLParser.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/CWLParser.java b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/CWLParser.java
index a2007ad..5a4d6cf 100644
--- a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/CWLParser.java
+++ b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/CWLParser.java
@@ -18,7 +18,9 @@
  */
 package org.apache.taverna.scufl2.cwl;
 
-import java.util.*;
+import java.util.Map;
+import java.util.Set;
+import java.util.HashSet;
 
 import org.apache.taverna.scufl2.api.core.Workflow;
 import org.apache.taverna.scufl2.api.core.Processor;

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/289583c8/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Converter.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Converter.java b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Converter.java
index 8be949a..7ddf9de 100644
--- a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Converter.java
+++ b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Converter.java
@@ -18,7 +18,8 @@
  */
 package org.apache.taverna.scufl2.cwl;
 
-import java.util.*;
+import java.util.Set;
+import java.util.HashSet;
 
 import org.apache.taverna.scufl2.api.core.Workflow;
 import org.apache.taverna.scufl2.api.core.Processor;

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/289583c8/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/WorkflowParser.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/WorkflowParser.java b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/WorkflowParser.java
index f0f6b2a..0b6c095 100644
--- a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/WorkflowParser.java
+++ b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/WorkflowParser.java
@@ -18,8 +18,12 @@
  */
 package org.apache.taverna.scufl2.cwl;
 
-import java.io.*;
-import java.util.*;
+import java.io.File;
+import java.io.IOException;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.HashSet;
 
 import java.lang.NullPointerException;
 

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/289583c8/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java b/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
index 23b9533..89c81ba 100644
--- a/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
+++ b/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
@@ -1,7 +1,8 @@
 package org.apache.taverna.scufl2.cwl;
 
 
-import java.util.*;
+import java.util.Set;
+import java.util.HashSet;
 
 import org.junit.Before;
 import org.junit.Test;


[07/13] incubator-taverna-language git commit: Add dummy test and workflow example

Posted by st...@apache.org.
Add dummy test and workflow example


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/commit/ee6b282e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/ee6b282e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/ee6b282e

Branch: refs/heads/cwlparser
Commit: ee6b282edad17a1095af7a3c6a885c383ca71ee5
Parents: ba29413
Author: Majdi Haouech <m....@criteo.com>
Authored: Mon Jun 4 10:38:37 2018 +0100
Committer: Majdi Haouech <m....@criteo.com>
Committed: Mon Jun 4 10:38:37 2018 +0100

----------------------------------------------------------------------
 .../apache/taverna/scufl2/cwl/TestParser.java   | 97 +++++++-------------
 .../src/test/resources/simple_string_input.cwl  |  5 +-
 2 files changed, 37 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/ee6b282e/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java b/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
index 01b5bc2..83c48e1 100644
--- a/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
+++ b/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
@@ -1,84 +1,53 @@
 package org.apache.taverna.scufl2.cwl;
 
-import java.io.*;
-import java.util.ArrayList;
+
+import java.util.*;
 
 import org.junit.Test;
 import static org.junit.Assert.assertEquals;
-import org.apache.commons.io.FileUtils;
-
-import org.apache.taverna.scufl2.cwl.Parser;
-import org.apache.taverna.scufl2.cwl.InputField;
-
-public class TestParser {
-
-    private static final String SIMPLE_STRING_INPUT = "/simple_string_input.cwl";
-    private static final String INT_INPUT = "/int_input.cwl";
-
-    @Test
-    public void testGetDepth() throws Exception {
-
-        assert Parser.getDepth("  test") == 1;
-        assert Parser.getDepth("test") == 0;
-        assert Parser.getDepth("    test") == 2;
-    }
-
-    @Test
-    public void testGetKey() throws Exception {
 
-        assert Parser.getKeyFromLine("  test: test_value").equals("test");
-        assert Parser.getKeyFromLine("test: 1 ").equals("test");
-        assert Parser.getKeyFromLine("    test:").equals("test");
-    }
+import org.yaml.snakeyaml.Yaml;
 
-    @Test
-    public void testGetValue() throws Exception {
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
 
-        assert Parser.getValueFromLine("  test: test_value").equals("test_value");
-        assert Parser.getValueFromLine("test: 1 ").equals("1");
-        assert Parser.getValueFromLine("    test:").equals("");
-    }
+import org.apache.taverna.scufl2.api.port.InputWorkflowPort;
+import org.apache.taverna.scufl2.api.port.OutputWorkflowPort;
 
-    @Test
-    public void testSimpleInput() throws Exception {
-        File yaml = FileUtils.getFile("src", "test", "resources", SIMPLE_STRING_INPUT);
 
-        Parser parser = new Parser(yaml);
-
-        ArrayList<InputField> inputs = parser.parseInputs();
+public class TestParser {
+    private static final String SIMPLE_STRING_INPUT = "/simple_string_input.cwl";
+    private static final String INT_INPUT = "/int_input.cwl";
 
-        assertEquals(1, inputs.size());
-        assertEquals("example_string", inputs.get(0).key);
-    }
+    private static JsonNode cwlFile;
 
     @Test
-    public void testIntInput() throws Exception {
-        File yaml = FileUtils.getFile("src", "test", "resources", INT_INPUT);
-
-        Parser parser = new Parser(yaml);
+    public void testStringInput() throws Exception {
 
-        ArrayList<InputField> inputs = parser.parseInputs();
+        Yaml reader = new Yaml();
+        ObjectMapper mapper = new ObjectMapper();
+        cwlFile = mapper.valueToTree(reader.load(TestParser.class.getResourceAsStream(SIMPLE_STRING_INPUT)));
+        System.out.println(cwlFile);
+        Parser parser = new Parser(cwlFile);
 
-        assertEquals(1, inputs.size());
-        assertEquals("example_int", inputs.get(0).key);
-        assertEquals("int", inputs.get(0).type);
-        assertEquals(2, inputs.get(0).position);
-        assertEquals("-i", inputs.get(0).prefix);
-    }
+        Set<InputWorkflowPort> result = parser.parseInputs();
+        for(InputWorkflowPort port: result) {
+            System.out.println(port.getName());
+        }
+        ArrayList<InputWorkflowPort> inputs = new ArrayList<>(result);
+        assertEquals(inputs.get(0).getName(), "example_string");
 
-    void printFile(File yaml) throws Exception {
-        /**
-         * Print file
-         */
-        FileReader fdesc = new FileReader(yaml);
-        BufferedReader bufferedReader = new BufferedReader(fdesc);
-        String yamlLine;
-        while((yamlLine = bufferedReader.readLine()) != null) {
-            System.out.println(yamlLine);
+        Set<OutputWorkflowPort> result2 = parser.parseOutputs();
+        for(OutputWorkflowPort port: result2) {
+            System.out.println(port.getName());
         }
+        System.out.println("Showing steps:");
 
-        System.out.println("*************************");
-        bufferedReader.close();
-        /*****/
+        Set<Step> steps = parser.parseSteps();
+        for(Step step: steps) {
+            System.out.println(step);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/ee6b282e/taverna-scufl2-cwl/src/test/resources/simple_string_input.cwl
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/test/resources/simple_string_input.cwl b/taverna-scufl2-cwl/src/test/resources/simple_string_input.cwl
index c075b22..b474f9d 100644
--- a/taverna-scufl2-cwl/src/test/resources/simple_string_input.cwl
+++ b/taverna-scufl2-cwl/src/test/resources/simple_string_input.cwl
@@ -1,2 +1,5 @@
 inputs:
-  example_string: string
\ No newline at end of file
+  example_string: string
+steps:
+  step1:
+    run: run1
\ No newline at end of file


[02/13] incubator-taverna-language git commit: Add helper functions

Posted by st...@apache.org.
Add helper functions


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/commit/252e3d8b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/252e3d8b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/252e3d8b

Branch: refs/heads/cwlparser
Commit: 252e3d8b11914b16a8212ef86d1cf435017209fe
Parents: 3091092
Author: Majdi Haouech <m....@criteo.com>
Authored: Mon May 21 15:29:02 2018 +0200
Committer: Majdi Haouech <m....@criteo.com>
Committed: Mon May 21 15:29:38 2018 +0200

----------------------------------------------------------------------
 .../org/apache/taverna/scufl2/cwl/Parser.java   | 79 ++++++++++++++++++++
 1 file changed, 79 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/252e3d8b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
index 544d3d4..8cc6655 100644
--- a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
+++ b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
@@ -6,6 +6,44 @@ import java.util.HashMap;
 import java.util.Map;
 
 
+
+class InputField {
+
+    public String key;
+    public String type;
+    public int position;
+    public String prefix;
+
+    public InputField(String _key) {
+        key = _key;
+        type = "";
+        position = -1;
+        prefix = "";
+    }
+
+    public InputField(String _key, String _type) {
+        key = _key;
+        type = _type;
+        position = -1;
+        prefix = "";
+    }
+
+    public InputField(String _key, String _type, int pos) {
+        key = _key;
+        type = _type;
+        position = pos;
+        prefix = "";
+    }
+
+    public InputField(String _key, String _type, int pos, String _prefix) {
+        key = _key;
+        type = _type;
+        position = pos;
+        prefix = _prefix;
+    }
+}
+
+
 public class Parser {
 
     private String yamlLine;
@@ -38,4 +76,45 @@ public class Parser {
             System.err.println("Parser init error: " + e );
         }
     }
+
+
+
+
+    private int getNextLineIndex(int index) {
+        index++;
+
+        while(yamlFile.get(index).equals("")) {
+            index++;
+        }
+
+        return index;
+    }
+
+    public static int getDepth(String line) {
+        int count = 0;
+        int idx = 0;
+        while(idx < line.length()) {
+            if(line.charAt(idx) != ' ') {
+                break;
+            }
+            count++;
+            idx++;
+        }
+        assert count % 2 == 0;
+        return count / 2;
+    }
+
+    public static String getKeyFromLine(String line) {
+        int commaIndex = line.indexOf(':');
+        assert commaIndex != -1;
+
+        return line.substring(0, commaIndex).trim();
+    }
+
+    public static String getValueFromLine(String line) {
+        int commaIndex = line.indexOf(':');
+        assert commaIndex != -1;
+
+        return line.substring(commaIndex + 1).trim();
+    }
 }


[05/13] incubator-taverna-language git commit: Add CWL Parser, import helper from common activities

Posted by st...@apache.org.
Add CWL Parser, import helper from common activities


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/commit/6d6dc200
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/6d6dc200
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/6d6dc200

Branch: refs/heads/cwlparser
Commit: 6d6dc20086ca9b8e0f1c0ff0eccd9b58b936e452
Parents: ecc3b67
Author: Majdi Haouech <m....@criteo.com>
Authored: Mon Jun 4 10:33:46 2018 +0100
Committer: Majdi Haouech <m....@criteo.com>
Committed: Mon Jun 4 10:33:46 2018 +0100

----------------------------------------------------------------------
 .../org/apache/taverna/scufl2/cwl/Parser.java   | 262 ++++------
 .../apache/taverna/scufl2/cwl/YAMLHelper.java   | 484 +++++++++++++++++++
 2 files changed, 566 insertions(+), 180 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/6d6dc200/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
index 65844b9..c0ef438 100644
--- a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
+++ b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/Parser.java
@@ -1,212 +1,114 @@
+/*
+ * 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.taverna.scufl2.cwl;
 
-import java.io.*;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
 
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.core.Processor;
 
+import org.apache.taverna.scufl2.api.port.InputWorkflowPort;
+import org.apache.taverna.scufl2.api.port.OutputWorkflowPort;
+import org.apache.taverna.scufl2.api.port.InputProcessorPort;
+import org.apache.taverna.scufl2.api.port.OutputProcessorPort;
 
-class InputField {
+import com.fasterxml.jackson.databind.JsonNode;
 
-    public String key;
-    public String type;
-    public int position;
-    public String prefix;
-
-    public InputField(String _key) {
-        key = _key;
-        type = "";
-        position = -1;
-        prefix = "";
-    }
+public class Parser {
 
-    public InputField(String _key, String _type) {
-        key = _key;
-        type = _type;
-        position = -1;
-        prefix = "";
-    }
+    private JsonNode cwlFile;
+    private YAMLHelper yamlHelper;
+    private Workflow workflow;
 
-    public InputField(String _key, String _type, int pos) {
-        key = _key;
-        type = _type;
-        position = pos;
-        prefix = "";
+    public Parser(JsonNode cwlFile) {
+        this.cwlFile = cwlFile;
+        this.yamlHelper = new YAMLHelper();
+        this.workflow = new Workflow();
+        this.workflow.setInputPorts(parseInputs());
+        this.workflow.setOutputPorts(parseOutputs());
     }
 
-    public InputField(String _key, String _type, int pos, String _prefix) {
-        key = _key;
-        type = _type;
-        position = pos;
-        prefix = _prefix;
+    public Workflow getWorkflow() {
+        return this.workflow;
     }
-}
-
-
-public class Parser {
-
-    private String yamlLine;
-    private int fileLength;
-
-    private Map<Integer, String> yamlFile = null;
-
-    public Parser(File file) {
-        int counter = 0;
-
-        yamlFile = new HashMap<>();
-
-        FileReader yamlFileDescriptor = null;
-
 
-        try {
-            yamlFileDescriptor = new FileReader(file);
-            BufferedReader bufferedReader = new BufferedReader(yamlFileDescriptor);
-            String parent = null;
-            int parentDepth = 0;
-            while((yamlLine = bufferedReader.readLine()) != null) {
-
-                yamlFile.put(counter, yamlLine);
-                counter = counter + 1;
-            }
-
-            bufferedReader.close();
-            fileLength = counter;
-        } catch (IOException e) {
-            System.err.println("Parser init error: " + e );
-        }
+    public Set<Step> parseSteps() {
+        return yamlHelper.processSteps(cwlFile);
     }
 
-    public ArrayList<InputField> parseInputs() {
-        int startIndex = 0;
-        int endIndex = -1;
-        int depth = -1;
-
-        /**
-         * Search for start and end of inputs section
-         */
-        for(Map.Entry<Integer, String> entry: yamlFile.entrySet()) {
-            int index = entry.getKey();
-            String line = entry.getValue();
-            String key = getKeyFromLine(line);
-            if(key.equals("inputs")) {
-                startIndex = index;
-                endIndex = index;
-                depth = getDepth(line);
-            } else if(!line.equals("") && getDepth(line) <= depth) {
-                break;
-            } else {
-                endIndex++;
-            }
+    public Processor convertStepToProcessor(Step step) {
+        Processor processor = new Processor(null, step.getId());
+        // Convert input ports
+        Set<InputProcessorPort> processorInputs = new HashSet<>();
+        Set<StepInput> inputs = step.getInputs();
+        for(StepInput input: inputs) {
+            InputProcessorPort port = new InputProcessorPort(processor, input.getId());
+            processorInputs.add(port);
         }
-        /**
-         * Parse each input
-         */
-        ArrayList<InputField> result = new ArrayList<>();
-        for(int i = startIndex+1; i <= endIndex; i++) {
-            int curDepth = getDepth(yamlFile.get(i));
-            // If current element is a child of inputs key
-            if(curDepth == depth + 1) {
-                result.add(parseInputField(i));
-            }
+        processor.setInputPorts(processorInputs);
+        // Convert output ports
+        Set<OutputProcessorPort> processorOutputs = new HashSet<>();
+        Set<StepOutput> outputs = step.getOutputs();
+        for(StepOutput output: outputs) {
+            OutputProcessorPort port = new OutputProcessorPort(processor, output.getId());
+            processorOutputs.add(port);
         }
+        processor.setOutputPorts(processorOutputs);
 
-        return result;
+        return processor;
     }
 
-    public InputField parseInputField(int startIndex) {
-        String line = yamlFile.get(startIndex);
-        int depth = getDepth(line);
-        String id = getKeyFromLine(line);
-        String value = getValueFromLine(line);
+    public Set<InputWorkflowPort> parseInputs() {
+        Map<String, PortDetail> inputs = yamlHelper.processInputDetails(cwlFile);
+        Map<String, Integer> inputDepths = yamlHelper.processInputDepths(cwlFile);
 
-        if(!value.equals("")) {
-            return new InputField(id, value);
+        if(inputs == null || inputDepths == null) {
+            return null;
         }
-
-        InputField field = new InputField(id);
-        for(int i = startIndex+1; i < length; i++) {
-            String curLine = yamlFile.get(i);
-            if(curLine.equals("")) {
-                // Ignore empty lines
-                continue;
-            }
-            if(getDepth(curLine) <= depth) {
-                // Out of input section
-                break;
-            }
-            String key = getKeyFromLine(curLine);
-            value = getValueFromLine(curLine);
-
-            if(key.trim().equals("type")) {
-                field.type = value;
-            } else if(key.trim().equals("inputBinding")) {
-                
-                int curDepth = getDepth(curLine);
-                int nextIndex = getNextLineIndex(i);
-                String nextLine = yamlFile.get(nextIndex);
-                String nextKey = getKeyFromLine(nextLine);
-                String nextValue = getValueFromLine(nextLine);
-
-                if(nextKey.equals("position")){
-                    field.position = Integer.parseInt(nextValue);
-                } else if(nextKey.equals("prefix")){
-                    field.prefix = nextValue;
-                }
-
-                // Check if we have another inputBinding property
-                nextIndex = getNextLineIndex(nextIndex);
-                nextLine = yamlFile.get(nextIndex);
-                if(getDepth(nextLine) == curDepth + 1) {
-                    nextKey = getKeyFromLine(nextLine);
-                    nextValue = getValueFromLine(nextLine);
-                    if(nextKey.equals("position")){
-                        field.position = Integer.parseInt(nextValue);
-                    } else if(nextKey.equals("prefix")){
-                        field.prefix = nextValue.trim();
-                    }
-                }
-            }
+        Set<InputWorkflowPort> result = new HashSet<InputWorkflowPort>();
+        for(String id: inputs.keySet()) {
+            PortDetail detail = inputs.get(id);
+            int depth = inputDepths.get(id);
+            InputWorkflowPort port = new InputWorkflowPort();
+            port.setName(id);
+            port.setDepth(depth);
+            result.add(port);
         }
 
-        return field;
+        return result;
     }
 
-    private int getNextLineIndex(int index) {
-        index++;
+    public Set<OutputWorkflowPort> parseOutputs() {
+        Map<String, PortDetail> inputs = yamlHelper.processOutputDetails(cwlFile);
 
-        while(yamlFile.get(index).equals("")) {
-            index++;
+        if(inputs == null) {
+            return null;
         }
-
-        return index;
-    }
-
-    public static int getDepth(String line) {
-        int count = 0;
-        int idx = 0;
-        while(idx < line.length()) {
-            if(line.charAt(idx) != ' ') {
-                break;
-            }
-            count++;
-            idx++;
+        Set<OutputWorkflowPort> result = new HashSet<OutputWorkflowPort>();
+        for(String id: inputs.keySet()) {
+            PortDetail detail = inputs.get(id);
+            OutputWorkflowPort port = new OutputWorkflowPort();
+            port.setName(id);
+            result.add(port);
         }
-        assert count % 2 == 0;
-        return count / 2;
-    }
-
-    public static String getKeyFromLine(String line) {
-        int commaIndex = line.indexOf(':');
-        assert commaIndex != -1;
 
-        return line.substring(0, commaIndex).trim();
+        return result;
     }
 
-    public static String getValueFromLine(String line) {
-        int commaIndex = line.indexOf(':');
-        assert commaIndex != -1;
-
-        return line.substring(commaIndex + 1).trim();
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/6d6dc200/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/YAMLHelper.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/YAMLHelper.java b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/YAMLHelper.java
new file mode 100644
index 0000000..dacdc4f
--- /dev/null
+++ b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/YAMLHelper.java
@@ -0,0 +1,484 @@
+/*
+ * 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.taverna.scufl2.cwl;
+
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.fasterxml.jackson.databind.node.TextNode;
+
+public class YAMLHelper {
+
+    public static final String ARRAY_SPLIT_BRACKETS = "\\[\\]";
+    public static final String ARRAY_SIGNATURE_BRACKETS = "\\[\\]$";
+    private static final String INPUTS = "inputs";
+    private static final String OUTPUTS = "outputs";
+    private static final String STEPS = "steps";
+    private static final String ID = "id";
+    private static final String TYPE = "type";
+    private static final String ARRAY = "array";
+    private static final String DESCRIPTION = "description";
+    private static final int DEPTH_0 = 0;
+    private static final int DEPTH_1 = 1;
+    private static final int DEPTH_2 = 2;
+
+    private static final String FLOAT = "float";
+    private static final String NULL = "null";
+    private static final String BOOLEAN = "boolean";
+    private static final String INT = "int";
+    private static final String DOUBLE = "double";
+    private static final String STRING = "string";
+    private static final String LABEL = "label";
+    private static final String FILE = "file";
+    private static final String DIRECTORY = "directory";
+    private static final String FORMAT = "format";
+    private static final String RUN = "run";
+    private static final String SOURCE = "source";
+
+    private JsonNode nameSpace;
+
+    public YAMLHelper() {
+        this.nameSpace = null;
+    }
+
+    public JsonNode getNameSpace() {
+        return nameSpace;
+    }
+
+    /**
+     * This method is processing the CWL NameSpace for later use such as
+     * figuring out the Format of a input or output
+     */
+    public void processNameSpace(JsonNode file) {
+
+        if (file != null && file.has("$namespaces")) {
+            nameSpace = file.path("$namespaces");
+        }
+
+    }
+
+    public Map<String, Integer> processInputDepths(JsonNode file) {
+        return process(file.get(INPUTS));
+    }
+
+    public Map<String, Integer> processOutputDepths(JsonNode file) {
+        return process(file.get(OUTPUTS));
+    }
+
+    public Map<String, PortDetail> processInputDetails(JsonNode file) {
+        return processdetails(file.get(INPUTS));
+    }
+
+    public Map<String, PortDetail> processOutputDetails(JsonNode file) {
+        return processdetails(file.get(OUTPUTS));
+    }
+
+    /**
+     *
+     */
+    public Set<Step> processSteps(JsonNode file) {
+        Set<Step> result = new HashSet<>();
+
+        if(file == null) {
+            return result;
+        }
+
+        if(file.has(STEPS)) {
+            JsonNode steps = file.get(STEPS);
+            if(steps.isArray()) {
+                for (JsonNode stepNode : steps) {
+                    Step step = new Step();
+                    String id = stepNode.get(ID).asText();
+
+                    String run = stepNode.get(RUN).asText();
+                    Set<StepInput> inputs = processStepInput(stepNode.get(INPUTS));
+                    step.setId(id);
+                    step.setRun(run);
+                    step.setInputs(inputs);
+                    result.add(step);
+                }
+            } else if(steps.isObject()) {
+                Iterator<Entry<String, JsonNode>> iterator = steps.fields();
+                while(iterator.hasNext()) {
+                    Entry<String, JsonNode> entry = iterator.next();
+                    Step step = new Step();
+
+                    String id = entry.getKey();
+                    JsonNode value = entry.getValue();
+                    if(value.has(RUN)) {
+                        String run = entry.getValue().get(RUN).asText();
+                        step.setRun(run);
+                    }
+                    Set<StepInput> inputs = processStepInput(value.get(INPUTS));
+                    step.setId(id);
+                    step.setInputs(inputs);
+
+                    result.add(step);
+                }
+            }
+        }
+
+        return result;
+    }
+
+    private Set<StepInput> processStepInput(JsonNode inputs) {
+
+        Set<StepInput> result = new HashSet<>();
+        if(inputs == null) {
+            return result;
+        }
+        if (inputs.getClass() == ArrayNode.class) {
+
+            for (JsonNode input : inputs) {
+                String id = input.get(ID).asText();
+                String source = input.get(SOURCE).asText();
+
+                result.add(new StepInput(id, source));
+            }
+        } else if (inputs.getClass() == ObjectNode.class) {
+            Iterator<Entry<String, JsonNode>> iterator = inputs.fields();
+            while (iterator.hasNext()) {
+                Entry<String, JsonNode> entry = iterator.next();
+
+                String id = entry.getKey();
+                String source = entry.getValue().get(SOURCE).asText();
+
+                result.add(new StepInput(id, source));
+            }
+        }
+        return result;
+    }
+
+    /**
+     * This method will go through CWL tool input or out puts and figure outs
+     * their IDs and the respective depths
+     *
+     * @param inputs
+     *            This is JsonNode object which contains the Inputs or outputs
+     *            of the respective CWL tool
+     * @return This the respective, ID and the depth of the input or output
+     */
+    public Map<String, Integer> process(JsonNode inputs) {
+
+        Map<String, Integer> result = new HashMap<>();
+
+        if (inputs == null)
+            return result;
+
+        if (inputs.getClass() == ArrayNode.class) {
+            Iterator<JsonNode> iterator = inputs.iterator();
+
+            while (iterator.hasNext()) {
+                JsonNode input = iterator.next();
+                String currentInputId = input.get(ID).asText();
+
+                JsonNode typeConfigurations;
+                try {
+
+                    typeConfigurations = input.get(TYPE);
+                    // if type :single argument
+                    if (typeConfigurations.getClass() == TextNode.class) {
+                        // inputs:
+                        /// -id: input_1
+                        //// type: int[]
+                        if (isValidArrayType(typeConfigurations.asText()))
+                            result.put(currentInputId, DEPTH_1);
+                            // inputs:
+                            /// -id: input_1
+                            //// type: int or int?
+                        else
+                            result.put(currentInputId, DEPTH_0);
+                        // type : defined as another map which contains type:
+                    } else if (typeConfigurations.getClass() == ObjectNode.class) {
+                        // inputs:
+                        /// -id: input_1
+                        //// type:
+                        ///// type: array or int[]
+                        String inputType = typeConfigurations.get(TYPE).asText();
+                        if (inputType.equals(ARRAY) || isValidArrayType(inputType)) {
+                            result.put(currentInputId, DEPTH_1);
+
+                        }
+                        // inputs:
+                        // -id: input_1
+                        // type:
+                        // type: ["null",int]
+                    } else if (typeConfigurations.getClass() == ArrayNode.class) {
+                        if (isValidDataType(typeConfigurations)) {
+                            result.put(currentInputId, DEPTH_0);
+                        }
+
+                    }
+
+                } catch (ClassCastException e) {
+
+                    System.out.println("Class cast exception !!!");
+                }
+
+            }
+        } else if (inputs.getClass() == ObjectNode.class) {
+
+            Iterator<Entry<String, JsonNode>> iterator = inputs.fields();
+
+            while (iterator.hasNext()) {
+                Entry<String, JsonNode> entry = iterator.next();
+                String currentInputId = entry.getKey();
+                JsonNode typeConfigurations = entry.getValue();
+
+                if (typeConfigurations.getClass() == TextNode.class) {
+                    if (typeConfigurations.asText().startsWith("$")) {
+                        System.out.println("Exception");
+                    }
+                    // inputs:
+                    /// input_1: int[]
+                    else if (isValidArrayType(typeConfigurations.asText()))
+                        result.put(currentInputId, DEPTH_1);
+                        // inputs:
+                        /// input_1: int or int?
+                    else
+                        result.put(currentInputId, DEPTH_0);
+
+                } else if (typeConfigurations.getClass() == ObjectNode.class) {
+
+                    if (typeConfigurations.has(TYPE)) {
+                        JsonNode inputType = typeConfigurations.get(TYPE);
+                        // inputs:
+                        /// input_1:
+                        //// type: [int,"null"]
+                        if (inputType.getClass() == ArrayNode.class) {
+                            if (isValidDataType(inputType))
+                                result.put(currentInputId, DEPTH_0);
+                        } else {
+                            // inputs:
+                            /// input_1:
+                            //// type: array or int[]
+                            if (inputType.asText().equals(ARRAY) || isValidArrayType(inputType.asText()))
+                                result.put(currentInputId, DEPTH_1);
+                                // inputs:
+                                /// input_1:
+                                //// type: int or int?
+                            else
+                                result.put(currentInputId, DEPTH_0);
+                        }
+                    }
+                }
+            }
+
+        }
+        return result;
+    }
+
+    /**
+     * This method is used for extracting details of the CWL tool inputs or
+     * outputs. ex:Label, Format, Description
+     *
+     * @param inputs
+     *            This is JsonNode object which contains the Inputs or outputs
+     *            of the respective CWL tool
+     * @return
+     */
+    private Map<String, PortDetail> processdetails(JsonNode inputs) {
+
+        Map<String, PortDetail> result = new HashMap<>();
+        if(inputs == null) {
+            return result;
+        }
+        if (inputs.getClass() == ArrayNode.class) {
+
+            for (JsonNode input : inputs) {
+                PortDetail detail = new PortDetail();
+                String currentInputId = input.get(ID).asText();
+
+                getParamDetails(result, input, detail, currentInputId);
+
+            }
+        } else if (inputs.getClass() == ObjectNode.class) {
+            Iterator<Entry<String, JsonNode>> iterator = inputs.fields();
+            while (iterator.hasNext()) {
+                PortDetail detail = new PortDetail();
+                Entry<String, JsonNode> entry = iterator.next();
+                getParamDetails(result, entry.getValue(), detail, entry.getKey());
+            }
+        }
+        return result;
+    }
+
+    private void getParamDetails(Map<String, PortDetail> result, JsonNode input, PortDetail detail,
+                                 String currentInputId) {
+        extractDescription(input, detail);
+
+        extractFormat(input, detail);
+
+        extractLabel(input, detail);
+
+        result.put(currentInputId, detail);
+    }
+
+    /**
+     * This method is used for extracting the Label of a CWL input or Output
+     *
+     * @param input
+     *            Single CWL input or output as a JsonNode
+     * @param detail
+     *            respective PortDetail Object to hold the extracted Label
+     */
+    public void extractLabel(JsonNode input, PortDetail detail) {
+        if (input != null)
+            if (input.has(LABEL)) {
+                detail.setLabel(input.get(LABEL).asText());
+            } else {
+                detail.setLabel(null);
+            }
+    }
+
+    /**
+     *
+     * @param input
+     *            Single CWL input or output as a JsonNode
+     * @param detail
+     *            respective PortDetail Object to hold the extracted Label
+     */
+    public void extractDescription(JsonNode input, PortDetail detail) {
+        if (input != null)
+            if (input.has(DESCRIPTION)) {
+                detail.setDescription(input.get(DESCRIPTION).asText());
+            } else {
+                detail.setDescription(null);
+            }
+    }
+
+    /**
+     * This method is used for extracting the Formats of a CWL input or Output
+     * Single argument(Input or Output) can have multiple Formats.
+     *
+     * @param input
+     *            Single CWL input or output as a JsonNode
+     * @param detail
+     *            respective PortDetail Object to hold the extracted Label
+     */
+    public void extractFormat(JsonNode input, PortDetail detail) {
+        if (input != null)
+            if (input.has(FORMAT)) {
+
+                JsonNode formatInfo = input.get(FORMAT);
+
+                ArrayList<String> format = new ArrayList<>();
+                detail.setFormat(format);
+
+                if (formatInfo.getClass() == TextNode.class) {
+
+                    figureOutFormats(formatInfo.asText(), detail);
+                } else if (formatInfo.getClass() == ArrayNode.class) {
+                    for (JsonNode eachFormat : formatInfo) {
+                        figureOutFormats(eachFormat.asText(), detail);
+                    }
+                }
+
+            }
+    }
+
+    /**
+     * Re Format the CWL format using the NameSpace in CWL Tool if possible
+     * otherwise it doesn't change the current nameSpace => edam:http://edam.org
+     * format : edam :1245 => http://edamontology.org/1245
+     *
+     * @param formatInfoString
+     *            Single Format
+     * @param detail
+     *            respective PortDetail Object to hold the extracted Label
+     */
+    public void figureOutFormats(String formatInfoString, PortDetail detail) {
+        if (formatInfoString.startsWith("$")) {
+
+            detail.addFormat(formatInfoString);
+        } else if (formatInfoString.contains(":")) {
+            String format[] = formatInfoString.split(":");
+            String namespaceKey = format[0];
+            String urlAppednd = format[1];
+
+            if (nameSpace.has(namespaceKey))
+                detail.addFormat(nameSpace.get(namespaceKey).asText() + urlAppednd);
+            else
+                // can't figure out the format
+                detail.addFormat(formatInfoString);
+
+        } else {
+            // can't figure out the format
+            detail.addFormat(formatInfoString);
+        }
+    }
+
+    /**
+     * This method is used to check whether the input/output is valid CWL TYPE
+     * when the type is represented as type: ["null","int"]
+     *
+     * @param typeConfigurations
+     *            Type of the CWl input or output
+     * @return
+     */
+    public boolean isValidDataType(JsonNode typeConfigurations) {
+        if (typeConfigurations == null)
+            return false;
+        for (JsonNode type : typeConfigurations) {
+            if (!(type.asText().equals(FLOAT) || type.asText().equals(NULL) || type.asText().equals(BOOLEAN)
+                    || type.asText().equals(INT) || type.asText().equals(STRING) || type.asText().equals(DOUBLE)
+                    || type.asText().equals(FILE)||type.asText().equals(DIRECTORY)))
+                return false;
+        }
+        return true;
+    }
+
+    /**
+     *
+     * This method is for figure out whether the parameter is an array or not.
+     * As from CWL document v1.0, array can be defined as "TYPE[]". For Example
+     * : int[] This method will look for "[]" sequence of characters in the end
+     * of the type and is provided type is a valid CWL TYPE or not
+     *
+     * @param type
+     *            type of the CWL parameter
+     * @return
+     */
+    public boolean isValidArrayType(String type) {
+        if (type == null)
+            return false;
+        Pattern pattern = Pattern.compile(ARRAY_SIGNATURE_BRACKETS);
+        Matcher matcher = pattern.matcher(type);
+        ObjectMapper mapper = new ObjectMapper();
+        ArrayNode node = mapper.createArrayNode();
+        node.add(type.split(ARRAY_SPLIT_BRACKETS)[0]);
+        if (matcher.find() && isValidDataType(node))
+            return true;
+        else
+            return false;
+    }
+}
\ No newline at end of file


[13/13] incubator-taverna-language git commit: Merge branch haouech:cwlparser (#38) into cwlparser

Posted by st...@apache.org.
Merge branch haouech:cwlparser (#38) into cwlparser

Contributed by Majdi Haouech @haouech
(ASF ICLA on file)

Add structural import for a CWL workflow to Apache Taverna.  The current
code parses the cwl file to extract inputs, outputs and steps of a
workflow, and then converts them to a Taverna workflow containing ports,
processors and data links.

This closes #38


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/commit/48f7dd9f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/48f7dd9f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/48f7dd9f

Branch: refs/heads/cwlparser
Commit: 48f7dd9f7040c5b3b571af0b675992d556b66ef0
Parents: e5547ef d39a8a2
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Thu Jul 5 11:44:01 2018 +0100
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jul 5 11:44:01 2018 +0100

----------------------------------------------------------------------
 taverna-scufl2-cwl/pom.xml                      |  57 +++
 .../apache/taverna/scufl2/cwl/CWLParser.java    |  83 ++++
 .../apache/taverna/scufl2/cwl/Converter.java    |  76 +++
 .../taverna/scufl2/cwl/WorkflowParser.java      | 236 +++++++++
 .../apache/taverna/scufl2/cwl/YAMLHelper.java   | 484 +++++++++++++++++++
 .../scufl2/cwl/components/PortDetail.java       |  72 +++
 .../taverna/scufl2/cwl/components/Step.java     |  85 ++++
 .../scufl2/cwl/components/StepInput.java        |  54 +++
 .../scufl2/cwl/components/StepOutput.java       |  41 ++
 .../apache/taverna/scufl2/cwl/TestParser.java   | 120 +++++
 .../src/test/resources/1st-tool.cwl             |  26 +
 .../src/test/resources/hello_world.cwl          |  36 ++
 .../src/test/resources/int_input.cwl            |  22 +
 .../src/test/resources/simple_string_input.cwl  |  21 +
 .../src/test/resources/worklflow2.cwl           |  44 ++
 15 files changed, 1457 insertions(+)
----------------------------------------------------------------------



[04/13] incubator-taverna-language git commit: Add CWL components

Posted by st...@apache.org.
Add CWL components


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/commit/ecc3b672
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/ecc3b672
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/ecc3b672

Branch: refs/heads/cwlparser
Commit: ecc3b6729c0dccfe0943475b3207c255b1bb3cb1
Parents: 4d32489
Author: Majdi Haouech <m....@criteo.com>
Authored: Mon Jun 4 10:33:03 2018 +0100
Committer: Majdi Haouech <m....@criteo.com>
Committed: Mon Jun 4 10:33:03 2018 +0100

----------------------------------------------------------------------
 .../scufl2/cwl/components/PortDetail.java       | 62 ++++++++++++++
 .../taverna/scufl2/cwl/components/Step.java     | 85 ++++++++++++++++++++
 .../scufl2/cwl/components/StepInput.java        | 54 +++++++++++++
 .../scufl2/cwl/components/StepOutput.java       | 41 ++++++++++
 4 files changed, 242 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/ecc3b672/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/PortDetail.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/PortDetail.java b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/PortDetail.java
new file mode 100644
index 0000000..563c76f
--- /dev/null
+++ b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/PortDetail.java
@@ -0,0 +1,62 @@
+/*
+ * 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.taverna.scufl2.cwl;
+
+
+import java.util.ArrayList;
+
+public class PortDetail {
+
+
+    private String label;
+
+    private int depth;
+    private String description;
+    private ArrayList<String> format;
+    public int getDepth() {
+        return depth;
+    }
+    public void setDepth(int depth) {
+        this.depth = depth;
+    }
+    public String getDescription() {
+        return description;
+    }
+    public void setDescription(String description) {
+        this.description = description;
+    }
+    public String getLabel() {
+        return label;
+    }
+    public void setLabel(String label) {
+        this.label = label;
+    }
+    public ArrayList<String> getFormat() {
+        return format;
+    }
+    public void setFormat(ArrayList<String> format) {
+        this.format = format;
+    }
+
+    public void addFormat(String format){
+        this.format.add(format);
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/ecc3b672/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/Step.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/Step.java b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/Step.java
new file mode 100644
index 0000000..3f3d653
--- /dev/null
+++ b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/Step.java
@@ -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.taverna.scufl2.cwl;
+
+
+import java.util.ArrayList;
+import java.util.Set;
+import java.util.HashSet;
+
+public class Step {
+
+
+    private String id;
+    private String run;
+
+    private Set<StepInput> inputs;
+    private Set<StepOutput> outputs;
+
+    public Step() {
+        inputs = new HashSet<>();
+        outputs = new HashSet<>();
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getRun() {
+        return run;
+    }
+
+    public void setRun(String run) {
+        this.run = run;
+    }
+
+    public void addInput(String id, String source) {
+        inputs.add(new StepInput(id, source));
+    }
+
+    public void setInputs(Set<StepInput> inputs) {
+        this.inputs = inputs;
+    }
+
+    public Set<StepInput> getInputs() {
+        return inputs;
+    }
+
+    public void addOutput(String id) {
+        outputs.add(new StepOutput(id));
+    }
+
+    public void setOutputs(Set<StepOutput> outputs) {
+        this.outputs = outputs;
+    }
+
+    public Set<StepOutput> getOutputs() {
+        return outputs;
+    }
+
+    public String toString() {
+        return "Step " + id + ": run = " + run;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/ecc3b672/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/StepInput.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/StepInput.java b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/StepInput.java
new file mode 100644
index 0000000..0432272
--- /dev/null
+++ b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/StepInput.java
@@ -0,0 +1,54 @@
+/*
+ * 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.taverna.scufl2.cwl;
+
+import java.util.*;
+
+public class StepInput {
+
+    private String id;
+    private String source;
+
+    public StepInput() {
+        this.id = null;
+        this.source = null;
+    }
+
+    public StepInput(String id, String source) {
+        this.id = id;
+        this.source = source;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public void setSource(String source) {
+        this.source = source;
+    }
+
+    public String getSource() {
+        return source;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/ecc3b672/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/StepOutput.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/StepOutput.java b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/StepOutput.java
new file mode 100644
index 0000000..145fa2d
--- /dev/null
+++ b/taverna-scufl2-cwl/src/main/java/org/apache/taverna/scufl2/cwl/components/StepOutput.java
@@ -0,0 +1,41 @@
+/*
+ * 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.taverna.scufl2.cwl;
+
+public class StepOutput {
+
+    private String id;
+
+    public StepOutput() {
+        this.id = null;
+    }
+
+    public StepOutput(String id) {
+        this.id = id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getId() {
+        return id;
+    }
+}
\ No newline at end of file


[10/13] incubator-taverna-language git commit: Add parser tests

Posted by st...@apache.org.
Add parser tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/commit/62c3615b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/62c3615b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/62c3615b

Branch: refs/heads/cwlparser
Commit: 62c3615bf2bbd4a50d6bc864b399bfeb4064743d
Parents: 4ee2f5b
Author: Majdi Haouech <m....@criteo.com>
Authored: Mon Jun 11 16:53:09 2018 +0200
Committer: Majdi Haouech <m....@criteo.com>
Committed: Mon Jun 11 16:53:09 2018 +0200

----------------------------------------------------------------------
 .../apache/taverna/scufl2/cwl/TestParser.java   | 90 ++++++++++++++------
 .../src/test/resources/hello_world.cwl          | 18 ++++
 2 files changed, 84 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/62c3615b/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java b/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
index 83c48e1..23b9533 100644
--- a/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
+++ b/taverna-scufl2-cwl/src/test/java/org/apache/taverna/scufl2/cwl/TestParser.java
@@ -3,6 +3,7 @@ package org.apache.taverna.scufl2.cwl;
 
 import java.util.*;
 
+import org.junit.Before;
 import org.junit.Test;
 import static org.junit.Assert.assertEquals;
 
@@ -13,41 +14,82 @@ import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ArrayNode;
 
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.core.Processor;
+import org.apache.taverna.scufl2.api.core.DataLink;
+
+import org.apache.taverna.scufl2.api.common.NamedSet;
+
 import org.apache.taverna.scufl2.api.port.InputWorkflowPort;
 import org.apache.taverna.scufl2.api.port.OutputWorkflowPort;
+import org.apache.taverna.scufl2.api.port.InputProcessorPort;
 
 
 public class TestParser {
-    private static final String SIMPLE_STRING_INPUT = "/simple_string_input.cwl";
-    private static final String INT_INPUT = "/int_input.cwl";
+    private static final String HELLO_WORLD_CWL = "/hello_world.cwl";
 
     private static JsonNode cwlFile;
+    private WorkflowParser parser;
+    private Workflow workflow;
 
-    @Test
-    public void testStringInput() throws Exception {
+    @Before
+    public void initialize() {
 
         Yaml reader = new Yaml();
         ObjectMapper mapper = new ObjectMapper();
-        cwlFile = mapper.valueToTree(reader.load(TestParser.class.getResourceAsStream(SIMPLE_STRING_INPUT)));
+        cwlFile = mapper.valueToTree(reader.load(TestParser.class.getResourceAsStream(HELLO_WORLD_CWL)));
         System.out.println(cwlFile);
-        Parser parser = new Parser(cwlFile);
-
-        Set<InputWorkflowPort> result = parser.parseInputs();
-        for(InputWorkflowPort port: result) {
-            System.out.println(port.getName());
-        }
-        ArrayList<InputWorkflowPort> inputs = new ArrayList<>(result);
-        assertEquals(inputs.get(0).getName(), "example_string");
-
-        Set<OutputWorkflowPort> result2 = parser.parseOutputs();
-        for(OutputWorkflowPort port: result2) {
-            System.out.println(port.getName());
-        }
-        System.out.println("Showing steps:");
-
-        Set<Step> steps = parser.parseSteps();
-        for(Step step: steps) {
-            System.out.println(step);
-        }
+        this.parser = new WorkflowParser(cwlFile);
+
+        this.workflow = parser.buildWorkflow();
+    }
+
+    @Test
+    public void testParseInputs() throws Exception {
+
+        NamedSet<InputWorkflowPort> workflowInputs = workflow.getInputPorts();
+        NamedSet<InputWorkflowPort> expectedInputs = new NamedSet<>();
+        expectedInputs.add(new InputWorkflowPort(workflow, "name"));
+
+        assertEquals(expectedInputs, workflowInputs);
+    }
+
+    @Test
+    public void testParseOutputs() throws Exception {
+
+        NamedSet<OutputWorkflowPort> workflowOutputs = workflow.getOutputPorts();
+        NamedSet<OutputWorkflowPort> expectedOutputs = new NamedSet<>();
+
+        assertEquals(expectedOutputs, workflowOutputs);
+    }
+
+    @Test
+    public void testParseProcessors() throws Exception {
+
+        NamedSet<Processor> workflowProcessors = workflow.getProcessors();
+        NamedSet<Processor> expectedProcessors = new NamedSet<>();
+        expectedProcessors.add(new Processor(workflow, "step1"));
+
+        assertEquals(expectedProcessors, workflowProcessors);
+    }
+
+    @Test
+    public void testParseDataLinks() throws Exception {
+
+        Set<DataLink> workflowDataLinks = workflow.getDataLinks();
+        Set<DataLink> expectedDataLinks = new HashSet<>();
+        Set<Processor> processorSet = workflow.getProcessors();
+        // processorSet has one processor
+        Processor processor = processorSet.iterator().next();
+
+        expectedDataLinks.add(
+                new DataLink(
+                        workflow,
+                        new InputWorkflowPort(workflow, "name"),
+                        new InputProcessorPort(processor, "text")
+                )
+        );
+
+        assertEquals(expectedDataLinks, workflowDataLinks);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/62c3615b/taverna-scufl2-cwl/src/test/resources/hello_world.cwl
----------------------------------------------------------------------
diff --git a/taverna-scufl2-cwl/src/test/resources/hello_world.cwl b/taverna-scufl2-cwl/src/test/resources/hello_world.cwl
new file mode 100644
index 0000000..d716812
--- /dev/null
+++ b/taverna-scufl2-cwl/src/test/resources/hello_world.cwl
@@ -0,0 +1,18 @@
+#!/usr/bin/env cwl-runner
+cwlVersion: v1.0
+class: Workflow
+
+inputs:
+  name: string
+
+outputs: []
+
+steps:
+  step1:
+    run: example.cwl
+
+    inputs:
+      - id: text
+        source: "#x/name"
+
+    outputs: []