JWS-17: fix problem with undefined URL for the furtherDetails tag
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Thu, 19 Sep 2013 12:46:16 +0000 (13:46 +0100)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Thu, 19 Sep 2013 12:46:16 +0000 (13:46 +0100)
datamodel/compbio/metadata/Argument.java
datamodel/compbio/metadata/Limit.java
datamodel/compbio/metadata/LimitsManager.java
datamodel/compbio/metadata/Option.java
datamodel/compbio/metadata/Parameter.java
datamodel/compbio/metadata/Preset.java
datamodel/compbio/metadata/PresetManager.java
datamodel/compbio/metadata/ValueConstrain.java
runner/compbio/runner/Util.java
webservices/compbio/ws/client/Jws2Client.java
webservices/compbio/ws/client/MetadataHelper.java

index 60a8f86..ac8d02a 100644 (file)
@@ -32,35 +32,35 @@ import java.util.List;
  *         Date December 2009\r
  * @param <T>\r
  *            executable type\r
- */\r
+*/\r
 public interface Argument<T> {\r
 \r
-    URL getFurtherDetails();\r
+       String getFurtherDetails();\r
 \r
-    String getDefaultValue();\r
+       String getDefaultValue();\r
 \r
-    String getDescription();\r
+       String getDescription();\r
 \r
-    String getName();\r
+       String getName();\r
 \r
-    /**\r
-     * \r
-     * @return List of values allowed for an Argument\r
-     */\r
-    List<String> getPossibleValues();\r
+       /**\r
+        *\r
+        * @return List of values allowed for an Argument\r
+       */\r
+       List<String> getPossibleValues();\r
 \r
-    /**\r
-     * Set default values for the parameter or an option\r
-     * \r
-     * @param defaultValue\r
-     *            the value to be set\r
-     * @throws WrongParameterException\r
-     *             - when the value to be set is illegal. Wrong value for\r
-     *             numeric parameter is the value defined outside it , for\r
-     *             string type parameter, wrong value is the one which is not\r
-     *             listed in possible values list\r
-     * @see ValueConstrain\r
-     */\r
-    void setValue(String defaultValue) throws WrongParameterException;\r
+       /**\r
+        * Set default values for the parameter or an option\r
+        * \r
+        * @param defaultValue\r
+        *            the value to be set\r
+        * @throws WrongParameterException\r
+        *             - when the value to be set is illegal. Wrong value for\r
+        *             numeric parameter is the value defined outside it , for\r
+        *             string type parameter, wrong value is the one which is not\r
+        *             listed in possible values list\r
+        * @see ValueConstrain\r
+       */\r
+       void setValue(String defaultValue) throws WrongParameterException;\r
 \r
 }\r
