2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.gui.AlignFrame;
24 import jalview.gui.Desktop;
25 import jalview.gui.WebserviceInfo;
26 import jalview.gui.WsJobParameters;
27 import jalview.util.MessageManager;
28 import jalview.ws.api.ServiceWithParameters;
29 import jalview.ws.api.UIinfo;
30 import jalview.ws.params.ArgumentI;
31 import jalview.ws.params.ParamDatastoreI;
32 import jalview.ws.params.WsParamSetI;
34 import java.util.List;
36 public abstract class WSClient // implements WSMenuEntryProviderI
39 * WSClient holds the basic attributes that are displayed to the user for all
40 * jalview web service clients
43 * displayed name for this web service
45 protected String WebServiceName;
48 * specific job title (e.g. 'ClustalW Alignment of Selection from Aligment
49 * from Cut and Paste input')
51 protected String WebServiceJobTitle;
54 * String giving additional information such as method citations for this
57 protected String WebServiceReference;
62 protected String WsURL;
65 * Web service information used to initialise the WSClient attributes
67 protected WebserviceInfo wsInfo;
70 * the root object for the service client
72 protected UIinfo serviceHandle;
75 * total number of jobs managed by this web service client instance.
80 * TODO: this is really service metadata, and should be moved elsewhere.
81 * mappings between abstract interface names and menu entries
83 protected java.util.Hashtable ServiceActions;
86 * alignFrame associated with this client
88 protected AlignFrame alignFrame;
90 ServiceActions = new java.util.Hashtable();
91 ServiceActions.put("MsaWS", "Multiple Sequence Alignment");
92 ServiceActions.put("SecStrPred", "Secondary Structure Prediction");
96 * The preset for the job executed by this client (may be null)
98 protected WsParamSetI preset;
101 * The parameters for the job executed by this client (may be null)
103 protected List<ArgumentI> paramset;
110 * base constructor for a web service with parameters. Extending classes
111 * should implement this constructor with additional logic to verify that
112 * preset and arguments are compatible with the service being configured.
118 public WSClient(AlignFrame _alignFrame, WsParamSetI preset,
119 List<ArgumentI> arguments)
121 alignFrame = _alignFrame;
122 this.preset = preset;
123 this.paramset = arguments;
126 protected WebserviceInfo setWebService(UIinfo serv, boolean b)
128 WebServiceName = serv.getName();
129 WebServiceJobTitle = serv.getActionText();
130 WsURL = serv.getHostURL();
133 return new WebserviceInfo(WebServiceJobTitle,
134 WebServiceJobTitle + " using service hosted at "
136 + (serv.getDescription() != null
137 ? serv.getDescription()
145 * called to open a parameter editing dialog for parameterised services
151 protected boolean processParams(ServiceWithParameters sh,
154 return processParams(sh, editParams, false);
157 protected boolean processParams(ServiceWithParameters sh,
159 boolean adjustingExisting)
165 sh.initParamStore(Desktop.getUserParameterStore());
167 WsJobParameters jobParams = (preset == null && paramset != null
168 && paramset.size() > 0)
169 ? new WsJobParameters((ParamDatastoreI) null, sh,
170 (WsParamSetI) null, paramset)
171 : new WsJobParameters((ParamDatastoreI) null, sh,
172 preset, (List<ArgumentI>) null);
173 if (adjustingExisting)
175 jobParams.setName(MessageManager
176 .getString("label.adjusting_parameters_for_calculation"));
178 if (!jobParams.showRunDialog())
180 return false; // dialog cancelled
183 WsParamSetI prset = jobParams.getPreset();
186 paramset = jobParams.isServiceDefaults() ? null
187 : jobParams.getJobParams();
192 this.preset = prset; // ((JabaPreset) prset).p;
193 paramset = null; // no user supplied parameters.