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 2016/06/08 12:40:48 UTC
[07/15] incubator-taverna-common-activities git commit: remove type
class and change it to define depth interm of int value
remove type class and change it to define depth interm of int value
Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/commit/3a7d33e4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/tree/3a7d33e4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/diff/3a7d33e4
Branch: refs/heads/cwl-browse
Commit: 3a7d33e4106a9657c93380674b8358163dc33185
Parents: 135c416
Author: ThilinaManamgoda <ma...@gmail.com>
Authored: Thu Jun 2 06:41:14 2016 +0530
Committer: ThilinaManamgoda <ma...@gmail.com>
Committed: Thu Jun 2 06:41:14 2016 +0530
----------------------------------------------------------------------
taverna-cwl-activity-ui/CWLFiles/cat2-tool.cwl | 16 ---
.../CWLFiles/count-lines3-wf.cwl | 25 ++++
taverna-cwl-activity-ui/CWLFiles/params2.cwl | 10 ++
.../taverna/cwl/ui/serviceprovider/Testing.java | 116 +++++++------------
.../org/apache/taverna/cwl/CwlDumyActivity.java | 99 ++++++++--------
5 files changed, 127 insertions(+), 139 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/3a7d33e4/taverna-cwl-activity-ui/CWLFiles/cat2-tool.cwl
----------------------------------------------------------------------
diff --git a/taverna-cwl-activity-ui/CWLFiles/cat2-tool.cwl b/taverna-cwl-activity-ui/CWLFiles/cat2-tool.cwl
deleted file mode 100644
index 5569156..0000000
--- a/taverna-cwl-activity-ui/CWLFiles/cat2-tool.cwl
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/usr/bin/env cwl-runner
-class: CommandLineTool
-cwlVersion: cwl:draft-3
-description: "Print the contents of a file to stdout using 'cat' running in a docker container."
-hints:
- - class: DockerRequirement
- dockerPull: debian:wheezy
-inputs:
- - id: file1
- type: File
- - id: file2
- type: File
-
-outputs: []
-baseCommand: cat
-stdin: $(inputs.file1.path)
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/3a7d33e4/taverna-cwl-activity-ui/CWLFiles/count-lines3-wf.cwl
----------------------------------------------------------------------
diff --git a/taverna-cwl-activity-ui/CWLFiles/count-lines3-wf.cwl b/taverna-cwl-activity-ui/CWLFiles/count-lines3-wf.cwl
new file mode 100644
index 0000000..e22092a
--- /dev/null
+++ b/taverna-cwl-activity-ui/CWLFiles/count-lines3-wf.cwl
@@ -0,0 +1,25 @@
+#!/usr/bin/env cwl-runner
+class: Workflow
+cwlVersion: cwl:draft-3
+
+inputs:
+ - id: file12
+ type: { type: array, items: File }
+
+outputs:
+ - id: count_output
+ type: { type: array, items: int }
+ source: "#step1/output"
+
+requirements:
+ - class: ScatterFeatureRequirement
+
+steps:
+ - id: step1
+ run: wc2-tool.cwl
+ scatter: "#step1/file1"
+ inputs:
+ - id: file1
+ source: "#file1"
+ outputs:
+ - id: output
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/3a7d33e4/taverna-cwl-activity-ui/CWLFiles/params2.cwl
----------------------------------------------------------------------
diff --git a/taverna-cwl-activity-ui/CWLFiles/params2.cwl b/taverna-cwl-activity-ui/CWLFiles/params2.cwl
new file mode 100644
index 0000000..6352c4f
--- /dev/null
+++ b/taverna-cwl-activity-ui/CWLFiles/params2.cwl
@@ -0,0 +1,10 @@
+class: CommandLineTool
+cwlVersion: cwl:draft-3
+requirements:
+ - class: InlineJavascriptRequirement
+
+inputs: {"$import": params_inc.yml}
+
+outputs: {"$import": params_inc.yml}
+
+baseCommand: "true"
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/3a7d33e4/taverna-cwl-activity-ui/src/main/java/org/apache/taverna/cwl/ui/serviceprovider/Testing.java
----------------------------------------------------------------------
diff --git a/taverna-cwl-activity-ui/src/main/java/org/apache/taverna/cwl/ui/serviceprovider/Testing.java b/taverna-cwl-activity-ui/src/main/java/org/apache/taverna/cwl/ui/serviceprovider/Testing.java
index e4b1686..b220775 100644
--- a/taverna-cwl-activity-ui/src/main/java/org/apache/taverna/cwl/ui/serviceprovider/Testing.java
+++ b/taverna-cwl-activity-ui/src/main/java/org/apache/taverna/cwl/ui/serviceprovider/Testing.java
@@ -22,12 +22,10 @@ public class Testing {
private static final String ITEMS = "items";
static int i = 0;
- // CWLTYPES
- private static final String FILE = "File";
- private static final String INTEGER = "int";
- private static final String DOUBLE = "double";
- private static final String FLOAT = "float";
- private static final String STRING = "string";
+
+ private static final int DEPTH_0 = 0;
+ private static final int DEPTH_1 = 1;
+ private static final int DEPTH_2 = 2;
public static void main(String[] args) {
File[] cwlFiles = getCwlFiles();
@@ -39,6 +37,11 @@ public class Testing {
Yaml cwlReader = new Yaml();
try {
cwlFile = (Map) cwlReader.load(new FileInputStream(file));
+ System.out.println(file.getName().split("\\.")[0]);
+ HashMap<String, Integer> map =processInputs(cwlFile);
+ for (String s : map.keySet()) {
+ //System.out.println(map.get(s));
+ }
} catch (FileNotFoundException e) {
e.printStackTrace();
}
@@ -46,88 +49,55 @@ public class Testing {
// Creating the CWL configuration bean
CwlActivityConfigurationBean configurationBean = new CwlActivityConfigurationBean();
configurationBean.setCwlConfigurations(cwlFile);
- // getInputs(configurationBean);
- if (isCompatible(cwlFile))
- System.out.println(file.getName().split("\\.")[0]);
+
+
}
}
+
+
}
- public static boolean isCompatible(Map cwlFile) {
-
- /*
- * in this method cwl tool is verified whether it's compatible with
- * Taverna or not
- */
- ArrayList<Map> inputs = (ArrayList<Map>) cwlFile.get(INPUTS);
-
- if (inputs != null) {
-
- HashMap<String, Type> processedinputs = processInputs(inputs);
-
- for (String inputId : processedinputs.keySet()) {
- Type type = processedinputs.get(inputId);
- if (type != null)
- if (type.getItems() == null) {
- String inputType = type.getType();
- if (!(inputType.equals(DOUBLE) || inputType.equals(FILE) || inputType.equals(FLOAT)
- || inputType.equals(INTEGER) || inputType.equals(STRING)))
- return false;
-
- } else {
- if (type.getType().equals(ARRAY)) {
- String inputType = type.getItems();
- if (!(inputType.equals(DOUBLE) || inputType.equals(FILE) || inputType.equals(FLOAT)
- || inputType.equals(INTEGER) || inputType.equals(STRING)))
- return false;
-
+ private static HashMap<String, Integer> processInputs(Map cwlFile) {
+
+ HashMap<String, Integer> result = new HashMap<>();
+
+ // Get all input objects in
+ Object inputs = cwlFile.get(INPUTS);
+ if(inputs.getClass()==ArrayList.class){
+
+
+ for (Map input :( ArrayList<Map>)inputs) {
+ String currentInputId = (String) input.get(ID);
+ Object typeConfigurations;
+ try {
+
+ typeConfigurations = input.get(TYPE);
+ // if type :single argument
+ if (typeConfigurations.getClass() == String.class) {
+ result.put(currentInputId, DEPTH_0);
+ // type : defined as another map which contains type:
+ } else if (typeConfigurations.getClass() == LinkedHashMap.class) {
+ String inputType = (String) ((Map) typeConfigurations).get(TYPE);
+ if (inputType.equals(ARRAY)){
+ result.put(currentInputId, DEPTH_1);
}
}
- else
- return false;
- }
- }
- return true;
- }
-
- private static HashMap<String, Type> processInputs(ArrayList<Map> inputs) {
-
- HashMap<String, Type> result = new HashMap<>();
- for (Map input : inputs) {
- String currentInputId = (String) input.get(ID);
- Object typeConfigurations;
- Type type = null;
-
- try {
+ } catch (ClassCastException e) {
- typeConfigurations = input.get(TYPE);
- //if type :single argument
- if (typeConfigurations.getClass() == String.class) {
- type = new Type();
- type.setType((String) typeConfigurations);
- type.setItems(null);
-
- //type : defined as another map which contains type:
- } else if (typeConfigurations.getClass() == LinkedHashMap.class) {
-
- type = new Type();
- type.setType((String) ((Map) typeConfigurations).get(TYPE));
- type.setItems((String) ((Map) typeConfigurations).get(ITEMS));
+ System.out.println("Class cast exception !!!");
}
- } catch (ClassCastException e) {
-
- System.out.println("Class cast exception !!!");
}
- if (type != null)//see whether type is defined or not
- result.put(currentInputId, type);
-
+ }else if(inputs.getClass()==LinkedHashMap.class){
+
+ for (Object parameter : ((Map) inputs).keySet()) {
+ if(parameter.toString().startsWith("$")) System.out.println("Exception");
+ }
}
return result;
}
-
private static File[] getCwlFiles() {
// Get the cwl files in the directory using the FileName Filter
FilenameFilter fileNameFilter = new FilenameFilter() {
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/3a7d33e4/taverna-cwl-activity/src/main/java/org/apache/taverna/cwl/CwlDumyActivity.java
----------------------------------------------------------------------
diff --git a/taverna-cwl-activity/src/main/java/org/apache/taverna/cwl/CwlDumyActivity.java b/taverna-cwl-activity/src/main/java/org/apache/taverna/cwl/CwlDumyActivity.java
index ba95d68..c3a979c 100644
--- a/taverna-cwl-activity/src/main/java/org/apache/taverna/cwl/CwlDumyActivity.java
+++ b/taverna-cwl-activity/src/main/java/org/apache/taverna/cwl/CwlDumyActivity.java
@@ -36,14 +36,10 @@ public class CwlDumyActivity extends AbstractAsynchronousActivity<CwlActivityCon
private static final String TYPE = "type";
private static final String ARRAY = "array";
- private static final String ITEMS = "items";
- //CWLTYPES
- private static final String FILE = "File";
- private static final String INTEGER="int";
- private static final String DOUBLE="double";
- private static final String FLOAT="float";
- private static final String STRING="string";
+ private static final int DEPTH_0 = 0;
+ private static final int DEPTH_1 = 1;
+ private static final int DEPTH_2 = 2;
@Override
public void configure(CwlActivityConfigurationBean configurationBean) throws ActivityConfigurationException {
@@ -51,19 +47,18 @@ public class CwlDumyActivity extends AbstractAsynchronousActivity<CwlActivityCon
removeOutputs();
Map cwlFile = configurationBean.getCwlConfigurations();
- // Get all input objects in
- ArrayList<Map> inputs = (ArrayList<Map>) cwlFile.get(INPUTS);
-
- HashMap<String, Type> processedInputs;
+ HashMap<String, Integer> processedInputs;
- if (inputs != null) {
- processedInputs = processInputs(inputs);
+ if (cwlFile != null) {
+ processedInputs = processInputs(cwlFile);
for (String inputId : processedInputs.keySet()) {
- if (processedInputs.get(inputId).getType().equals(FILE))
- addInput(inputId, 0, true, null, String.class);
- if (processedInputs.get(inputId).getType().equals(ARRAY))
- addInput(inputId, 1, true, null, byte[].class);
+ int depth = processedInputs.get(inputId);
+ if (depth == DEPTH_0)
+ addInput(inputId, DEPTH_0, true, null, String.class);
+ else if (depth == DEPTH_1)
+ addInput(inputId, DEPTH_1, true, null, byte[].class);
+
}
}
@@ -71,42 +66,46 @@ public class CwlDumyActivity extends AbstractAsynchronousActivity<CwlActivityCon
- private HashMap<String, Type> processInputs(ArrayList<Map> inputs) {
-
- HashMap<String, Type> result = new HashMap<>();
- for (Map input : inputs) {
- String currentInputId = (String) input.get(ID);
- Object typeConfigurations;
- Type type = null;// this object holds the type of the input/output
- // or if it's an array then the type of the
- // elements in the array
-
- try {
-
- typeConfigurations = input.get(TYPE);
- // if type :single argument
- if (typeConfigurations.getClass() == String.class) {
- type = new Type();
- type.setType((String) typeConfigurations);
- type.setItems(null);// set it to null so that later we can
- // figure out this a single argument
- // type
-
- // type : defined as another map which contains type:
- } else if (typeConfigurations.getClass() == LinkedHashMap.class) {
-
- type = new Type();
- type.setType((String) ((Map) typeConfigurations).get(TYPE));
- type.setItems((String) ((Map) typeConfigurations).get(ITEMS));
- }
+ private HashMap<String, Integer> processInputs(Map cwlFile) {
- } catch (ClassCastException e) {
+ HashMap<String, Integer> result = new HashMap<>();
- System.out.println("Class cast exception !!!");
- }
- if (type != null)// see whether type is defined or not
- result.put(currentInputId, type);
+ // Get all input objects in
+ Object inputs = cwlFile.get(INPUTS);
+
+
+ if (inputs.getClass() == ArrayList.class) {
+
+ for (Map input : (ArrayList<Map>) inputs) {
+ String currentInputId = (String) input.get(ID);
+ Object typeConfigurations;
+
+ try {
+
+ typeConfigurations = input.get(TYPE);
+ // if type :single argument
+ if (typeConfigurations.getClass() == String.class) {
+ result.put(currentInputId, DEPTH_0);
+ // type : defined as another map which contains type:
+ } else if (typeConfigurations.getClass() == LinkedHashMap.class) {
+ String inputType = (String) ((Map) typeConfigurations).get(TYPE);
+ if (inputType.equals(ARRAY))
+ result.put(currentInputId, DEPTH_1);
+ }
+
+ } catch (ClassCastException e) {
+
+ System.out.println("Class cast exception !!!");
+ }
+ }
+
+ //See whether it contains an EXPRESSION
+ } else if (inputs.getClass() == LinkedHashMap.class) {
+ for (Object parameter : ((Map) inputs).keySet()) {
+ if (parameter.toString().startsWith("$"))
+ System.out.println("Exception");
+ }
}
return result;
}