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/02/17 21:36:58 UTC
[27/28] incubator-taverna-common-activities git commit: Temporarily
empty repository
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/2e8f451e/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/RuntimeEnvironmentConstraint.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/RuntimeEnvironmentConstraint.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/RuntimeEnvironmentConstraint.java
deleted file mode 100644
index baa68d2..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/RuntimeEnvironmentConstraint.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/* Part of the KnowARC Janitor Use-case processor for taverna
- * written 2007-2010 by Hajo Nils Krabbenhoeft and Steffen Moeller
- * University of Luebeck, Institute for Neuro- and Bioinformatics
- * University of Luebeck, Institute for Dermatolgy
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This package is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this package; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package de.uni_luebeck.inb.knowarc.usecases;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.apache.log4j.Logger;
-
-
-/**
- * When use cases present a runtime environment, then they don't want to express
- * that these would provide such, but that these request such, i.e. they constrain
- * lists of potentially eligible queues.
- * @author Steffen Moeller
- * @since 2008
- */
-public class RuntimeEnvironmentConstraint extends RuntimeEnvironment {
-
- private static Logger logger = Logger.getLogger(RuntimeEnvironmentConstraint.class);
-
- private static String[] ACCEPTED_RELATIONS = new String[] {"=", ">=", "<=", ">", "<"};
- /**
- * If there is no relation specified, presume >=
- */
- private static String DEFAULT_RELATION = ">=";
-
- public static String[] getAcceptedRelations() {
- return ACCEPTED_RELATIONS;
- }
-
- public static String getDefaultRelation() {
- return DEFAULT_RELATION;
- }
-
- /**
- * Identifies the relation between runtime environments to be tested
- */
- protected String relation;
-
- /**
- * Accessor function for relation
- */
- public String getRelation() {
- return this.relation;
- }
-
- /**
- * Tests of a relation is supported
- * @param relation
- * @return true iff in <, > , <=, >=, =
- */
- public static boolean acceptedRelation(String relation) {
- if ((null == relation) || relation.equals("")) {
- return false;
- }
- return relation.equals("=")||relation.equals(">=")||relation.equals("<=")||relation.equals(">")||relation.equals("<");
- }
-
- /**
- * Constructor
- * @param id - expects the name of the runtime environment together with the version to which the
- * @param relation - relates to (">","<","=",">=","<=")
- */
- public RuntimeEnvironmentConstraint(String id, String relation) {
- super(id);
- if (null == relation || relation.equals("")) {
- relation=RuntimeEnvironmentConstraint.getDefaultRelation();
- }
- if (relation.equals("==")) {
- relation="=";
- }
- else if (relation.equals("=<")) {
- relation="<=";
- }
- else if (!RuntimeEnvironmentConstraint.acceptedRelation(relation)) {
- logger.warn("Unknown relation '"+relation+"', presuming '"+RuntimeEnvironmentConstraint.getDefaultRelation()+"'");
- relation=RuntimeEnvironmentConstraint.getDefaultRelation();
- }
- this.relation=relation;
- }
-
- /**
- * Perfoms test if the RuntimeEnvironment (RE) passed as argument fulfills the requirements set by the constraint.
- * @param re - RE to test
- * @return true iff the RE fulfills this REconstraint.
- */
- public boolean isFulfilledBy(RuntimeEnvironment re) {
- logger.info(re.getID()+" " + this.getRelation() + " "+this.getID() + " ?");
- if (this.getRelation().equals("=")) {
- logger.info("=");
- return re.getID().equals(this.getID());
- }
- if (!re.getName().equals(this.getName())) {
- logger.warn("Name match failed");
- return false;
- }
- int c = RuntimeEnvironment.compareVersions(re.getVersion(),this.getVersion());
- logger.info("c="+c);
- if (this.getRelation().equals(">")) return c>0;
- if (this.getRelation().equals(">=")) return c>=0;
- if (this.getRelation().equals("<=")) return c<=0;
- if (this.getRelation().equals("<")) return c<0;
- throw new RuntimeException("Unknown/untreated releation '"+this.getRelation()+"'");
- }
-
- /**
- * Iterates over all the RuntimeEnvironments passed as argument.
- * @param REs - list of RuntimeEnvironments, mostly those offered at a particular queue
- * @return true iff any RE among the REs passed as argument are fulfilling the constraint
- */
- public boolean isFulfilledByAtLeastOneIn(Collection<RuntimeEnvironment> REs) {
- boolean fulfilled = false;
- Iterator<RuntimeEnvironment> i = REs.iterator();
- while(i.hasNext() && !fulfilled) {
- RuntimeEnvironment r = i.next();
- fulfilled = this.isFulfilledBy(r);
- }
- return fulfilled;
- }
- /**
- * For testing purposes
- */
- public static void main(String argv[]) {
- try {
- if (argv[0].equals("--help") || argv.length != 3) {
- logger.error("Expecting arguments (<|>|=|<=|>=) runtime1-version runtime2-version");
- }
- else {
- RuntimeEnvironmentConstraint r1 = new RuntimeEnvironmentConstraint(argv[1], argv[0]);
- RuntimeEnvironment r2 = new RuntimeEnvironment(argv[2]);
- logger.info("r1.getName(): "+r1.getName());
- logger.info("r1.getVersion(): "+r1.getVersion());
- logger.info("r1.getRelation(): "+r1.getRelation());
- logger.info("r2.getName(): "+r2.getName());
- logger.info("r2.getVersion(): "+r2.getVersion());
- logger.info("r1.isFulfilledBy(r2): "+String.valueOf(r1.isFulfilledBy(r2)));
- }
- }
- catch (Exception e) {
- logger.error(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/2e8f451e/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInput.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInput.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInput.java
deleted file mode 100644
index a9f97b0..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInput.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/* Part of the KnowARC Janitor Use-case processor for taverna
- * written 2007-2010 by Hajo Nils Krabbenhoeft and Steffen Moeller
- * University of Luebeck, Institute for Neuro- and Bioinformatics
- * University of Luebeck, Institute for Dermatolgy
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This package is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this package; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package de.uni_luebeck.inb.knowarc.usecases;
-
-import java.nio.charset.Charset;
-
-import net.sf.taverna.t2.activities.externaltool.ExternalToolActivity;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty;
-
-/**
- * Integrates inputs to the grid that come from the use case descriptions
- * with those that are fed through the workflow.
- *
- * this class controls name and data storage of one input,
- * no matter where the data comes from
- */
-@ConfigurationBean(uri = ExternalToolActivity.URI + "#AbstractScriptInput")
-public abstract class ScriptInput {
- /**
- * This input can be referenced under the name 'tag'.
- */
- private String tag = null;
- /**
- * In most cases, the data will be stored under a specific
- * filename.
- */
- private boolean file = false;
- /**
- * Set, if the name of the file to be executed is not
- * explicitly set but prepared by some automatism and referenced
- * via the tagging principle.
- */
- private boolean tempFile = false;
- /**
- * True if (!) the data is binary. (Text otherwise)
- */
- private boolean binary = false;
-
- private String charsetName = Charset.defaultCharset().name();
- private boolean forceCopy = false;
-
- /**
- * @return the tag
- */
- public final String getTag() {
- return tag;
- }
- /**
- * @param tag the tag to set
- */
- @ConfigurationProperty(name = "tag", label = "Tag")
- public final void setTag(String tag) {
- this.tag = tag;
- }
- /**
- * @return the file
- */
- public final boolean isFile() {
- return file;
- }
- /**
- * @param file the file to set
- */
- @ConfigurationProperty(name = "file", label = "File")
- public final void setFile(boolean file) {
- this.file = file;
- }
- /**
- * @return the tempFile
- */
- public final boolean isTempFile() {
- return tempFile;
- }
- /**
- * @param tempFile the tempFile to set
- */
- @ConfigurationProperty(name = "tempFile", label = "Temporary File")
- public final void setTempFile(boolean tempFile) {
- this.tempFile = tempFile;
- }
- /**
- * @return the binary
- */
- public final boolean isBinary() {
- return binary;
- }
- /**
- * @param binary the binary to set
- */
- @ConfigurationProperty(name = "binary", label = "Binary")
- public final void setBinary(boolean binary) {
- this.binary = binary;
- }
-
- public String getCharsetName() {
- return this.charsetName;
- }
- /**
- * @param charsetName the charsetName to set
- */
- @ConfigurationProperty(name = "charsetName", label = "Chararter Set")
- public void setCharsetName(String charsetName) {
- this.charsetName = charsetName;
- }
-
- @ConfigurationProperty(name = "forceCopy", label = "Force Copy")
- public final void setForceCopy(boolean forceCopy) {
- this.forceCopy = forceCopy;
-
- }
- /**
- * @return the forceCopy
- */
- public boolean isForceCopy() {
- return forceCopy;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/2e8f451e/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputStatic.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputStatic.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputStatic.java
deleted file mode 100644
index 4e108b9..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputStatic.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Part of the KnowARC Janitor Use-case processor for taverna
- * written 2007-2010 by Hajo Nils Krabbenhoeft and Steffen Moeller
- * University of Luebeck, Institute for Neuro- and Bioinformatics
- * University of Luebeck, Institute for Dermatolgy
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This package is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this package; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package de.uni_luebeck.inb.knowarc.usecases;
-
-import net.sf.taverna.t2.activities.externaltool.ExternalToolActivity;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty;
-
-/**
- * This subclass of script input is used to manage static content
- * which is embedded into the use case description.
- */
-@ConfigurationBean(uri = ExternalToolActivity.URI + "#ScriptInputStatic")
-public class ScriptInputStatic extends ScriptInput {
-
- public ScriptInputStatic() {
- }
-
- private String url = null; //if this is set, load content from remote URL
- private String content = null;
-
- @Override
- public String toString() {
- return "InputStatic[tag: " +
- getTag() + (isFile() ? ", file" : "") + (isTempFile() ? ", tempfile" : "") + (isBinary() ? ", binary" : "") + ", content: " + content + "]";
- }
-
- /**
- * @return the url
- */
- public final String getUrl() {
- return url;
- }
-
- /**
- * @param url the url to set
- */
- @ConfigurationProperty(name = "url", label = "URL", required=false)
- public final void setUrl(String url) {
- this.url = url;
- }
-
- /**
- * @return the content
- */
- public final String getContent() {
- return content;
- }
-
- /**
- * @param content the content to set
- */
- @ConfigurationProperty(name = "content", label = "Content", required=false)
- public final void setContent(String content) {
- this.content = content;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/2e8f451e/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputUser.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputUser.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputUser.java
deleted file mode 100644
index 858b7fa..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptInputUser.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/* Part of the KnowARC Janitor Use-case processor for taverna
- * written 2007-2010 by Hajo Nils Krabbenhoeft and Steffen Moeller
- * University of Luebeck, Institute for Neuro- and Bioinformatics
- * University of Luebeck, Institute for Dermatolgy
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This package is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this package; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package de.uni_luebeck.inb.knowarc.usecases;
-import java.util.ArrayList;
-
-import net.sf.taverna.t2.activities.externaltool.ExternalToolActivity;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty;
-
-/**
- * Internal description of output
- */
-@ConfigurationBean(uri = ExternalToolActivity.URI + "#ScriptInput")
-public class ScriptInputUser extends ScriptInput {
-
- /**
- * This input may be fed from multiple ouputs.
- */
- private boolean list = false;
- /**
- * True if the data from a list input in taverna is concatenated into one single input file.
- */
- private boolean concatenate = false;
-
- private ArrayList<String> mime = new ArrayList<String>();
-
- @Override
- public String toString() {
- return "Input[tag: " + getTag() + (isFile() ? ", file" : "")
- + (isTempFile() ? ", tempfile" : "")
- + (isBinary() ? ", binary" : "") + (list ? ", list" : "")
- + (concatenate ? ", concatenate" : "")
- + " mime: " + mime.toString() + "]";
- }
-
- /**
- * @return the list
- */
- public final boolean isList() {
- return list;
- }
-
- /**
- * @param list the list to set
- */
- @ConfigurationProperty(name = "list", label = "List")
- public final void setList(boolean list) {
- this.list = list;
- }
-
- /**
- * @return the concatenate
- */
- public final boolean isConcatenate() {
- return concatenate;
- }
-
- /**
- * @param concatenate the concatenate to set
- */
- @ConfigurationProperty(name = "concatenate", label = "Concatenate")
- public final void setConcatenate(boolean concatenate) {
- this.concatenate = concatenate;
- }
-
- /**
- * @return the mime
- */
- public final ArrayList<String> getMime() {
- if (mime == null) {
- mime = new ArrayList<String>();
- }
- return mime;
- }
-
- /**
- * @param mime the mime to set
- */
- @ConfigurationProperty(name = "mime", label = "Mime Types", required=false)
- public final void setMime(ArrayList<String> mime) {
- this.mime = mime;
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/2e8f451e/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptOutput.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptOutput.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptOutput.java
deleted file mode 100644
index fe63cc9..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/ScriptOutput.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Part of the KnowARC Janitor Use-case processor for taverna
- * written 2007-2010 by Hajo Nils Krabbenhoeft and Steffen Moeller
- * University of Luebeck, Institute for Neuro- and Bioinformatics
- * University of Luebeck, Institute for Dermatolgy
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This package is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this package; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package de.uni_luebeck.inb.knowarc.usecases;
-import java.util.ArrayList;
-
-import net.sf.taverna.t2.activities.externaltool.ExternalToolActivity;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty;
-
-/**
- * Internal description of input
- */
-@ConfigurationBean(uri = ExternalToolActivity.URI + "#ScriptOutput")
-public class ScriptOutput {
- private String path;
- private boolean binary;
- private ArrayList<String> mime = new ArrayList<String>();
-
- @Override
- public String toString() {
- return "Output[path: " + path + (binary ? ", binary" : "")
- + " mime: " + mime.toString() + "]";
- }
-
- /**
- * @return the path
- */
- public final String getPath() {
- return path;
- }
-
- /**
- * @param path the path to set
- */
- @ConfigurationProperty(name = "path", label = "Path")
- public final void setPath(String path) {
- this.path = path;
- }
-
- /**
- * @return the binary
- */
- public final boolean isBinary() {
- return binary;
- }
-
- /**
- * @param binary the binary to set
- */
- @ConfigurationProperty(name = "binary", label = "Binary")
- public final void setBinary(boolean binary) {
- this.binary = binary;
- }
-
- /**
- * @return the mime
- */
- public final ArrayList<String> getMime() {
- if (mime == null) {
- mime = new ArrayList<String>();
- }
- return mime;
- }
-
- /**
- * @param mime the mime to set
- */
- @ConfigurationProperty(name = "mime", label = "Mime Types", required=false)
- public final void setMime(ArrayList<String> mime) {
- this.mime = mime;
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/2e8f451e/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseDescription.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseDescription.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseDescription.java
deleted file mode 100644
index 217eae5..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseDescription.java
+++ /dev/null
@@ -1,899 +0,0 @@
-/* Part of the KnowARC Janitor Use-case processor for taverna
- * written 2007-2010 by Hajo Nils Krabbenhoeft and Steffen Moeller
- * University of Luebeck, Institute for Neuro- and Bioinformatics
- * University of Luebeck, Institute for Dermatolgy
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This package is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this package; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package de.uni_luebeck.inb.knowarc.usecases;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import javax.swing.ImageIcon;
-
-import net.sf.taverna.t2.activities.externaltool.ExternalToolActivity;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationBean;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty;
-import net.sf.taverna.t2.workflowmodel.processor.config.ConfigurationProperty.OrderPolicy;
-import net.sf.taverna.t2.workflowmodel.serialization.DeserializationException;
-import net.sf.taverna.t2.workflowmodel.utils.Tools;
-
-import org.apache.log4j.Logger;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jdom.input.SAXBuilder;
-
-import org.apache.commons.lang.StringUtils;
-
-/**
- * Class representation of XML-description of UseCases
- */
-@ConfigurationBean(uri = ExternalToolActivity.URI + "#ToolDescription")
-public class UseCaseDescription {
-
- private static Logger logger = Logger.getLogger(UseCaseDescription.class);
-
- /**
- * Identifier for the retrieval of this UseCase in the sharedRepository
- * database, respectively its XML export.
- */
- private String usecaseid = "";
- /**
- * Workflow Elements now can get a group identifier. There may be subgroups
- * divided by :
- */
- private String group = "";
- /**
- * Textual description of the use case itself. This description is very
- * short to fit on the single line that is prepared for such descriptions in
- * the Taverna workflow element list.
- */
- private String description = "";
- /**
- * What is actually executed on the shell.
- */
- private String command = "";
-
- /**
- * Accessor function of command
- *
- * @return shell-executable series of commands
- */
- public String getCommand() {
- if (null == command) {
- // FIXME: Is this possible?
- return "";
- } else {
- return command;
- }
- }
-
- /**
- * Routine that may be executed as a first check if the program is indeed
- * installed.
- */
- private String test_local = null;
-
- /**
- * URL of an icon that would help users to recognise the use case
- */
- private String icon_url = null;
-
- private int preparingTimeoutInSeconds = 20 * 60; // 20 minutes
- private int executionTimeoutInSeconds = 30 * 60; // 30 minutes
-
- private List<String> tags = new ArrayList<String>();
- private List<RuntimeEnvironmentConstraint> REs = new ArrayList<RuntimeEnvironmentConstraint>();
- private ArrayList<String> queue_preferred = new ArrayList<String>();
- private ArrayList<String> queue_deny = new ArrayList<String>();
-
- private List<ScriptInputStatic> static_inputs = new ArrayList<ScriptInputStatic>();
- private Map<String, ScriptInput> inputs = new HashMap<String, ScriptInput>();
- private Map<String, ScriptOutput> outputs = new HashMap<String, ScriptOutput>();
-
- private boolean includeStdIn = false;
- private boolean includeStdOut = true;
- private boolean includeStdErr = true;
-
- private List<Integer> validReturnCodes = new ArrayList<Integer>();
-
- /**
- * Default constructor to make xstream happy
- */
- public UseCaseDescription() {
-
- }
-
- /**
- * Constructor, for special purpose usecases.
- *
- * @param usecaseid
- */
- public UseCaseDescription(String usecaseid) {
- this.setUsecaseid(usecaseid);
- }
-
- /**
- * Constructor, expects an input stream containing the xml. for example, use
- * getClass().getClassLoader().getResourceAsStream("..") to load a usecase
- * from your program jar
- */
- public UseCaseDescription(InputStream programAsStream) throws DeserializationException {
- SAXBuilder builder = new SAXBuilder();
- Document doc;
- try {
- doc = builder.build(programAsStream);
- programAsStream.close();
- } catch (JDOMException e) {
- throw new DeserializationException("Error deserializing usecase", e);
- } catch (IOException e) {
- throw new DeserializationException("Error deserializing usecase", e);
- }
- readFromXmlElement(doc.getRootElement());
- }
-
- /**
- * Constructor, expects an XML-root to dissect.
- */
- public UseCaseDescription(Element programNode) throws DeserializationException {
- readFromXmlElement(programNode);
- }
-
-/**
- * Produce an XML description of the UseCaseDescription
- */
- public Element writeToXMLElement() {
- Element programNode = new Element("program");
- programNode.setAttribute("name", getUsecaseid());
- programNode.setAttribute("description", getDescription());
- // Always use element version of command
-// programNode.setAttribute("command", getCommand());
- Element commandNode = new Element("command");
- commandNode.addContent(getCommand());
- programNode.addContent(commandNode);
- programNode.setAttribute("timeout", Integer.toString(getExecutionTimeoutInSeconds()));
- programNode.setAttribute("preparing_timeout", Integer.toString(getPreparingTimeoutInSeconds()));
- programNode.setAttribute("includeStdIn", Boolean.toString(isIncludeStdIn()));
- programNode.setAttribute("includeStdOut", Boolean.toString(isIncludeStdOut()));
- programNode.setAttribute("includeStdErr", Boolean.toString(isIncludeStdErr()));
- for (ScriptInputStatic si : getStatic_inputs()) {
- Element staticNode = new Element("static");
- if (si.isBinary()) {
- staticNode.setAttribute("binary", "true");
- }
- if (si.isForceCopy()) {
- staticNode.setAttribute("forceCopy", "true");
- }
- if (si.isFile()) {
- Element fileNode = new Element("file");
- fileNode.setAttribute("path", si.getTag());
- staticNode.addContent(fileNode);
- } else if (si.isTempFile()) {
- Element tempfileNode = new Element("tempfile");
- tempfileNode.setAttribute("tag", si.getTag());
- staticNode.addContent(tempfileNode);
- } else {
- Element replaceNode = new Element("replace");
- replaceNode.setAttribute("tag", si.getTag());
- staticNode.addContent(replaceNode);
- }
- if (si.getUrl() != null) {
- Element contentNode = new Element("content");
- contentNode.setAttribute("url", si.getUrl());
- staticNode.addContent(contentNode);
- } else {
- Element contentNode = new Element("content");
- contentNode.addContent((String) si.getContent());
- staticNode.addContent(contentNode);
- }
- programNode.addContent(staticNode);
- }
- for (Entry<String, ScriptInput> entry : getInputs().entrySet()) {
- String name = entry.getKey();
- ScriptInputUser si = (ScriptInputUser) entry.getValue();
- Element inputNode = new Element("input");
- inputNode.setAttribute("name", name);
- if (si.isBinary()) {
- inputNode.setAttribute("binary", "true");
- }
- if (si.isForceCopy()) {
- inputNode.setAttribute("forceCopy", "true");
- }
- if (si.isConcatenate()) {
- inputNode.setAttribute("concatenate", "true");
- }
- if (si.isList()) {
- inputNode.setAttribute("list", "true");
- }
- if (si.isFile()) {
- Element fileNode = new Element("file");
- fileNode.setAttribute("path", si.getTag());
- inputNode.addContent(fileNode);
- } else if (si.isTempFile()) {
- Element tempfileNode = new Element("tempfile");
- tempfileNode.setAttribute("tag", si.getTag());
- inputNode.addContent(tempfileNode);
- } else {
- Element replaceNode = new Element("replace");
- replaceNode.setAttribute("tag", si.getTag());
- inputNode.addContent(replaceNode);
- }
- for (String mime : si.getMime()) {
- Element mimeNode = new Element("mime");
- mimeNode.setAttribute("type", mime);
- inputNode.addContent(mimeNode);
- }
- programNode.addContent(inputNode);
- }
- for (Entry<String, ScriptOutput> entry : getOutputs().entrySet()) {
- String name = entry.getKey();
- ScriptOutput so = entry.getValue();
- Element outputNode = new Element("output");
- outputNode.setAttribute("name", name);
- if (so.isBinary()) {
- outputNode.setAttribute("binary", "true");
- }
- Element fromfileNode = new Element("fromfile");
- fromfileNode.setAttribute("path", so.getPath());
- outputNode.addContent(fromfileNode);
- for (String mime : so.getMime()) {
- Element mimeNode = new Element("mime");
- mimeNode.setAttribute("type", mime);
- outputNode.addContent(mimeNode);
- }
- programNode.addContent(outputNode);
- }
- for (RuntimeEnvironmentConstraint rec : getREs()) {
- Element rteNode = new Element("rte");
- rteNode.setAttribute("name", rec.getID());
- rteNode.setAttribute("relation", rec.getRelation());
- programNode.addContent(rteNode);
- }
- if ((group != null) && !group.isEmpty()) {
- Element groupNode = new Element("group");
- groupNode.setAttribute("name", group);
- programNode.addContent(groupNode);
- }
- if ((test_local != null) && !test_local.isEmpty()) {
- Element testNode = new Element("test");
- testNode.setAttribute("local", test_local);
- programNode.addContent(testNode);
- }
- if ((icon_url != null) && !icon_url.isEmpty()) {
- Element iconNode = new Element("icon");
- iconNode.setAttribute("url", icon_url);
- programNode.addContent(iconNode);
- }
- if (!getQueue_preferred().isEmpty() || !getQueue_deny().isEmpty()) {
- Element queueNode = new Element("queue");
- for (String url : getQueue_preferred()) {
- Element preferredNode = new Element("prefer");
- preferredNode.setAttribute("url", url);
- queueNode.addContent(preferredNode);
- }
- for (String url : getQueue_deny()) {
- Element denyNode = new Element("deny");
- denyNode.setAttribute("url", url);
- queueNode.addContent(denyNode);
- }
- programNode.addContent(queueNode);
- }
- Element validReturnCodesNode = new Element("validReturnCodes");
- validReturnCodesNode.setAttribute("codes", getReturnCodesAsText());
- programNode.addContent(validReturnCodesNode);
-
- return programNode;
- }
- /**
- * Specifies the UseCaseDescription from the root of an XML description
- * which is accessible online.
- *
- * @param programNode
- * @throws DeserializationException
- */
- private void readFromXmlElement(Element programNode) throws DeserializationException {
- if (programNode.getName().compareToIgnoreCase("program") != 0)
- throw new DeserializationException("Expected <program>, read '" + programNode.getName() + "'");
-
- setUsecaseid(programNode.getAttributeValue("name"));
- setDescription(programNode.getAttributeValue("description"));
- setCommand(programNode.getAttributeValue("command"));
- String timeoutStr = programNode.getAttributeValue("timeout");
- if (timeoutStr != null)
- setExecutionTimeoutInSeconds(Integer.parseInt(timeoutStr));
- timeoutStr = programNode.getAttributeValue("preparing_timeout");
- if (timeoutStr != null)
- setPreparingTimeoutInSeconds(Integer.parseInt(timeoutStr));
-
- String includeStdInStr = programNode.getAttributeValue("includeStdIn");
- if (includeStdInStr != null && !includeStdInStr.isEmpty()) {
- setIncludeStdIn(includeStdInStr.equals("true"));
- }
-
- String includeStdOutStr = programNode.getAttributeValue("includeStdOut");
- if (includeStdOutStr != null && !includeStdOutStr.isEmpty()) {
- setIncludeStdOut(includeStdOutStr.equals("true"));
- }
-
- String includeStdErrStr = programNode.getAttributeValue("includeStdErr");
- if (includeStdErrStr != null && !includeStdErrStr.isEmpty()) {
- setIncludeStdErr(includeStdErrStr.equals("true"));
- }
-
- for (Object cur_ob : programNode.getChildren()) {
- Element cur = (Element) cur_ob;
-
- String name = cur.getAttributeValue("name");
-
- String type = cur.getName();
- boolean binary = false;
- if (null != cur.getAttributeValue("binary") && cur.getAttributeValue("binary").equalsIgnoreCase("true")) {
- binary = true;
- }
- boolean list = false;
- if (null != cur.getAttributeValue("list") && cur.getAttributeValue("list").equalsIgnoreCase("true")) {
- list = true;
- }
- boolean concatenate = false;
- if (null != cur.getAttributeValue("concatenate") && cur.getAttributeValue("concatenate").equalsIgnoreCase("true")) {
- concatenate = true;
- }
- boolean forceCopy = false;
- if (null != cur.getAttributeValue("forceCopy") && cur.getAttributeValue("forceCopy").equalsIgnoreCase("true")) {
- forceCopy = true;
- }
-
- Element inner = null;
- String innerType = null, tag = null, path = null;
- if (cur.getChildren().size() > 0) {
- inner = (Element) cur.getChildren().get(0);
- innerType = inner.getName();
- tag = inner.getAttributeValue("tag");
- path = inner.getAttributeValue("path");
- }
- // build mime type declaration list
- ArrayList<String> mime = new ArrayList<String>();
- for (Object child : cur.getChildren()) {
- Element curChild = (Element) child;
- if (curChild.getName().equalsIgnoreCase("mime")) {
- mime.add(curChild.getAttributeValue("type"));
- }
- }
- if (type.equalsIgnoreCase("static")) {
- ScriptInputStatic si = new ScriptInputStatic();
- Element content = cur.getChild("content");
- if (content == null)
- throw new DeserializationException("FIXME: script tag without embedded content tag");
- si.setUrl(content.getAttributeValue("url"));
- if (si.getUrl() == null)
- si.setContent(content.getText());
- fillInputDescription(si, binary, forceCopy, innerType, tag, path);
- getStatic_inputs().add(si);
- } else if (type.equalsIgnoreCase("input")) {
- ScriptInputUser indesc = new ScriptInputUser();
- indesc.setList(list);
- indesc.setMime(mime);
- indesc.setConcatenate(concatenate);
- fillInputDescription(indesc, binary, forceCopy, innerType, tag, path);
- getInputs().put(Tools.sanitiseName(name), indesc);
- } else if (type.equalsIgnoreCase("output")) {
- ScriptOutput outdesc = new ScriptOutput();
- outdesc.setMime(mime);
-
- boolean ok = true;
- if (null == innerType) {
- // don't know what to do
- throw new DeserializationException("FIXME: Found null == innerType for output, is this the bug?");
- } else if (innerType.equalsIgnoreCase("fromfile")) {
- outdesc.setPath(path);
- outdesc.setBinary(binary);
- } else {
- throw new DeserializationException("Problem reading output port: unknown innerType '" + innerType + "'");
- }
- if (ok) {
- getOutputs().put(Tools.sanitiseName(name), outdesc);
- }
- } else if (type.equalsIgnoreCase("rte") || type.equalsIgnoreCase("re")) {
- getREs().add(new RuntimeEnvironmentConstraint(name, cur.getAttributeValue("relation")));
- } else if (type.equalsIgnoreCase("group")) {
- group = name;
- } else if (type.equalsIgnoreCase("test")) {
- test_local = cur.getAttributeValue("local");
- } else if (type.equalsIgnoreCase("icon")) {
- icon_url = cur.getAttributeValue("url");
- } else if (type.equalsIgnoreCase("queue")) {
- for (Object child_ob : cur.getChildren()) {
- Element child = (Element) child_ob;
- if (child.getName().equalsIgnoreCase("prefer"))
- getQueue_preferred().add(child.getAttributeValue("url"));
- else if (child.getName().equalsIgnoreCase("deny"))
- getQueue_deny().add(child.getAttributeValue("url"));
- else
- throw new DeserializationException("Error while reading usecase " + this.getUsecaseid() + ": invalid queue entry");
- }
- } else if (type.equalsIgnoreCase("command")) {
- // i like to have the ability to inject complete shell script
- // fragments into the use case,
- // so this should be replace and should allow multiple lines
- if ((getCommand() != null) && !getCommand().isEmpty()) {
- throw new DeserializationException("You have specified both command attribute and command tag.");
- }
- setCommand(cur.getText());
- } else if (type.equalsIgnoreCase("validReturnCodes")) {
- String codeString = cur.getAttributeValue("codes");
- if (codeString != null) {
- setReturnCodesAsText(codeString);
- }
- }
- else {
- throw new DeserializationException("Unexpected and uninterpreted attribute " + type);
- }
- }
- }
-
- private void fillInputDescription(ScriptInput fillMe, boolean binary, boolean forceCopy, String innerType, String tag, String path) throws DeserializationException {
- fillMe.setBinary(binary);
- fillMe.setForceCopy(forceCopy);
- if (null == innerType) {
- // don't know what to do
- throw new DeserializationException("FIXME: Found null == innerType for input, is this the bug?");
- } else if (innerType.equalsIgnoreCase("replace")) {
- fillMe.setTag(tag);
- fillMe.setTempFile(false);
- fillMe.setFile(false);
- getTags().add(tag);
- } else if (innerType.equalsIgnoreCase("tempfile")) {
- fillMe.setTag(tag);
- fillMe.setTempFile(true);
- fillMe.setFile(false);
- getTags().add(tag);
- } else if (innerType.equalsIgnoreCase("file")) {
- fillMe.setTag(path);
- fillMe.setTempFile(false);
- fillMe.setFile(true);
- } else {
- throw new DeserializationException("Problem reading input port: unknown innerType '" + innerType + "'");
- }
- }
-
- /**
- * returns icon that is referenced in use case description
- */
- public ImageIcon getImageIcon() {
- if (null == icon_url) return null;
- try {
- URL u = new URL(icon_url);
- return new ImageIcon(u, getUsecaseid());
- } catch (Exception e) {
- logger.error(e);
- return null;
- }
- }
-
- /**
- * String representation of the use case. It also contains interesting
- * information on the availability of resources in the grid to actually
- * execute that workflow element.
- *
- * @return String
- */
- @Override
- public String toString() {
- List<String> hlp = new ArrayList<String>();
- hlp.add("usecaseid: " + getUsecaseid());
- hlp.add("description: " + getDescription());
- hlp.add("group: " + group);
- hlp.add("test: " + test_local);
- hlp.add("tags: " + getTags());
- for (Map.Entry<String, ScriptInput> cur : getInputs().entrySet()) {
- hlp.add(">" + cur.getKey() + ">: " + cur.getValue().toString());
- }
- for (Map.Entry<String, ScriptOutput> cur : getOutputs().entrySet()) {
- hlp.add("<" + cur.getKey() + "<: " + cur.getValue().toString());
- }
- hlp.add("RE: " + getREs().toString());
- hlp.add("preferred queues: " + getQueue_preferred());
- hlp.add("denied queues: " + getQueue_deny());
- String tos = super.toString() + "[";
- for (int i = 0; i < hlp.size(); i++) {
- if (i != 0)
- tos += ", ";
- tos += hlp.get(i);
- }
- return tos + " ]";
- }
-
- /**
- * hajo's test just pass an url or file url to an xml file
- *
- * @throws IOException
- * @throws MalformedURLException
- * @throws DeserializationException
- */
- public static void main(String[] argv) throws MalformedURLException, IOException, DeserializationException {
- UseCaseDescription d = new UseCaseDescription(new URL(argv[0]).openStream());
- logger.info(d.getCommand());
- }
-
- /**
- * @param command the command to set
- */
- @ConfigurationProperty(name = "command", label = "Command", description="What is actually executed on the shell")
- public void setCommand(String command) {
- this.command = command;
- }
-
- /**
- * @param description the description to set
- */
- @ConfigurationProperty(name = "description", label = "Description", description="Textual description of the tool", required=false, uri="http://purl.org/dc/elements/1.1/description")
- public void setDescription(String description) {
- this.description = description;
- }
-
- /**
- * @return the description
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * @param executionTimeoutInSeconds the executionTimeoutInSeconds to set
- */
- @ConfigurationProperty(name = "executionTimeoutInSeconds", label = "Execution Timeout In Seconds")
- public void setExecutionTimeoutInSeconds(int executionTimeoutInSeconds) {
- this.executionTimeoutInSeconds = executionTimeoutInSeconds;
- }
-
- /**
- * @return the executionTimeoutInSeconds
- */
- public int getExecutionTimeoutInSeconds() {
- return executionTimeoutInSeconds;
- }
-
- /**
- * @param inputs the inputs to set
- */
- public void setInputs(Map<String, ScriptInput> inputs) {
- this.inputs = inputs;
- }
-
- @ConfigurationProperty(name = "inputs", label = "Inputs", required=false)
- public void setInputs(Set<InputMap> inputs) {
- if (inputs != null) {
- this.inputs = new HashMap<String, ScriptInput>();
- for (InputMap inputMap : inputs) {
- this.inputs.put(inputMap.getPort(), inputMap.getInput());
- }
- } else {
- this.inputs = null;
- }
- }
-
- /**
- * @return the inputs
- */
- public Map<String, ScriptInput> getInputs() {
- if (inputs == null) {
- inputs = new HashMap<String, ScriptInput>();
- }
- return inputs;
- }
-
- /**
- * @param outputs the outputs to set
- */
- public void setOutputs(Map<String, ScriptOutput> outputs) {
- this.outputs = outputs;
- }
-
- @ConfigurationProperty(name = "outputs", label = "Outputs", required=false)
- public void setOutputs(Set<OutputMap> outputs) {
- if (outputs != null) {
- this.outputs = new HashMap<String, ScriptOutput>();
- for (OutputMap outputMap : outputs) {
- this.outputs.put(outputMap.getPort(), outputMap.getOutput());
- }
- } else {
- this.outputs = null;
- }
- }
-
- /**
- * @return the outputs
- */
- public Map<String, ScriptOutput> getOutputs() {
- if (outputs == null) {
- outputs = new HashMap<String, ScriptOutput>();
- }
- return outputs;
- }
-
- /**
- * @param preparingTimeoutInSeconds the preparingTimeoutInSeconds to set
- */
- @ConfigurationProperty(name = "preparingTimeoutInSeconds", label = "Preparing Timeout In Seconds")
- public void setPreparingTimeoutInSeconds(int preparingTimeoutInSeconds) {
- this.preparingTimeoutInSeconds = preparingTimeoutInSeconds;
- }
-
- /**
- * @return the preparingTimeoutInSeconds
- */
- public int getPreparingTimeoutInSeconds() {
- return preparingTimeoutInSeconds;
- }
-
- /**
- * @param queue_deny the queue_deny to set
- */
- public void setQueue_deny(ArrayList<String> queue_deny) {
- this.queue_deny = queue_deny;
- }
-
- /**
- * @return the queue_deny
- */
- public ArrayList<String> getQueue_deny() {
- if (queue_deny == null) {
- queue_deny = new ArrayList<String>();
- }
- return queue_deny;
- }
-
- /**
- * @param queue_preferred the queue_preferred to set
- */
- public void setQueue_preferred(ArrayList<String> queue_preferred) {
- this.queue_preferred = queue_preferred;
- }
-
- /**
- * @return the queue_preferred
- */
- public ArrayList<String> getQueue_preferred() {
- if (queue_preferred == null) {
- queue_preferred = new ArrayList<String>();
- }
- return queue_preferred;
- }
-
- /**
- * @param rEs the rEs to set
- */
- public void setREs(List<RuntimeEnvironmentConstraint> rEs) {
- REs = rEs;
- }
-
- /**
- * @return the rEs
- */
- public List<RuntimeEnvironmentConstraint> getREs() {
- if (REs == null) {
- REs = new ArrayList<RuntimeEnvironmentConstraint>();
- }
- return REs;
- }
-
- /**
- * @param static_inputs the static_inputs to set
- */
- @ConfigurationProperty(name = "staticInputs", label = "Static Inputs", ordering=OrderPolicy.NON_ORDERED, required=false)
- public void setStatic_inputs(List<ScriptInputStatic> static_inputs) {
- this.static_inputs = static_inputs;
- }
-
- /**
- * @return the static_inputs
- */
- public List<ScriptInputStatic> getStatic_inputs() {
- if (static_inputs == null) {
- static_inputs = new ArrayList<ScriptInputStatic>();
- }
- return static_inputs;
- }
-
- /**
- * @param tags the tags to set
- */
- public void setTags(List<String> tags) {
- this.tags = tags;
- }
-
- /**
- * @return the tags
- */
- public List<String> getTags() {
- if (tags == null) {
- tags = new ArrayList<String>();
- }
- return tags;
- }
-
- /**
- * @param usecaseid the usecaseid to set
- */
- @ConfigurationProperty(name = "usecaseid", label = "Title", uri="http://purl.org/dc/elements/1.1/title", required=false)
- public void setUsecaseid(String usecaseid) {
- this.usecaseid = usecaseid;
- }
-
- /**
- * @return the usecaseid
- */
- public String getUsecaseid() {
- return usecaseid;
- }
-
- public boolean isIncludeStdIn() {
- return includeStdIn;
- }
-
- @ConfigurationProperty(name = "includeStdIn", label = "Include STDIN")
- public void setIncludeStdIn(boolean includeStdIn) {
- this.includeStdIn = includeStdIn;
- }
-
- public boolean isIncludeStdOut() {
- return includeStdOut;
- }
-
- @ConfigurationProperty(name = "includeStdOut", label = "Include STDOUT")
- public void setIncludeStdOut(boolean includeStdOut) {
- this.includeStdOut = includeStdOut;
- }
-
- public boolean isIncludeStdErr() {
- return includeStdErr;
- }
-
- @ConfigurationProperty(name = "includeStdErr", label = "Include STDERR")
- public void setIncludeStdErr(boolean includeStdErr) {
- this.includeStdErr = includeStdErr;
- }
-
- /**
- * @return the validReturnCodes
- */
- public List<Integer> getValidReturnCodes() {
- if (validReturnCodes == null) {
- validReturnCodes = new ArrayList<Integer>();
- }
- if (validReturnCodes.isEmpty()) {
- validReturnCodes.add(0);
- }
- return validReturnCodes;
- }
-
- /**
- * @param validReturnCodes the validReturnCodes to set
- */
- public void setValidReturnCodes(List<Integer> validReturnCodes) {
- this.validReturnCodes = validReturnCodes;
- }
-
- public String getReturnCodesAsText() {
- return StringUtils.join(getValidReturnCodes(), ",");
- }
-
- public void setReturnCodesAsText(String text) {
- if (getValidReturnCodes() == null) {
- validReturnCodes = new ArrayList<Integer>();
- }
- validReturnCodes.clear();
- String[] codes = text.split(",");
- for (String code : codes) {
- try {
- Integer codeInt = new Integer(code);
- if (!validReturnCodes.contains(codeInt)) {
- validReturnCodes.add(codeInt);
- }
- }
- catch (NumberFormatException e) {
- logger.error(e);
- }
- }
- if (validReturnCodes.isEmpty()) {
- validReturnCodes.add(0);
- }
- Collections.sort(validReturnCodes);
- }
-
- /**
- * @return the group
- */
- public String getGroup() {
- return group;
- }
-
- /**
- * @param group the group to set
- */
- public void setGroup(String group) {
- this.group = group;
- }
-
- /**
- * @return the icon_url
- */
- public String getIcon_url() {
- return icon_url;
- }
-
- @ConfigurationBean(uri = ExternalToolActivity.URI + "#OutputMap")
- public static class OutputMap {
- private String port;
-
- private ScriptOutput output;
-
- public String getPort() {
- return port;
- }
-
- @ConfigurationProperty(name = "port", label = "Port")
- public void setPort(String port) {
- this.port = port;
- }
-
- public ScriptOutput getOutput() {
- return output;
- }
-
- @ConfigurationProperty(name = "output", label = "Output")
- public void setOutput(ScriptOutput output) {
- this.output = output;
- }
- }
-
- @ConfigurationBean(uri = ExternalToolActivity.URI + "#InputMap")
- public static class InputMap {
- private String port;
-
- private ScriptInputUser input;
-
- public String getPort() {
- return port;
- }
-
- @ConfigurationProperty(name = "port", label = "Port")
- public void setPort(String port) {
- this.port = port;
- }
-
- public ScriptInputUser getInput() {
- return input;
- }
-
- @ConfigurationProperty(name = "input", label = "Input")
- public void setInput(ScriptInputUser input) {
- this.input = input;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/2e8f451e/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseEnumeration.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseEnumeration.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseEnumeration.java
deleted file mode 100644
index ea51c7b..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/UseCaseEnumeration.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/* Part of the KnowARC Janitor Use-case processor for taverna
- * written 2007-2010 by Hajo Nils Krabbenhoeft and Steffen Moeller
- * University of Luebeck, Institute for Neuro- and Bioinformatics
- * University of Luebeck, Institute for Dermatolgy
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This package is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this package; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package de.uni_luebeck.inb.knowarc.usecases;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.List;
-
-import net.sf.taverna.t2.workflowmodel.serialization.DeserializationException;
-
-import org.apache.log4j.Logger;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jdom.input.SAXBuilder;
-
-public class UseCaseEnumeration {
-
- private static Logger logger = Logger.getLogger(UseCaseEnumeration.class);
-
- public static List<UseCaseDescription> readDescriptionsFromUrl(String xmlFileUrl) throws IOException {
-
- List<UseCaseDescription> ret = new ArrayList<UseCaseDescription>();
- URLConnection con = null;
- try {
- URL url = new URL(xmlFileUrl);
-
- con = url.openConnection();
- con.setConnectTimeout(4000);
- ret = readDescriptionsFromStream(con.getInputStream());
-
- } catch (IOException ioe) {
- logger.error("Problem retrieving from " + xmlFileUrl);
- logger.error(ioe);
- throw ioe;
- }
- finally {
-
- }
-
- return ret;
-
- }
-
- public static List<UseCaseDescription> readDescriptionsFromStream(InputStream is) {
-
- List<UseCaseDescription> ret = new ArrayList<UseCaseDescription>();
-
- SAXBuilder builder = new SAXBuilder();
- Document doc = null;
- try {
- doc = builder.build(is);
- is.close();
- } catch (JDOMException e1) {
- logger.error(e1);
- return ret;
- } catch (IOException e1) {
- logger.error(e1);
- return ret;
- } finally {
- try {
- is.close();
- } catch (IOException e) {
- logger.error(e);
- }
- }
-
- Element usecases = doc.getRootElement();
- for (Object ochild : usecases.getChildren()) {
- Element child = (Element) ochild;
- if (child.getName().equalsIgnoreCase("program")) {
- try {
- ret.add(new UseCaseDescription(child));
- } catch (DeserializationException e) {
- logger.error(e);
- }
- }
- }
- return ret;
- }
-
- public static UseCaseDescription readDescriptionFromUrl(
- String repositoryUrl, String id) throws IOException {
- List<UseCaseDescription> descriptions = readDescriptionsFromUrl(repositoryUrl);
- for (UseCaseDescription usecase : descriptions) {
- if (usecase.getUsecaseid().equals(id)) {
- return usecase;
- }
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/2e8f451e/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/AskUserForPw.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/AskUserForPw.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/AskUserForPw.java
deleted file mode 100644
index 9c54b1d..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/AskUserForPw.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Part of the KnowARC Janitor Use-case processor for taverna
- * written 2007-2010 by Hajo Nils Krabbenhoeft and Steffen Moeller
- * University of Luebeck, Institute for Neuro- and Bioinformatics
- * University of Luebeck, Institute for Dermatolgy
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This package is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this package; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package de.uni_luebeck.inb.knowarc.usecases.invocation;
-
-public interface AskUserForPw {
-
- // we will try keyfile first
- public String getKeyfile();
- public String getPassphrase();
-
- // then username+password
- public String getUsername();
- public String getPassword();
-
- public void authenticationSucceeded();
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/2e8f451e/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/InvocationException.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/InvocationException.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/InvocationException.java
deleted file mode 100644
index d714ab1..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/InvocationException.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- *
- */
-package de.uni_luebeck.inb.knowarc.usecases.invocation;
-
-/**
- * @author alanrw
- *
- */
-public class InvocationException extends Exception {
-
- /**
- *
- */
- private static final long serialVersionUID = 437316164959631591L;
-
- public InvocationException(String string) {
- super(string);
- }
-
- public InvocationException(Exception e) {
- super(e);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-taverna-common-activities/blob/2e8f451e/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/UseCaseInvocation.java
----------------------------------------------------------------------
diff --git a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/UseCaseInvocation.java b/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/UseCaseInvocation.java
deleted file mode 100644
index 6154d05..0000000
--- a/taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/UseCaseInvocation.java
+++ /dev/null
@@ -1,324 +0,0 @@
-/* Part of the KnowARC Janitor Use-case processor for taverna
- * written 2007-2010 by Hajo Nils Krabbenhoeft and Steffen Moeller
- * University of Luebeck, Institute for Neuro- and Bioinformatics
- * University of Luebeck, Institute for Dermatolgy
- *
- * This package is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This package is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this package; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package de.uni_luebeck.inb.knowarc.usecases.invocation;
-
-import java.io.BufferedWriter;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.io.IOUtils;
-
-import net.sf.taverna.t2.invocation.InvocationContext;
-import net.sf.taverna.t2.reference.ExternalReferenceSPI;
-import net.sf.taverna.t2.reference.Identified;
-import net.sf.taverna.t2.reference.IdentifiedList;
-import net.sf.taverna.t2.reference.ReferenceService;
-import net.sf.taverna.t2.reference.ReferenceServiceException;
-import net.sf.taverna.t2.reference.ReferenceSet;
-import net.sf.taverna.t2.reference.T2Reference;
-import net.sf.taverna.t2.reference.impl.external.object.InlineByteArrayReferenceBuilder;
-import net.sf.taverna.t2.reference.impl.external.object.InlineStringReferenceBuilder;
-import de.uni_luebeck.inb.knowarc.usecases.ScriptInput;
-import de.uni_luebeck.inb.knowarc.usecases.ScriptInputStatic;
-import de.uni_luebeck.inb.knowarc.usecases.ScriptInputUser;
-import de.uni_luebeck.inb.knowarc.usecases.UseCaseDescription;
-
-/**
- * An abstraction of various forms to bring job using the software that is
- * referenced as a use case towards their execution.
- *
- * @author Hajo Nils Krabbenhoeft with some contribution by
- * @author Steffen Moeller
- */
-public abstract class UseCaseInvocation {
-
- private String runId;
-
-
- protected static String getActualOsCommand(String osCommand, String pathToOriginal,
- String targetName, String pathTarget) {
- String actualOsCommand = osCommand;
- actualOsCommand = actualOsCommand.replace("%%PATH_TO_ORIGINAL%%", pathToOriginal);
- actualOsCommand = actualOsCommand.replace("%%TARGET_NAME%%", targetName);
- actualOsCommand = actualOsCommand.replace("%%PATH_TO_TARGET%%", pathTarget);
- return actualOsCommand;
- }
-
- protected UseCaseDescription usecase;
- protected final HashMap<String, String> tags = new HashMap<String, String>();
- protected int nTempFiles = 0;
- private static int submissionID = 0;
- protected static InlineByteArrayReferenceBuilder inlineByteArrayReferenceBuilder = new InlineByteArrayReferenceBuilder();
- protected static InlineStringReferenceBuilder inlineStringReferenceBuilder = new InlineStringReferenceBuilder();
- private InvocationContext invocationContext;
- private boolean retrieveData;
-
- /*
- * get the class of the data we expect for a given input
- */
- @SuppressWarnings("unchecked")
- public Class getType(String inputName) {
- if (!usecase.getInputs().containsKey(inputName))
- return null;
- ScriptInputUser input = (ScriptInputUser) usecase.getInputs().get(inputName);
- if (input.isList()) {
- if (input.isBinary())
- return List.class;
- else
- return List.class;
- } else {
- if (input.isBinary())
- return byte[].class;
- else
- return String.class;
- }
- }
-
- /*
- * get a list of all the input port names
- */
- public Set<String> getInputs() {
- return usecase.getInputs().keySet();
- }
-
-
- /*
- * get a id, incremented with each job. thus, this should be thread-wide
- * unique
- */
- public synchronized int getSubmissionID() {
- return submissionID++;
- }
-
- /*
- * set the data for the input port with given name
- */
- @SuppressWarnings("unchecked")
- public void setInput(String inputName, ReferenceService referenceService, T2Reference t2Reference) throws InvocationException {
- if (t2Reference == null) {
- throw new InvocationException("No input specified for " + inputName);
- }
- ScriptInputUser input = (ScriptInputUser) usecase.getInputs().get(inputName);
- if (input.isList()) {
- IdentifiedList<T2Reference> listOfReferences = (IdentifiedList<T2Reference>) referenceService
- .getListService().getList(t2Reference);
-
- if (!input.isConcatenate()) {
- // this is a list input (not concatenated)
- // so write every element to its own temporary file
- // and create a filelist file
-
- // we need to write the list elements to temporary files
- ScriptInputUser listElementTemp = new ScriptInputUser();
- listElementTemp.setBinary(input.isBinary());
- listElementTemp.setTempFile(true);
-
- String lineEndChar = "\n";
- if (!input.isFile() && !input.isTempFile()) {
- lineEndChar = " ";
- }
-
- String listFileContent = "";
- String filenamesFileContent = "";
- // create a list of all temp file names
- for (T2Reference cur : listOfReferences) {
- String tmp = setOneInput(referenceService, cur,
- listElementTemp);
- listFileContent += tmp + lineEndChar;
- int ind = tmp.lastIndexOf('/');
- if (ind == -1) {
- ind = tmp.lastIndexOf('\\');
- }
- if (ind != -1) {
- tmp = tmp.substring(ind + 1);
- }
- filenamesFileContent += tmp + lineEndChar;
- }
-
- // how do we want the listfile to be stored?
- ScriptInputUser listFile = new ScriptInputUser();
- listFile.setBinary(false); // since its a list file
- listFile.setFile(input.isFile());
- listFile.setTempFile(input.isTempFile());
- listFile.setTag(input.getTag());
- T2Reference listFileContentReference = referenceService
- .register(listFileContent, 0, true, invocationContext);
-
- tags.put(listFile.getTag(), setOneInput(referenceService,
- listFileContentReference, listFile));
-
- listFile.setTag(input.getTag() + "_NAMES");
- T2Reference filenamesFileContentReference = referenceService
- .register(filenamesFileContent, 0, true, null);
- tags.put(listFile.getTag(), setOneInput(referenceService,
- filenamesFileContentReference, listFile));
- } else {
- try {
- // first, concatenate all data
- if (input.isBinary()) {
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- BufferedWriter outputWriter = new BufferedWriter(
- new OutputStreamWriter(outputStream));
- for (T2Reference cur : listOfReferences) {
- InputStreamReader inputReader = new InputStreamReader(
- getAsStream(referenceService, cur));
- IOUtils.copyLarge(inputReader, outputWriter);
- inputReader.close();
- }
- outputWriter.close();
- T2Reference binaryReference = referenceService
- .register(outputStream.toByteArray(), 0, true,
- invocationContext);
- tags.put(input.getTag(), setOneInput(referenceService,
- binaryReference, input));
- } else {
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- BufferedWriter outputWriter = new BufferedWriter(
- new OutputStreamWriter(outputStream));
- for (T2Reference cur : listOfReferences) {
- InputStreamReader inputReader = new InputStreamReader(
- getAsStream(referenceService, cur));
- IOUtils.copyLarge(inputReader, outputWriter);
- outputWriter.write(" ");
- inputReader.close();
- }
- outputWriter.close();
- T2Reference binaryReference = referenceService
- .register(outputStream.toByteArray(), 0, true,
- invocationContext);
- tags.put(input.getTag(), setOneInput(referenceService,
- binaryReference, input));
- }
- } catch (IOException e) {
- throw new InvocationException(e);
- }
- }
- } else {
- tags.put(input.getTag(), setOneInput(referenceService, t2Reference,
- input));
- }
- }
-
- /*
- * submit a grid job and wait for it to finish, then get the result as
- * on-demand downloads or directly as data (in case of local execution)
- */
- public HashMap<String, Object> Submit(ReferenceService referenceService) throws InvocationException {
- submit_generate_job(referenceService);
- return submit_wait_fetch_results(referenceService);
- }
-
- /*
- * just submit the job. useful if you want to wait for it to finish later on
- *
- * Can the statics be made more static?
- */
- public void submit_generate_job(ReferenceService referenceService) throws InvocationException {
- for (ScriptInputStatic input : usecase.getStatic_inputs()) {
- T2Reference ref;
- if (input.getUrl() != null) {
- // Does this work OK with binary
- try {
- ref = referenceService.register(new URL(input.getUrl()), 0, true, null);
- } catch (ReferenceServiceException e) {
- throw new InvocationException(e);
- } catch (MalformedURLException e) {
- throw new InvocationException(e);
- }
- } else {
- ref = referenceService.register((String) input.getContent(), 0, true, null);
- }
- tags.put(input.getTag(), setOneInput(referenceService, ref, input));
-
- }
- submit_generate_job_inner();
- }
-
- protected abstract void submit_generate_job_inner() throws InvocationException;
-
- /*
- * wait for a submitted job to finish and fetch the results
- */
- public abstract HashMap<String, Object> submit_wait_fetch_results(ReferenceService referenceService) throws InvocationException;
-
- public abstract String setOneInput(ReferenceService referenceService, T2Reference t2Reference, ScriptInput input) throws InvocationException;
-
- protected InputStream getAsStream(ReferenceService referenceService, T2Reference t2Reference) {
- Identified identified = referenceService.resolveIdentifier(t2Reference, null, null);
- if (identified instanceof ReferenceSet) {
- ExternalReferenceSPI ref = ((ReferenceSet) identified).getExternalReferences().iterator().next();
- return ref.openStream(invocationContext);
- }
- return null;
- }
-
- public void setContext(InvocationContext context) {
- this.invocationContext = context;
-
- }
-
- public InvocationContext getContext() {
- return this.invocationContext;
- }
-
- public abstract void setStdIn(ReferenceService referenceService,
- T2Reference t2Reference);
-
- public abstract void rememberRun(String runId);
-
- /**
- * @return the runId
- */
- protected String getRunId() {
- return runId;
- }
-
- /**
- * @param runId the runId to set
- */
- protected void setRunId(String runId) {
- this.runId = runId;
- }
-
- /**
- * @return the retrieveData
- */
- protected boolean isRetrieveData() {
- return retrieveData;
- }
-
- /**
- * @param retrieveData the retrieveData to set
- */
- protected void setRetrieveData(boolean retrieveData) {
- this.retrieveData = retrieveData;
- }
-
-
-}