index 9910e73..8132832 100644 (file)
@@ -157,13 +157,12 @@ public class Limit<T> {
        public String toString() {\r
                String value = "";\r
                if (isDefault) {\r
-                       value = "Default Limit" + SysPrefs.newlinechar;\r
+                       value = "Default Limits:" + SysPrefs.newlinechar;\r
                } else {\r
-                       value = "Limit for Preset '" + preset + "'" + SysPrefs.newlinechar;\r
+                       value = "Limits for Preset '" + preset + "'" + SysPrefs.newlinechar;\r
                }\r
                value += "Maximum sequence number=" + seqNumber + SysPrefs.newlinechar;\r
                value += "Average sequence length=" + seqLength + SysPrefs.newlinechar;\r
-               value += SysPrefs.newlinechar;\r
                return value;\r
        }\r
 \r
index 94de517..ee40a94 100644 (file)
@@ -54,12 +54,11 @@ public class LimitsManager<T> {
 \r
        @Override\r
        public String toString() {\r
-               if (limit == null) {\r
-                       return "";\r
-               }\r
                String value = "";\r
-               for (Limit<T> lim : limit) {\r
-                       value += lim.toString();\r
+               if (null != limit) {\r
+                       for (Limit<T> lim : limit) {\r
+                               value += lim.toString();\r
+                       }\r
                }\r
                return value;\r
        }\r
index 3f47bb0..93361dd 100644 (file)
@@ -18,6 +18,7 @@
 \r
 package compbio.metadata;\r
 \r
+import java.net.MalformedURLException;\r
 import java.net.URL;\r
 import java.util.ArrayList;\r
 import java.util.HashSet;\r
@@ -30,6 +31,7 @@ import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;\r
 import javax.xml.bind.annotation.XmlAttribute;\r
 import javax.xml.bind.annotation.XmlElement;\r
+import javax.xml.bind.annotation.XmlTransient;\r
 \r
 import compbio.util.SysPrefs;\r
 import compbio.util.Util;\r
@@ -59,15 +61,17 @@ public class Option<T> implements Argument<T> {
        @XmlAttribute\r
        protected boolean isRequired;\r
        @XmlElement\r
-       protected URL furtherDetails;\r
+       protected String furtherDetails;\r
        @XmlElement\r
        protected String defaultValue;\r
+       @XmlTransient\r
+       private URL basicURL;\r
 \r
        Option() {\r
                // Has to have no arg constructor for JAXB\r
        }\r
 \r
-       public Option(String name, String description) {\r
+       public Option(String name, String description) throws MalformedURLException {\r
                this.name = name;\r
                this.description = description;\r
        }\r
@@ -83,6 +87,16 @@ public class Option<T> implements Argument<T> {
                this.name = name;\r
        }\r
 \r
+       public void setBasicURL(URL url) {\r
+               this.basicURL = url;\r
+       }\r
+       public URL getBasicURL() throws MalformedURLException {\r
+               URL out = new URL ("http://unknown.jabaws.server.ac.uk");\r
+               if (null != basicURL) {\r
+                       out = basicURL;\r
+               }\r
+               return out;\r
+       }       \r
        /**\r
         * A long description of the Option\r
         */\r
@@ -96,12 +110,13 @@ public class Option<T> implements Argument<T> {
 \r
        /**\r
         * The URL where further details about the option can be found\r
+        * @throws MalformedURLException \r
         */\r
-       public URL getFurtherDetails() {\r
+       public String getFurtherDetails() {\r
                return furtherDetails;\r
        }\r
 \r
-       public void setFurtherDetails(URL furtherDetails) {\r
+       public void setFurtherDetails(String furtherDetails) {\r
                this.furtherDetails = furtherDetails;\r
        }\r
 \r
@@ -190,17 +205,23 @@ public class Option<T> implements Argument<T> {
                String value = "Option name: " + this.name + SysPrefs.newlinechar;\r
                value += "Description: " + this.description + SysPrefs.newlinechar;\r
                if (!Util.isEmpty(defaultValue)) {\r
-                       value += "Default value: " + this.defaultValue\r
-                                       + SysPrefs.newlinechar;\r
+                       value += "Default value: " + this.defaultValue + SysPrefs.newlinechar;\r
+               }\r
+               if (null != this.furtherDetails) {\r
+                       value += "URL: " + this.basicURL + this.furtherDetails + SysPrefs.newlinechar;\r
+               } else {\r
+                       value += "URL: unknown URL" + SysPrefs.newlinechar;\r
                }\r
-               value += "URL: " + this.furtherDetails + SysPrefs.newlinechar;\r
                value += "Is required: " + this.isRequired + SysPrefs.newlinechar;\r
                if (!this.optionNames.isEmpty()) {\r
                        Set<String> sortedPosval = new TreeSet<String>(this.optionNames);\r
-                       value += "Option Names: " + SysPrefs.newlinechar;\r
+                       value += "Option(s): ";\r
+                       String delim = "";\r
                        for (String val : sortedPosval) {\r
-                               value += val + SysPrefs.newlinechar;\r
+                               value += delim + val;\r
+                               delim = ", ";\r
                        }\r
+                       value += SysPrefs.newlinechar;\r
                }\r
                return value;\r
        }\r
index dcbf3d3..b89f150 100644 (file)
@@ -18,6 +18,7 @@
 \r
 package compbio.metadata;\r
 \r
+import java.net.MalformedURLException;\r
 import java.util.ArrayList;\r
 import java.util.Collections;\r
 import java.util.HashSet;\r
@@ -57,7 +58,7 @@ public class Parameter<T> extends Option<T> {
                // JAXB noargs const\r
        }\r
 \r
-       public Parameter(String name, String description) {\r
+       public Parameter(String name, String description) throws MalformedURLException {\r
                super(name, description);\r
        }\r
 \r
@@ -85,7 +86,6 @@ public class Parameter<T> extends Option<T> {
                                value += val + SysPrefs.newlinechar;\r
                        }\r
                }\r
-               value += SysPrefs.newlinechar;\r
                return value;\r
        }\r
 \r
index 06f0fd5..bca49d4 100644 (file)
@@ -149,11 +149,10 @@ public class Preset<T> {
        public String toString() {\r
                String value = "Preset name: '" + name + "'" + SysPrefs.newlinechar;\r
                value += "Description: " + description + SysPrefs.newlinechar;\r
-               value += "Options: " + SysPrefs.newlinechar;\r
+               value += "Options used: " + SysPrefs.newlinechar;\r
                for (String oname : this.option) {\r
                        value += oname + SysPrefs.newlinechar;\r
                }\r
-               value += SysPrefs.newlinechar;\r
                return value;\r
        }\r
 \r
index ed12fc0..b49bfc3 100644 (file)
@@ -161,9 +161,9 @@ public class PresetManager<T> {
 \r
        @Override\r
        public String toString() {\r
-               String value = "Runner: " + this.runnerClassName;\r
+               String value = "Runner: " + this.runnerClassName + "\n";\r
                for (Preset<T> p : preset) {\r
-                       value += p.toString() + "\n";\r
+                       value += "##############################################################################\n" + p.toString() + "\n";\r
                }\r
                return value;\r
        }\r
index 375a02c..2b99ecd 100644 (file)
@@ -126,10 +126,10 @@ public class ValueConstrain {
        public String toString() {\r
                String value = "Type: " + this.type + "\n";\r
                if (this.min != null) {\r
-                       value += "Min: " + this.min + "\n";\r
+                       value += "Minimal value: " + this.min + "\n";\r
                }\r
                if (this.max != null) {\r
-                       value += "Max: " + this.max + "\n";\r
+                       value += "Maximal value: " + this.max + "\n";\r
                }\r
                return value;\r
        }\r
index a0123a2..f8d7b80 100644 (file)
@@ -52,12 +52,9 @@ public final class Util {
                try {\r
                        return ConfExecutable.getRunnerOptions(clazz);\r
                } catch (FileNotFoundException e) {\r
-                       log.error(\r
-                                       "Could not load " + clazz + " Parameters !"\r
-                                                       + e.getMessage(), e.getCause());\r
+                       log.error("Could not load " + clazz + " parameters !" + e.getMessage(), e.getCause());\r
                } catch (IOException e) {\r
-                       log.error("IO exception while reading " + clazz + " Parameters !"\r
-                                       + e.getMessage(), e.getCause());\r
+                       log.error("IO exception while reading " + clazz + " parameters !" + e.getMessage(), e.getCause());\r
                }\r
                return null;\r
        }\r
@@ -67,28 +64,21 @@ public final class Util {
                try {\r
                        return ConfExecutable.getRunnerPresets(clazz);\r
                } catch (FileNotFoundException e) {\r
-                       log.warn(\r
-                                       "No presets are found for " + clazz + " executable! "\r
-                                                       + e.getLocalizedMessage(), e.getCause());\r
+                       log.warn("No presets are found for " + clazz + "! " + e.getLocalizedMessage(), e.getCause());\r
                } catch (IOException e) {\r
-                       log.warn("IO exception while reading presents! for " + clazz\r
-                                       + " executable! " + e.getLocalizedMessage(), e.getCause());\r
+                       log.warn("IO exception while reading presets for " + clazz + "! " + e.getLocalizedMessage(), e.getCause());\r
                }\r
                return null;\r
        }\r
 \r
-       public static final Alignment readClustalFile(String workDirectory,\r
-                       String clustFile) throws UnknownFileFormatException, IOException,\r
-                       FileNotFoundException, NullPointerException {\r
+       public static final Alignment readClustalFile(String workDirectory, String clustFile) \r
+                               throws UnknownFileFormatException, IOException, FileNotFoundException, NullPointerException {\r
                assert !compbio.util.Util.isEmpty(workDirectory);\r
                assert !compbio.util.Util.isEmpty(clustFile);\r
-               File cfile = new File(compbio.engine.client.Util.getFullPath(\r
-                               workDirectory, clustFile));\r
+               File cfile = new File(compbio.engine.client.Util.getFullPath(workDirectory, clustFile));\r
                log.trace("CLUSTAL OUTPUT FILE PATH: " + cfile.getAbsolutePath());\r
                if (!(cfile.exists() && cfile.length() > 0)) {\r
-                       throw new FileNotFoundException("Result for the jobId "\r
-                                       + workDirectory + " with file name " + clustFile\r
-                                       + " is not found!");\r
+                       throw new FileNotFoundException("Result for the jobId " + workDirectory + " with file name " + clustFile + " is not found!");\r
                }\r
                return ClustalAlignmentUtil.readClustalFile(cfile);\r
        }\r
@@ -102,9 +92,7 @@ public final class Util {
                                workDirectory, clustFile));\r
                log.trace("Jronn OUTPUT FILE PATH: " + cfile.getAbsolutePath());\r
                if (!(cfile.exists() && cfile.length() > 0)) {\r
-                       throw new FileNotFoundException("Result for the jobId "\r
-                                       + workDirectory + " with file name " + clustFile\r
-                                       + " is not found!");\r
+                       throw new FileNotFoundException("Result for the jobId " + workDirectory + " with file name " + clustFile + " is not found!");\r
                }\r
                return SequenceUtil.readJRonn(cfile);\r
        }\r
@@ -118,17 +106,13 @@ public final class Util {
                        SequenceUtil.writeFasta(fout, sequences);\r
                        fout.close();\r
                } catch (IOException e) {\r
-                       log.error("IOException while writing input file into the disk: "\r
-                                       + e.getLocalizedMessage(), e);\r
-                       throw new JobSubmissionException(\r
-                                       "We are sorry by JABAWS server seems to have a problem! "\r
-                                                       + e.getLocalizedMessage(), e);\r
+                       log.error("IOException while writing input file into the disk: " + e.getLocalizedMessage(), e);\r
+                       throw new JobSubmissionException("We are sorry by JABAWS server seems to have a problem! " + e.getLocalizedMessage(), e);\r
                }\r
        }\r
 \r
        public static void writeClustalInput(List<FastaSequence> sequences,\r
                        ConfiguredExecutable<?> exec, char gapChar) throws JobSubmissionException {\r
-               \r
                try {\r
                        File filein = new File(exec.getInput());\r
                        FileOutputStream fout = new FileOutputStream(filein);\r
@@ -136,11 +120,8 @@ public final class Util {
                        SequenceUtil.writeClustal(fout, sequences, gapChar);\r
                        fout.close();\r
                } catch (IOException e) {\r
-                       log.error("IOException while writing input file into the disk: "\r
-                                       + e.getLocalizedMessage(), e);\r
-                       throw new JobSubmissionException(\r
-                                       "We are sorry but JABAWS server seems to have a problem! "\r
-                                               + e.getLocalizedMessage(), e);\r
+                       log.error("IOException while writing input file into the disk: " + e.getLocalizedMessage(), e);\r
+                       throw new JobSubmissionException("We are sorry but JABAWS server seems to have a problem! " + e.getLocalizedMessage(), e);\r
                }\r
        }\r
 \r
@@ -150,16 +131,12 @@ public final class Util {
                assert !compbio.util.Util.isEmpty(workDirectory);\r
                assert !compbio.util.Util.isEmpty(structFile);\r
                // The stdout from RNAalifold\r
-               File sFile = new File(compbio.engine.client.Util.getFullPath(\r
-                               workDirectory, structFile));\r
+               File sFile = new File(compbio.engine.client.Util.getFullPath( workDirectory, structFile));\r
                // Base pair probability matrix (-p option)\r
-               File aliFile = new File(compbio.engine.client.Util.getFullPath(\r
-                               workDirectory, "alifold.out"));\r
+               File aliFile = new File(compbio.engine.client.Util.getFullPath( workDirectory, "alifold.out"));\r
                // Check that stdout file exists\r
                if(!(sFile.exists() && sFile.length() > 0)) {\r
-                       throw new FileNotFoundException("Result for the jobId "\r
-                                       + workDirectory + "with file name " + structFile\r
-                                       + " is not found!");\r
+                       throw new FileNotFoundException("Result for the jobId " + workDirectory + "with file name " + structFile + " is not found!");\r
                }\r
                // Check that base pair probability file exists\r
                if(!aliFile.exists()) {\r
index 666fa58..dbe999a 100644 (file)
@@ -57,7 +57,9 @@ import compbio.data.sequence.SequenceUtil;
 import compbio.data.sequence.UnknownFileFormatException;\r
 import compbio.metadata.JobSubmissionException;\r
 import compbio.metadata.Option;\r
+import compbio.metadata.Limit;\r
 import compbio.metadata.Preset;\r
+import compbio.metadata.PresetManager;\r
 import compbio.metadata.ResultNotAvailableException;\r
 import compbio.metadata.WrongParameterException;\r
 import compbio.util.FileUtil;\r
@@ -193,13 +195,24 @@ public class Jws2Client {
                }\r
 \r
                if (CmdHelper.listParameters(cmd)) {\r
-                       System.out.println(MetadataHelper.getParametersList(thews));\r
+                       List<Option<T>> opts = MetadataHelper.getParametersList(thews, hostname);\r
+                       for (Option<T> o : opts) {\r
+                               System.out.println("##############################################################################\n" + o.toString());\r
+                       }\r
                }\r
                if (CmdHelper.listPresets(cmd)) {\r
-                       System.out.println(MetadataHelper.getPresetList(thews));\r
+                       PresetManager<T> psm = MetadataHelper.getPresetList(thews);\r
+                       if (null != psm) {\r
+                               System.out.print(psm);\r
+                       } else {\r
+                               System.out.println("No presets are defined for the Web service");\r
+                       }\r
                }\r
                if (CmdHelper.listLimits(cmd)) {\r
-                       System.out.println(MetadataHelper.getLimits(thews));\r
+                       List<Limit<T>> lims = MetadataHelper.getLimits(thews);\r
+                       for (Limit<T> l : lims) {\r
+                               System.out.println("##############################################################################\n" + l.toString());\r
+                       }\r
                }\r
                log.fine("Disconnecting...");\r
                ((Closeable) thews).close();\r
@@ -307,8 +320,8 @@ public class Jws2Client {
 \r
        private static void listAllServices(String hostname) throws WebServiceException, IOException {\r
                RegistryWS registry = connectToRegistry(hostname);\r
-               Set<Services> func_services = Collections.EMPTY_SET;\r
-               Set<Services> nonfunc_services = Collections.EMPTY_SET;\r
+               Set<Services> func_services = Collections.emptySet();\r
+               Set<Services> nonfunc_services = Collections.emptySet();\r
                if (registry != null) {\r
                        func_services = registry.getSupportedServices();\r
                        nonfunc_services = registry.getNonoperatedServices();\r
index 4803e16..d5d8b06 100644 (file)
@@ -22,6 +22,8 @@ import static compbio.ws.client.Constraints.pseparator;
 import java.util.ArrayList;\r
 import java.util.Collections;\r
 import java.util.List;\r
+import java.net.MalformedURLException;\r
+import java.net.URL;\r
 \r
 import compbio.data.msa.Metadata;\r
 import compbio.metadata.Limit;\r
@@ -42,16 +44,26 @@ public class MetadataHelper {
         * @param msaws\r
         *            web service proxy\r
         * @return List of options supported by a web service\r
+        * @throws MalformedURLException \r
         */\r
-       static <T> List<Option<T>> getParametersList(Metadata<T> msaws) {\r
+       static <T> List<Option<T>> getParametersList(Metadata<T> msaws, String host) throws MalformedURLException {\r
                assert msaws != null;\r
                RunnerConfig<T> config = msaws.getRunnerOptions();\r
                if (config == null) {\r
                        return Collections.emptyList();\r
                }\r
-               return config.getArguments();\r
+               List<Option<T>> opts = config.getArguments();\r
+               for (Option<T> o : opts) {\r
+                       o.setBasicURL(new URL(host + "/"));\r
+               }\r
+               return opts;\r
        }\r
 \r
+       static <T> List<Option<T>> getParametersList(Metadata<T> msaws) throws MalformedURLException {\r
+               return getParametersList (msaws, "http://unknown.jabaws.server.ac.uk");\r
+       }\r
+       \r
+       \r
        /**\r
         * Returns an objects from which the list of presets supported by web\r
         * service <T> can be obtained\r
@@ -98,14 +110,12 @@ public class MetadataHelper {
                assert presetName != null;\r
                PresetManager<T> presets = MetadataHelper.getPresetList(msaws);\r
                if (presets == null) {\r
-                       System.out\r
-                                       .println("No presets are supported by the service! Ignoring -r directive!");\r
+                       System.out.println("No presets are supported by the service! Ignoring -r directive!");\r
                        return null;\r
                }\r
                Preset<T> pre = presets.getPresetByName(presetName);\r
                if (pre == null) {\r
-                       System.out.println("Cannot find preset: " + presetName\r
-                                       + " WARN: ignoring -r directive!");\r
+                       System.out.println("Cannot find preset: " + presetName + " WARN: ignoring -r directive!");\r
                }\r
                return pre;\r
        }\r
@@ -131,17 +141,14 @@ public class MetadataHelper {
                        }\r
                        Option<T> o = options.getArgumentByOptionName(oname);\r
                        if (o == null) {\r
-                               System.out.println("WARN ignoring unsuppoted parameter: "\r
-                                               + oname);\r
+                               System.out.println("WARN ignoring unsuppoted parameter: " + oname);\r
                                continue;\r
                        }\r
                        if (isParameter(param)) {\r
                                try {\r
                                        o.setValue(getParamValue(param));\r
                                } catch (WrongParameterException e) {\r
-                                       System.out\r
-                                                       .println("Problem setting value for the parameter: "\r
-                                                                       + param);\r
+                                       System.out.println("Problem setting value for the parameter: " + param);\r
                                        e.printStackTrace();\r
                                }\r
                        }\r