X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fws%2Fjws2%2FJabaParamStore.java;h=be18b5113633a70e49ec75bfb2d346bd8f8e5838;hb=b62d7ddaf034d0bb6b4c347aedd582f69d1119cc;hp=bdea5be032376b109c4eb620ca2faf7ca1342532;hpb=c13784724ba3826e6cc3faeb85571cf30776592d;p=jalview.git
diff --git a/src/jalview/ws/jws2/JabaParamStore.java b/src/jalview/ws/jws2/JabaParamStore.java
index bdea5be..be18b51 100644
--- a/src/jalview/ws/jws2/JabaParamStore.java
+++ b/src/jalview/ws/jws2/JabaParamStore.java
@@ -1,14 +1,33 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.ws.jws2;
-import java.io.BufferedReader;
import java.io.IOException;
-import java.io.Reader;
-import java.io.Writer;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Hashtable;
import java.util.List;
import java.util.StringTokenizer;
+import org.jmol.util.ArrayUtil;
import compbio.metadata.Argument;
import compbio.metadata.Option;
import compbio.metadata.Parameter;
@@ -16,10 +35,11 @@ import compbio.metadata.Preset;
import compbio.metadata.PresetManager;
import compbio.metadata.RunnerConfig;
-import jalview.ws.jws2.Jws2Discoverer.Jws2Instance;
+import jalview.util.MessageManager;
import jalview.ws.jws2.dm.JabaOption;
import jalview.ws.jws2.dm.JabaParameter;
import jalview.ws.jws2.dm.JabaWsParamSet;
+import jalview.ws.jws2.jabaws2.Jws2Instance;
import jalview.ws.params.ArgumentI;
import jalview.ws.params.ParamDatastoreI;
import jalview.ws.params.ParamManager;
@@ -123,24 +143,54 @@ public class JabaParamStore implements ParamDatastoreI
public static List getJwsArgsfromJaba(List jabargs)
{
+ return getJwsArgsfromJaba(jabargs, true);
+ }
+
+ public static List getJwsArgsfromJaba(List jabargs,
+ boolean sortByOpt)
+ {
List rgs = new ArrayList();
+ List rgnames = new ArrayList();
for (Object rg : jabargs)
{
- ArgumentI narg = (rg instanceof Parameter) ? new JabaParameter(
- (Parameter) rg) : (rg instanceof Option) ? new JabaOption(
- (Option) rg) : null;
+ ArgumentI narg = null;
+ String nargstring = null;
+ if (rg instanceof Parameter)
+ {
+ narg = new JabaParameter((Parameter) rg);
+ nargstring = narg.getName(); // just sort by name for this
+ }
+ else if (rg instanceof Option)
+ {
+ narg = new JabaOption((Option) rg);
+ nargstring = (String) ((Option) rg).getOptionNames().get(0);
+ }
if (narg == null)
{
- throw new Error(
- "Implementation Error: Cannot handle Jaba parameter object "
- + rg.getClass());
+ throw new Error(MessageManager.formatMessage("error.implementation_error_cannot_handle_jaba_param", new String[]{rg.getClass().toString()}));
}
else
{
rgs.add(narg);
+ rgnames.add(nargstring);
}
}
- return rgs;
+ if (!sortByOpt)
+ {
+ return rgs;
+ }
+ ArgumentI[] rgssort = rgs.toArray(new ArgumentI[rgs.size()]);
+ String[] rgssorton = rgnames.toArray(new String[rgs.size()]);
+ jalview.util.QuickSort.sort(rgssorton, rgssort);
+ ArgumentI tmp1;
+ int i = 0;
+ while (rgssort.length - i > i)
+ {
+ tmp1 = rgssort[rgssort.length - i - 1];
+ rgssort[rgssort.length - i - 1] = rgssort[i];
+ rgssort[i++] = tmp1;
+ }
+ return Arrays.asList(rgssort);
}
public static List getJabafromJwsArgs(List jwsargs)
@@ -152,9 +202,7 @@ public class JabaParamStore implements ParamDatastoreI
.getOption() : null;
if (narg == null)
{
- throw new Error(
- "Implementation Error: Cannot handle Jaba parameter object "
- + rg.getClass());
+ throw new Error(MessageManager.formatMessage("error.implementation_error_cannot_handle_jaba_param", new String[]{rg.getClass().toString()}));
}
else
{
@@ -192,8 +240,7 @@ public class JabaParamStore implements ParamDatastoreI
}
if (servicePresets.containsKey(name))
{
- throw new Error(
- "Implementation error: Attempt to delete a service preset!");
+ throw new Error(MessageManager.getString("error.implementation_error_attempt_to_delete_service_preset"));
}
}
@@ -219,9 +266,7 @@ public class JabaParamStore implements ParamDatastoreI
: getPreset(presetName));
if (jps == null)
{
- throw new Error("Implementation error: Can't locate either oldname ("
- + oldName + ") or presetName (" + presetName
- + "in the datastore!");
+ throw new Error(MessageManager.formatMessage("error.implementation_error_cannot_locate_oldname_presetname", new String[]{oldName,presetName}));
}
jps.setName(presetName);
jps.setDescription(text);
@@ -255,7 +300,8 @@ public class JabaParamStore implements ParamDatastoreI
boolean found = false;
for (String url : urls)
{
- if (service.getUri().equalsIgnoreCase(url))
+ if (service.getServiceTypeURI().equals(url)
+ || service.getUri().equalsIgnoreCase(url))
{
found = true;
break;
@@ -270,8 +316,7 @@ public class JabaParamStore implements ParamDatastoreI
{
if (!involves(urls))
{
- throw new IOException(
- "Implementation error: Cannot find service url in the given url set!");
+ throw new IOException(MessageManager.getString("error.implementation_error_cannot_find_service_url_in_given_set"));
}
JabaWsParamSet wsp = new JabaWsParamSet();
@@ -296,15 +341,11 @@ public class JabaParamStore implements ParamDatastoreI
{
if (!involves(pset.getApplicableUrls()))
{
- throw new IOException(
- "Implementation error: Cannot find service url in the given url set for this service parameter store ("
- + service.getUri() + ") !");
-
+ throw new IOException(MessageManager.formatMessage("error.implementation_error_cannot_find_service_url_in_given_set_param_store", new String[]{service.getUri()}));
}
if (!(pset instanceof JabaWsParamSet))
{
- throw new Error(
- "Implementation error: JabaWsParamSets can only be handled by JabaParamStore");
+ throw new Error(MessageManager.getString("error.implementation_error_jabaws_param_set_only_handled_by"));
}
StringBuffer rslt = new StringBuffer();