Clover icon

Coverage Report

  1. Project Clover database Thu Dec 4 2025 14:43:25 GMT
  2. Package jalview.ws

File WSClient.java

 

Coverage histogram

../../img/srcFileCovDistChart3.png
52% of files have more coverage

Code metrics

16
29
6
1
204
105
16
0.55
4.83
6
2.67

Classes

Class Line # Actions
WSClient 39 29 16
0.2352941223.5%
 

Contributing tests

This file is covered by 320 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
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.
11    *
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.
16    *
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.
20    */
21    package jalview.ws;
22   
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;
34   
35    import java.util.List;
36    import java.util.concurrent.CompletableFuture;
37    import java.util.concurrent.CompletionStage;
38   
 
39    public abstract class WSClient // implements WSMenuEntryProviderI
40    {
41    /**
42    * WSClient holds the basic attributes that are displayed to the user for all
43    * jalview web service clients
44    */
45    /**
46    * displayed name for this web service
47    */
48    protected String WebServiceName;
49   
50    /**
51    * specific job title (e.g. 'ClustalW Alignment of Selection from Aligment
52    * from Cut and Paste input')
53    */
54    protected String WebServiceJobTitle;
55   
56    /**
57    * String giving additional information such as method citations for this
58    * service
59    */
60    protected String WebServiceReference;
61   
62    /**
63    * Service endpoint
64    */
65    protected String WsURL;
66   
67    /**
68    * Web service information used to initialise the WSClient attributes
69    */
70    protected WebserviceInfo wsInfo;
71   
72    /**
73    * the root object for the service client
74    */
75    protected UIinfo serviceHandle;
76   
77    /**
78    * total number of jobs managed by this web service client instance.
79    */
80    int jobsRunning = 0;
81   
82    /**
83    * TODO: this is really service metadata, and should be moved elsewhere.
84    * mappings between abstract interface names and menu entries
85    */
86    protected java.util.Hashtable ServiceActions;
87   
88    /**
89    * alignFrame associated with this client
90    */
91    protected AlignFrame alignFrame;
 
92  26452 toggle {
93  26452 ServiceActions = new java.util.Hashtable();
94  26452 ServiceActions.put("MsaWS", "Multiple Sequence Alignment");
95  26452 ServiceActions.put("SecStrPred", "Secondary Structure Prediction");
96    };
97   
98    /**
99    * The preset for the job executed by this client (may be null)
100    */
101    protected WsParamSetI preset;
102   
103    /**
104    * The parameters for the job executed by this client (may be null)
105    */
106    protected List<ArgumentI> paramset;
107   
 
108  26452 toggle public WSClient()
109    {
110    }
111   
112    /**
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.
116    *
117    * @param _alignFrame
118    * @param preset
119    * @param arguments
120    */
 
121  0 toggle public WSClient(AlignFrame _alignFrame, WsParamSetI preset,
122    List<ArgumentI> arguments)
123    {
124  0 alignFrame = _alignFrame;
125  0 this.preset = preset;
126  0 this.paramset = arguments;
127    }
128   
 
129  12578 toggle protected WebserviceInfo setWebService(UIinfo serv, boolean b)
130    {
131  12578 WebServiceName = serv.getName();
132  12578 WebServiceJobTitle = serv.getActionText();
133  12578 WsURL = serv.getHostURL();
134  12578 if (!b)
135    {
136  0 return new WebserviceInfo(WebServiceJobTitle,
137    WebServiceJobTitle + " using service hosted at "
138    + WsURL + "\n"
139  0 + (serv.getDescription() != null
140    ? serv.getDescription()
141    : ""),
142    false);
143    }
144  12578 return null;
145    }
146   
147    /**
148    * called to open a parameter editing dialog for parameterised services
149    *
150    * @param sh
151    * @param editParams
152    * @return
153    */
 
154  0 toggle protected CompletionStage<Boolean> processParams(ServiceWithParameters sh,
155    boolean editParams)
156    {
157  0 return processParams(sh, editParams, false);
158    }
159   
 
160  0 toggle protected CompletionStage<Boolean> processParams(ServiceWithParameters sh,
161    boolean editParams, boolean adjustingExisting)
162    {
163   
164  0 if (editParams)
165    {
166    // always do this
167  0 sh.initParamStore(Desktop.getUserParameterStore());
168   
169  0 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  0 if (adjustingExisting)
176    {
177  0 jobParams.setName(MessageManager
178    .getString("label.adjusting_parameters_for_calculation"));
179    }
180  0 var stage = jobParams.showRunDialog();
181  0 return stage.thenApply((startJob) -> {
182  0 if (startJob)
183    {
184  0 WsParamSetI prset = jobParams.getPreset();
185  0 if (prset == null)
186    {
187  0 paramset = jobParams.isServiceDefaults() ? null
188    : jobParams.getJobParams();
189  0 this.preset = null;
190    }
191    else
192    {
193  0 this.preset = prset; // ((JabaPreset) prset).p;
194  0 paramset = null; // no user supplied parameters.
195    }
196    }
197  0 return startJob;
198    });
199   
200    }
201  0 return CompletableFuture.completedFuture(true);
202    }
203   
204    }