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.analysis.SeqsetUtils.SequenceInfo;
24 import jalview.ws.params.ArgumentI;
25 import jalview.ws.params.WsParamSetI;
27 import java.util.Hashtable;
28 import java.util.List;
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.
36 public abstract class AWsJob
38 protected int jobnum = 0;
40 protected String jobId;
46 public void setJobId(String jobId)
52 * has job been cancelled
54 protected boolean cancelled = false;
57 * number of exceptions left before job dies
59 int allowedServerExceptions = 3;
62 * @param allowedServerExceptions
63 * the allowedServerExceptions to set
65 public void setAllowedServerExceptions(int allowedServerExceptions)
67 this.allowedServerExceptions = allowedServerExceptions;
71 * has job been submitted to server ? if false, then no state info is
74 protected boolean submitted = false;
80 public void setJobnum(int jobnum)
87 * the submitted to set
89 public void setSubmitted(boolean submitted)
91 this.submitted = submitted;
95 * @param subjobComplete
96 * the subjobComplete to set
98 public void setSubjobComplete(boolean subjobComplete)
100 this.subjobComplete = subjobComplete;
106 public int getJobnum()
114 public String getJobId()
120 * @return the cancelled
122 public boolean isCancelled()
128 * @return the allowedServerExceptions
130 public int getAllowedServerExceptions()
132 return allowedServerExceptions;
136 * @return the submitted
138 public boolean isSubmitted()
144 * @return the subjobComplete
146 public boolean isSubjobComplete()
148 return subjobComplete;
152 * are all sub-jobs complete
154 protected boolean subjobComplete = false;
156 protected WsParamSetI preset = null;
158 protected List<ArgumentI> arguments = null;
160 protected Hashtable<String, SequenceInfo> SeqNames = new Hashtable();
168 * @return true if job has completed and valid results are available
170 abstract public boolean hasResults();
174 * @return boolean true if job can be submitted.
176 public abstract boolean hasValidInput();
180 * @return true if job is running
182 abstract public boolean isRunning();
186 * @return true if job is queued
188 abstract public boolean isQueued();
192 * @return true if job has finished
194 abstract public boolean isFinished();
198 * @return true if the job failed due to some problem with the input data or
201 abstract public boolean isFailed();
205 * @return true if job failed due to an unhandled technical issue
207 abstract public boolean isBroken();
211 * @return true if there was a problem contacting the server.
213 abstract public boolean isServerError();
217 * @return true if the job has status text.
219 abstract public boolean hasStatus();
223 * @return status text for job to be displayed to user.
225 abstract public String getStatus();
227 abstract public boolean hasResponse();
229 abstract public void clearResponse();
231 abstract public String getState();
234 * generates response using the abstract service flags.
236 * @return a standard state response
238 protected String _defaultState()
245 public void setPreset(WsParamSetI jobpreset)
250 public void setArguments(List<ArgumentI> paramset)
252 arguments = paramset;
256 public boolean isPresetJob()
258 return preset!=null && arguments==null;
261 public List<ArgumentI> getArguments()
266 public WsParamSetI getPreset()
274 * update the record of the last position in the log file read for this job
278 public void setnextChunk(long nextChunk)
280 this.nextChunk = nextChunk;
283 public long getNextChunk()