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:20 UTC
[01/31] incubator-taverna-language git commit: ToWfbundle converter
Repository: incubator-taverna-language
Updated Branches:
refs/heads/master 3f5ea6421 -> c92c45162
ToWfbundle 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/e978516f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/e978516f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/e978516f
Branch: refs/heads/master
Commit: e978516f7c26621441f46619bb8c53e04c1bffc4
Parents: a2d712c
Author: menaka121 <me...@gmail.com>
Authored: Tue Jun 9 04:06:29 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:28 2015 +0100
----------------------------------------------------------------------
.../commandline/tools/convert/ToWfbundle.java | 209 +++++++++++++++++++
1 file changed, 209 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/e978516f/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java
new file mode 100644
index 0000000..f268801
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java
@@ -0,0 +1,209 @@
+package org.apache.tavlang.commandline.tools.convert;
+
+/*
+ * 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 java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.io.ReaderException;
+import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
+import org.apache.taverna.scufl2.api.io.WriterException;
+
+
+/*
+ * Converts .t2flow workflows into .workflowbundle format.
+ * two constructors.
+ * ToWfbundle(List<String> list, String out) --> will save the converted files in 'out folder or a directory named /converted in the same folder.
+ * ToWfbundle(String in, String out) --> Will convert all the files in the 'in' folder and save them in 'out' folder --> -r must be true.
+ *
+ * */
+public class ToWfbundle implements Runnable{
+
+ private String MEDIA_TYPE = "application/vnd.taverna.scufl2.workflow-bundle";
+ private String input;
+ private String output;
+ private List<String> filesList;
+
+ public ToWfbundle(List<String> files, String out){
+ this.filesList = files;
+ this.output = out;
+ this.convert();
+ }
+
+ //When recursive case is on....
+ public ToWfbundle(String in, String out){
+ this.input = in;
+ this.output = out;
+
+ if(output == null){
+ File outFile = new File(this.input, "converted");
+ try {
+ FileUtils.forceMkdir(outFile);
+ this.output = outFile.getAbsolutePath();
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ System.err.println("Error creating the directory...!!!!");
+ e1.printStackTrace();
+ }
+ }else{
+ File outFile = new File(this.input);
+ try {
+ FileUtils.forceMkdir(outFile);
+
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ System.err.println("Error creating the directory...!!!!");
+ e1.printStackTrace();
+ }
+ }
+ this.run();
+ }
+
+ //Convert the given file. Return in case of an exception.
+ public void convert(){
+ WorkflowBundleIO wfbio = new WorkflowBundleIO();
+
+ // If the output folder is given, save the converted files in to that folder.
+
+ if(this.filesList.size()>0 && this.output != null){
+ File outFile = new File(this.output);
+ try {
+ FileUtils.forceMkdir(outFile);
+ } catch (IOException e1) {
+ System.err.println("Error creating the directory...!!!");
+ }
+ for(String file : this.filesList){
+ File t2File = new File(file);
+
+ String filename = t2File.getName();
+ filename = filename.replaceFirst("\\..*", ".wfbundle");
+ File scufl2File = new File(outFile.getAbsolutePath(), filename);
+
+ WorkflowBundle wfBundle;
+ try {
+ wfBundle = wfbio.readBundle(t2File, "application/vnd.taverna.t2flow+xml");
+ wfbio.writeBundle(wfBundle, scufl2File, this.MEDIA_TYPE);
+ System.out.println(scufl2File.getPath() + " is created.");
+
+ //Exceptions
+
+ } catch (ReaderException e){
+ System.err.println("Error reading the file");
+ }catch(IOException e){
+ System.err.println("Error reading the file");
+ }catch(WriterException e) {
+ System.err.println("Error writing the file");
+ }
+ }
+ }
+
+ /* If the output file is not given, save the converted files in
+ * '/converted' folder.
+ */
+
+ if(this.filesList.size()>0 && this.output == null){
+ for(String file : this.filesList){
+ File t2File = new File(file);
+
+ File out = new File(t2File.getParentFile(), "converted");
+ try {
+ FileUtils.forceMkdir(out);
+ } catch (IOException e1) {
+ System.err.println("Error creating the directory...!!!");
+ }
+
+ String filename = t2File.getName();
+ filename = filename.replaceFirst("\\..*", ".wfbundle");
+ File scufl2File = new File(out.getAbsolutePath(), filename);
+
+ WorkflowBundle wfBundle;
+ try {
+ wfBundle = wfbio.readBundle(t2File,
+ "application/vnd.taverna.t2flow+xml");
+ wfbio.writeBundle(wfBundle, scufl2File, this.MEDIA_TYPE);
+ System.out.println(scufl2File.getPath() + " is created.");
+ }catch (ReaderException e){
+ System.err.println("Error reading the file");
+ }catch(IOException e){
+ System.err.println("Error reading the file");
+ }catch(WriterException e) {
+ System.err.println("Error writing the file");
+ }
+
+ }
+ }
+ }
+
+ //Convert the files in a given directory and save the converted files in to specified dir or /converted folder.
+ //Recursive conversion
+ public void rec_convert(String dir){
+
+ File parent = new File(this.input);
+ if(!parent.exists()){
+ System.err.println("Input directory not found");
+ }else{
+ for(File file : parent.listFiles()){
+ if(file.isDirectory())
+ rec_convert(file.getAbsolutePath());
+ else{
+ recConvert(file);
+ }
+ }
+ }
+
+
+ }
+ public void recConvert(File t2File){
+
+// File t2File = new File(file);
+
+ String filename = t2File.getName();
+ System.out.println(t2File.getAbsolutePath());
+ filename = filename.replaceFirst("\\..*", ".wfbundle");
+ File scufl2File = new File(this.output, filename);
+
+ WorkflowBundleIO wfbio = new WorkflowBundleIO();
+
+ WorkflowBundle wfBundle;
+ try {
+ wfBundle = wfbio.readBundle(t2File, "application/vnd.taverna.t2flow+xml");
+ wfbio.writeBundle(wfBundle, scufl2File, this.MEDIA_TYPE);
+ System.out.println(scufl2File.getPath() + " is created.");
+
+ //Exceptions
+
+ } catch (ReaderException e){
+ System.err.println("Error reading the file");
+ }catch(IOException e){
+ System.err.println("Error reading the file");
+ }catch(WriterException e) {
+ System.err.println("Error writing the file");
+ }
+ }
+
+ @Override
+ public void run() {
+ // TODO Auto-generated method stub
+ rec_convert(this.input);
+ }
+}
[13/31] incubator-taverna-language git commit: Package name changed/
license header added
Posted by st...@apache.org.
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();
+
+ }
+
+
+}
[06/31] incubator-taverna-language git commit: Minor edits
Posted by st...@apache.org.
Minor edits
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/b894afd7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/b894afd7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/b894afd7
Branch: refs/heads/master
Commit: b894afd7d060a1ff8c29418cbe28bb58cfc7d17c
Parents: f1ad74a
Author: Menaka <me...@gmail.com>
Authored: Sun Jun 7 23:21:33 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:28 2015 +0100
----------------------------------------------------------------------
.../taverna/commandline/CommandLineTool.java | 35 ++++++++++++++------
.../taverna/commandline/TavernaCommandline.java | 2 +-
.../commandline/test/CommandLineTest.java | 3 +-
3 files changed, 27 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/b894afd7/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
index 46af29f..c636abb 100644
--- 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
@@ -46,7 +46,7 @@ import com.google.common.collect.Lists;
public class CommandLineTool {
private Cli<TvnLangTool> parser(){
- CliBuilder<TvnLangTool> build = Cli.<TvnLangTool>builder("tvnlang")
+ CliBuilder<TvnLangTool> build = Cli.<TvnLangTool>builder("tavlang")
.withDescription("Convert, manage workflows")
.withDefaultCommand(HelpCommand.class)
.withCommand(CommandConvert.class)
@@ -61,7 +61,7 @@ public class CommandLineTool {
public CommandLineTool(){};
public void parse(String... args)
{
- System.out.println("$ tvnlang " + Joiner.on(" ").join(args));
+ System.out.println("$ tavlang " + Joiner.on(" ").join(args));
TvnLangTool command = parser().parse(args);
command.execute();
System.out.println();
@@ -100,6 +100,20 @@ public class CommandLineTool {
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;
+ }
}
@@ -107,6 +121,10 @@ public class CommandLineTool {
//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;
@@ -123,9 +141,6 @@ public class CommandLineTool {
return out_file_dir;
}
-// public boolean isMulti(){
-// return this.multi;
-// }
}
@Command(name = "help", description = "Display help information about Tvarna")
@@ -194,7 +209,7 @@ public class CommandLineTool {
@Override
public void execute() {
// TODO Auto-generated method stub
-
+ System.out.println("Apache Taverna Language Command line tool. \nVersion 1.0 ");
}
}
@@ -206,13 +221,14 @@ public class CommandLineTool {
@Inject
Optional optional = new Optional();
- @Option(name={"-l", "--log"}, description = "Save a results to a file")
- public String log_file;
+ @Inject
+ Inspect inspect = new Inspect();
@Override
public void execute() {
// TODO Auto-generated method stub
+
}
}
@@ -224,9 +240,6 @@ public class CommandLineTool {
@Inject
Optional optional = new Optional();
- @Option(name={"-l", "--log"}, description = "Save a results to a file")
- public String log_file;
-
@Override
public void execute() {
// TODO Auto-generated method stub
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/b894afd7/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
index f7b998e..61beedb 100644
--- 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
@@ -23,7 +23,7 @@ public class TavernaCommandline {
public static void main(String args[]){
CommandLineTool tool = new CommandLineTool();
- tool.parse(args);
+ tool.parse("version");
}
}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/b894afd7/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
index 112cbfa..9a07552 100644
--- 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
@@ -11,13 +11,14 @@ public class CommandLineTest {
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", "this", "that", "-o", "/files/dir", "-i", "/files0/dir");
+ commandLineTool.parse("convert","-m", "-r", "-wfdesc", "-o", "/files/dir", "-i", "/files0/dir");
// commandLineTool.parse();
// commandLineTool.parse();
// commandLineTool.parse();
[10/31] incubator-taverna-language git commit: Update pom.xml
Posted by st...@apache.org.
Update pom.xml
main class changed
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/601e6640
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/601e6640
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/601e6640
Branch: refs/heads/master
Commit: 601e6640f028401a87596b22798ac699e40d214d
Parents: c79acc0
Author: Menaka Jayawardena <me...@gmail.com>
Authored: Tue Jun 9 01:01:59 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:28 2015 +0100
----------------------------------------------------------------------
taverna-language-commandline/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/601e6640/taverna-language-commandline/pom.xml
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/pom.xml b/taverna-language-commandline/pom.xml
index 93aa3e1..8eed74f 100644
--- a/taverna-language-commandline/pom.xml
+++ b/taverna-language-commandline/pom.xml
@@ -89,7 +89,7 @@
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
- <mainClass>org.apache.taverna.commandline.TavernaCommandline</mainClass>
+ <mainClass>org.apache.tavlang.commandline</mainClass>
</transformer>
</transformers>
</configuration>
[07/31] incubator-taverna-language git commit: Test
Posted by st...@apache.org.
Test
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/f1ad74af
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/f1ad74af
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/f1ad74af
Branch: refs/heads/master
Commit: f1ad74afbd1c7558c1ad56df60c2c56df3aa5066
Parents: c15bc54
Author: Menaka <me...@gmail.com>
Authored: Sun Jun 7 22:40:12 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:28 2015 +0100
----------------------------------------------------------------------
taverna-language-commandline/pom.xml | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/f1ad74af/taverna-language-commandline/pom.xml
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/pom.xml b/taverna-language-commandline/pom.xml
index 6a2b0ff..1c1a0c8 100644
--- a/taverna-language-commandline/pom.xml
+++ b/taverna-language-commandline/pom.xml
@@ -76,7 +76,6 @@
<artifactId>airline</artifactId>
<version>0.7</version>
</dependency>
-
</dependencies>
[22/31] incubator-taverna-language git commit: Readme.md updated -
usage
Posted by st...@apache.org.
Readme.md updated - usage
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/941bd39b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/941bd39b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/941bd39b
Branch: refs/heads/master
Commit: 941bd39bc8eb67c98bf1a5128e9f1067095130e7
Parents: 997f48f
Author: menaka121 <me...@gmail.com>
Authored: Thu Jun 11 20:04:49 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:29 2015 +0100
----------------------------------------------------------------------
taverna-language-commandline/README.md | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/941bd39b/taverna-language-commandline/README.md
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/README.md b/taverna-language-commandline/README.md
index e232cb2..1c22526 100644
--- a/taverna-language-commandline/README.md
+++ b/taverna-language-commandline/README.md
@@ -63,11 +63,9 @@ before accepting a larger contribution.
# Building and install requirements
-_TODO_
-
## Requisites
-* Java 1.8 or newer
+* Java 1.7 or newer
* [Apache Maven](https://maven.apache.org/download.html) 3.2.5 or newer (older
versions probably also work)
@@ -81,9 +79,16 @@ To build, run:
# Usage
-_TODO_
-
-* ...
+ usage: tavlang <command> [<args>]
+
+ The most commonly used tavlang commands are:
+ convert Convert the given workflow
+ help Display help information about Tvarna
+ inspect Inspect the given workflow and show the results on the terminal
+ validate validate the given workflow
+ version Show version informantion
+
+ See 'tavlang help <command>' for more information on a specific command.
# Documentation
[05/31] incubator-taverna-language git commit: pom updated
Posted by st...@apache.org.
pom updated
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/ddd12450
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/ddd12450
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/ddd12450
Branch: refs/heads/master
Commit: ddd124505e674a0cfc8a2c0dd35149b1265b6549
Parents: b87be25
Author: Menaka <me...@gmail.com>
Authored: Sun Jun 7 21:43:41 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:28 2015 +0100
----------------------------------------------------------------------
taverna-language-commandline/pom.xml | 70 ++++++++++++++++++++++++-------
1 file changed, 54 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/ddd12450/taverna-language-commandline/pom.xml
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/pom.xml b/taverna-language-commandline/pom.xml
index 2776003..6a2b0ff 100644
--- a/taverna-language-commandline/pom.xml
+++ b/taverna-language-commandline/pom.xml
@@ -26,58 +26,96 @@
<name>Apache Taverna Language Commandline</name>
<description>Command line for Taverna Language (experimental)</description>
+
<dependencies>
+
+ <dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>taverna-scufl2-api</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>taverna-scufl2-wfbundle</artifactId>
<version>${project.version}</version>
</dependency>
+
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>taverna-scufl2-t2flow</artifactId>
<version>${project.version}</version>
</dependency>
- <!-- Temporarily disabled
+ <!-- Dissabled temperory
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>taverna-scufl2-wfdesc</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>
- -->
+
+ <dependency>
+ <groupId>org.purl.wf4ever</groupId>
+ <artifactId>scufl2-wfdesc</artifactId>
+ <version>0.3.7</version>
+ </dependency>
+ -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>taverna-robundle</artifactId>
<version>${project.version}</version>
</dependency>
+
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>${junit.version}</version>
<scope>test</scope>
</dependency>
+
<dependency>
- <groupId>com.beust</groupId>
- <artifactId>jcommander</artifactId>
- <version>1.30</version>
- </dependency>
+ <groupId>io.airlift</groupId>
+ <artifactId>airline</artifactId>
+ <version>0.7</version>
+ </dependency>
+
+
</dependencies>
<build>
+ <!-- TODO: plugins for launchers and executable jar files? -->
<plugins>
- <!-- TODO: plugins for launchers and executable jar files? -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>2.3</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <transformers>
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <mainClass>org.apache.taverna.commandline.TavernaCommandline</mainClass>
+ </transformer>
+ </transformers>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
</plugins>
</build>
<repositories>
- <repository>
- <id>apache.snapshots</id>
- <name>Apache Snapshot Repository</name>
- <url>http://repository.apache.org/snapshots</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- </repository>
+ <repository>
+ <id>apache.snapshots</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ </repository>
</repositories>
</project>
[17/31] incubator-taverna-language git commit: conversion tools
Posted by st...@apache.org.
conversion tools
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/db163a65
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/db163a65
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/db163a65
Branch: refs/heads/master
Commit: db163a65a0c35ffea0ffcf09351972d7ca4cd93d
Parents: 33a3d5f
Author: menaka121 <me...@gmail.com>
Authored: Wed Jun 10 04:23:38 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:29 2015 +0100
----------------------------------------------------------------------
.../apache/tavlang/commandline/tools/Tools.java | 89 ++++++++++++++++++++
1 file changed, 89 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/db163a65/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/Tools.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/Tools.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/Tools.java
new file mode 100644
index 0000000..c5ba1b3
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/Tools.java
@@ -0,0 +1,89 @@
+package org.apache.tavlang.commandline.tools;
+
+/*
+ * 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 javax.print.attribute.standard.Media;
+
+public class Tools {
+
+ public static enum ConvertionTools {
+ wfbundle{
+ public String mediaType = "application/vnd.taverna.scufl2.workflow-bundle";
+
+
+ @Override
+ public String getMediaType(ConvertionTools t) {
+ // TODO Auto-generated method stub
+ System.out.println(mediaType);
+ return this.mediaType;
+ }
+ },
+ json{
+ public String mediaType = "application/json";
+
+
+ @Override
+ public String getMediaType(ConvertionTools t) {
+ // TODO Auto-generated method stub
+ System.out.println(mediaType);
+ return mediaType;
+ }
+ },
+ wfdesc{
+ public String mediaType = "text/vnd.wf4ever.wfdesc+turtle";
+
+
+ @Override
+ public String getMediaType(ConvertionTools t) {
+ // TODO Auto-generated method stub
+ System.out.println(mediaType);
+ return mediaType;
+ }
+ },
+ robundle{
+
+ @Override
+ public String getMediaType(ConvertionTools t) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ },
+ structure{
+ public String mediaType = "text/vnd.taverna.scufl2.structure";
+
+ @Override
+ public String getMediaType(ConvertionTools t) {
+ // TODO Auto-generated method stub
+ System.out.println(mediaType);
+ return mediaType;
+ }
+
+
+ };
+
+ ConvertionTools(){}
+
+ public abstract String getMediaType(ConvertionTools t);
+
+ }
+
+}
[09/31] incubator-taverna-language git commit: Pom -> dependencies
added
Posted by st...@apache.org.
Pom -> dependencies 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/a2d712c2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/a2d712c2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/a2d712c2
Branch: refs/heads/master
Commit: a2d712c2b3c586cb900f590180f15df3297c419e
Parents: c63fdb2
Author: menaka121 <me...@gmail.com>
Authored: Tue Jun 9 01:47:53 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:28 2015 +0100
----------------------------------------------------------------------
taverna-language-commandline/pom.xml | 28 ++++++++++++++++----
.../tavlang/commandline/CommandLineTool.java | 1 +
.../commandline/test/CommandLineTest.java | 12 ++++++---
3 files changed, 33 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/a2d712c2/taverna-language-commandline/pom.xml
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/pom.xml b/taverna-language-commandline/pom.xml
index 26d1f6d..16d3593 100644
--- a/taverna-language-commandline/pom.xml
+++ b/taverna-language-commandline/pom.xml
@@ -33,7 +33,8 @@
<groupId>${project.parent.groupId}</groupId>
<artifactId>taverna-scufl2-api</artifactId>
<version>${project.parent.version}</version>
- </dependency>
+ </dependency>
+
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>taverna-scufl2-wfbundle</artifactId>
@@ -53,6 +54,22 @@
<optional>true</optional>
</dependency>
-->
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>taverna-scufl2-ucfpackage</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>taverna-robundle</artifactId>
@@ -66,10 +83,11 @@
</dependency>
<dependency>
- <groupId>io.airlift</groupId>
- <artifactId>airline</artifactId>
- <version>0.7</version>
- </dependency>
+ <groupId>io.airlift</groupId>
+ <artifactId>airline</artifactId>
+ <version>0.7</version>
+ </dependency>
+
</dependencies>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/a2d712c2/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
index 17e3945..5201986 100644
--- 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
@@ -181,6 +181,7 @@ public class CommandLineTool {
public void execute(){
Tools to = new Tools();
+ System.out.println(filetypes.isTrue());
ConvertionTools t = ConvertionTools.valueOf(filetypes.isTrue());
t.run();
//
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/a2d712c2/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
index 2b72966..e97c715 100644
--- 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
@@ -28,7 +28,7 @@ public class CommandLineTest {
CommandLineTool commandLineTool = new CommandLineTool();
@Test
- public void test(){
+ public void testHelp(){
// Assert
commandLineTool.parse();
commandLineTool.parse("version");
@@ -37,9 +37,15 @@ public class CommandLineTest {
commandLineTool.parse("help", "inspect");
commandLineTool.parse("help", "validate");
commandLineTool.parse("help", "help");
+ }
+
+ @Test
+ public void testConvert(){
- commandLineTool.parse("convert", "-r", "-robundle", "-o", "/files/dir", "-i", "/files0/dir");
- commandLineTool.parse("convert", "-r", "-json", "-o", "/files/dir", "-i", "/files0/dir");
+// CommandLineTool tool = new CommandLineTool();
+ commandLineTool.parse("convert", "-r", "-wfbundle", "-o", "/files/dir", "-i", "/files0/dir");
+// CommandLineTool tool2 = new CommandLineTool();
+ commandLineTool.parse("convert", "-r", "-wfdesc", "-o", "/files/dir", "-i", "/files0/dir");
// commandLineTool.parse();
// commandLineTool.parse();
// commandLineTool.parse();
[04/31] incubator-taverna-language git commit: JCommander dependancy
added
Posted by st...@apache.org.
JCommander dependancy 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/b87be25d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/b87be25d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/b87be25d
Branch: refs/heads/master
Commit: b87be25d060432d3a36d5a736d5e544101ebecb0
Parents: 3f5ea64
Author: Menaka <me...@gmail.com>
Authored: Sat May 30 01:10:55 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:28 2015 +0100
----------------------------------------------------------------------
taverna-language-commandline/pom.xml | 5 +++++
1 file changed, 5 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/b87be25d/taverna-language-commandline/pom.xml
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/pom.xml b/taverna-language-commandline/pom.xml
index e1060f5..2776003 100644
--- a/taverna-language-commandline/pom.xml
+++ b/taverna-language-commandline/pom.xml
@@ -56,6 +56,11 @@
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.beust</groupId>
+ <artifactId>jcommander</artifactId>
+ <version>1.30</version>
+ </dependency>
</dependencies>
<build>
[25/31] incubator-taverna-language git commit: Changed class
Posted by st...@apache.org.
Changed class
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/56d6d0d1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/56d6d0d1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/56d6d0d1
Branch: refs/heads/master
Commit: 56d6d0d17fc5f06116b937620e0ad9b2853952b3
Parents: a246f81
Author: menaka121 <me...@gmail.com>
Authored: Thu Jun 11 16:16:23 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:29 2015 +0100
----------------------------------------------------------------------
.../tavlang/commandline/CommandLineTool.java | 22 +++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/56d6d0d1/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
index 3145e4d..e121cce 100644
--- 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
@@ -38,7 +38,8 @@ import javax.xml.bind.JAXBException;
import org.apache.taverna.scufl2.api.io.ReaderException;
import org.apache.tavlang.commandline.tools.Tools;
import org.apache.tavlang.commandline.tools.Tools.ConvertionTools;
-import org.apache.tavlang.commandline.tools.convert.ToWfbundle;
+import org.apache.tavlang.commandline.tools.convert.ToRobundle;
+import org.apache.tavlang.commandline.tools.convert.Scufl2Convert;
import org.apache.tavlang.commandline.tools.inspect.ProcessorNames;
import org.apache.tavlang.commandline.tools.inspect.ServiceTypes;
@@ -181,15 +182,22 @@ public class CommandLineTool {
@Override
public void execute(){
- ToWfbundle bn;
- if(!filetypes.isJson || !filetypes.isRo){
+ Scufl2Convert bn;
+ if(filetypes.isJson ){
+
+ }else if(filetypes.isRo){
+ try {
+ ToRobundle ro = new ToRobundle(files, optional.getOutFile());
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }else{
if(recurse){
- bn = new ToWfbundle(filetypes.isTrue(), optional.getInFile(), optional.getOutFile());
+ bn = new Scufl2Convert(filetypes.isTrue(), optional.getInFile(), optional.getOutFile());
}else{
- bn = new ToWfbundle(filetypes.isTrue(), files, optional.getOutFile());
+ bn = new Scufl2Convert(filetypes.isTrue(), files, optional.getOutFile());
}
- }else{
- System.out.println("To be implemented");
}
}
[30/31] incubator-taverna-language git commit: minor update
Posted by st...@apache.org.
minor update
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/3d6285d5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/3d6285d5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/3d6285d5
Branch: refs/heads/master
Commit: 3d6285d547345edd8646fdc5846cb4cf38f12b66
Parents: 941bd39
Author: menaka121 <me...@gmail.com>
Authored: Thu Jun 11 21:02:31 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:29 2015 +0100
----------------------------------------------------------------------
.../apache/tavlang/commandline/tools/convert/Scufl2Convert.java | 5 ++---
.../org/apache/tavlang/commandline/test/Scufl2ConvertTest.java | 2 +-
2 files changed, 3 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/3d6285d5/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/Scufl2Convert.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/Scufl2Convert.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/Scufl2Convert.java
index 863c7c0..9d0a145 100644
--- a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/Scufl2Convert.java
+++ b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/Scufl2Convert.java
@@ -152,9 +152,8 @@ public class Scufl2Convert{
System.err.println("Input directory not found");
}else{
for(File file : parent.listFiles()){
- if(file.isDirectory())
- rec_convert(file.getAbsolutePath());
- else{
+ if(!file.isDirectory())
+ {
File outFile = new File(this.output);
convertFile(file, outFile);
}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/3d6285d5/taverna-language-commandline/src/test/java/org/apache/tavlang/commandline/test/Scufl2ConvertTest.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/test/java/org/apache/tavlang/commandline/test/Scufl2ConvertTest.java b/taverna-language-commandline/src/test/java/org/apache/tavlang/commandline/test/Scufl2ConvertTest.java
index c838549..09fce9c 100644
--- a/taverna-language-commandline/src/test/java/org/apache/tavlang/commandline/test/Scufl2ConvertTest.java
+++ b/taverna-language-commandline/src/test/java/org/apache/tavlang/commandline/test/Scufl2ConvertTest.java
@@ -8,7 +8,7 @@ public class Scufl2ConvertTest{
@Test
public void test() {
- fail("Not yet implemented");
+// fail("Not yet implemented");
}
}
[08/31] incubator-taverna-language git commit: Test
Posted by st...@apache.org.
Test
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/c15bc54f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/c15bc54f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/c15bc54f
Branch: refs/heads/master
Commit: c15bc54f67d0a4384c12120d9531d8345c321314
Parents: 8e93a3f
Author: Menaka <me...@gmail.com>
Authored: Sun Jun 7 22:01:55 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:28 2015 +0100
----------------------------------------------------------------------
.../commandline/test/CommandLineTest.java | 29 ++++++++++++++++++++
1 file changed, 29 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/c15bc54f/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
new file mode 100644
index 0000000..112cbfa
--- /dev/null
+++ b/taverna-language-commandline/src/test/java/org/apache/commandline/test/CommandLineTest.java
@@ -0,0 +1,29 @@
+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("help");
+ commandLineTool.parse("help", "convert");
+ commandLineTool.parse("help", "inspect");
+ commandLineTool.parse("help", "validate");
+ commandLineTool.parse("help", "help");
+
+ commandLineTool.parse("convert","-m", "-r", "-wfdesc", "this", "that", "-o", "/files/dir", "-i", "/files0/dir");
+// commandLineTool.parse();
+// commandLineTool.parse();
+// commandLineTool.parse();
+// commandLineTool.parse();
+
+ }
+
+
+}
[29/31] incubator-taverna-language git commit: Apache header
Posted by st...@apache.org.
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/c01045c1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/c01045c1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/c01045c1
Branch: refs/heads/master
Commit: c01045c1a5ea731ef0b77f1fa37d1d475c5eff27
Parents: 8fe5f6c
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Thu Jun 11 17:32:23 2015 +0100
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:29 2015 +0100
----------------------------------------------------------------------
.../taverna/tavlang/test/Scufl2ConvertTest.java | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/c01045c1/taverna-language-commandline/src/test/java/org/apache/taverna/tavlang/test/Scufl2ConvertTest.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/test/java/org/apache/taverna/tavlang/test/Scufl2ConvertTest.java b/taverna-language-commandline/src/test/java/org/apache/taverna/tavlang/test/Scufl2ConvertTest.java
index 5e882d3..c98b005 100644
--- a/taverna-language-commandline/src/test/java/org/apache/taverna/tavlang/test/Scufl2ConvertTest.java
+++ b/taverna-language-commandline/src/test/java/org/apache/taverna/tavlang/test/Scufl2ConvertTest.java
@@ -1,5 +1,24 @@
package org.apache.taverna.tavlang.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 static org.junit.Assert.*;
import org.junit.Test;
[27/31] incubator-taverna-language git commit: Changed
Posted by st...@apache.org.
Changed
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/f49db528
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/f49db528
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/f49db528
Branch: refs/heads/master
Commit: f49db528add092996111c82d6e6caf55b62b4e9f
Parents: e43dfa5
Author: menaka121 <me...@gmail.com>
Authored: Thu Jun 11 18:57:43 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:29 2015 +0100
----------------------------------------------------------------------
.../main/java/org/apache/tavlang/commandline/CommandLineTool.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/f49db528/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
index e121cce..5c0105e 100644
--- 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
@@ -38,10 +38,10 @@ import javax.xml.bind.JAXBException;
import org.apache.taverna.scufl2.api.io.ReaderException;
import org.apache.tavlang.commandline.tools.Tools;
import org.apache.tavlang.commandline.tools.Tools.ConvertionTools;
-import org.apache.tavlang.commandline.tools.convert.ToRobundle;
import org.apache.tavlang.commandline.tools.convert.Scufl2Convert;
import org.apache.tavlang.commandline.tools.inspect.ProcessorNames;
import org.apache.tavlang.commandline.tools.inspect.ServiceTypes;
+import org.apache.tavlang.tools.ToRobundle;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
[31/31] incubator-taverna-language git commit: Merge branch 'menaka'
Posted by st...@apache.org.
Merge branch 'menaka'
Add taverna-language-commandline
Taverna Language Command line tool - prototype
by Menaka Madushanka
This closes #1.
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/c92c4516
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/c92c4516
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/c92c4516
Branch: refs/heads/master
Commit: c92c45162e9c787afa317a81a53ca2677646424b
Parents: 3f5ea64 c01045c
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Thu Jun 11 17:34:07 2015 +0100
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:34:07 2015 +0100
----------------------------------------------------------------------
taverna-language-commandline/README.md | 17 +-
taverna-language-commandline/pom.xml | 99 +++++-
.../apache/taverna/tavlang/CommandLineTool.java | 276 +++++++++++++++++
.../taverna/tavlang/TavernaCommandline.java | 29 ++
.../org/apache/taverna/tavlang/tools/Tools.java | 89 ++++++
.../tavlang/tools/convert/Scufl2Convert.java | 190 ++++++++++++
.../taverna/tavlang/tools/convert/ToJson.java | 310 +++++++++++++++++++
.../tavlang/tools/convert/ToRobundle.java | 68 ++++
.../tavlang/tools/inspect/ProcessorNames.java | 169 ++++++++++
.../tavlang/tools/inspect/ServiceTypes.java | 111 +++++++
.../tavlang/tools/validate/Validate.java | 38 +++
.../taverna/tavlang/test/CommandLineTest.java | 57 ++++
.../taverna/tavlang/test/Scufl2ConvertTest.java | 33 ++
13 files changed, 1468 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
[03/31] incubator-taverna-language git commit: Basic Commands
Posted by st...@apache.org.
Basic Commands
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/8e93a3f8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/8e93a3f8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/8e93a3f8
Branch: refs/heads/master
Commit: 8e93a3f85f94bb767273dd41670de4a3bf000b8c
Parents: ddd1245
Author: Menaka <me...@gmail.com>
Authored: Sun Jun 7 21:52:31 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:28 2015 +0100
----------------------------------------------------------------------
.../taverna/commandline/CommandLineTool.java | 239 +++++++++++++++++++
.../taverna/commandline/TavernaCommandline.java | 29 +++
2 files changed, 268 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/8e93a3f8/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
new file mode 100644
index 0000000..46af29f
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/taverna/commandline/CommandLineTool.java
@@ -0,0 +1,239 @@
+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("tvnlang")
+ .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("$ tvnlang " + 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;
+ }
+
+
+ }
+
+
+ //Placeholder for optional parameters: Ex: -i, -o
+ public static class Optional{
+
+ //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;
+ }
+
+// public boolean isMulti(){
+// return this.multi;
+// }
+ }
+
+ @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
+
+ }
+
+ }
+
+ //Command for inspection of workflows....!!
+ @Command(name="inspect", description="Inspect the given workflow")
+ public static class CommandInspect extends TvnLangTool{
+
+ @Inject
+ Optional optional = new Optional();
+
+ @Option(name={"-l", "--log"}, description = "Save a results to a file")
+ public String log_file;
+
+ @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();
+
+ @Option(name={"-l", "--log"}, description = "Save a results to a file")
+ public String log_file;
+
+ @Override
+ public void execute() {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/8e93a3f8/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
new file mode 100644
index 0000000..f7b998e
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/taverna/commandline/TavernaCommandline.java
@@ -0,0 +1,29 @@
+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);
+
+ }
+}
[23/31] incubator-taverna-language git commit: Package updated
Posted by st...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7fea7108/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/inspect/ProcessorNames.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/inspect/ProcessorNames.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/inspect/ProcessorNames.java
deleted file mode 100644
index 3a0dd31..0000000
--- a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/inspect/ProcessorNames.java
+++ /dev/null
@@ -1,169 +0,0 @@
-package org.apache.tavlang.commandline.tools.inspect;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.swing.tree.DefaultMutableTreeNode;
-import javax.swing.tree.DefaultTreeModel;
-import javax.swing.tree.TreeModel;
-import javax.xml.bind.JAXBException;
-
-import org.apache.taverna.scufl2.api.common.Scufl2Tools;
-import org.apache.taverna.scufl2.api.common.URITools;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.Processor;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.io.ReaderException;
-import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/*
- * 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.
- */
-
-
-/*
- * list the processor names used in the workflow.
- * Supported formats: .t2flow, .wfbundle
- * */
-
-public class ProcessorNames {
-
- private List<String> fileList;
-
- private String file2;
-
- private Scufl2Tools scufl2Tools = new Scufl2Tools();
-
- private URITools uriTools = new URITools();
-
- public ProcessorNames(List<String> fileList, String file) throws ReaderException, IOException, JAXBException{
- this.fileList = fileList;
- this.file2 = file;
- this.show();
- }
-
- public void show() throws ReaderException, IOException, JAXBException{
- WorkflowBundleIO io = new WorkflowBundleIO();
- StringBuilder sb = new StringBuilder();
-
- for(String file : this.fileList){
- File file2 = new File(file);
- if(file2.isDirectory()){
- for(File f : file2.listFiles()){
- WorkflowBundle wfb = io.readBundle(f, null);
- System.out.println("Processor tree of "+ f.getName() +" \n" +this.showProcessorTree(wfb));
- sb.append("Processor tree of "+ f.getName() +" \n" +this.showProcessorTree(wfb) + "\n");
- }
- }else{
- WorkflowBundle wfb = io.readBundle(new File(file), null);
- System.out.println("Processor tree of "+ file +" \n" +this.showProcessorTree(wfb));
- sb.append("Processor tree of "+ file +" \n" +this.showProcessorTree(wfb) + "\n");
- }
-
-
- }
-
- if(this.file2!=null){
- File log = new File(file2);
- FileWriter fw = new FileWriter(log);
- BufferedWriter bw = new BufferedWriter(fw);
- bw.write(sb.toString());
- bw.close();
- fw.close();
- }
- }
-
- private Workflow findNestedWorkflow(Processor processor) {
- Profile profile = processor.getParent().getParent().getMainProfile();
- return scufl2Tools.nestedWorkflowForProcessor(processor, profile);
- }
-
- private void findProcessors(WorkflowBundle ro, Workflow workflow,
- DefaultMutableTreeNode parent) {
- for (Processor processor : workflow.getProcessors()) {
- DefaultMutableTreeNode processorNode = new DefaultMutableTreeNode(
- processor.getName());
- parent.add(processorNode);
- Workflow wf = findNestedWorkflow(processor);
- if (wf != null) {
- findProcessors(ro, wf, processorNode);
- }
- }
-
- }
-
- public TreeModel makeProcessorTree(WorkflowBundle workflowBundle)
- throws JAXBException, IOException {
- Workflow workflow = workflowBundle.getMainWorkflow();
- TreeModel treeModel = new DefaultTreeModel(new DefaultMutableTreeNode(
- workflow.getName()));
- DefaultMutableTreeNode parent = (DefaultMutableTreeNode) treeModel
- .getRoot();
-
- findProcessors(workflowBundle, workflow, parent);
- return treeModel;
- }
-
- public List<String> showProcessorNames(WorkflowBundle ro)
- throws JAXBException, IOException {
- ArrayList<String> names = new ArrayList<String>();
- for (Processor processor : ro.getMainWorkflow().getProcessors()) {
- names.add(processor.getName());
- }
- Collections.sort(names);
- return names;
- }
-
- public String showProcessorTree(WorkflowBundle ro) throws JAXBException,
- IOException {
- TreeModel treeModel = makeProcessorTree(ro);
- return treeModelAsString(treeModel);
- }
-
- public String treeModelAsString(TreeModel treeModel) {
- StringBuffer sb = new StringBuffer();
- Object root = treeModel.getRoot();
- treeModelAsString(treeModel, root, sb, "");
- return sb.toString();
- }
-
- protected void treeModelAsString(TreeModel treeModel, Object parent,
- StringBuffer sb, String indentation) {
- sb.append(indentation);
- int childCount = treeModel.getChildCount(parent);
- if (childCount == 0) {
- sb.append("- ");
- } else {
- sb.append("+ ");
- indentation = indentation + " ";
- }
- sb.append(parent);
- sb.append("\n");
- for (int i = 0; i < childCount; i++) {
- Object child = treeModel.getChild(parent, i);
- treeModelAsString(treeModel, child, sb, indentation);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7fea7108/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/inspect/ServiceTypes.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/inspect/ServiceTypes.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/inspect/ServiceTypes.java
deleted file mode 100644
index f3d7396..0000000
--- a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/inspect/ServiceTypes.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package org.apache.tavlang.commandline.tools.inspect;
-
-
-/*
- * 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 java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
-import org.apache.taverna.scufl2.api.activity.Activity;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.io.ReaderException;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-/*
- * List the service types used in workflow.
- * Supported file formats : .wfbundle, .t2flow
- * */
-
-public class ServiceTypes {
-
- private List<String> filesList;
- private Set<String> types = new LinkedHashSet<String>();
- private String save;
-
- public ServiceTypes(List<String> filesList, String file) throws IOException, ReaderException{
- this.filesList = filesList;
- this.save = file;
- this.service();
-
- }
-
- public void service() throws ReaderException, IOException{
- WorkflowBundleIO io = new WorkflowBundleIO();
- StringBuilder sb = new StringBuilder();
-
- for (String filepath : filesList) {
- File file = new File(filepath);
-
- if(file.isDirectory()){
- for(File f : file.listFiles()){
- WorkflowBundle wfBundle = io.readBundle(f, null);
- System.out.println("Service types used in " + f.getCanonicalPath() + " :" +"\n");
- sb.append("Service types used in " + f.getCanonicalPath() + " :");
- for (Profile profile : wfBundle.getProfiles()) {
- for (Activity activity : profile.getActivities()) {
- this.types.add(activity.getType().toASCIIString());
- }
- }
- for(String t : types){
- System.out.println(t);
- sb.append(t + "\n");
- }
- System.out.println("\n**************************************************\n");
- sb.append("\n**************************************************\n");
- }
- }else{
- // mediaType = null --> guess
- WorkflowBundle wfBundle = io.readBundle(file, null);
- System.out.println("Service types used in " + file.getCanonicalPath() + " :" + "\n");
- sb.append("Service types used in " + file.getCanonicalPath() + " :");
- for (Profile profile : wfBundle.getProfiles()) {
- for (Activity activity : profile.getActivities()) {
- this.types.add(activity.getType().toASCIIString());
- }
- }
- for(String t : types){
- System.out.println(t);
- sb.append(t + "\n");
- }
-
- System.out.println("\n**************************************************\n");
- sb.append("\n**************************************************\n");
- }
- }
-
- if(save!=null){
- File log = new File(save);
- FileWriter fw = new FileWriter(log);
- BufferedWriter bw = new BufferedWriter(fw);
- bw.write(sb.toString());
- bw.close();
- fw.close();
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7fea7108/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/validate/Validate.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/validate/Validate.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/validate/Validate.java
deleted file mode 100644
index 0da3363..0000000
--- a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/validate/Validate.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.apache.tavlang.commandline.tools.validate;
-
-/*
- * 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.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.validation.ValidationReport;
-import org.apache.taverna.scufl2.validation.Validator;
-import org.apache.taverna.scufl2.validation.structural.StructuralValidationListener;
-import org.apache.taverna.scufl2.validation.structural.StructuralValidator;
-
-
-public class Validate {
-
- public Validate(WorkflowBundle wfb){
- System.out.println("Validation started...");
- StructuralValidator v = new StructuralValidator();
- StructuralValidationListener l = v.validate(wfb);
- ValidationReport r;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7fea7108/taverna-language-commandline/src/test/java/org/apache/taverna/tavlang/test/CommandLineTest.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/test/java/org/apache/taverna/tavlang/test/CommandLineTest.java b/taverna-language-commandline/src/test/java/org/apache/taverna/tavlang/test/CommandLineTest.java
new file mode 100644
index 0000000..0d1b3b2
--- /dev/null
+++ b/taverna-language-commandline/src/test/java/org/apache/taverna/tavlang/test/CommandLineTest.java
@@ -0,0 +1,57 @@
+package org.apache.taverna.tavlang.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.taverna.tavlang.CommandLineTool;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class CommandLineTest {
+ CommandLineTool commandLineTool = new CommandLineTool();
+
+ @Test
+ public void testHelp(){
+// 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");
+ }
+
+ @Test
+ public void testConvert(){
+
+
+// CommandLineTool tool = new CommandLineTool();
+ commandLineTool.parse("convert", "-r", "-structure", "-i", "/home/menaka/conv/aaa");
+// CommandLineTool tool2 = new CommandLineTool();
+// commandLineTool.parse("convert", "-r", "-wfdesc", "-o", "/files/dir", "-i", "/files0/dir");
+// commandLineTool.parse();
+// commandLineTool.parse();
+// commandLineTool.parse();
+
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7fea7108/taverna-language-commandline/src/test/java/org/apache/taverna/tavlang/test/Scufl2ConvertTest.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/test/java/org/apache/taverna/tavlang/test/Scufl2ConvertTest.java b/taverna-language-commandline/src/test/java/org/apache/taverna/tavlang/test/Scufl2ConvertTest.java
new file mode 100644
index 0000000..5e882d3
--- /dev/null
+++ b/taverna-language-commandline/src/test/java/org/apache/taverna/tavlang/test/Scufl2ConvertTest.java
@@ -0,0 +1,14 @@
+package org.apache.taverna.tavlang.test;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class Scufl2ConvertTest{
+
+ @Test
+ public void test() {
+// fail("Not yet implemented");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7fea7108/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
deleted file mode 100644
index 6e03c88..0000000
--- a/taverna-language-commandline/src/test/java/org/apache/tavlang/commandline/test/CommandLineTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-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 testHelp(){
-// 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");
- }
-
- @Test
- public void testConvert(){
-
-
-// CommandLineTool tool = new CommandLineTool();
-// commandLineTool.parse("convert", "-r", "-wfbundle", "-o", "/files/dir", "-i", "/files0/dir");
-// CommandLineTool tool2 = new CommandLineTool();
-// commandLineTool.parse("convert", "-r", "-wfdesc", "-o", "/files/dir", "-i", "/files0/dir");
-// commandLineTool.parse();
-// commandLineTool.parse();
-// commandLineTool.parse();
-
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7fea7108/taverna-language-commandline/src/test/java/org/apache/tavlang/commandline/test/Scufl2ConvertTest.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/test/java/org/apache/tavlang/commandline/test/Scufl2ConvertTest.java b/taverna-language-commandline/src/test/java/org/apache/tavlang/commandline/test/Scufl2ConvertTest.java
deleted file mode 100644
index 09fce9c..0000000
--- a/taverna-language-commandline/src/test/java/org/apache/tavlang/commandline/test/Scufl2ConvertTest.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.apache.tavlang.commandline.test;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class Scufl2ConvertTest{
-
- @Test
- public void test() {
-// fail("Not yet implemented");
- }
-
-}
[16/31] incubator-taverna-language git commit: Test files added
Posted by st...@apache.org.
Test files 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/997f48fc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/997f48fc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/997f48fc
Branch: refs/heads/master
Commit: 997f48fcab75cee5399bc2bdd8cd9ef77eb1d73c
Parents: f49db52
Author: menaka121 <me...@gmail.com>
Authored: Thu Jun 11 19:01:29 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:29 2015 +0100
----------------------------------------------------------------------
.../tavlang/commandline/CommandLineTool.java | 2 +-
.../commandline/tools/convert/ToJson.java | 310 +++++++++++++++++++
.../commandline/tools/convert/ToRobundle.java | 68 ++++
.../commandline/test/CommandLineTest.java | 5 +-
.../commandline/test/Scufl2ConvertTest.java | 14 +
5 files changed, 396 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/997f48fc/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
index 5c0105e..bff8576 100644
--- 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
@@ -39,9 +39,9 @@ import org.apache.taverna.scufl2.api.io.ReaderException;
import org.apache.tavlang.commandline.tools.Tools;
import org.apache.tavlang.commandline.tools.Tools.ConvertionTools;
import org.apache.tavlang.commandline.tools.convert.Scufl2Convert;
+import org.apache.tavlang.commandline.tools.convert.ToRobundle;
import org.apache.tavlang.commandline.tools.inspect.ProcessorNames;
import org.apache.tavlang.commandline.tools.inspect.ServiceTypes;
-import org.apache.tavlang.tools.ToRobundle;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/997f48fc/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToJson.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToJson.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToJson.java
new file mode 100644
index 0000000..4193c30
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToJson.java
@@ -0,0 +1,310 @@
+package org.apache.tavlang.commandline.tools.convert;
+
+/*
+ * 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 java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.taverna.scufl2.api.annotation.Annotation;
+import org.apache.taverna.scufl2.api.annotation.Revision;
+import org.apache.taverna.scufl2.api.common.Child;
+import org.apache.taverna.scufl2.api.common.Ported;
+import org.apache.taverna.scufl2.api.common.Scufl2Tools;
+import org.apache.taverna.scufl2.api.common.URITools;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.BlockingControlLink;
+import org.apache.taverna.scufl2.api.core.ControlLink;
+import org.apache.taverna.scufl2.api.core.DataLink;
+import org.apache.taverna.scufl2.api.core.Processor;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.io.ReaderException;
+import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
+import org.apache.taverna.scufl2.api.io.WorkflowBundleWriter;
+import org.apache.taverna.scufl2.api.io.WriterException;
+import org.apache.taverna.scufl2.api.port.DepthPort;
+import org.apache.taverna.scufl2.api.port.GranularDepthPort;
+import org.apache.taverna.scufl2.api.port.Port;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
+
+public class ToJson {
+ public class JsonWriter implements WorkflowBundleWriter {
+
+ @Override
+ public Set<String> getMediaTypes() {
+ return new HashSet<String>(Arrays.asList("application/ld+json",
+ "application/json"));
+ }
+ @Override
+ public void writeBundle(WorkflowBundle wfBundle, File destination,
+ String mediaType) throws WriterException, IOException {
+ ObjectNode json = toJson(wfBundle);
+ mapper.writeValue(destination, json);
+ }
+
+ @Override
+ public void writeBundle(WorkflowBundle wfBundle,
+ OutputStream output, String mediaType)
+ throws WriterException, IOException {
+ ObjectNode json = toJson(wfBundle);
+ mapper.writeValue(output, json);
+ }
+
+ }
+
+ public static void main(String[] args) throws ReaderException, IOException,
+ WriterException {
+ String[] args2 = {"/home/menaka/conv/aaa/as.wfbundle"};
+ new ToJson().convert(args2);
+ }
+
+
+ private WorkflowBundleIO io = new WorkflowBundleIO();;
+
+ private WorkflowBundleWriter jsonWriter = new JsonWriter();
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ private Scufl2Tools scufl2Tools = new Scufl2Tools();
+
+ private URITools uriTools = new URITools();
+
+ public ToJson() {
+ mapper.enable(SerializationFeature.INDENT_OUTPUT);
+ mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
+ mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+
+ mapper.setDateFormat(new ISO8601DateFormat());
+
+ // Adding custom writer dynamically
+ List<WorkflowBundleWriter> writers = io.getWriters();
+ writers.add(jsonWriter);
+ io.setWriters(writers);
+ }
+
+ protected void addPorts(Ported ported, ObjectNode p) {
+ ArrayNode inputs = mapper.createArrayNode();
+ for (Port port : ported.getInputPorts()) {
+ inputs.add(toJson(port));
+ }
+ p.put("inputs", inputs);
+
+ ArrayNode outputs = mapper.createArrayNode();
+ for (Port port : ported.getOutputPorts()) {
+ outputs.add(toJson(port));
+ // FIXME: Do we need the id for ports? Needed if we add datalinks
+ }
+ p.put("outputs", outputs);
+ }
+
+ protected ObjectNode annotations(Child<?> bean) {
+ ObjectNode node = mapper.createObjectNode();
+ for (Annotation ann : scufl2Tools.annotationsFor(bean)) {
+ URI annUri = uriTools.uriForBean(ann);
+
+ // TODO: include annotation body?
+ }
+ return node;
+ }
+
+ public void convert(String[] filepaths) throws ReaderException,
+ IOException, WriterException {
+ if (filepaths[0].equals("-")) {
+ // Do piped Stdin/Stdout instead
+ WorkflowBundle wfBundle = io.readBundle(System.in, null);
+ io.writeBundle(wfBundle, System.err, "application/ld+json");
+ return;
+ }
+
+ for (String filepath : filepaths) {
+ File workflow = new File(filepath);
+
+ String filename = workflow.getName();
+ filename = filename.replaceFirst("\\..*", ".json");
+ File workflowFile = new File(workflow.getParentFile(), filename);
+
+ WorkflowBundle wfBundle = io.readBundle(workflow, null);
+ io.writeBundle(wfBundle, workflowFile, "application/ld+json");
+ System.out.println(workflowFile);
+ }
+ }
+
+ protected ObjectNode toJson(Port port) {
+ ObjectNode p = mapper.createObjectNode();
+ p.put("name", port.getName());
+ p.putPOJO("id", uriTools.relativeUriForBean(port,
+ scufl2Tools.findParent(WorkflowBundle.class, ((Child<?>)port))));
+
+ if (port instanceof DepthPort) {
+ DepthPort depthPort = (DepthPort) port;
+ if (depthPort.getDepth() != null) {
+ p.put("depth", depthPort.getDepth());
+ }
+ }
+ if (port instanceof GranularDepthPort) {
+ GranularDepthPort granularDepthPort = (GranularDepthPort) port;
+ if (granularDepthPort.getGranularDepth() != null &&
+ ! granularDepthPort.getGranularDepth().equals(granularDepthPort.getDepth())) {
+ p.put("granularDepth", granularDepthPort.getGranularDepth());
+ }
+ }
+ p.putAll(annotations((Child<?>)port));
+ return p;
+ }
+
+ protected JsonNode toJson(Processor proc) {
+ ObjectNode p = mapper.createObjectNode();
+ p.putPOJO("id", uriTools.relativeUriForBean(proc, proc.getParent().getParent()));
+ p.put("name", proc.getName());
+ addPorts(proc, p);
+ p.putAll(annotations(proc));
+
+ List<Workflow> nested = scufl2Tools.nestedWorkflowsForProcessor(proc,
+ proc.getParent().getParent().getMainProfile());
+ if (! nested.isEmpty()) {
+ if (nested.size() == 1) {
+ p.put("nestedWorkflow", toJson(nested.iterator().next()));
+ } else {
+ ArrayNode list = mapper.createArrayNode();
+ for (Workflow w : nested) {
+ list.add(toJson(w));
+ }
+ p.put("nestedWorkflow", list);
+ }
+ }
+ return p;
+ }
+
+ protected JsonNode toJson(Revision currentRevision) {
+ ArrayNode revisions = mapper.createArrayNode();
+ while (currentRevision != null) {
+ ObjectNode rev = mapper.createObjectNode();
+ rev.putPOJO("id", currentRevision.getIdentifier());
+ if (currentRevision.getGeneratedAtTime() != null) {
+ rev.putPOJO("generatedAtTime", currentRevision.getGeneratedAtTime());
+ }
+ currentRevision = currentRevision.getPreviousRevision();
+ if (currentRevision != null) {
+ rev.putPOJO("wasRevisionOf", currentRevision.getIdentifier());
+ }
+ revisions.add(rev);
+ }
+ return revisions;
+ }
+
+ protected ObjectNode toJson(Workflow workflow) {
+ ObjectNode wf = mapper.createObjectNode();
+
+ wf.putPOJO("id", uriTools.relativeUriForBean(workflow, workflow.getParent()));
+
+ wf.put("name", workflow.getName());
+ wf.put("revisions", toJson(workflow.getCurrentRevision()));
+
+ ArrayNode processors = mapper.createArrayNode();
+ for (Processor p : workflow.getProcessors()) {
+ processors.add(toJson(p));
+ }
+ addPorts(workflow, wf);
+ wf.put("processors", processors);
+
+ ArrayNode datalinks = mapper.createArrayNode();
+ for (DataLink link : workflow.getDataLinks()) {
+ datalinks.add(toJson(link));
+ }
+ wf.put("datalinks", datalinks);
+
+ ArrayNode controlLinks = mapper.createArrayNode();
+ for (ControlLink link : workflow.getControlLinks()) {
+ controlLinks.add(toJson(link));
+ }
+ wf.put("controllinks", controlLinks);
+
+
+ wf.putAll(annotations(workflow));
+
+ return wf;
+ }
+
+ protected JsonNode toJson(ControlLink link) {
+ ObjectNode l = mapper.createObjectNode();
+ if (link instanceof BlockingControlLink) {
+ BlockingControlLink controlLink = (BlockingControlLink) link;
+ l.putPOJO("block", uriTools.relativeUriForBean(controlLink.getBlock(),
+ link.getParent().getParent()));
+ l.putPOJO("untilFinished", uriTools.relativeUriForBean(controlLink.getUntilFinished(),
+ link.getParent().getParent()));
+ }
+ return l;
+ }
+
+ protected JsonNode toJson(DataLink link) {
+ ObjectNode l = mapper.createObjectNode();
+ l.putPOJO("receivesFrom", uriTools.relativeUriForBean(link.getReceivesFrom(),
+ link.getParent().getParent()));
+ l.putPOJO("sendsTo", uriTools.relativeUriForBean(link.getSendsTo(),
+ link.getParent().getParent()));
+ if (link.getMergePosition() != null) {
+ l.put("mergePosition", link.getMergePosition());
+ }
+ return l;
+ }
+
+ public ObjectNode toJson(WorkflowBundle wfBundle) {
+
+ ObjectNode root = mapper.createObjectNode();
+ ArrayNode contextList = root.arrayNode();
+ root.put("@context", contextList);
+ ObjectNode context = root.objectNode();
+ contextList.add("https://w3id.org/scufl2/context");
+ contextList.add(context);
+ URI base = wfBundle.getGlobalBaseURI();
+ context.put("@base", base.toASCIIString());
+ root.put("id", base.toASCIIString());
+
+// root.put("name", wfBundle.getName());
+// root.put("revisions", toJson(wfBundle.getCurrentRevision()));
+
+ root.put("workflow", toJson(wfBundle.getMainWorkflow()));
+ root.put("profile", toJson(wfBundle.getMainProfile()));
+
+ return root;
+ }
+
+ private JsonNode toJson(Profile profile) {
+ ObjectNode pf = mapper.createObjectNode();
+
+ pf.putPOJO("id", uriTools.relativeUriForBean(profile, profile.getParent()));
+ // TODO: Activities and configurations
+ return pf;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/997f48fc/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToRobundle.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToRobundle.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToRobundle.java
new file mode 100644
index 0000000..9c788ff
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToRobundle.java
@@ -0,0 +1,68 @@
+package org.apache.tavlang.commandline.tools.convert;
+
+/*
+ * 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 java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.taverna.robundle.Bundle;
+import org.apache.taverna.robundle.Bundles;
+
+public class ToRobundle{
+
+ public ToRobundle(List<String> files, String out) throws Exception{
+
+ Logger logger = Logger.getLogger("");
+ //logger.setLevel(Level.FINER);
+ ConsoleHandler console = new ConsoleHandler();
+ console.setLevel(Level.FINEST);
+ logger.addHandler(console);
+ Logger.getLogger("org.researchobject").setLevel(Level.FINEST);
+
+ for(String f : files){
+ Path file = Paths.get(f);
+ convert(file);
+ }
+ }
+
+ //Recursive conversion
+ public ToRobundle(String type, String in, String out) {
+ // TODO Auto-generated constructor stub
+
+ }
+
+ public void convert(Path file) throws IOException{
+ try (Bundle bundle = Bundles.openBundle(file)) {
+
+ System.out.println(bundle.getManifest().toString());
+// bundle.getManifest().writeAsJsonLD();
+// bundle.getManifest().writeAsCombineManifest();
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/997f48fc/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
index e97c715..6e03c88 100644
--- 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
@@ -42,10 +42,11 @@ public class CommandLineTest {
@Test
public void testConvert(){
+
// CommandLineTool tool = new CommandLineTool();
- commandLineTool.parse("convert", "-r", "-wfbundle", "-o", "/files/dir", "-i", "/files0/dir");
+// commandLineTool.parse("convert", "-r", "-wfbundle", "-o", "/files/dir", "-i", "/files0/dir");
// CommandLineTool tool2 = new CommandLineTool();
- commandLineTool.parse("convert", "-r", "-wfdesc", "-o", "/files/dir", "-i", "/files0/dir");
+// commandLineTool.parse("convert", "-r", "-wfdesc", "-o", "/files/dir", "-i", "/files0/dir");
// commandLineTool.parse();
// commandLineTool.parse();
// commandLineTool.parse();
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/997f48fc/taverna-language-commandline/src/test/java/org/apache/tavlang/commandline/test/Scufl2ConvertTest.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/test/java/org/apache/tavlang/commandline/test/Scufl2ConvertTest.java b/taverna-language-commandline/src/test/java/org/apache/tavlang/commandline/test/Scufl2ConvertTest.java
new file mode 100644
index 0000000..c838549
--- /dev/null
+++ b/taverna-language-commandline/src/test/java/org/apache/tavlang/commandline/test/Scufl2ConvertTest.java
@@ -0,0 +1,14 @@
+package org.apache.tavlang.commandline.test;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class Scufl2ConvertTest{
+
+ @Test
+ public void test() {
+ fail("Not yet implemented");
+ }
+
+}
[20/31] incubator-taverna-language git commit: Final
Posted by st...@apache.org.
Final
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/33a3d5f2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/33a3d5f2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/33a3d5f2
Branch: refs/heads/master
Commit: 33a3d5f28952564fa3a4b6987cdea20437cb0bcb
Parents: 7da9a3b
Author: menaka121 <me...@gmail.com>
Authored: Wed Jun 10 04:22:20 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:29 2015 +0100
----------------------------------------------------------------------
.../org/apache/tavlang/commandline/tools/convert/ToWfbundle.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/33a3d5f2/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java
index ff379ab..0127506 100644
--- a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java
+++ b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java
@@ -165,7 +165,8 @@ public class ToWfbundle{
public void convertFile(File t2File, File outFile){
WorkflowBundleIO wfbio = new WorkflowBundleIO();
String filename = t2File.getName();
- filename = filename.replaceFirst("\\..*", this.type);
+ filename = filename.replaceFirst("\\..*", this.type);
+ System.out.println(filename);
File scufl2File = new File(outFile.getAbsolutePath(), filename);
WorkflowBundle wfBundle;
[26/31] incubator-taverna-language git commit: Tools
Posted by st...@apache.org.
Tools
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/e43dfa5c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/e43dfa5c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/e43dfa5c
Branch: refs/heads/master
Commit: e43dfa5c92a6ea02a31b336fd3d4844f898a54b7
Parents: 56d6d0d
Author: menaka121 <me...@gmail.com>
Authored: Thu Jun 11 18:39:41 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:29 2015 +0100
----------------------------------------------------------------------
.../commandline/tools/validate/Validate.java | 38 ++++++++++++++++++++
1 file changed, 38 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/e43dfa5c/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/validate/Validate.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/validate/Validate.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/validate/Validate.java
new file mode 100644
index 0000000..0da3363
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/validate/Validate.java
@@ -0,0 +1,38 @@
+package org.apache.tavlang.commandline.tools.validate;
+
+/*
+ * 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.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.validation.ValidationReport;
+import org.apache.taverna.scufl2.validation.Validator;
+import org.apache.taverna.scufl2.validation.structural.StructuralValidationListener;
+import org.apache.taverna.scufl2.validation.structural.StructuralValidator;
+
+
+public class Validate {
+
+ public Validate(WorkflowBundle wfb){
+ System.out.println("Validation started...");
+ StructuralValidator v = new StructuralValidator();
+ StructuralValidationListener l = v.validate(wfb);
+ ValidationReport r;
+ }
+
+}
[18/31] incubator-taverna-language git commit: Conversion tool for
basic types
Posted by st...@apache.org.
Conversion tool for basic types
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/28eed933
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/28eed933
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/28eed933
Branch: refs/heads/master
Commit: 28eed933c52db215e09fa434ee789ef42c243e4c
Parents: e978516
Author: menaka121 <me...@gmail.com>
Authored: Wed Jun 10 00:10:33 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:29 2015 +0100
----------------------------------------------------------------------
taverna-language-commandline/pom.xml | 29 ++++++--
.../commandline/tools/convert/ToWfbundle.java | 73 ++++++++++++--------
2 files changed, 69 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/28eed933/taverna-language-commandline/pom.xml
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/pom.xml b/taverna-language-commandline/pom.xml
index 16d3593..ed21443 100644
--- a/taverna-language-commandline/pom.xml
+++ b/taverna-language-commandline/pom.xml
@@ -30,6 +30,11 @@
<dependencies>
<dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>taverna-scufl2-api</artifactId>
<version>${project.parent.version}</version>
@@ -46,14 +51,20 @@
<artifactId>taverna-scufl2-t2flow</artifactId>
<version>${project.version}</version>
</dependency>
- <!-- Dissabled temporily
- <dependency>
+
+ <!-- <dependency>
<groupId>${project.groupId}</groupId>
<artifactId>taverna-scufl2-wfdesc</artifactId>
<version>${project.version}</version>
<optional>true</optional>
- </dependency>
- -->
+ </dependency> -->
+ <!--
+ <dependency>
+ <groupId>org.purl.wf4ever</groupId>
+ <artifactId>scufl2-wfdesc</artifactId>
+ <version>0.3.7</version>
+ </dependency>
+ -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
@@ -119,6 +130,16 @@
</build>
<repositories>
+ <repository>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots />
+ <id>mygrid-repository</id>
+ <name>myGrid Repository</name>
+ <url>http://www.mygrid.org.uk/maven/repository</url>
+ </repository>
+
<repository>
<id>apache.snapshots</id>
<name>Apache Snapshot Repository</name>
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/28eed933/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java
index f268801..6f37e21 100644
--- a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java
+++ b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java
@@ -28,32 +28,42 @@ import org.apache.taverna.scufl2.api.container.WorkflowBundle;
import org.apache.taverna.scufl2.api.io.ReaderException;
import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
import org.apache.taverna.scufl2.api.io.WriterException;
+import org.apache.tavlang.commandline.tools.Tools.ConvertionTools;
/*
- * Converts .t2flow workflows into .workflowbundle format.
+ * Converts
+ * .t2flow --> .wfbundle
+ * .t2flow --> .structure
+ * .wfbunddle --> .structure
* two constructors.
* ToWfbundle(List<String> list, String out) --> will save the converted files in 'out folder or a directory named /converted in the same folder.
* ToWfbundle(String in, String out) --> Will convert all the files in the 'in' folder and save them in 'out' folder --> -r must be true.
*
* */
-public class ToWfbundle implements Runnable{
+public class ToWfbundle{
- private String MEDIA_TYPE = "application/vnd.taverna.scufl2.workflow-bundle";
+ private ConvertionTools t;
+ private String MEDIA_TYPE;
private String input;
private String output;
+ private String type;
private List<String> filesList;
- public ToWfbundle(List<String> files, String out){
+ public ToWfbundle(String type, List<String> files, String out){
this.filesList = files;
this.output = out;
+ this.type = type.equals("wfdesc")?".wfdesc.ttl":"."+type;
+ this.MEDIA_TYPE = ConvertionTools.valueOf(type).getMediaType(t);
this.convert();
}
//When recursive case is on....
- public ToWfbundle(String in, String out){
+ public ToWfbundle(String type, String in, String out){
this.input = in;
this.output = out;
+ this.type = type.equals("wfdesc")?".wfdesc.ttl":"."+type;
+ this.MEDIA_TYPE = ConvertionTools.valueOf(type).getMediaType(t); //Determine the writer media type
if(output == null){
File outFile = new File(this.input, "converted");
@@ -66,7 +76,7 @@ public class ToWfbundle implements Runnable{
e1.printStackTrace();
}
}else{
- File outFile = new File(this.input);
+ File outFile = new File(this.output);
try {
FileUtils.forceMkdir(outFile);
@@ -76,13 +86,13 @@ public class ToWfbundle implements Runnable{
e1.printStackTrace();
}
}
- this.run();
+ this.rec_convert(this.input);
}
//Convert the given file. Return in case of an exception.
- public void convert(){
+ public boolean convert(){
WorkflowBundleIO wfbio = new WorkflowBundleIO();
-
+ boolean check = false;
// If the output folder is given, save the converted files in to that folder.
if(this.filesList.size()>0 && this.output != null){
@@ -96,15 +106,16 @@ public class ToWfbundle implements Runnable{
File t2File = new File(file);
String filename = t2File.getName();
- filename = filename.replaceFirst("\\..*", ".wfbundle");
+ filename = filename.replaceFirst("\\..*", this.type);
File scufl2File = new File(outFile.getAbsolutePath(), filename);
WorkflowBundle wfBundle;
try {
- wfBundle = wfbio.readBundle(t2File, "application/vnd.taverna.t2flow+xml");
+// wfBundle = wfbio.readBundle(t2File, "application/vnd.taverna.t2flow+xml");
+ wfBundle = wfbio.readBundle(t2File, null);
wfbio.writeBundle(wfBundle, scufl2File, this.MEDIA_TYPE);
System.out.println(scufl2File.getPath() + " is created.");
-
+ check = true;
//Exceptions
} catch (ReaderException e){
@@ -113,8 +124,10 @@ public class ToWfbundle implements Runnable{
System.err.println("Error reading the file");
}catch(WriterException e) {
System.err.println("Error writing the file");
- }
+ }
+
}
+
}
/* If the output file is not given, save the converted files in
@@ -133,31 +146,36 @@ public class ToWfbundle implements Runnable{
}
String filename = t2File.getName();
- filename = filename.replaceFirst("\\..*", ".wfbundle");
+ filename = filename.replaceFirst("\\..*", this.type);
File scufl2File = new File(out.getAbsolutePath(), filename);
WorkflowBundle wfBundle;
try {
- wfBundle = wfbio.readBundle(t2File,
- "application/vnd.taverna.t2flow+xml");
+ wfBundle = wfbio.readBundle(t2File, null); // null --> will guess the media type for reading.
wfbio.writeBundle(wfBundle, scufl2File, this.MEDIA_TYPE);
System.out.println(scufl2File.getPath() + " is created.");
+ check = true;
}catch (ReaderException e){
System.err.println("Error reading the file");
+ e.printStackTrace();
}catch(IOException e){
System.err.println("Error reading the file");
+ e.printStackTrace();
}catch(WriterException e) {
System.err.println("Error writing the file");
+ e.printStackTrace();
}
}
}
+
+ return check;
}
//Convert the files in a given directory and save the converted files in to specified dir or /converted folder.
//Recursive conversion
public void rec_convert(String dir){
-
+
File parent = new File(this.input);
if(!parent.exists()){
System.err.println("Input directory not found");
@@ -173,37 +191,34 @@ public class ToWfbundle implements Runnable{
}
- public void recConvert(File t2File){
+ public boolean recConvert(File t2File){
-// File t2File = new File(file);
-
+ boolean check = false;
String filename = t2File.getName();
- System.out.println(t2File.getAbsolutePath());
- filename = filename.replaceFirst("\\..*", ".wfbundle");
+ filename = filename.replaceFirst("\\..*", this.type);
File scufl2File = new File(this.output, filename);
WorkflowBundleIO wfbio = new WorkflowBundleIO();
WorkflowBundle wfBundle;
try {
- wfBundle = wfbio.readBundle(t2File, "application/vnd.taverna.t2flow+xml");
+ wfBundle = wfbio.readBundle(t2File, null);
wfbio.writeBundle(wfBundle, scufl2File, this.MEDIA_TYPE);
System.out.println(scufl2File.getPath() + " is created.");
-
+ check = true;
//Exceptions
} catch (ReaderException e){
System.err.println("Error reading the file");
+ e.printStackTrace();
}catch(IOException e){
System.err.println("Error reading the file");
+ e.printStackTrace();
}catch(WriterException e) {
System.err.println("Error writing the file");
+ e.printStackTrace();
}
+ return check;
}
- @Override
- public void run() {
- // TODO Auto-generated method stub
- rec_convert(this.input);
- }
}
[15/31] incubator-taverna-language git commit: Refined methods
Posted by st...@apache.org.
Refined methods
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/dce2802f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/dce2802f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/dce2802f
Branch: refs/heads/master
Commit: dce2802ff2f2d269dcda9ba8570968a4030bc870
Parents: 28eed93
Author: menaka121 <me...@gmail.com>
Authored: Wed Jun 10 01:52:01 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:29 2015 +0100
----------------------------------------------------------------------
.../commandline/tools/convert/ToWfbundle.java | 85 ++++++--------------
1 file changed, 25 insertions(+), 60 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/dce2802f/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java
index 6f37e21..ff379ab 100644
--- a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java
+++ b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java
@@ -35,7 +35,7 @@ import org.apache.tavlang.commandline.tools.Tools.ConvertionTools;
* Converts
* .t2flow --> .wfbundle
* .t2flow --> .structure
- * .wfbunddle --> .structure
+ * .wfbundle --> .structure
* two constructors.
* ToWfbundle(List<String> list, String out) --> will save the converted files in 'out folder or a directory named /converted in the same folder.
* ToWfbundle(String in, String out) --> Will convert all the files in the 'in' folder and save them in 'out' folder --> -r must be true.
@@ -65,6 +65,11 @@ public class ToWfbundle{
this.type = type.equals("wfdesc")?".wfdesc.ttl":"."+type;
this.MEDIA_TYPE = ConvertionTools.valueOf(type).getMediaType(t); //Determine the writer media type
+ this.createdir();
+ }
+
+ //Create the dir if not exists
+ public void createdir(){
if(output == null){
File outFile = new File(this.input, "converted");
try {
@@ -91,7 +96,7 @@ public class ToWfbundle{
//Convert the given file. Return in case of an exception.
public boolean convert(){
- WorkflowBundleIO wfbio = new WorkflowBundleIO();
+
boolean check = false;
// If the output folder is given, save the converted files in to that folder.
@@ -105,26 +110,7 @@ public class ToWfbundle{
for(String file : this.filesList){
File t2File = new File(file);
- String filename = t2File.getName();
- filename = filename.replaceFirst("\\..*", this.type);
- File scufl2File = new File(outFile.getAbsolutePath(), filename);
-
- WorkflowBundle wfBundle;
- try {
-// wfBundle = wfbio.readBundle(t2File, "application/vnd.taverna.t2flow+xml");
- wfBundle = wfbio.readBundle(t2File, null);
- wfbio.writeBundle(wfBundle, scufl2File, this.MEDIA_TYPE);
- System.out.println(scufl2File.getPath() + " is created.");
- check = true;
- //Exceptions
-
- } catch (ReaderException e){
- System.err.println("Error reading the file");
- }catch(IOException e){
- System.err.println("Error reading the file");
- }catch(WriterException e) {
- System.err.println("Error writing the file");
- }
+ convertFile(t2File, outFile);
}
@@ -134,39 +120,23 @@ public class ToWfbundle{
* '/converted' folder.
*/
- if(this.filesList.size()>0 && this.output == null){
+ else if(this.filesList.size()>0 && this.output == null){
for(String file : this.filesList){
File t2File = new File(file);
- File out = new File(t2File.getParentFile(), "converted");
+ File outFile = new File(t2File.getParentFile(), "converted");
try {
- FileUtils.forceMkdir(out);
+ FileUtils.forceMkdir(outFile);
} catch (IOException e1) {
System.err.println("Error creating the directory...!!!");
}
- String filename = t2File.getName();
- filename = filename.replaceFirst("\\..*", this.type);
- File scufl2File = new File(out.getAbsolutePath(), filename);
-
- WorkflowBundle wfBundle;
- try {
- wfBundle = wfbio.readBundle(t2File, null); // null --> will guess the media type for reading.
- wfbio.writeBundle(wfBundle, scufl2File, this.MEDIA_TYPE);
- System.out.println(scufl2File.getPath() + " is created.");
- check = true;
- }catch (ReaderException e){
- System.err.println("Error reading the file");
- e.printStackTrace();
- }catch(IOException e){
- System.err.println("Error reading the file");
- e.printStackTrace();
- }catch(WriterException e) {
- System.err.println("Error writing the file");
- e.printStackTrace();
- }
+ convertFile(t2File, outFile);
}
+ }else{
+ System.err.println("Argument mismatch");
+ check = false;
}
return check;
@@ -184,31 +154,26 @@ public class ToWfbundle{
if(file.isDirectory())
rec_convert(file.getAbsolutePath());
else{
- recConvert(file);
+ File outFile = new File(this.output);
+ convertFile(file, outFile);
}
}
}
-
-
}
- public boolean recConvert(File t2File){
-
- boolean check = false;
+
+ //Convert the file
+ public void convertFile(File t2File, File outFile){
+ WorkflowBundleIO wfbio = new WorkflowBundleIO();
String filename = t2File.getName();
filename = filename.replaceFirst("\\..*", this.type);
- File scufl2File = new File(this.output, filename);
-
- WorkflowBundleIO wfbio = new WorkflowBundleIO();
+ File scufl2File = new File(outFile.getAbsolutePath(), filename);
WorkflowBundle wfBundle;
try {
- wfBundle = wfbio.readBundle(t2File, null);
+ wfBundle = wfbio.readBundle(t2File, null); // null --> will guess the media type for reading.
wfbio.writeBundle(wfBundle, scufl2File, this.MEDIA_TYPE);
System.out.println(scufl2File.getPath() + " is created.");
- check = true;
- //Exceptions
-
- } catch (ReaderException e){
+ }catch (ReaderException e){
System.err.println("Error reading the file");
e.printStackTrace();
}catch(IOException e){
@@ -218,7 +183,7 @@ public class ToWfbundle{
System.err.println("Error writing the file");
e.printStackTrace();
}
- return check;
}
+
}
[24/31] incubator-taverna-language git commit: Package updated
Posted by st...@apache.org.
Package updated
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/7fea7108
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/7fea7108
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/7fea7108
Branch: refs/heads/master
Commit: 7fea710801088662588afbb3630c43c5fb3e6b8e
Parents: 3d6285d
Author: Menaka Madushanka <me...@gmail.com>
Authored: Thu Jun 11 21:11:11 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:29 2015 +0100
----------------------------------------------------------------------
.../apache/taverna/tavlang/CommandLineTool.java | 276 +++++++++++++++++
.../taverna/tavlang/TavernaCommandline.java | 29 ++
.../org/apache/taverna/tavlang/tools/Tools.java | 89 ++++++
.../tavlang/tools/convert/Scufl2Convert.java | 190 ++++++++++++
.../taverna/tavlang/tools/convert/ToJson.java | 310 +++++++++++++++++++
.../tavlang/tools/convert/ToRobundle.java | 68 ++++
.../tavlang/tools/inspect/ProcessorNames.java | 169 ++++++++++
.../tavlang/tools/inspect/ServiceTypes.java | 111 +++++++
.../tavlang/tools/validate/Validate.java | 38 +++
.../tavlang/commandline/CommandLineTool.java | 276 -----------------
.../tavlang/commandline/TavernaCommandline.java | 29 --
.../apache/tavlang/commandline/tools/Tools.java | 89 ------
.../tools/convert/Scufl2Convert.java | 190 ------------
.../commandline/tools/convert/ToJson.java | 310 -------------------
.../commandline/tools/convert/ToRobundle.java | 68 ----
.../tools/inspect/ProcessorNames.java | 169 ----------
.../commandline/tools/inspect/ServiceTypes.java | 111 -------
.../commandline/tools/validate/Validate.java | 38 ---
.../taverna/tavlang/test/CommandLineTest.java | 57 ++++
.../taverna/tavlang/test/Scufl2ConvertTest.java | 14 +
.../commandline/test/CommandLineTest.java | 57 ----
.../commandline/test/Scufl2ConvertTest.java | 14 -
22 files changed, 1351 insertions(+), 1351 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7fea7108/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/CommandLineTool.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/CommandLineTool.java b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/CommandLineTool.java
new file mode 100644
index 0000000..57ee3cb
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/CommandLineTool.java
@@ -0,0 +1,276 @@
+package org.apache.taverna.tavlang;
+
+
+/*
+ * 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.io.IOException;
+import java.util.List;
+
+import javax.inject.Inject;
+import javax.xml.bind.JAXBException;
+
+import org.apache.taverna.scufl2.api.io.ReaderException;
+import org.apache.taverna.tavlang.tools.Tools;
+import org.apache.taverna.tavlang.tools.Tools.ConvertionTools;
+import org.apache.taverna.tavlang.tools.convert.Scufl2Convert;
+import org.apache.taverna.tavlang.tools.convert.ToRobundle;
+import org.apache.taverna.tavlang.tools.inspect.ProcessorNames;
+import org.apache.taverna.tavlang.tools.inspect.ServiceTypes;
+
+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{
+
+ //The input file or directory
+ @Option(name = {"-i", "--input"}, description="Input file/ file dir for conversion")
+ 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(){
+ Scufl2Convert bn;
+ if(filetypes.isJson ){
+
+ }else if(filetypes.isRo){
+ try {
+ ToRobundle ro = new ToRobundle(files, optional.getOutFile());
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }else{
+ if(recurse){
+ bn = new Scufl2Convert(filetypes.isTrue(), optional.getInFile(), optional.getOutFile());
+ }else{
+ bn = new Scufl2Convert(filetypes.isTrue(), files, optional.getOutFile());
+ }
+ }
+
+ }
+
+ }
+
+ //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 and show the results on the terminal")
+ public static class CommandInspect extends TvnLangTool{
+
+ @Inject
+ Inspect inspect = new Inspect();
+
+ @Option(name={"-l", "--log"}, description="Specify the file name where results should be stored ([some dir]/log.txt)")
+ public String file;
+
+ @Arguments(usage="<option> <input files>", description="Inspect the given workflow")
+ public List<String> toInspect = Lists.newArrayList();
+
+ @Override
+ public void execute() {
+ // TODO Auto-generated method stub
+ if(inspect.processor){
+ try {
+ ProcessorNames pn = new ProcessorNames(toInspect, file);
+
+ } catch (ReaderException | IOException | JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }else if(inspect.servicetypes){
+ try {
+ ServiceTypes st = new ServiceTypes(toInspect, file);
+ } catch (IOException | ReaderException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ }
+
+ }
+
+ //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/7fea7108/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/TavernaCommandline.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/TavernaCommandline.java b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/TavernaCommandline.java
new file mode 100644
index 0000000..016488c
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/TavernaCommandline.java
@@ -0,0 +1,29 @@
+package org.apache.taverna.tavlang;
+
+/*
+ * 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/7fea7108/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/Tools.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/Tools.java b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/Tools.java
new file mode 100644
index 0000000..a8ee5f4
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/Tools.java
@@ -0,0 +1,89 @@
+package org.apache.taverna.tavlang.tools;
+
+/*
+ * 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 javax.print.attribute.standard.Media;
+
+public class Tools {
+
+ public static enum ConvertionTools {
+ wfbundle{
+ public String mediaType = "application/vnd.taverna.scufl2.workflow-bundle";
+
+
+ @Override
+ public String getMediaType(ConvertionTools t) {
+ // TODO Auto-generated method stub
+ System.out.println(mediaType);
+ return this.mediaType;
+ }
+ },
+ json{
+ public String mediaType = "application/json";
+
+
+ @Override
+ public String getMediaType(ConvertionTools t) {
+ // TODO Auto-generated method stub
+ System.out.println(mediaType);
+ return mediaType;
+ }
+ },
+ wfdesc{
+ public String mediaType = "text/vnd.wf4ever.wfdesc+turtle";
+
+
+ @Override
+ public String getMediaType(ConvertionTools t) {
+ // TODO Auto-generated method stub
+ System.out.println(mediaType);
+ return mediaType;
+ }
+ },
+ robundle{
+
+ @Override
+ public String getMediaType(ConvertionTools t) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ },
+ structure{
+ public String mediaType = "text/vnd.taverna.scufl2.structure";
+
+ @Override
+ public String getMediaType(ConvertionTools t) {
+ // TODO Auto-generated method stub
+ System.out.println(mediaType);
+ return mediaType;
+ }
+
+
+ };
+
+ ConvertionTools(){}
+
+ public abstract String getMediaType(ConvertionTools t);
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7fea7108/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/convert/Scufl2Convert.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/convert/Scufl2Convert.java b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/convert/Scufl2Convert.java
new file mode 100644
index 0000000..02135dc
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/convert/Scufl2Convert.java
@@ -0,0 +1,190 @@
+package org.apache.taverna.tavlang.tools.convert;
+
+/*
+ * 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 java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.io.ReaderException;
+import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
+import org.apache.taverna.scufl2.api.io.WriterException;
+import org.apache.taverna.tavlang.tools.Tools.ConvertionTools;
+import org.apache.taverna.tavlang.tools.validate.Validate;
+
+
+/*
+ * Converts
+ * .t2flow --> .wfbundle
+ * .t2flow --> .structure
+ * .wfbundle --> .structure
+ * two constructors.
+ * Scufl2Convert(List<String> list, String out) --> will save the converted files in 'out folder or a directory named /converted in the same folder.
+ * Scufl2Convert(String in, String out) --> Will convert all the files in the 'in' folder and save them in 'out' folder --> -r must be true.
+ *
+ * */
+public class Scufl2Convert{
+
+ private ConvertionTools t;
+ private String MEDIA_TYPE;
+ private String input;
+ private String output;
+ private String type;
+ private List<String> filesList;
+
+ public Scufl2Convert(String type, List<String> files, String out){
+ this.filesList = files;
+ this.output = out;
+ this.type = type.equals("wfdesc")?".wfdesc.ttl":"."+type;
+ this.MEDIA_TYPE = ConvertionTools.valueOf(type).getMediaType(t);
+ this.convert();
+ }
+
+ //When recursive case is on....
+ public Scufl2Convert(String type, String in, String out){
+ this.input = in;
+ this.output = out;
+ this.type = type.equals("wfdesc")?".wfdesc.ttl":"."+type;
+ this.MEDIA_TYPE = ConvertionTools.valueOf(type).getMediaType(t); //Determine the writer media type
+
+ this.createdir();
+ }
+
+ //Create the dir if not exists
+ public void createdir(){
+ if(output == null){
+ File outFile = new File(this.input, "converted");
+ try {
+ FileUtils.forceMkdir(outFile);
+ this.output = outFile.getAbsolutePath();
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ System.err.println("Error creating the directory...!!!!");
+ e1.printStackTrace();
+ }
+ }else{
+ File outFile = new File(this.output);
+ try {
+ FileUtils.forceMkdir(outFile);
+
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ System.err.println("Error creating the directory...!!!!");
+ e1.printStackTrace();
+ }
+ }
+ this.rec_convert(this.input);
+ }
+
+ //Convert the given file. Return in case of an exception.
+ public boolean convert(){
+
+ boolean check = false;
+ // If the output folder is given, save the converted files in to that folder.
+
+ if(this.filesList.size()>0 && this.output != null){
+ File outFile = new File(this.output);
+ try {
+ FileUtils.forceMkdir(outFile);
+ } catch (IOException e1) {
+ System.err.println("Error creating the directory...!!!");
+ }
+ for(String file : this.filesList){
+ File t2File = new File(file);
+
+ convertFile(t2File, outFile);
+
+ }
+
+ }
+
+ /* If the output file is not given, save the converted files in
+ * '/converted' folder.
+ */
+
+ else if(this.filesList.size()>0 && this.output == null){
+ for(String file : this.filesList){
+ File t2File = new File(file);
+
+ File outFile = new File(t2File.getParentFile(), "converted");
+ try {
+ FileUtils.forceMkdir(outFile);
+ } catch (IOException e1) {
+ System.err.println("Error creating the directory...!!!");
+ }
+
+ convertFile(t2File, outFile);
+
+ }
+ }else{
+ System.err.println("Argument mismatch");
+ check = false;
+ }
+
+ return check;
+ }
+
+ //Convert the files in a given directory and save the converted files in to specified dir or /converted folder.
+ //Recursive conversion
+ public void rec_convert(String dir){
+
+ File parent = new File(this.input);
+ if(!parent.exists()){
+ System.err.println("Input directory not found");
+ }else{
+ for(File file : parent.listFiles()){
+ if(!file.isDirectory())
+ {
+ File outFile = new File(this.output);
+ convertFile(file, outFile);
+ }
+ }
+ }
+ }
+
+ //Convert the file
+ public void convertFile(File t2File, File outFile){
+ WorkflowBundleIO wfbio = new WorkflowBundleIO();
+ String filename = t2File.getName();
+ filename = filename.replaceFirst("\\..*", this.type);
+// System.out.println(filename);
+ File scufl2File = new File(outFile.getAbsolutePath(), filename);
+
+ WorkflowBundle wfBundle;
+ try {
+ wfBundle = wfbio.readBundle(t2File, null);// null --> will guess the media type for reading.
+ wfbio.writeBundle(wfBundle, scufl2File, this.MEDIA_TYPE);
+ System.out.println(scufl2File.getPath() + " is created.");
+ }catch (ReaderException e){
+ System.err.println(e.getLocalizedMessage());
+// e.printStackTrace();
+ }catch(IOException e){
+ System.err.println(e.getLocalizedMessage());
+// e.printStackTrace();
+ }catch(WriterException e) {
+ System.err.println(e.getLocalizedMessage());
+// e.printStackTrace();
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7fea7108/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/convert/ToJson.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/convert/ToJson.java b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/convert/ToJson.java
new file mode 100644
index 0000000..f2ab156
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/convert/ToJson.java
@@ -0,0 +1,310 @@
+package org.apache.taverna.tavlang.tools.convert;
+
+/*
+ * 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 java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.taverna.scufl2.api.annotation.Annotation;
+import org.apache.taverna.scufl2.api.annotation.Revision;
+import org.apache.taverna.scufl2.api.common.Child;
+import org.apache.taverna.scufl2.api.common.Ported;
+import org.apache.taverna.scufl2.api.common.Scufl2Tools;
+import org.apache.taverna.scufl2.api.common.URITools;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.BlockingControlLink;
+import org.apache.taverna.scufl2.api.core.ControlLink;
+import org.apache.taverna.scufl2.api.core.DataLink;
+import org.apache.taverna.scufl2.api.core.Processor;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.io.ReaderException;
+import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
+import org.apache.taverna.scufl2.api.io.WorkflowBundleWriter;
+import org.apache.taverna.scufl2.api.io.WriterException;
+import org.apache.taverna.scufl2.api.port.DepthPort;
+import org.apache.taverna.scufl2.api.port.GranularDepthPort;
+import org.apache.taverna.scufl2.api.port.Port;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
+
+public class ToJson {
+ public class JsonWriter implements WorkflowBundleWriter {
+
+ @Override
+ public Set<String> getMediaTypes() {
+ return new HashSet<String>(Arrays.asList("application/ld+json",
+ "application/json"));
+ }
+ @Override
+ public void writeBundle(WorkflowBundle wfBundle, File destination,
+ String mediaType) throws WriterException, IOException {
+ ObjectNode json = toJson(wfBundle);
+ mapper.writeValue(destination, json);
+ }
+
+ @Override
+ public void writeBundle(WorkflowBundle wfBundle,
+ OutputStream output, String mediaType)
+ throws WriterException, IOException {
+ ObjectNode json = toJson(wfBundle);
+ mapper.writeValue(output, json);
+ }
+
+ }
+
+ public static void main(String[] args) throws ReaderException, IOException,
+ WriterException {
+ String[] args2 = {"/home/menaka/conv/aaa/as.wfbundle"};
+ new ToJson().convert(args2);
+ }
+
+
+ private WorkflowBundleIO io = new WorkflowBundleIO();;
+
+ private WorkflowBundleWriter jsonWriter = new JsonWriter();
+
+ private ObjectMapper mapper = new ObjectMapper();
+
+ private Scufl2Tools scufl2Tools = new Scufl2Tools();
+
+ private URITools uriTools = new URITools();
+
+ public ToJson() {
+ mapper.enable(SerializationFeature.INDENT_OUTPUT);
+ mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
+ mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+
+ mapper.setDateFormat(new ISO8601DateFormat());
+
+ // Adding custom writer dynamically
+ List<WorkflowBundleWriter> writers = io.getWriters();
+ writers.add(jsonWriter);
+ io.setWriters(writers);
+ }
+
+ protected void addPorts(Ported ported, ObjectNode p) {
+ ArrayNode inputs = mapper.createArrayNode();
+ for (Port port : ported.getInputPorts()) {
+ inputs.add(toJson(port));
+ }
+ p.put("inputs", inputs);
+
+ ArrayNode outputs = mapper.createArrayNode();
+ for (Port port : ported.getOutputPorts()) {
+ outputs.add(toJson(port));
+ // FIXME: Do we need the id for ports? Needed if we add datalinks
+ }
+ p.put("outputs", outputs);
+ }
+
+ protected ObjectNode annotations(Child<?> bean) {
+ ObjectNode node = mapper.createObjectNode();
+ for (Annotation ann : scufl2Tools.annotationsFor(bean)) {
+ URI annUri = uriTools.uriForBean(ann);
+
+ // TODO: include annotation body?
+ }
+ return node;
+ }
+
+ public void convert(String[] filepaths) throws ReaderException,
+ IOException, WriterException {
+ if (filepaths[0].equals("-")) {
+ // Do piped Stdin/Stdout instead
+ WorkflowBundle wfBundle = io.readBundle(System.in, null);
+ io.writeBundle(wfBundle, System.err, "application/ld+json");
+ return;
+ }
+
+ for (String filepath : filepaths) {
+ File workflow = new File(filepath);
+
+ String filename = workflow.getName();
+ filename = filename.replaceFirst("\\..*", ".json");
+ File workflowFile = new File(workflow.getParentFile(), filename);
+
+ WorkflowBundle wfBundle = io.readBundle(workflow, null);
+ io.writeBundle(wfBundle, workflowFile, "application/ld+json");
+ System.out.println(workflowFile);
+ }
+ }
+
+ protected ObjectNode toJson(Port port) {
+ ObjectNode p = mapper.createObjectNode();
+ p.put("name", port.getName());
+ p.putPOJO("id", uriTools.relativeUriForBean(port,
+ scufl2Tools.findParent(WorkflowBundle.class, ((Child<?>)port))));
+
+ if (port instanceof DepthPort) {
+ DepthPort depthPort = (DepthPort) port;
+ if (depthPort.getDepth() != null) {
+ p.put("depth", depthPort.getDepth());
+ }
+ }
+ if (port instanceof GranularDepthPort) {
+ GranularDepthPort granularDepthPort = (GranularDepthPort) port;
+ if (granularDepthPort.getGranularDepth() != null &&
+ ! granularDepthPort.getGranularDepth().equals(granularDepthPort.getDepth())) {
+ p.put("granularDepth", granularDepthPort.getGranularDepth());
+ }
+ }
+ p.putAll(annotations((Child<?>)port));
+ return p;
+ }
+
+ protected JsonNode toJson(Processor proc) {
+ ObjectNode p = mapper.createObjectNode();
+ p.putPOJO("id", uriTools.relativeUriForBean(proc, proc.getParent().getParent()));
+ p.put("name", proc.getName());
+ addPorts(proc, p);
+ p.putAll(annotations(proc));
+
+ List<Workflow> nested = scufl2Tools.nestedWorkflowsForProcessor(proc,
+ proc.getParent().getParent().getMainProfile());
+ if (! nested.isEmpty()) {
+ if (nested.size() == 1) {
+ p.put("nestedWorkflow", toJson(nested.iterator().next()));
+ } else {
+ ArrayNode list = mapper.createArrayNode();
+ for (Workflow w : nested) {
+ list.add(toJson(w));
+ }
+ p.put("nestedWorkflow", list);
+ }
+ }
+ return p;
+ }
+
+ protected JsonNode toJson(Revision currentRevision) {
+ ArrayNode revisions = mapper.createArrayNode();
+ while (currentRevision != null) {
+ ObjectNode rev = mapper.createObjectNode();
+ rev.putPOJO("id", currentRevision.getIdentifier());
+ if (currentRevision.getGeneratedAtTime() != null) {
+ rev.putPOJO("generatedAtTime", currentRevision.getGeneratedAtTime());
+ }
+ currentRevision = currentRevision.getPreviousRevision();
+ if (currentRevision != null) {
+ rev.putPOJO("wasRevisionOf", currentRevision.getIdentifier());
+ }
+ revisions.add(rev);
+ }
+ return revisions;
+ }
+
+ protected ObjectNode toJson(Workflow workflow) {
+ ObjectNode wf = mapper.createObjectNode();
+
+ wf.putPOJO("id", uriTools.relativeUriForBean(workflow, workflow.getParent()));
+
+ wf.put("name", workflow.getName());
+ wf.put("revisions", toJson(workflow.getCurrentRevision()));
+
+ ArrayNode processors = mapper.createArrayNode();
+ for (Processor p : workflow.getProcessors()) {
+ processors.add(toJson(p));
+ }
+ addPorts(workflow, wf);
+ wf.put("processors", processors);
+
+ ArrayNode datalinks = mapper.createArrayNode();
+ for (DataLink link : workflow.getDataLinks()) {
+ datalinks.add(toJson(link));
+ }
+ wf.put("datalinks", datalinks);
+
+ ArrayNode controlLinks = mapper.createArrayNode();
+ for (ControlLink link : workflow.getControlLinks()) {
+ controlLinks.add(toJson(link));
+ }
+ wf.put("controllinks", controlLinks);
+
+
+ wf.putAll(annotations(workflow));
+
+ return wf;
+ }
+
+ protected JsonNode toJson(ControlLink link) {
+ ObjectNode l = mapper.createObjectNode();
+ if (link instanceof BlockingControlLink) {
+ BlockingControlLink controlLink = (BlockingControlLink) link;
+ l.putPOJO("block", uriTools.relativeUriForBean(controlLink.getBlock(),
+ link.getParent().getParent()));
+ l.putPOJO("untilFinished", uriTools.relativeUriForBean(controlLink.getUntilFinished(),
+ link.getParent().getParent()));
+ }
+ return l;
+ }
+
+ protected JsonNode toJson(DataLink link) {
+ ObjectNode l = mapper.createObjectNode();
+ l.putPOJO("receivesFrom", uriTools.relativeUriForBean(link.getReceivesFrom(),
+ link.getParent().getParent()));
+ l.putPOJO("sendsTo", uriTools.relativeUriForBean(link.getSendsTo(),
+ link.getParent().getParent()));
+ if (link.getMergePosition() != null) {
+ l.put("mergePosition", link.getMergePosition());
+ }
+ return l;
+ }
+
+ public ObjectNode toJson(WorkflowBundle wfBundle) {
+
+ ObjectNode root = mapper.createObjectNode();
+ ArrayNode contextList = root.arrayNode();
+ root.put("@context", contextList);
+ ObjectNode context = root.objectNode();
+ contextList.add("https://w3id.org/scufl2/context");
+ contextList.add(context);
+ URI base = wfBundle.getGlobalBaseURI();
+ context.put("@base", base.toASCIIString());
+ root.put("id", base.toASCIIString());
+
+// root.put("name", wfBundle.getName());
+// root.put("revisions", toJson(wfBundle.getCurrentRevision()));
+
+ root.put("workflow", toJson(wfBundle.getMainWorkflow()));
+ root.put("profile", toJson(wfBundle.getMainProfile()));
+
+ return root;
+ }
+
+ private JsonNode toJson(Profile profile) {
+ ObjectNode pf = mapper.createObjectNode();
+
+ pf.putPOJO("id", uriTools.relativeUriForBean(profile, profile.getParent()));
+ // TODO: Activities and configurations
+ return pf;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7fea7108/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/convert/ToRobundle.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/convert/ToRobundle.java b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/convert/ToRobundle.java
new file mode 100644
index 0000000..8781ca6
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/convert/ToRobundle.java
@@ -0,0 +1,68 @@
+package org.apache.taverna.tavlang.tools.convert;
+
+/*
+ * 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 java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.taverna.robundle.Bundle;
+import org.apache.taverna.robundle.Bundles;
+
+public class ToRobundle{
+
+ public ToRobundle(List<String> files, String out) throws Exception{
+
+ Logger logger = Logger.getLogger("");
+ //logger.setLevel(Level.FINER);
+ ConsoleHandler console = new ConsoleHandler();
+ console.setLevel(Level.FINEST);
+ logger.addHandler(console);
+ Logger.getLogger("org.researchobject").setLevel(Level.FINEST);
+
+ for(String f : files){
+ Path file = Paths.get(f);
+ convert(file);
+ }
+ }
+
+ //Recursive conversion
+ public ToRobundle(String type, String in, String out) {
+ // TODO Auto-generated constructor stub
+
+ }
+
+ public void convert(Path file) throws IOException{
+ try (Bundle bundle = Bundles.openBundle(file)) {
+
+ System.out.println(bundle.getManifest().toString());
+// bundle.getManifest().writeAsJsonLD();
+// bundle.getManifest().writeAsCombineManifest();
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7fea7108/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/inspect/ProcessorNames.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/inspect/ProcessorNames.java b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/inspect/ProcessorNames.java
new file mode 100644
index 0000000..8cbf989
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/inspect/ProcessorNames.java
@@ -0,0 +1,169 @@
+package org.apache.taverna.tavlang.tools.inspect;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeModel;
+import javax.xml.bind.JAXBException;
+
+import org.apache.taverna.scufl2.api.common.Scufl2Tools;
+import org.apache.taverna.scufl2.api.common.URITools;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Processor;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.io.ReaderException;
+import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/*
+ * 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.
+ */
+
+
+/*
+ * list the processor names used in the workflow.
+ * Supported formats: .t2flow, .wfbundle
+ * */
+
+public class ProcessorNames {
+
+ private List<String> fileList;
+
+ private String file2;
+
+ private Scufl2Tools scufl2Tools = new Scufl2Tools();
+
+ private URITools uriTools = new URITools();
+
+ public ProcessorNames(List<String> fileList, String file) throws ReaderException, IOException, JAXBException{
+ this.fileList = fileList;
+ this.file2 = file;
+ this.show();
+ }
+
+ public void show() throws ReaderException, IOException, JAXBException{
+ WorkflowBundleIO io = new WorkflowBundleIO();
+ StringBuilder sb = new StringBuilder();
+
+ for(String file : this.fileList){
+ File file2 = new File(file);
+ if(file2.isDirectory()){
+ for(File f : file2.listFiles()){
+ WorkflowBundle wfb = io.readBundle(f, null);
+ System.out.println("Processor tree of "+ f.getName() +" \n" +this.showProcessorTree(wfb));
+ sb.append("Processor tree of "+ f.getName() +" \n" +this.showProcessorTree(wfb) + "\n");
+ }
+ }else{
+ WorkflowBundle wfb = io.readBundle(new File(file), null);
+ System.out.println("Processor tree of "+ file +" \n" +this.showProcessorTree(wfb));
+ sb.append("Processor tree of "+ file +" \n" +this.showProcessorTree(wfb) + "\n");
+ }
+
+
+ }
+
+ if(this.file2!=null){
+ File log = new File(file2);
+ FileWriter fw = new FileWriter(log);
+ BufferedWriter bw = new BufferedWriter(fw);
+ bw.write(sb.toString());
+ bw.close();
+ fw.close();
+ }
+ }
+
+ private Workflow findNestedWorkflow(Processor processor) {
+ Profile profile = processor.getParent().getParent().getMainProfile();
+ return scufl2Tools.nestedWorkflowForProcessor(processor, profile);
+ }
+
+ private void findProcessors(WorkflowBundle ro, Workflow workflow,
+ DefaultMutableTreeNode parent) {
+ for (Processor processor : workflow.getProcessors()) {
+ DefaultMutableTreeNode processorNode = new DefaultMutableTreeNode(
+ processor.getName());
+ parent.add(processorNode);
+ Workflow wf = findNestedWorkflow(processor);
+ if (wf != null) {
+ findProcessors(ro, wf, processorNode);
+ }
+ }
+
+ }
+
+ public TreeModel makeProcessorTree(WorkflowBundle workflowBundle)
+ throws JAXBException, IOException {
+ Workflow workflow = workflowBundle.getMainWorkflow();
+ TreeModel treeModel = new DefaultTreeModel(new DefaultMutableTreeNode(
+ workflow.getName()));
+ DefaultMutableTreeNode parent = (DefaultMutableTreeNode) treeModel
+ .getRoot();
+
+ findProcessors(workflowBundle, workflow, parent);
+ return treeModel;
+ }
+
+ public List<String> showProcessorNames(WorkflowBundle ro)
+ throws JAXBException, IOException {
+ ArrayList<String> names = new ArrayList<String>();
+ for (Processor processor : ro.getMainWorkflow().getProcessors()) {
+ names.add(processor.getName());
+ }
+ Collections.sort(names);
+ return names;
+ }
+
+ public String showProcessorTree(WorkflowBundle ro) throws JAXBException,
+ IOException {
+ TreeModel treeModel = makeProcessorTree(ro);
+ return treeModelAsString(treeModel);
+ }
+
+ public String treeModelAsString(TreeModel treeModel) {
+ StringBuffer sb = new StringBuffer();
+ Object root = treeModel.getRoot();
+ treeModelAsString(treeModel, root, sb, "");
+ return sb.toString();
+ }
+
+ protected void treeModelAsString(TreeModel treeModel, Object parent,
+ StringBuffer sb, String indentation) {
+ sb.append(indentation);
+ int childCount = treeModel.getChildCount(parent);
+ if (childCount == 0) {
+ sb.append("- ");
+ } else {
+ sb.append("+ ");
+ indentation = indentation + " ";
+ }
+ sb.append(parent);
+ sb.append("\n");
+ for (int i = 0; i < childCount; i++) {
+ Object child = treeModel.getChild(parent, i);
+ treeModelAsString(treeModel, child, sb, indentation);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7fea7108/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/inspect/ServiceTypes.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/inspect/ServiceTypes.java b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/inspect/ServiceTypes.java
new file mode 100644
index 0000000..d27e024
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/inspect/ServiceTypes.java
@@ -0,0 +1,111 @@
+package org.apache.taverna.tavlang.tools.inspect;
+
+
+/*
+ * 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 java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
+import org.apache.taverna.scufl2.api.activity.Activity;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.io.ReaderException;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/*
+ * List the service types used in workflow.
+ * Supported file formats : .wfbundle, .t2flow
+ * */
+
+public class ServiceTypes {
+
+ private List<String> filesList;
+ private Set<String> types = new LinkedHashSet<String>();
+ private String save;
+
+ public ServiceTypes(List<String> filesList, String file) throws IOException, ReaderException{
+ this.filesList = filesList;
+ this.save = file;
+ this.service();
+
+ }
+
+ public void service() throws ReaderException, IOException{
+ WorkflowBundleIO io = new WorkflowBundleIO();
+ StringBuilder sb = new StringBuilder();
+
+ for (String filepath : filesList) {
+ File file = new File(filepath);
+
+ if(file.isDirectory()){
+ for(File f : file.listFiles()){
+ WorkflowBundle wfBundle = io.readBundle(f, null);
+ System.out.println("Service types used in " + f.getCanonicalPath() + " :" +"\n");
+ sb.append("Service types used in " + f.getCanonicalPath() + " :");
+ for (Profile profile : wfBundle.getProfiles()) {
+ for (Activity activity : profile.getActivities()) {
+ this.types.add(activity.getType().toASCIIString());
+ }
+ }
+ for(String t : types){
+ System.out.println(t);
+ sb.append(t + "\n");
+ }
+ System.out.println("\n**************************************************\n");
+ sb.append("\n**************************************************\n");
+ }
+ }else{
+ // mediaType = null --> guess
+ WorkflowBundle wfBundle = io.readBundle(file, null);
+ System.out.println("Service types used in " + file.getCanonicalPath() + " :" + "\n");
+ sb.append("Service types used in " + file.getCanonicalPath() + " :");
+ for (Profile profile : wfBundle.getProfiles()) {
+ for (Activity activity : profile.getActivities()) {
+ this.types.add(activity.getType().toASCIIString());
+ }
+ }
+ for(String t : types){
+ System.out.println(t);
+ sb.append(t + "\n");
+ }
+
+ System.out.println("\n**************************************************\n");
+ sb.append("\n**************************************************\n");
+ }
+ }
+
+ if(save!=null){
+ File log = new File(save);
+ FileWriter fw = new FileWriter(log);
+ BufferedWriter bw = new BufferedWriter(fw);
+ bw.write(sb.toString());
+ bw.close();
+ fw.close();
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7fea7108/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/validate/Validate.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/validate/Validate.java b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/validate/Validate.java
new file mode 100644
index 0000000..572679f
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/tools/validate/Validate.java
@@ -0,0 +1,38 @@
+package org.apache.taverna.tavlang.tools.validate;
+
+/*
+ * 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.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.validation.ValidationReport;
+import org.apache.taverna.scufl2.validation.Validator;
+import org.apache.taverna.scufl2.validation.structural.StructuralValidationListener;
+import org.apache.taverna.scufl2.validation.structural.StructuralValidator;
+
+
+public class Validate {
+
+ public Validate(WorkflowBundle wfb){
+ System.out.println("Validation started...");
+ StructuralValidator v = new StructuralValidator();
+ StructuralValidationListener l = v.validate(wfb);
+ ValidationReport r;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7fea7108/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
deleted file mode 100644
index bff8576..0000000
--- a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/CommandLineTool.java
+++ /dev/null
@@ -1,276 +0,0 @@
-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.io.IOException;
-import java.util.List;
-
-import javax.inject.Inject;
-import javax.xml.bind.JAXBException;
-
-import org.apache.taverna.scufl2.api.io.ReaderException;
-import org.apache.tavlang.commandline.tools.Tools;
-import org.apache.tavlang.commandline.tools.Tools.ConvertionTools;
-import org.apache.tavlang.commandline.tools.convert.Scufl2Convert;
-import org.apache.tavlang.commandline.tools.convert.ToRobundle;
-import org.apache.tavlang.commandline.tools.inspect.ProcessorNames;
-import org.apache.tavlang.commandline.tools.inspect.ServiceTypes;
-
-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{
-
- //The input file or directory
- @Option(name = {"-i", "--input"}, description="Input file/ file dir for conversion")
- 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(){
- Scufl2Convert bn;
- if(filetypes.isJson ){
-
- }else if(filetypes.isRo){
- try {
- ToRobundle ro = new ToRobundle(files, optional.getOutFile());
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }else{
- if(recurse){
- bn = new Scufl2Convert(filetypes.isTrue(), optional.getInFile(), optional.getOutFile());
- }else{
- bn = new Scufl2Convert(filetypes.isTrue(), files, optional.getOutFile());
- }
- }
-
- }
-
- }
-
- //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 and show the results on the terminal")
- public static class CommandInspect extends TvnLangTool{
-
- @Inject
- Inspect inspect = new Inspect();
-
- @Option(name={"-l", "--log"}, description="Specify the file name where results should be stored ([some dir]/log.txt)")
- public String file;
-
- @Arguments(usage="<option> <input files>", description="Inspect the given workflow")
- public List<String> toInspect = Lists.newArrayList();
-
- @Override
- public void execute() {
- // TODO Auto-generated method stub
- if(inspect.processor){
- try {
- ProcessorNames pn = new ProcessorNames(toInspect, file);
-
- } catch (ReaderException | IOException | JAXBException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }else if(inspect.servicetypes){
- try {
- ServiceTypes st = new ServiceTypes(toInspect, file);
- } catch (IOException | ReaderException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- }
-
- }
-
- //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/7fea7108/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
deleted file mode 100644
index 0bd0226..0000000
--- a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/TavernaCommandline.java
+++ /dev/null
@@ -1,29 +0,0 @@
-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/7fea7108/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/Tools.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/Tools.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/Tools.java
deleted file mode 100644
index c5ba1b3..0000000
--- a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/Tools.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package org.apache.tavlang.commandline.tools;
-
-/*
- * 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 javax.print.attribute.standard.Media;
-
-public class Tools {
-
- public static enum ConvertionTools {
- wfbundle{
- public String mediaType = "application/vnd.taverna.scufl2.workflow-bundle";
-
-
- @Override
- public String getMediaType(ConvertionTools t) {
- // TODO Auto-generated method stub
- System.out.println(mediaType);
- return this.mediaType;
- }
- },
- json{
- public String mediaType = "application/json";
-
-
- @Override
- public String getMediaType(ConvertionTools t) {
- // TODO Auto-generated method stub
- System.out.println(mediaType);
- return mediaType;
- }
- },
- wfdesc{
- public String mediaType = "text/vnd.wf4ever.wfdesc+turtle";
-
-
- @Override
- public String getMediaType(ConvertionTools t) {
- // TODO Auto-generated method stub
- System.out.println(mediaType);
- return mediaType;
- }
- },
- robundle{
-
- @Override
- public String getMediaType(ConvertionTools t) {
- // TODO Auto-generated method stub
- return null;
- }
-
- },
- structure{
- public String mediaType = "text/vnd.taverna.scufl2.structure";
-
- @Override
- public String getMediaType(ConvertionTools t) {
- // TODO Auto-generated method stub
- System.out.println(mediaType);
- return mediaType;
- }
-
-
- };
-
- ConvertionTools(){}
-
- public abstract String getMediaType(ConvertionTools t);
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7fea7108/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/Scufl2Convert.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/Scufl2Convert.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/Scufl2Convert.java
deleted file mode 100644
index 9d0a145..0000000
--- a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/Scufl2Convert.java
+++ /dev/null
@@ -1,190 +0,0 @@
-package org.apache.tavlang.commandline.tools.convert;
-
-/*
- * 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 java.io.File;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.io.ReaderException;
-import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
-import org.apache.taverna.scufl2.api.io.WriterException;
-import org.apache.tavlang.commandline.tools.Tools.ConvertionTools;
-import org.apache.tavlang.commandline.tools.validate.Validate;
-
-
-/*
- * Converts
- * .t2flow --> .wfbundle
- * .t2flow --> .structure
- * .wfbundle --> .structure
- * two constructors.
- * Scufl2Convert(List<String> list, String out) --> will save the converted files in 'out folder or a directory named /converted in the same folder.
- * Scufl2Convert(String in, String out) --> Will convert all the files in the 'in' folder and save them in 'out' folder --> -r must be true.
- *
- * */
-public class Scufl2Convert{
-
- private ConvertionTools t;
- private String MEDIA_TYPE;
- private String input;
- private String output;
- private String type;
- private List<String> filesList;
-
- public Scufl2Convert(String type, List<String> files, String out){
- this.filesList = files;
- this.output = out;
- this.type = type.equals("wfdesc")?".wfdesc.ttl":"."+type;
- this.MEDIA_TYPE = ConvertionTools.valueOf(type).getMediaType(t);
- this.convert();
- }
-
- //When recursive case is on....
- public Scufl2Convert(String type, String in, String out){
- this.input = in;
- this.output = out;
- this.type = type.equals("wfdesc")?".wfdesc.ttl":"."+type;
- this.MEDIA_TYPE = ConvertionTools.valueOf(type).getMediaType(t); //Determine the writer media type
-
- this.createdir();
- }
-
- //Create the dir if not exists
- public void createdir(){
- if(output == null){
- File outFile = new File(this.input, "converted");
- try {
- FileUtils.forceMkdir(outFile);
- this.output = outFile.getAbsolutePath();
- } catch (IOException e1) {
- // TODO Auto-generated catch block
- System.err.println("Error creating the directory...!!!!");
- e1.printStackTrace();
- }
- }else{
- File outFile = new File(this.output);
- try {
- FileUtils.forceMkdir(outFile);
-
- } catch (IOException e1) {
- // TODO Auto-generated catch block
- System.err.println("Error creating the directory...!!!!");
- e1.printStackTrace();
- }
- }
- this.rec_convert(this.input);
- }
-
- //Convert the given file. Return in case of an exception.
- public boolean convert(){
-
- boolean check = false;
- // If the output folder is given, save the converted files in to that folder.
-
- if(this.filesList.size()>0 && this.output != null){
- File outFile = new File(this.output);
- try {
- FileUtils.forceMkdir(outFile);
- } catch (IOException e1) {
- System.err.println("Error creating the directory...!!!");
- }
- for(String file : this.filesList){
- File t2File = new File(file);
-
- convertFile(t2File, outFile);
-
- }
-
- }
-
- /* If the output file is not given, save the converted files in
- * '/converted' folder.
- */
-
- else if(this.filesList.size()>0 && this.output == null){
- for(String file : this.filesList){
- File t2File = new File(file);
-
- File outFile = new File(t2File.getParentFile(), "converted");
- try {
- FileUtils.forceMkdir(outFile);
- } catch (IOException e1) {
- System.err.println("Error creating the directory...!!!");
- }
-
- convertFile(t2File, outFile);
-
- }
- }else{
- System.err.println("Argument mismatch");
- check = false;
- }
-
- return check;
- }
-
- //Convert the files in a given directory and save the converted files in to specified dir or /converted folder.
- //Recursive conversion
- public void rec_convert(String dir){
-
- File parent = new File(this.input);
- if(!parent.exists()){
- System.err.println("Input directory not found");
- }else{
- for(File file : parent.listFiles()){
- if(!file.isDirectory())
- {
- File outFile = new File(this.output);
- convertFile(file, outFile);
- }
- }
- }
- }
-
- //Convert the file
- public void convertFile(File t2File, File outFile){
- WorkflowBundleIO wfbio = new WorkflowBundleIO();
- String filename = t2File.getName();
- filename = filename.replaceFirst("\\..*", this.type);
-// System.out.println(filename);
- File scufl2File = new File(outFile.getAbsolutePath(), filename);
-
- WorkflowBundle wfBundle;
- try {
- wfBundle = wfbio.readBundle(t2File, null);// null --> will guess the media type for reading.
- wfbio.writeBundle(wfBundle, scufl2File, this.MEDIA_TYPE);
- System.out.println(scufl2File.getPath() + " is created.");
- }catch (ReaderException e){
- System.err.println(e.getLocalizedMessage());
-// e.printStackTrace();
- }catch(IOException e){
- System.err.println(e.getLocalizedMessage());
-// e.printStackTrace();
- }catch(WriterException e) {
- System.err.println(e.getLocalizedMessage());
-// e.printStackTrace();
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7fea7108/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToJson.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToJson.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToJson.java
deleted file mode 100644
index 4193c30..0000000
--- a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToJson.java
+++ /dev/null
@@ -1,310 +0,0 @@
-package org.apache.tavlang.commandline.tools.convert;
-
-/*
- * 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 java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.taverna.scufl2.api.annotation.Annotation;
-import org.apache.taverna.scufl2.api.annotation.Revision;
-import org.apache.taverna.scufl2.api.common.Child;
-import org.apache.taverna.scufl2.api.common.Ported;
-import org.apache.taverna.scufl2.api.common.Scufl2Tools;
-import org.apache.taverna.scufl2.api.common.URITools;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.core.BlockingControlLink;
-import org.apache.taverna.scufl2.api.core.ControlLink;
-import org.apache.taverna.scufl2.api.core.DataLink;
-import org.apache.taverna.scufl2.api.core.Processor;
-import org.apache.taverna.scufl2.api.core.Workflow;
-import org.apache.taverna.scufl2.api.io.ReaderException;
-import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
-import org.apache.taverna.scufl2.api.io.WorkflowBundleWriter;
-import org.apache.taverna.scufl2.api.io.WriterException;
-import org.apache.taverna.scufl2.api.port.DepthPort;
-import org.apache.taverna.scufl2.api.port.GranularDepthPort;
-import org.apache.taverna.scufl2.api.port.Port;
-import org.apache.taverna.scufl2.api.profiles.Profile;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
-
-public class ToJson {
- public class JsonWriter implements WorkflowBundleWriter {
-
- @Override
- public Set<String> getMediaTypes() {
- return new HashSet<String>(Arrays.asList("application/ld+json",
- "application/json"));
- }
- @Override
- public void writeBundle(WorkflowBundle wfBundle, File destination,
- String mediaType) throws WriterException, IOException {
- ObjectNode json = toJson(wfBundle);
- mapper.writeValue(destination, json);
- }
-
- @Override
- public void writeBundle(WorkflowBundle wfBundle,
- OutputStream output, String mediaType)
- throws WriterException, IOException {
- ObjectNode json = toJson(wfBundle);
- mapper.writeValue(output, json);
- }
-
- }
-
- public static void main(String[] args) throws ReaderException, IOException,
- WriterException {
- String[] args2 = {"/home/menaka/conv/aaa/as.wfbundle"};
- new ToJson().convert(args2);
- }
-
-
- private WorkflowBundleIO io = new WorkflowBundleIO();;
-
- private WorkflowBundleWriter jsonWriter = new JsonWriter();
-
- private ObjectMapper mapper = new ObjectMapper();
-
- private Scufl2Tools scufl2Tools = new Scufl2Tools();
-
- private URITools uriTools = new URITools();
-
- public ToJson() {
- mapper.enable(SerializationFeature.INDENT_OUTPUT);
- mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
- mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
-
- mapper.setDateFormat(new ISO8601DateFormat());
-
- // Adding custom writer dynamically
- List<WorkflowBundleWriter> writers = io.getWriters();
- writers.add(jsonWriter);
- io.setWriters(writers);
- }
-
- protected void addPorts(Ported ported, ObjectNode p) {
- ArrayNode inputs = mapper.createArrayNode();
- for (Port port : ported.getInputPorts()) {
- inputs.add(toJson(port));
- }
- p.put("inputs", inputs);
-
- ArrayNode outputs = mapper.createArrayNode();
- for (Port port : ported.getOutputPorts()) {
- outputs.add(toJson(port));
- // FIXME: Do we need the id for ports? Needed if we add datalinks
- }
- p.put("outputs", outputs);
- }
-
- protected ObjectNode annotations(Child<?> bean) {
- ObjectNode node = mapper.createObjectNode();
- for (Annotation ann : scufl2Tools.annotationsFor(bean)) {
- URI annUri = uriTools.uriForBean(ann);
-
- // TODO: include annotation body?
- }
- return node;
- }
-
- public void convert(String[] filepaths) throws ReaderException,
- IOException, WriterException {
- if (filepaths[0].equals("-")) {
- // Do piped Stdin/Stdout instead
- WorkflowBundle wfBundle = io.readBundle(System.in, null);
- io.writeBundle(wfBundle, System.err, "application/ld+json");
- return;
- }
-
- for (String filepath : filepaths) {
- File workflow = new File(filepath);
-
- String filename = workflow.getName();
- filename = filename.replaceFirst("\\..*", ".json");
- File workflowFile = new File(workflow.getParentFile(), filename);
-
- WorkflowBundle wfBundle = io.readBundle(workflow, null);
- io.writeBundle(wfBundle, workflowFile, "application/ld+json");
- System.out.println(workflowFile);
- }
- }
-
- protected ObjectNode toJson(Port port) {
- ObjectNode p = mapper.createObjectNode();
- p.put("name", port.getName());
- p.putPOJO("id", uriTools.relativeUriForBean(port,
- scufl2Tools.findParent(WorkflowBundle.class, ((Child<?>)port))));
-
- if (port instanceof DepthPort) {
- DepthPort depthPort = (DepthPort) port;
- if (depthPort.getDepth() != null) {
- p.put("depth", depthPort.getDepth());
- }
- }
- if (port instanceof GranularDepthPort) {
- GranularDepthPort granularDepthPort = (GranularDepthPort) port;
- if (granularDepthPort.getGranularDepth() != null &&
- ! granularDepthPort.getGranularDepth().equals(granularDepthPort.getDepth())) {
- p.put("granularDepth", granularDepthPort.getGranularDepth());
- }
- }
- p.putAll(annotations((Child<?>)port));
- return p;
- }
-
- protected JsonNode toJson(Processor proc) {
- ObjectNode p = mapper.createObjectNode();
- p.putPOJO("id", uriTools.relativeUriForBean(proc, proc.getParent().getParent()));
- p.put("name", proc.getName());
- addPorts(proc, p);
- p.putAll(annotations(proc));
-
- List<Workflow> nested = scufl2Tools.nestedWorkflowsForProcessor(proc,
- proc.getParent().getParent().getMainProfile());
- if (! nested.isEmpty()) {
- if (nested.size() == 1) {
- p.put("nestedWorkflow", toJson(nested.iterator().next()));
- } else {
- ArrayNode list = mapper.createArrayNode();
- for (Workflow w : nested) {
- list.add(toJson(w));
- }
- p.put("nestedWorkflow", list);
- }
- }
- return p;
- }
-
- protected JsonNode toJson(Revision currentRevision) {
- ArrayNode revisions = mapper.createArrayNode();
- while (currentRevision != null) {
- ObjectNode rev = mapper.createObjectNode();
- rev.putPOJO("id", currentRevision.getIdentifier());
- if (currentRevision.getGeneratedAtTime() != null) {
- rev.putPOJO("generatedAtTime", currentRevision.getGeneratedAtTime());
- }
- currentRevision = currentRevision.getPreviousRevision();
- if (currentRevision != null) {
- rev.putPOJO("wasRevisionOf", currentRevision.getIdentifier());
- }
- revisions.add(rev);
- }
- return revisions;
- }
-
- protected ObjectNode toJson(Workflow workflow) {
- ObjectNode wf = mapper.createObjectNode();
-
- wf.putPOJO("id", uriTools.relativeUriForBean(workflow, workflow.getParent()));
-
- wf.put("name", workflow.getName());
- wf.put("revisions", toJson(workflow.getCurrentRevision()));
-
- ArrayNode processors = mapper.createArrayNode();
- for (Processor p : workflow.getProcessors()) {
- processors.add(toJson(p));
- }
- addPorts(workflow, wf);
- wf.put("processors", processors);
-
- ArrayNode datalinks = mapper.createArrayNode();
- for (DataLink link : workflow.getDataLinks()) {
- datalinks.add(toJson(link));
- }
- wf.put("datalinks", datalinks);
-
- ArrayNode controlLinks = mapper.createArrayNode();
- for (ControlLink link : workflow.getControlLinks()) {
- controlLinks.add(toJson(link));
- }
- wf.put("controllinks", controlLinks);
-
-
- wf.putAll(annotations(workflow));
-
- return wf;
- }
-
- protected JsonNode toJson(ControlLink link) {
- ObjectNode l = mapper.createObjectNode();
- if (link instanceof BlockingControlLink) {
- BlockingControlLink controlLink = (BlockingControlLink) link;
- l.putPOJO("block", uriTools.relativeUriForBean(controlLink.getBlock(),
- link.getParent().getParent()));
- l.putPOJO("untilFinished", uriTools.relativeUriForBean(controlLink.getUntilFinished(),
- link.getParent().getParent()));
- }
- return l;
- }
-
- protected JsonNode toJson(DataLink link) {
- ObjectNode l = mapper.createObjectNode();
- l.putPOJO("receivesFrom", uriTools.relativeUriForBean(link.getReceivesFrom(),
- link.getParent().getParent()));
- l.putPOJO("sendsTo", uriTools.relativeUriForBean(link.getSendsTo(),
- link.getParent().getParent()));
- if (link.getMergePosition() != null) {
- l.put("mergePosition", link.getMergePosition());
- }
- return l;
- }
-
- public ObjectNode toJson(WorkflowBundle wfBundle) {
-
- ObjectNode root = mapper.createObjectNode();
- ArrayNode contextList = root.arrayNode();
- root.put("@context", contextList);
- ObjectNode context = root.objectNode();
- contextList.add("https://w3id.org/scufl2/context");
- contextList.add(context);
- URI base = wfBundle.getGlobalBaseURI();
- context.put("@base", base.toASCIIString());
- root.put("id", base.toASCIIString());
-
-// root.put("name", wfBundle.getName());
-// root.put("revisions", toJson(wfBundle.getCurrentRevision()));
-
- root.put("workflow", toJson(wfBundle.getMainWorkflow()));
- root.put("profile", toJson(wfBundle.getMainProfile()));
-
- return root;
- }
-
- private JsonNode toJson(Profile profile) {
- ObjectNode pf = mapper.createObjectNode();
-
- pf.putPOJO("id", uriTools.relativeUriForBean(profile, profile.getParent()));
- // TODO: Activities and configurations
- return pf;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7fea7108/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToRobundle.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToRobundle.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToRobundle.java
deleted file mode 100644
index 9c788ff..0000000
--- a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToRobundle.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.apache.tavlang.commandline.tools.convert;
-
-/*
- * 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 java.io.File;
-import java.io.IOException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.logging.ConsoleHandler;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.taverna.robundle.Bundle;
-import org.apache.taverna.robundle.Bundles;
-
-public class ToRobundle{
-
- public ToRobundle(List<String> files, String out) throws Exception{
-
- Logger logger = Logger.getLogger("");
- //logger.setLevel(Level.FINER);
- ConsoleHandler console = new ConsoleHandler();
- console.setLevel(Level.FINEST);
- logger.addHandler(console);
- Logger.getLogger("org.researchobject").setLevel(Level.FINEST);
-
- for(String f : files){
- Path file = Paths.get(f);
- convert(file);
- }
- }
-
- //Recursive conversion
- public ToRobundle(String type, String in, String out) {
- // TODO Auto-generated constructor stub
-
- }
-
- public void convert(Path file) throws IOException{
- try (Bundle bundle = Bundles.openBundle(file)) {
-
- System.out.println(bundle.getManifest().toString());
-// bundle.getManifest().writeAsJsonLD();
-// bundle.getManifest().writeAsCombineManifest();
- }
- }
-
-
-}
[21/31] incubator-taverna-language git commit: changed - to --
Posted by st...@apache.org.
changed - to --
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/8fe5f6cf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/8fe5f6cf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/8fe5f6cf
Branch: refs/heads/master
Commit: 8fe5f6cf1950b30fc542a58e3c7c308f8ef3b184
Parents: 7fea710
Author: menaka121 <me...@gmail.com>
Authored: Thu Jun 11 21:18:55 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:29 2015 +0100
----------------------------------------------------------------------
.../org/apache/taverna/tavlang/CommandLineTool.java | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/8fe5f6cf/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/CommandLineTool.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/CommandLineTool.java b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/CommandLineTool.java
index 57ee3cb..39db384 100644
--- a/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/CommandLineTool.java
+++ b/taverna-language-commandline/src/main/java/org/apache/taverna/tavlang/CommandLineTool.java
@@ -83,19 +83,19 @@ public class CommandLineTool {
//placeholder for output file types
public static class Filetypes{
- @Option(name= "-wfdesc", description="Convert the workflow file to wfdesc-turtle")
+ @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")
+ @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")
+ @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")
+ @Option(name= "--structure", description = "Convert the workflow into *.structure")
public static boolean isStructure = false;
- @Option(name = "-json", description = "Convert the workflow into json")
+ @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.
@@ -112,10 +112,10 @@ public class CommandLineTool {
}
public static class Inspect{
- @Option(name = "-servicetypes", description = "List the service types used in workflow")
+ @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")
+ @Option(name = "--processornames", description = "List a tree of processor names used in workflow")
public static boolean processor = false;
public String getWay(){
[28/31] incubator-taverna-language git commit: Changed the class name
Posted by st...@apache.org.
Changed the class name
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/a246f817
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/a246f817
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/a246f817
Branch: refs/heads/master
Commit: a246f8176019cb92a537d001eccd270a94ca29d3
Parents: db163a6
Author: menaka121 <me...@gmail.com>
Authored: Thu Jun 11 16:06:49 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:29 2015 +0100
----------------------------------------------------------------------
.../tools/convert/Scufl2Convert.java | 191 +++++++++++++++++++
.../commandline/tools/convert/ToWfbundle.java | 190 ------------------
2 files changed, 191 insertions(+), 190 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/a246f817/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/Scufl2Convert.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/Scufl2Convert.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/Scufl2Convert.java
new file mode 100644
index 0000000..863c7c0
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/Scufl2Convert.java
@@ -0,0 +1,191 @@
+package org.apache.tavlang.commandline.tools.convert;
+
+/*
+ * 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 java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.io.ReaderException;
+import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
+import org.apache.taverna.scufl2.api.io.WriterException;
+import org.apache.tavlang.commandline.tools.Tools.ConvertionTools;
+import org.apache.tavlang.commandline.tools.validate.Validate;
+
+
+/*
+ * Converts
+ * .t2flow --> .wfbundle
+ * .t2flow --> .structure
+ * .wfbundle --> .structure
+ * two constructors.
+ * Scufl2Convert(List<String> list, String out) --> will save the converted files in 'out folder or a directory named /converted in the same folder.
+ * Scufl2Convert(String in, String out) --> Will convert all the files in the 'in' folder and save them in 'out' folder --> -r must be true.
+ *
+ * */
+public class Scufl2Convert{
+
+ private ConvertionTools t;
+ private String MEDIA_TYPE;
+ private String input;
+ private String output;
+ private String type;
+ private List<String> filesList;
+
+ public Scufl2Convert(String type, List<String> files, String out){
+ this.filesList = files;
+ this.output = out;
+ this.type = type.equals("wfdesc")?".wfdesc.ttl":"."+type;
+ this.MEDIA_TYPE = ConvertionTools.valueOf(type).getMediaType(t);
+ this.convert();
+ }
+
+ //When recursive case is on....
+ public Scufl2Convert(String type, String in, String out){
+ this.input = in;
+ this.output = out;
+ this.type = type.equals("wfdesc")?".wfdesc.ttl":"."+type;
+ this.MEDIA_TYPE = ConvertionTools.valueOf(type).getMediaType(t); //Determine the writer media type
+
+ this.createdir();
+ }
+
+ //Create the dir if not exists
+ public void createdir(){
+ if(output == null){
+ File outFile = new File(this.input, "converted");
+ try {
+ FileUtils.forceMkdir(outFile);
+ this.output = outFile.getAbsolutePath();
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ System.err.println("Error creating the directory...!!!!");
+ e1.printStackTrace();
+ }
+ }else{
+ File outFile = new File(this.output);
+ try {
+ FileUtils.forceMkdir(outFile);
+
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ System.err.println("Error creating the directory...!!!!");
+ e1.printStackTrace();
+ }
+ }
+ this.rec_convert(this.input);
+ }
+
+ //Convert the given file. Return in case of an exception.
+ public boolean convert(){
+
+ boolean check = false;
+ // If the output folder is given, save the converted files in to that folder.
+
+ if(this.filesList.size()>0 && this.output != null){
+ File outFile = new File(this.output);
+ try {
+ FileUtils.forceMkdir(outFile);
+ } catch (IOException e1) {
+ System.err.println("Error creating the directory...!!!");
+ }
+ for(String file : this.filesList){
+ File t2File = new File(file);
+
+ convertFile(t2File, outFile);
+
+ }
+
+ }
+
+ /* If the output file is not given, save the converted files in
+ * '/converted' folder.
+ */
+
+ else if(this.filesList.size()>0 && this.output == null){
+ for(String file : this.filesList){
+ File t2File = new File(file);
+
+ File outFile = new File(t2File.getParentFile(), "converted");
+ try {
+ FileUtils.forceMkdir(outFile);
+ } catch (IOException e1) {
+ System.err.println("Error creating the directory...!!!");
+ }
+
+ convertFile(t2File, outFile);
+
+ }
+ }else{
+ System.err.println("Argument mismatch");
+ check = false;
+ }
+
+ return check;
+ }
+
+ //Convert the files in a given directory and save the converted files in to specified dir or /converted folder.
+ //Recursive conversion
+ public void rec_convert(String dir){
+
+ File parent = new File(this.input);
+ if(!parent.exists()){
+ System.err.println("Input directory not found");
+ }else{
+ for(File file : parent.listFiles()){
+ if(file.isDirectory())
+ rec_convert(file.getAbsolutePath());
+ else{
+ File outFile = new File(this.output);
+ convertFile(file, outFile);
+ }
+ }
+ }
+ }
+
+ //Convert the file
+ public void convertFile(File t2File, File outFile){
+ WorkflowBundleIO wfbio = new WorkflowBundleIO();
+ String filename = t2File.getName();
+ filename = filename.replaceFirst("\\..*", this.type);
+// System.out.println(filename);
+ File scufl2File = new File(outFile.getAbsolutePath(), filename);
+
+ WorkflowBundle wfBundle;
+ try {
+ wfBundle = wfbio.readBundle(t2File, null);// null --> will guess the media type for reading.
+ wfbio.writeBundle(wfBundle, scufl2File, this.MEDIA_TYPE);
+ System.out.println(scufl2File.getPath() + " is created.");
+ }catch (ReaderException e){
+ System.err.println(e.getLocalizedMessage());
+// e.printStackTrace();
+ }catch(IOException e){
+ System.err.println(e.getLocalizedMessage());
+// e.printStackTrace();
+ }catch(WriterException e) {
+ System.err.println(e.getLocalizedMessage());
+// e.printStackTrace();
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/a246f817/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java
deleted file mode 100644
index 0127506..0000000
--- a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/convert/ToWfbundle.java
+++ /dev/null
@@ -1,190 +0,0 @@
-package org.apache.tavlang.commandline.tools.convert;
-
-/*
- * 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 java.io.File;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.taverna.scufl2.api.container.WorkflowBundle;
-import org.apache.taverna.scufl2.api.io.ReaderException;
-import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
-import org.apache.taverna.scufl2.api.io.WriterException;
-import org.apache.tavlang.commandline.tools.Tools.ConvertionTools;
-
-
-/*
- * Converts
- * .t2flow --> .wfbundle
- * .t2flow --> .structure
- * .wfbundle --> .structure
- * two constructors.
- * ToWfbundle(List<String> list, String out) --> will save the converted files in 'out folder or a directory named /converted in the same folder.
- * ToWfbundle(String in, String out) --> Will convert all the files in the 'in' folder and save them in 'out' folder --> -r must be true.
- *
- * */
-public class ToWfbundle{
-
- private ConvertionTools t;
- private String MEDIA_TYPE;
- private String input;
- private String output;
- private String type;
- private List<String> filesList;
-
- public ToWfbundle(String type, List<String> files, String out){
- this.filesList = files;
- this.output = out;
- this.type = type.equals("wfdesc")?".wfdesc.ttl":"."+type;
- this.MEDIA_TYPE = ConvertionTools.valueOf(type).getMediaType(t);
- this.convert();
- }
-
- //When recursive case is on....
- public ToWfbundle(String type, String in, String out){
- this.input = in;
- this.output = out;
- this.type = type.equals("wfdesc")?".wfdesc.ttl":"."+type;
- this.MEDIA_TYPE = ConvertionTools.valueOf(type).getMediaType(t); //Determine the writer media type
-
- this.createdir();
- }
-
- //Create the dir if not exists
- public void createdir(){
- if(output == null){
- File outFile = new File(this.input, "converted");
- try {
- FileUtils.forceMkdir(outFile);
- this.output = outFile.getAbsolutePath();
- } catch (IOException e1) {
- // TODO Auto-generated catch block
- System.err.println("Error creating the directory...!!!!");
- e1.printStackTrace();
- }
- }else{
- File outFile = new File(this.output);
- try {
- FileUtils.forceMkdir(outFile);
-
- } catch (IOException e1) {
- // TODO Auto-generated catch block
- System.err.println("Error creating the directory...!!!!");
- e1.printStackTrace();
- }
- }
- this.rec_convert(this.input);
- }
-
- //Convert the given file. Return in case of an exception.
- public boolean convert(){
-
- boolean check = false;
- // If the output folder is given, save the converted files in to that folder.
-
- if(this.filesList.size()>0 && this.output != null){
- File outFile = new File(this.output);
- try {
- FileUtils.forceMkdir(outFile);
- } catch (IOException e1) {
- System.err.println("Error creating the directory...!!!");
- }
- for(String file : this.filesList){
- File t2File = new File(file);
-
- convertFile(t2File, outFile);
-
- }
-
- }
-
- /* If the output file is not given, save the converted files in
- * '/converted' folder.
- */
-
- else if(this.filesList.size()>0 && this.output == null){
- for(String file : this.filesList){
- File t2File = new File(file);
-
- File outFile = new File(t2File.getParentFile(), "converted");
- try {
- FileUtils.forceMkdir(outFile);
- } catch (IOException e1) {
- System.err.println("Error creating the directory...!!!");
- }
-
- convertFile(t2File, outFile);
-
- }
- }else{
- System.err.println("Argument mismatch");
- check = false;
- }
-
- return check;
- }
-
- //Convert the files in a given directory and save the converted files in to specified dir or /converted folder.
- //Recursive conversion
- public void rec_convert(String dir){
-
- File parent = new File(this.input);
- if(!parent.exists()){
- System.err.println("Input directory not found");
- }else{
- for(File file : parent.listFiles()){
- if(file.isDirectory())
- rec_convert(file.getAbsolutePath());
- else{
- File outFile = new File(this.output);
- convertFile(file, outFile);
- }
- }
- }
- }
-
- //Convert the file
- public void convertFile(File t2File, File outFile){
- WorkflowBundleIO wfbio = new WorkflowBundleIO();
- String filename = t2File.getName();
- filename = filename.replaceFirst("\\..*", this.type);
- System.out.println(filename);
- File scufl2File = new File(outFile.getAbsolutePath(), filename);
-
- WorkflowBundle wfBundle;
- try {
- wfBundle = wfbio.readBundle(t2File, null); // null --> will guess the media type for reading.
- wfbio.writeBundle(wfBundle, scufl2File, this.MEDIA_TYPE);
- System.out.println(scufl2File.getPath() + " is created.");
- }catch (ReaderException e){
- System.err.println("Error reading the file");
- e.printStackTrace();
- }catch(IOException e){
- System.err.println("Error reading the file");
- e.printStackTrace();
- }catch(WriterException e) {
- System.err.println("Error writing the file");
- e.printStackTrace();
- }
- }
-
-
-}
[11/31] incubator-taverna-language git commit: Finished commands
Posted by st...@apache.org.
Finished commands
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/ef1c045d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/ef1c045d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/ef1c045d
Branch: refs/heads/master
Commit: ef1c045df88ef102319ee80d889c29fae80ea9c9
Parents: 82a2402
Author: Menaka <me...@gmail.com>
Authored: Mon Jun 8 14:12:20 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:28 2015 +0100
----------------------------------------------------------------------
.../java/org/apache/taverna/commandline/CommandLineTool.java | 6 ++++++
1 file changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/ef1c045d/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
index c636abb..8dd61b3 100644
--- 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
@@ -224,6 +224,9 @@ public class CommandLineTool {
@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
@@ -240,6 +243,9 @@ public class CommandLineTool {
@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
[19/31] incubator-taverna-language git commit: processornames and
servicetypes
Posted by st...@apache.org.
processornames and servicetypes
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/7da9a3be
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/7da9a3be
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/7da9a3be
Branch: refs/heads/master
Commit: 7da9a3befa72c17933e159059b6b222cb0899e39
Parents: dce2802
Author: menaka121 <me...@gmail.com>
Authored: Wed Jun 10 03:46:30 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:29 2015 +0100
----------------------------------------------------------------------
.../tavlang/commandline/CommandLineTool.java | 75 ++++----
.../tools/inspect/ProcessorNames.java | 169 +++++++++++++++++++
.../commandline/tools/inspect/ServiceTypes.java | 111 ++++++++++++
3 files changed, 319 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7da9a3be/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
index 5201986..3145e4d 100644
--- 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
@@ -29,12 +29,18 @@ import io.airlift.airline.Help;
import io.airlift.airline.Option;
import java.io.File;
+import java.io.IOException;
import java.util.List;
import javax.inject.Inject;
+import javax.xml.bind.JAXBException;
+import org.apache.taverna.scufl2.api.io.ReaderException;
import org.apache.tavlang.commandline.tools.Tools;
import org.apache.tavlang.commandline.tools.Tools.ConvertionTools;
+import org.apache.tavlang.commandline.tools.convert.ToWfbundle;
+import org.apache.tavlang.commandline.tools.inspect.ProcessorNames;
+import org.apache.tavlang.commandline.tools.inspect.ServiceTypes;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
@@ -123,12 +129,8 @@ public class CommandLineTool {
//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")
+ @Option(name = {"-i", "--input"}, description="Input file/ file dir for conversion")
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.
@@ -179,31 +181,16 @@ public class CommandLineTool {
@Override
public void execute(){
- Tools to = new Tools();
-
- System.out.println(filetypes.isTrue());
- 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);
-//
-// }
-//
-// }
-
-
+ ToWfbundle bn;
+ if(!filetypes.isJson || !filetypes.isRo){
+ if(recurse){
+ bn = new ToWfbundle(filetypes.isTrue(), optional.getInFile(), optional.getOutFile());
+ }else{
+ bn = new ToWfbundle(filetypes.isTrue(), files, optional.getOutFile());
+ }
+ }else{
+ System.out.println("To be implemented");
+ }
}
@@ -222,22 +209,38 @@ public class CommandLineTool {
}
//Command for inspection of workflows....!!
- @Command(name="inspect", description="Inspect the given workflow")
+ @Command(name="inspect", description="Inspect the given workflow and show the results on the terminal")
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")
+ @Option(name={"-l", "--log"}, description="Specify the file name where results should be stored ([some dir]/log.txt)")
+ public String file;
+
+ @Arguments(usage="<option> <input files>", description="Inspect the given workflow")
public List<String> toInspect = Lists.newArrayList();
@Override
public void execute() {
// TODO Auto-generated method stub
-
+ if(inspect.processor){
+ try {
+ ProcessorNames pn = new ProcessorNames(toInspect, file);
+
+ } catch (ReaderException | IOException | JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }else if(inspect.servicetypes){
+ try {
+ ServiceTypes st = new ServiceTypes(toInspect, file);
+ } catch (IOException | ReaderException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7da9a3be/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/inspect/ProcessorNames.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/inspect/ProcessorNames.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/inspect/ProcessorNames.java
new file mode 100644
index 0000000..3a0dd31
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/inspect/ProcessorNames.java
@@ -0,0 +1,169 @@
+package org.apache.tavlang.commandline.tools.inspect;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeModel;
+import javax.xml.bind.JAXBException;
+
+import org.apache.taverna.scufl2.api.common.Scufl2Tools;
+import org.apache.taverna.scufl2.api.common.URITools;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.core.Processor;
+import org.apache.taverna.scufl2.api.core.Workflow;
+import org.apache.taverna.scufl2.api.io.ReaderException;
+import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/*
+ * 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.
+ */
+
+
+/*
+ * list the processor names used in the workflow.
+ * Supported formats: .t2flow, .wfbundle
+ * */
+
+public class ProcessorNames {
+
+ private List<String> fileList;
+
+ private String file2;
+
+ private Scufl2Tools scufl2Tools = new Scufl2Tools();
+
+ private URITools uriTools = new URITools();
+
+ public ProcessorNames(List<String> fileList, String file) throws ReaderException, IOException, JAXBException{
+ this.fileList = fileList;
+ this.file2 = file;
+ this.show();
+ }
+
+ public void show() throws ReaderException, IOException, JAXBException{
+ WorkflowBundleIO io = new WorkflowBundleIO();
+ StringBuilder sb = new StringBuilder();
+
+ for(String file : this.fileList){
+ File file2 = new File(file);
+ if(file2.isDirectory()){
+ for(File f : file2.listFiles()){
+ WorkflowBundle wfb = io.readBundle(f, null);
+ System.out.println("Processor tree of "+ f.getName() +" \n" +this.showProcessorTree(wfb));
+ sb.append("Processor tree of "+ f.getName() +" \n" +this.showProcessorTree(wfb) + "\n");
+ }
+ }else{
+ WorkflowBundle wfb = io.readBundle(new File(file), null);
+ System.out.println("Processor tree of "+ file +" \n" +this.showProcessorTree(wfb));
+ sb.append("Processor tree of "+ file +" \n" +this.showProcessorTree(wfb) + "\n");
+ }
+
+
+ }
+
+ if(this.file2!=null){
+ File log = new File(file2);
+ FileWriter fw = new FileWriter(log);
+ BufferedWriter bw = new BufferedWriter(fw);
+ bw.write(sb.toString());
+ bw.close();
+ fw.close();
+ }
+ }
+
+ private Workflow findNestedWorkflow(Processor processor) {
+ Profile profile = processor.getParent().getParent().getMainProfile();
+ return scufl2Tools.nestedWorkflowForProcessor(processor, profile);
+ }
+
+ private void findProcessors(WorkflowBundle ro, Workflow workflow,
+ DefaultMutableTreeNode parent) {
+ for (Processor processor : workflow.getProcessors()) {
+ DefaultMutableTreeNode processorNode = new DefaultMutableTreeNode(
+ processor.getName());
+ parent.add(processorNode);
+ Workflow wf = findNestedWorkflow(processor);
+ if (wf != null) {
+ findProcessors(ro, wf, processorNode);
+ }
+ }
+
+ }
+
+ public TreeModel makeProcessorTree(WorkflowBundle workflowBundle)
+ throws JAXBException, IOException {
+ Workflow workflow = workflowBundle.getMainWorkflow();
+ TreeModel treeModel = new DefaultTreeModel(new DefaultMutableTreeNode(
+ workflow.getName()));
+ DefaultMutableTreeNode parent = (DefaultMutableTreeNode) treeModel
+ .getRoot();
+
+ findProcessors(workflowBundle, workflow, parent);
+ return treeModel;
+ }
+
+ public List<String> showProcessorNames(WorkflowBundle ro)
+ throws JAXBException, IOException {
+ ArrayList<String> names = new ArrayList<String>();
+ for (Processor processor : ro.getMainWorkflow().getProcessors()) {
+ names.add(processor.getName());
+ }
+ Collections.sort(names);
+ return names;
+ }
+
+ public String showProcessorTree(WorkflowBundle ro) throws JAXBException,
+ IOException {
+ TreeModel treeModel = makeProcessorTree(ro);
+ return treeModelAsString(treeModel);
+ }
+
+ public String treeModelAsString(TreeModel treeModel) {
+ StringBuffer sb = new StringBuffer();
+ Object root = treeModel.getRoot();
+ treeModelAsString(treeModel, root, sb, "");
+ return sb.toString();
+ }
+
+ protected void treeModelAsString(TreeModel treeModel, Object parent,
+ StringBuffer sb, String indentation) {
+ sb.append(indentation);
+ int childCount = treeModel.getChildCount(parent);
+ if (childCount == 0) {
+ sb.append("- ");
+ } else {
+ sb.append("+ ");
+ indentation = indentation + " ";
+ }
+ sb.append(parent);
+ sb.append("\n");
+ for (int i = 0; i < childCount; i++) {
+ Object child = treeModel.getChild(parent, i);
+ treeModelAsString(treeModel, child, sb, indentation);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/7da9a3be/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/inspect/ServiceTypes.java
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/inspect/ServiceTypes.java b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/inspect/ServiceTypes.java
new file mode 100644
index 0000000..f3d7396
--- /dev/null
+++ b/taverna-language-commandline/src/main/java/org/apache/tavlang/commandline/tools/inspect/ServiceTypes.java
@@ -0,0 +1,111 @@
+package org.apache.tavlang.commandline.tools.inspect;
+
+
+/*
+ * 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 java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.taverna.scufl2.api.io.WorkflowBundleIO;
+import org.apache.taverna.scufl2.api.activity.Activity;
+import org.apache.taverna.scufl2.api.container.WorkflowBundle;
+import org.apache.taverna.scufl2.api.io.ReaderException;
+import org.apache.taverna.scufl2.api.profiles.Profile;
+
+/*
+ * List the service types used in workflow.
+ * Supported file formats : .wfbundle, .t2flow
+ * */
+
+public class ServiceTypes {
+
+ private List<String> filesList;
+ private Set<String> types = new LinkedHashSet<String>();
+ private String save;
+
+ public ServiceTypes(List<String> filesList, String file) throws IOException, ReaderException{
+ this.filesList = filesList;
+ this.save = file;
+ this.service();
+
+ }
+
+ public void service() throws ReaderException, IOException{
+ WorkflowBundleIO io = new WorkflowBundleIO();
+ StringBuilder sb = new StringBuilder();
+
+ for (String filepath : filesList) {
+ File file = new File(filepath);
+
+ if(file.isDirectory()){
+ for(File f : file.listFiles()){
+ WorkflowBundle wfBundle = io.readBundle(f, null);
+ System.out.println("Service types used in " + f.getCanonicalPath() + " :" +"\n");
+ sb.append("Service types used in " + f.getCanonicalPath() + " :");
+ for (Profile profile : wfBundle.getProfiles()) {
+ for (Activity activity : profile.getActivities()) {
+ this.types.add(activity.getType().toASCIIString());
+ }
+ }
+ for(String t : types){
+ System.out.println(t);
+ sb.append(t + "\n");
+ }
+ System.out.println("\n**************************************************\n");
+ sb.append("\n**************************************************\n");
+ }
+ }else{
+ // mediaType = null --> guess
+ WorkflowBundle wfBundle = io.readBundle(file, null);
+ System.out.println("Service types used in " + file.getCanonicalPath() + " :" + "\n");
+ sb.append("Service types used in " + file.getCanonicalPath() + " :");
+ for (Profile profile : wfBundle.getProfiles()) {
+ for (Activity activity : profile.getActivities()) {
+ this.types.add(activity.getType().toASCIIString());
+ }
+ }
+ for(String t : types){
+ System.out.println(t);
+ sb.append(t + "\n");
+ }
+
+ System.out.println("\n**************************************************\n");
+ sb.append("\n**************************************************\n");
+ }
+ }
+
+ if(save!=null){
+ File log = new File(save);
+ FileWriter fw = new FileWriter(log);
+ BufferedWriter bw = new BufferedWriter(fw);
+ bw.write(sb.toString());
+ bw.close();
+ fw.close();
+ }
+
+ }
+
+}
[14/31] incubator-taverna-language git commit: Update pom.xml
Posted by st...@apache.org.
Update pom.xml
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/c63fdb28
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/c63fdb28
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/c63fdb28
Branch: refs/heads/master
Commit: c63fdb28c3e0098e2c918382d6bed77b52534b99
Parents: 601e664
Author: Menaka Jayawardena <me...@gmail.com>
Authored: Tue Jun 9 01:03:20 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:28 2015 +0100
----------------------------------------------------------------------
taverna-language-commandline/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/c63fdb28/taverna-language-commandline/pom.xml
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/pom.xml b/taverna-language-commandline/pom.xml
index 8eed74f..26d1f6d 100644
--- a/taverna-language-commandline/pom.xml
+++ b/taverna-language-commandline/pom.xml
@@ -89,7 +89,7 @@
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
- <mainClass>org.apache.tavlang.commandline</mainClass>
+ <mainClass>org.apache.tavlang.commandline.TavernaCommandline</mainClass>
</transformer>
</transformers>
</configuration>
[12/31] incubator-taverna-language git commit: Update pom.xml
Posted by st...@apache.org.
Update pom.xml
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/82a24027
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/82a24027
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/82a24027
Branch: refs/heads/master
Commit: 82a24027804e4154da96fd310207de09ea59a94c
Parents: cfb3bf3
Author: Menaka Jayawardena <me...@gmail.com>
Authored: Sun Jun 7 23:45:55 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:28 2015 +0100
----------------------------------------------------------------------
taverna-language-commandline/pom.xml | 28 +++++++++++-----------------
1 file changed, 11 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/82a24027/taverna-language-commandline/pom.xml
----------------------------------------------------------------------
diff --git a/taverna-language-commandline/pom.xml b/taverna-language-commandline/pom.xml
index 1c1a0c8..93aa3e1 100644
--- a/taverna-language-commandline/pom.xml
+++ b/taverna-language-commandline/pom.xml
@@ -30,10 +30,10 @@
<dependencies>
<dependency>
- <groupId>${project.parent.groupId}</groupId>
- <artifactId>taverna-scufl2-api</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
+ <groupId>${project.parent.groupId}</groupId>
+ <artifactId>taverna-scufl2-api</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>taverna-scufl2-wfbundle</artifactId>
@@ -45,20 +45,14 @@
<artifactId>taverna-scufl2-t2flow</artifactId>
<version>${project.version}</version>
</dependency>
- <!-- Dissabled temperory
+ <!-- Dissabled temporily
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>taverna-scufl2-wfdesc</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>
-
- <dependency>
- <groupId>org.purl.wf4ever</groupId>
- <artifactId>scufl2-wfdesc</artifactId>
- <version>0.3.7</version>
- </dependency>
- -->
+ -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>taverna-robundle</artifactId>
@@ -72,17 +66,17 @@
</dependency>
<dependency>
- <groupId>io.airlift</groupId>
- <artifactId>airline</artifactId>
- <version>0.7</version>
- </dependency>
+ <groupId>io.airlift</groupId>
+ <artifactId>airline</artifactId>
+ <version>0.7</version>
+ </dependency>
</dependencies>
<build>
<!-- TODO: plugins for launchers and executable jar files? -->
<plugins>
- <plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
[02/31] incubator-taverna-language git commit: Final
Posted by st...@apache.org.
Final
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/cfb3bf35
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/cfb3bf35
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/cfb3bf35
Branch: refs/heads/master
Commit: cfb3bf35d205ffd35dca14311cc572ab650a6351
Parents: b894afd
Author: Menaka <me...@gmail.com>
Authored: Sun Jun 7 23:42:43 2015 +0530
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Thu Jun 11 17:33:28 2015 +0100
----------------------------------------------------------------------
.../java/org/apache/taverna/commandline/TavernaCommandline.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/cfb3bf35/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
index 61beedb..f7b998e 100644
--- 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
@@ -23,7 +23,7 @@ public class TavernaCommandline {
public static void main(String args[]){
CommandLineTool tool = new CommandLineTool();
- tool.parse("version");
+ tool.parse(args);
}
}