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 2015/06/11 18:35:32 UTC
[13/31] incubator-taverna-language git commit: Package name changed/
license header added
Package name changed/ license header added
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/c79acc09
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/c79acc09
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/c79acc09
Branch: refs/heads/master
Commit: c79acc0940f16a409edabab42ae27a5b8e8025d3
Parents: ef1c045
Author: Menaka <me...@gmail.com>
Authored: Mon Jun 8 19:48:36 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:28 2015 +0100
----------------------------------------------------------------------
.../taverna/commandline/CommandLineTool.java | 258 ------------------
.../taverna/commandline/TavernaCommandline.java | 29 --
.../tavlang/commandline/CommandLineTool.java | 264 +++++++++++++++++++
.../tavlang/commandline/TavernaCommandline.java | 29 ++
.../commandline/test/CommandLineTest.java | 30 ---
.../commandline/test/CommandLineTest.java | 50 ++++
6 files changed, 343 insertions(+), 317 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/c79acc09/taverna-language-commandline/src/main/java/org/apache/taverna/commandline/CommandLineTool.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/taverna/commandline/CommandLineTool.java b/taverna-language-commandline/src/main/java/org/apache/taverna/commandline/CommandLineTool.java
deleted file mode 100644
index 8dd61b3..0000000
--- a/taverna-language-commandline/src/main/java/org/apache/taverna/commandline/CommandLineTool.java
+++ /dev/null
@@ -1,258 +0,0 @@
-package org.apache.taverna.commandline;
-
-
-/*
- * 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.
- */
-
-
-import io.airlift.airline.Arguments;
-import io.airlift.airline.Cli;
-import io.airlift.airline.Cli.CliBuilder;
-import io.airlift.airline.Command;
-import io.airlift.airline.Help;
-import io.airlift.airline.Option;
-
-import java.io.File;
-import java.util.List;
-
-import javax.inject.Inject;
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.Lists;
-
-
-/*
- * The command line options for convert, validate and inspect workflows.
- * Use the airlift/airline library
- * Author: Menaka Madushanka <me...@gmail.com>
- * */
-
-public class CommandLineTool {
-
- private Cli<TvnLangTool> parser(){
- CliBuilder<TvnLangTool> build = Cli.<TvnLangTool>builder("tavlang")
- .withDescription("Convert, manage workflows")
- .withDefaultCommand(HelpCommand.class)
- .withCommand(CommandConvert.class)
- .withCommand(HelpCommand.class)
- .withCommand(CommandInspect.class)
- .withCommand(CommandValidate.class)
- .withCommand(CommandVersion.class);
-
- return build.build();
- }
-
- public CommandLineTool(){};
- public void parse(String... args)
- {
- System.out.println("$ tavlang " + Joiner.on(" ").join(args));
- TvnLangTool command = parser().parse(args);
- command.execute();
- System.out.println();
- }
-
- public static abstract class TvnLangTool{
-
- public abstract void execute();
- }
-
- //placeholder for output file types
- public static class Filetypes{
- @Option(name= "-wfdesc", description="Convert the workflow file to wfdesc-turtle")
- public static boolean isWfdesc = false;
-
- @Option(name="-wfbundel", description="Convert the workflow file to wfbundel")
- public static boolean isWfbundel = false;
-
- @Option(name = "-robundel", description = "Convert given bundel in to Research Object bundel")
- public static boolean isRo = false;
-
- @Option(name= "-structure", description = "Convert the workflow into *.structure")
- public static boolean isStructure = false;
-
- @Option(name = "-json", description = "Convert the workflow into json")
- public static boolean isJson = false;
-
- //The tool can only handle one output format at a time.
- //Return the file type which is selected
- public static String isTrue(){
- if(isWfdesc) return "wfdesc";
- else if(isWfbundel) return "wfbundel";
- else if(isRo) return "ro";
- else if(isStructure) return "structure";
- else if(isJson) return "json";
- else return null;
- }
-
- }
-
- public static class Inspect{
- @Option(name = "-servicetypes", description = "List the service types")
- public static boolean servicetypes = false;
-
- @Option(name = "-processornames", description = "List the processor names")
- public static boolean processor = false;
-
- public String getWay(){
- if(servicetypes) return "servicetypes";
- else if (processor) return "processornames";
- else return null;
- }
-
- }
-
-
- //Placeholder for optional parameters: Ex: -i, -o
- public static class Optional{
-
-
- @Option(name={"-l", "--log"}, description = "Save a results to a file")
- public boolean log = false;
-
- //The input file or directory
- @Option(name = {"-i", "--input"}, description="Input file/ file dir for convertion")
- public static String in_file_dir;
-
- //The out put file or directory. When this is set, all the converted files will be saved into the directory that specified.
- @Option(name = {"-o", "--output"}, description="Output file/ directory")
- public static String out_file_dir;
-
- public static String getInFile(){
- return in_file_dir;
- }
-
- public static String getOutFile(){
- return out_file_dir;
- }
-
- }
-
- @Command(name = "help", description = "Display help information about Tvarna")
- public static class HelpCommand extends TvnLangTool{
- @Inject
- public Help help;
-
- @Override
- public void execute(){
- help.call();
- }
- }
-
- //Command for convert workflows
- @Command(name="convert", description="Convert the given workflow")
- public static class CommandConvert extends TvnLangTool{
- @Inject
- Optional optional = new Optional();
-
- @Inject
- Filetypes filetypes = new Filetypes();
-
- @Arguments(usage = "<output format> <input files> ", description = "List of files to be converted.\n "
- + "Give the list of files to be converted without -i/-o and the converted files will be saved in to /converted folder in the same dir")
- public final List<String> files = Lists.newArrayList();
-
- //When this is true, the command will run recursively in a directory.
- @Option(name={"-r", "--recursive"}, description="Execute the command recursively")
- public boolean recurse = false;
-
- //Option for validate the given workflow when converting
- @Option(name = {"-V", "--validate"}, description="Validate the workflow before convert")
- public boolean validate = false;
-
- @Override
- public void execute(){
-//
-// if(Filetypes.isWfbundel){
-// if(!files.isEmpty() && optional.getInFile()!=null){
-// System.err.println("Unexpected arguments:"+" " + files.toString() + " "+ optional.getInFile());
-// return;
-// }
-// File dir = new File(Optional.getInFile());
-// File odir = new File(Optional.getOutFile());
-// if(!odir.exists()){
-// odir.mkdirs();
-// }
-// for(File f : dir.listFiles()){
-//// (new ToWfbundel(f.toString(), odir.toString())).run();
-//// System.out.println(f);
-//
-// }
-//
-// }
-
-
-
- }
-
- }
-
- //Version command
- @Command(name="version", description = "Show version informantion")
- public static class CommandVersion extends TvnLangTool{
-
- @Override
- public void execute() {
- // TODO Auto-generated method stub
- System.out.println("Apache Taverna Language Command line tool. \nVersion 1.0 ");
- }
-
- }
-
- //Command for inspection of workflows....!!
- @Command(name="inspect", description="Inspect the given workflow")
- public static class CommandInspect extends TvnLangTool{
-
- @Inject
- Optional optional = new Optional();
-
- @Inject
- Inspect inspect = new Inspect();
-
- @Arguments(usage="<option> <input files> <output dir>", description="Inspect the given workflow")
- public List<String> toInspect = Lists.newArrayList();
-
- @Override
- public void execute() {
- // TODO Auto-generated method stub
-
-
- }
-
- }
-
- //Command for validation
- @Command(name = "validate", description = "validate the given workflow")
- public static class CommandValidate extends TvnLangTool{
-
- @Inject
- Optional optional = new Optional();
-
- @Arguments(usage="<option> <input files> <output dir>", description="Validate the given workflow file/s")
- public List<String> toValidate = Lists.newArrayList();
-
- @Override
- public void execute() {
- // TODO Auto-generated method stub
-
- }
-
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/c79acc09/taverna-language-commandline/src/main/java/org/apache/taverna/commandline/TavernaCommandline.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/taverna/commandline/TavernaCommandline.java b/taverna-language-commandline/src/main/java/org/apache/taverna/commandline/TavernaCommandline.java
deleted file mode 100644
index f7b998e..0000000
--- a/taverna-language-commandline/src/main/java/org/apache/taverna/commandline/TavernaCommandline.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.apache.taverna.commandline;
-
-/*
- * 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.
- */
-
-public class TavernaCommandline {
-
- public static void main(String args[]){
- CommandLineTool tool = new CommandLineTool();
- tool.parse(args);
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/c79acc09/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/CommandLineTool.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/CommandLineTool.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/CommandLineTool.java
new file mode 100644
index 0000000..17e3945
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/CommandLineTool.java
@@ -0,0 +1,264 @@
+package org.apache.tavlang.commandline;
+
+
+/*
+ * 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.
+ */
+
+
+import io.airlift.airline.Arguments;
+import io.airlift.airline.Cli;
+import io.airlift.airline.Cli.CliBuilder;
+import io.airlift.airline.Command;
+import io.airlift.airline.Help;
+import io.airlift.airline.Option;
+
+import java.io.File;
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.tavlang.commandline.tools.Tools;
+import org.apache.tavlang.commandline.tools.Tools.ConvertionTools;
+
+import com.google.common.base.Joiner;
+import com.google.common.collect.Lists;
+
+
+/*
+ * The command line options for convert, validate and inspect workflows.
+ * Use the airlift/airline library
+ * */
+
+public class CommandLineTool {
+
+ private Cli<TvnLangTool> parser(){
+ CliBuilder<TvnLangTool> build = Cli.<TvnLangTool>builder("tavlang")
+ .withDescription("Convert, manage workflows")
+ .withDefaultCommand(HelpCommand.class)
+ .withCommand(CommandConvert.class)
+ .withCommand(HelpCommand.class)
+ .withCommand(CommandInspect.class)
+ .withCommand(CommandValidate.class)
+ .withCommand(CommandVersion.class);
+
+ return build.build();
+ }
+
+ public CommandLineTool(){};
+ public void parse(String... args)
+ {
+ System.out.println("$ tavlang " + Joiner.on(" ").join(args));
+ TvnLangTool command = parser().parse(args);
+ command.execute();
+ System.out.println();
+ }
+
+ public static abstract class TvnLangTool{
+
+ public abstract void execute();
+ }
+
+ //placeholder for output file types
+ public static class Filetypes{
+ @Option(name= "-wfdesc", description="Convert the workflow file to wfdesc-turtle")
+ public static boolean isWfdesc = false;
+
+ @Option(name="-wfbundle", description="Convert the workflow file to wfbundel")
+ public static boolean isWfbundel = false;
+
+ @Option(name = "-robundle", description = "Convert given bundel in to Research Object bundel")
+ public static boolean isRo = false;
+
+ @Option(name= "-structure", description = "Convert the workflow into *.structure")
+ public static boolean isStructure = false;
+
+ @Option(name = "-json", description = "Convert the workflow into json")
+ public static boolean isJson = false;
+
+ //The tool can only handle one output format at a time.
+ //Return the file type which is selected
+ public static String isTrue(){
+ if(isWfdesc) return "wfdesc";
+ else if(isWfbundel) return "wfbundle";
+ else if(isRo) return "robundle";
+ else if(isStructure) return "structure";
+ else if(isJson) return "json";
+ else return null;
+ }
+
+ }
+
+ public static class Inspect{
+ @Option(name = "-servicetypes", description = "List the service types used in workflow")
+ public static boolean servicetypes = false;
+
+ @Option(name = "-processornames", description = "List a tree of processor names used in workflow")
+ public static boolean processor = false;
+
+ public String getWay(){
+ if(servicetypes) return "servicetypes";
+ else if (processor) return "processornames";
+ else return null;
+ }
+
+ }
+
+
+ //Placeholder for optional parameters: Ex: -i, -o
+ public static class Optional{
+
+
+ @Option(name={"-l", "--log"}, description = "Save a results to a file")
+ public boolean log = false;
+
+ //The input file or directory
+ @Option(name = {"-i", "--input"}, description="Input file/ file dir for convertion")
+ public static String in_file_dir;
+
+ //The out put file or directory. When this is set, all the converted files will be saved into the directory that specified.
+ @Option(name = {"-o", "--output"}, description="Output file/ directory")
+ public static String out_file_dir;
+
+ public static String getInFile(){
+ return in_file_dir;
+ }
+
+ public static String getOutFile(){
+ return out_file_dir;
+ }
+
+ }
+
+ @Command(name = "help", description = "Display help information about Tvarna")
+ public static class HelpCommand extends TvnLangTool{
+ @Inject
+ public Help help;
+
+ @Override
+ public void execute(){
+ help.call();
+ }
+ }
+
+ //Command for convert workflows
+ @Command(name="convert", description="Convert the given workflow")
+ public static class CommandConvert extends TvnLangTool{
+ @Inject
+ Optional optional = new Optional();
+
+ @Inject
+ Filetypes filetypes = new Filetypes();
+
+ @Arguments(usage = "<output format> <input files> ", description = "List of files to be converted.\n "
+ + "Give the list of files to be converted without -i/-o and the converted files will be saved in to /converted folder in the same dir")
+ public final List<String> files = Lists.newArrayList();
+
+ //When this is true, the command will run recursively in a directory.
+ @Option(name={"-r", "--recursive"}, description="Execute the command recursively")
+ public boolean recurse = false;
+
+ //Option for validate the given workflow when converting
+ @Option(name = {"-V", "--validate"}, description="Validate the workflow before convert")
+ public boolean validate = false;
+
+ @Override
+ public void execute(){
+ Tools to = new Tools();
+
+ ConvertionTools t = ConvertionTools.valueOf(filetypes.isTrue());
+ t.run();
+//
+// if(Filetypes.isWfbundel){
+// if(!files.isEmpty() && optional.getInFile()!=null){
+// System.err.println("Unexpected arguments:"+" " + files.toString() + " "+ optional.getInFile());
+// return;
+// }
+// File dir = new File(Optional.getInFile());
+// File odir = new File(Optional.getOutFile());
+// if(!odir.exists()){
+// odir.mkdirs();
+// }
+// for(File f : dir.listFiles()){
+//// (new ToWfbundel(f.toString(), odir.toString())).run();
+//// System.out.println(f);
+//
+// }
+//
+// }
+
+
+
+ }
+
+ }
+
+ //Version command
+ @Command(name="version", description = "Show version informantion")
+ public static class CommandVersion extends TvnLangTool{
+
+ @Override
+ public void execute() {
+ // TODO Auto-generated method stub
+ System.out.println("Apache Taverna Language Command line tool. \nVersion 1.0 ");
+ }
+
+ }
+
+ //Command for inspection of workflows....!!
+ @Command(name="inspect", description="Inspect the given workflow")
+ public static class CommandInspect extends TvnLangTool{
+
+ @Inject
+ Optional optional = new Optional();
+
+ @Inject
+ Inspect inspect = new Inspect();
+
+ @Arguments(usage="<option> <input files> <output dir>", description="Inspect the given workflow")
+ public List<String> toInspect = Lists.newArrayList();
+
+ @Override
+ public void execute() {
+ // TODO Auto-generated method stub
+
+
+ }
+
+ }
+
+ //Command for validation
+ @Command(name = "validate", description = "validate the given workflow")
+ public static class CommandValidate extends TvnLangTool{
+
+ @Inject
+ Optional optional = new Optional();
+
+ @Arguments(usage="<option> <input files> <output dir>", description="Validate the given workflow file/s")
+ public List<String> toValidate = Lists.newArrayList();
+
+ @Override
+ public void execute() {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/c79acc09/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/TavernaCommandline.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/TavernaCommandline.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/TavernaCommandline.java
new file mode 100644
index 0000000..0bd0226
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/TavernaCommandline.java
@@ -0,0 +1,29 @@
+package org.apache.tavlang.commandline;
+
+/*
+ * 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.
+ */
+
+public class TavernaCommandline {
+
+ public static void main(String args[]){
+ CommandLineTool tool = new CommandLineTool();
+ tool.parse(args);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/c79acc09/taverna-language-commandline/src/test/java/org/apache/commandline/test/CommandLineTest.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/test/java/org/apache/commandline/test/CommandLineTest.java b/taverna-language-commandline/src/test/java/org/apache/commandline/test/CommandLineTest.java
deleted file mode 100644
index 9a07552..0000000
--- a/taverna-language-commandline/src/test/java/org/apache/commandline/test/CommandLineTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.apache.commandline.test;
-
-import org.apache.taverna.commandline.CommandLineTool;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class CommandLineTest {
- CommandLineTool commandLineTool = new CommandLineTool();
-
- @Test
- public void test(){
-// Assert
- commandLineTool.parse();
- commandLineTool.parse("version");
- commandLineTool.parse("help");
- commandLineTool.parse("help", "convert");
- commandLineTool.parse("help", "inspect");
- commandLineTool.parse("help", "validate");
- commandLineTool.parse("help", "help");
-
- commandLineTool.parse("convert","-m", "-r", "-wfdesc", "-o", "/files/dir", "-i", "/files0/dir");
-// commandLineTool.parse();
-// commandLineTool.parse();
-// commandLineTool.parse();
-// commandLineTool.parse();
-
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/c79acc09/taverna-language-commandline/src/test/java/org/apache/tavlang/commandline/test/CommandLineTest.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/test/java/org/apache/tavlang/commandline/test/CommandLineTest.java b/taverna-language-commandline/src/test/java/org/apache/tavlang/commandline/test/CommandLineTest.java
new file mode 100644
index 0000000..2b72966
--- /dev/null
+++ b/taverna-language-commandline/src/test/java/org/apache/tavlang/commandline/test/CommandLineTest.java
@@ -0,0 +1,50 @@
+package org.apache.tavlang.commandline.test;
+
+/*
+ * 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.
+ */
+
+
+import org.apache.tavlang.commandline.CommandLineTool;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class CommandLineTest {
+ CommandLineTool commandLineTool = new CommandLineTool();
+
+ @Test
+ public void test(){
+// Assert
+ commandLineTool.parse();
+ commandLineTool.parse("version");
+ commandLineTool.parse("help");
+ commandLineTool.parse("help", "convert");
+ commandLineTool.parse("help", "inspect");
+ commandLineTool.parse("help", "validate");
+ commandLineTool.parse("help", "help");
+
+ commandLineTool.parse("convert", "-r", "-robundle", "-o", "/files/dir", "-i", "/files0/dir");
+ commandLineTool.parse("convert", "-r", "-json", "-o", "/files/dir", "-i", "/files0/dir");
+// commandLineTool.parse();
+// commandLineTool.parse();
+// commandLineTool.parse();
+
+ }
+
+
+}