Clover icon

Coverage Report

  1. Project Clover database Thu Dec 4 2025 16:11:35 GMT
  2. Package jalview.ws

File AWsJob.java

 

Coverage histogram

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

Code metrics

0
20
20
1
287
113
20
1
1
20
1

Classes

Class Line # Actions
AWsJob 36 20 20
0.27527.5%
 

Contributing tests

This file is covered by 1 test. .

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.analysis.SeqsetUtils.SequenceInfo;
24    import jalview.ws.params.ArgumentI;
25    import jalview.ws.params.WsParamSetI;
26   
27    import java.util.Hashtable;
28    import java.util.List;
29    import java.util.Map;
30   
31    /**
32    * Generic properties for an individual job within a Web Service Client thread.
33    * Derived from jalview web services version 1 statuses, and revised for Jws2.
34    */
35   
 
36    public abstract class AWsJob
37    {
38    protected int jobnum = 0;
39   
40    protected String jobId;
41   
42    /**
43    * @param jobId
44    * the jobId to set
45    */
 
46  1 toggle public void setJobId(String jobId)
47    {
48  1 this.jobId = jobId;
49    }
50   
51    /**
52    * has job been cancelled
53    */
54    protected boolean cancelled = false;
55   
56    /**
57    * number of exceptions left before job dies
58    */
59    int allowedServerExceptions = 3;
60   
61    /**
62    * @param allowedServerExceptions
63    * the allowedServerExceptions to set
64    */
 
65  1 toggle public void setAllowedServerExceptions(int allowedServerExceptions)
66    {
67  1 this.allowedServerExceptions = allowedServerExceptions;
68    }
69   
70    /**
71    * has job been submitted to server ? if false, then no state info is
72    * available.
73    */
74    protected boolean submitted = false;
75   
76    /**
77    * @param jobnum
78    * the jobnum to set
79    */
 
80  0 toggle public void setJobnum(int jobnum)
81    {
82  0 this.jobnum = jobnum;
83    }
84   
85    /**
86    * @param submitted
87    * the submitted to set
88    */
 
89  1 toggle public void setSubmitted(boolean submitted)
90    {
91  1 this.submitted = submitted;
92    }
93   
94    /**
95    * @param subjobComplete
96    * the subjobComplete to set
97    */
 
98  1 toggle public void setSubjobComplete(boolean subjobComplete)
99    {
100  1 this.subjobComplete = subjobComplete;
101    }
102   
103    /**
104    * @return the jobnum
105    */
 
106  0 toggle public int getJobnum()
107    {
108  0 return jobnum;
109    }
110   
111    /**
112    * @return the jobId
113    */
 
114  0 toggle public String getJobId()
115    {
116  0 return jobId;
117    }
118   
119    /**
120    * @return the cancelled
121    */
 
122  0 toggle public boolean isCancelled()
123    {
124  0 return cancelled;
125    }
126   
127    /**
128    * @return the allowedServerExceptions
129    */
 
130  0 toggle public int getAllowedServerExceptions()
131    {
132  0 return allowedServerExceptions;
133    }
134   
135    /**
136    * @return the submitted
137    */
 
138  1 toggle public boolean isSubmitted()
139    {
140  1 return submitted;
141    }
142   
143    /**
144    * @return the subjobComplete
145    */
 
146  0 toggle public boolean isSubjobComplete()
147    {
148  0 return subjobComplete;
149    }
150   
151    /**
152    * are all sub-jobs complete
153    */
154    protected boolean subjobComplete = false;
155   
156    protected WsParamSetI preset = null;
157   
158    protected List<ArgumentI> arguments = null;
159   
160    protected Hashtable<String, SequenceInfo> SeqNames = new Hashtable();
161   
 
162  3 toggle public AWsJob()
163    {
164    }
165   
166    /**
167    *
168    * @return true if job has completed and valid results are available
169    */
170    abstract public boolean hasResults();
171   
172    /**
173    *
174    * @return boolean true if job can be submitted.
175    */
176    public abstract boolean hasValidInput();
177   
178    /**
179    *
180    * @return true if job is running
181    */
182    abstract public boolean isRunning();
183   
184    /**
185    *
186    * @return true if job is queued
187    */
188    abstract public boolean isQueued();
189   
190    /**
191    *
192    * @return true if job has finished
193    */
194    abstract public boolean isFinished();
195   
196    /**
197    *
198    * @return true if the job failed due to some problem with the input data or
199    * parameters.
200    */
201    abstract public boolean isFailed();
202   
203    /**
204    *
205    * @return true if job failed due to an unhandled technical issue
206    */
207    abstract public boolean isBroken();
208   
209    /**
210    *
211    * @return true if there was a problem contacting the server.
212    */
213    abstract public boolean isServerError();
214   
215    /**
216    *
217    * @return true if the job has status text.
218    */
219    abstract public boolean hasStatus();
220   
221    /**
222    *
223    * @return status text for job to be displayed to user.
224    */
225    abstract public String getStatus();
226   
227    abstract public boolean hasResponse();
228   
229    abstract public void clearResponse();
230   
231    abstract public String getState();
232   
233    /**
234    * generates response using the abstract service flags.
235    *
236    * @return a standard state response
237    */
 
238  0 toggle protected String _defaultState()
239    {
240   
241  0 String state = "";
242  0 return state;
243    }
244   
 
245  0 toggle public void setPreset(WsParamSetI jobpreset)
246    {
247  0 preset = jobpreset;
248    }
249   
 
250  0 toggle public void setArguments(List<ArgumentI> paramset)
251    {
252  0 arguments = paramset;
253   
254    }
255   
 
256  0 toggle public boolean isPresetJob()
257    {
258  0 return preset!=null && arguments==null;
259    }
260   
 
261  0 toggle public List<ArgumentI> getArguments()
262    {
263  0 return arguments;
264    }
265   
 
266  0 toggle public WsParamSetI getPreset()
267    {
268  0 return preset;
269    }
270   
271    long nextChunk = 0;
272   
273    /**
274    * update the record of the last position in the log file read for this job
275    *
276    * @param nextChunk
277    */
 
278  0 toggle public void setnextChunk(long nextChunk)
279    {
280  0 this.nextChunk = nextChunk;
281    }
282   
 
283  0 toggle public long getNextChunk()
284    {
285  0 return nextChunk;
286    }
287    }