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.bin.Cache;
24 import jalview.gui.AlignFrame;
25 import jalview.gui.Desktop;
26 import jalview.gui.WebserviceInfo;
27 import jalview.gui.WsJobParameters;
28 import jalview.util.MessageManager;
29 import jalview.ws.api.ServiceWithParameters;
30 import jalview.ws.api.UIinfo;
31 import jalview.ws.params.ArgumentI;
32 import jalview.ws.params.ParamDatastoreI;
33 import jalview.ws.params.WsParamSetI;
35 import java.util.List;
36 import java.util.concurrent.CompletableFuture;
37 import java.util.concurrent.CompletionStage;
39 public abstract class WSClient // implements WSMenuEntryProviderI
42 * WSClient holds the basic attributes that are displayed to the user for all
43 * jalview web service clients
46 * displayed name for this web service
48 protected String WebServiceName;
51 * specific job title (e.g. 'ClustalW Alignment of Selection from Aligment
52 * from Cut and Paste input')
54 protected String WebServiceJobTitle;
57 * String giving additional information such as method citations for this
60 protected String WebServiceReference;
65 protected String WsURL;
68 * Web service information used to initialise the WSClient attributes
70 protected WebserviceInfo wsInfo;
73 * the root object for the service client
75 protected UIinfo serviceHandle;
78 * total number of jobs managed by this web service client instance.
83 * TODO: this is really service metadata, and should be moved elsewhere.
84 * mappings between abstract interface names and menu entries
86 protected java.util.Hashtable ServiceActions;
89 * alignFrame associated with this client
91 protected AlignFrame alignFrame;
93 ServiceActions = new java.util.Hashtable();
94 ServiceActions.put("MsaWS", "Multiple Sequence Alignment");
95 ServiceActions.put("SecStrPred", "Secondary Structure Prediction");
99 * The preset for the job executed by this client (may be null)
101 protected WsParamSetI preset;
104 * The parameters for the job executed by this client (may be null)
106 protected List<ArgumentI> paramset;
113 * base constructor for a web service with parameters. Extending classes
114 * should implement this constructor with additional logic to verify that
115 * preset and arguments are compatible with the service being configured.
121 public WSClient(AlignFrame _alignFrame, WsParamSetI preset,
122 List<ArgumentI> arguments)
124 alignFrame = _alignFrame;
125 this.preset = preset;
126 this.paramset = arguments;
129 protected WebserviceInfo setWebService(UIinfo serv, boolean b)
131 WebServiceName = serv.getName();
132 WebServiceJobTitle = serv.getActionText();
133 WsURL = serv.getHostURL();
136 return new WebserviceInfo(WebServiceJobTitle,
137 WebServiceJobTitle + " using service hosted at "
139 + (serv.getDescription() != null
140 ? serv.getDescription()
148 * called to open a parameter editing dialog for parameterised services
154 protected CompletionStage<Boolean> processParams(ServiceWithParameters sh,
157 return processParams(sh, editParams, false);
160 protected CompletionStage<Boolean> processParams(ServiceWithParameters sh,
161 boolean editParams, boolean adjustingExisting)
167 sh.initParamStore(Desktop.getUserParameterStore());
169 WsJobParameters jobParams = (preset == null && paramset != null
170 && paramset.size() > 0)
171 ? new WsJobParameters((ParamDatastoreI) null, sh,
172 (WsParamSetI) null, paramset)
173 : new WsJobParameters((ParamDatastoreI) null, sh,
174 preset, (List<ArgumentI>) null);
175 if (adjustingExisting)
177 jobParams.setName(MessageManager
178 .getString("label.adjusting_parameters_for_calculation"));
180 var stage = jobParams.showRunDialog();
181 return stage.thenApply((startJob) -> {
184 WsParamSetI prset = jobParams.getPreset();
187 paramset = jobParams.isServiceDefaults() ? null
188 : jobParams.getJobParams();
193 this.preset = prset; // ((JabaPreset) prset).p;
194 paramset = null; // no user supplied parameters.
201 return CompletableFuture.completedFuture(true);