X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fjws2%2FJabaParamStore.java;h=929c5e2bacf302c85bc58ca6edab1985b8eb8f5a;hb=4898f0ae429e0c61ddba72ca46be89b34bb4df8b;hp=baa1d9d9c5e4ba428963ddb2dea21d12205b8de6;hpb=f59ae49cdd2bb8f6721424ea6ce167e8245e7d15;p=jalview.git diff --git a/src/jalview/ws/jws2/JabaParamStore.java b/src/jalview/ws/jws2/JabaParamStore.java index baa1d9d..929c5e2 100644 --- a/src/jalview/ws/jws2/JabaParamStore.java +++ b/src/jalview/ws/jws2/JabaParamStore.java @@ -20,6 +20,16 @@ */ package jalview.ws.jws2; +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; +import jalview.ws.params.WsParamSetI; + import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -34,20 +44,10 @@ import compbio.metadata.Preset; import compbio.metadata.PresetManager; import compbio.metadata.RunnerConfig; -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; -import jalview.ws.params.WsParamSetI; - public class JabaParamStore implements ParamDatastoreI { - Hashtable editedParams = new Hashtable(); + Hashtable editedParams = new Hashtable<>(); private Jws2Instance service; @@ -84,8 +84,8 @@ public class JabaParamStore implements ParamDatastoreI } else { - System.err - .println("Warning: Ignoring parameter set instance of type " + System.err.println( + "Warning: Ignoring parameter set instance of type " + paramset.getClass() + " : Bound but not applicable for service at " + service.getUri()); @@ -98,10 +98,10 @@ public class JabaParamStore implements ParamDatastoreI @Override public List getPresets() { - List prefs = new ArrayList(); + List prefs = new ArrayList<>(); if (servicePresets == null) { - servicePresets = new Hashtable(); + servicePresets = new Hashtable<>(); PresetManager prman; if ((prman = service.getPresets()) != null) { @@ -148,8 +148,8 @@ public class JabaParamStore implements ParamDatastoreI public static List getJwsArgsfromJaba(List jabargs, boolean sortByOpt) { - List rgs = new ArrayList(); - List rgnames = new ArrayList(); + List rgs = new ArrayList<>(); + List rgnames = new ArrayList<>(); for (Object rg : jabargs) { ArgumentI narg = null; @@ -166,7 +166,10 @@ public class JabaParamStore implements ParamDatastoreI } if (narg == null) { - throw new Error(MessageManager.formatMessage("error.implementation_error_cannot_handle_jaba_param", new String[]{rg.getClass().toString()})); + throw new Error(MessageManager.formatMessage( + "error.implementation_error_cannot_handle_jaba_param", + new String[] + { rg.getClass().toString() })); } else { @@ -197,11 +200,15 @@ public class JabaParamStore implements ParamDatastoreI List rgs = new ArrayList(); for (ArgumentI rg : jwsargs) { - Argument narg = (rg instanceof JabaOption) ? ((JabaOption) rg) - .getOption() : null; + Argument narg = (rg instanceof JabaOption) + ? ((JabaOption) rg).getOption() + : null; if (narg == null) { - throw new Error(MessageManager.formatMessage("error.implementation_error_cannot_handle_jaba_param", new String[]{rg.getClass().toString()})); + throw new Error(MessageManager.formatMessage( + "error.implementation_error_cannot_handle_jaba_param", + new String[] + { rg.getClass().toString() })); } else { @@ -220,8 +227,8 @@ public class JabaParamStore implements ParamDatastoreI @Override public boolean presetExists(String name) { - return (editedParams.containsKey(name) || servicePresets - .containsKey(name)); + return (editedParams.containsKey(name) + || servicePresets.containsKey(name)); } @Override @@ -239,7 +246,8 @@ public class JabaParamStore implements ParamDatastoreI } if (servicePresets.containsKey(name)) { - throw new Error(MessageManager.getString("error.implementation_error_attempt_to_delete_service_preset")); + throw new Error(MessageManager.getString( + "error.implementation_error_attempt_to_delete_service_preset")); } } @@ -248,8 +256,7 @@ public class JabaParamStore implements ParamDatastoreI List jobParams) { JabaWsParamSet jps = new JabaWsParamSet(presetName, text, jobParams); - jps.setApplicableUrls(new String[] - { service.getUri() }); + jps.setApplicableUrls(new String[] { service.getUri() }); editedParams.put(jps.getName(), jps); if (manager != null) { @@ -261,17 +268,20 @@ public class JabaParamStore implements ParamDatastoreI public void updatePreset(String oldName, String presetName, String text, List jobParams) { - JabaWsParamSet jps = (JabaWsParamSet) ((oldName != null) ? getPreset(oldName) + JabaWsParamSet jps = (JabaWsParamSet) ((oldName != null) + ? getPreset(oldName) : getPreset(presetName)); if (jps == null) { - throw new Error(MessageManager.formatMessage("error.implementation_error_cannot_locate_oldname_presetname", new String[]{oldName,presetName})); + throw new Error(MessageManager.formatMessage( + "error.implementation_error_cannot_locate_oldname_presetname", + new String[] + { oldName, presetName })); } jps.setName(presetName); jps.setDescription(text); jps.setArguments(jobParams); - jps.setApplicableUrls(new String[] - { service.getUri() }); + jps.setApplicableUrls(new String[] { service.getUri() }); if (oldName != null && !oldName.equals(jps.getName())) { editedParams.remove(oldName); @@ -299,7 +309,7 @@ public class JabaParamStore implements ParamDatastoreI boolean found = false; for (String url : urls) { - if (service.getServiceTypeURI().equals(url) + if (service.getNameURI().equals(url) || service.getUri().equalsIgnoreCase(url)) { found = true; @@ -315,7 +325,8 @@ public class JabaParamStore implements ParamDatastoreI { if (!involves(urls)) { - throw new IOException(MessageManager.getString("error.implementation_error_cannot_find_service_url_in_given_set")); + throw new IOException(MessageManager.getString( + "error.implementation_error_cannot_find_service_url_in_given_set")); } JabaWsParamSet wsp = new JabaWsParamSet(); @@ -323,14 +334,14 @@ public class JabaParamStore implements ParamDatastoreI wsp.setDescription(descr); wsp.setApplicableUrls(urls.clone()); - List lines = new ArrayList(); + List lines = new ArrayList<>(); StringTokenizer st = new StringTokenizer(parameterfile, "\n"); while (st.hasMoreTokens()) { lines.add(st.nextToken()); } - wsp.setjabaArguments(ParameterUtils.processParameters(lines, - serviceOptions, " ")); + wsp.setjabaArguments( + ParameterUtils.processParameters(lines, serviceOptions, " ")); return wsp; } @@ -340,11 +351,15 @@ public class JabaParamStore implements ParamDatastoreI { if (!involves(pset.getApplicableUrls())) { - throw new IOException(MessageManager.formatMessage("error.implementation_error_cannot_find_service_url_in_given_set_param_store", new String[]{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(MessageManager.getString("error.implementation_error_jabaws_param_set_only_handled_by")); + throw new Error(MessageManager.getString( + "error.implementation_error_jabaws_param_set_only_handled_by")); } StringBuffer rslt = new StringBuffer();