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.ws.params.ArgumentI;
24 import jalview.ws.params.WsParamSetI;
26 import java.util.Hashtable;
27 import java.util.List;
31 * Generic properties for an individual job within a Web Service Client thread.
32 * Derived from jalview web services version 1 statuses, and revised for Jws2.
35 public abstract class AWsJob
37 protected int jobnum = 0;
39 protected String jobId;
45 public void setJobId(String jobId)
51 * has job been cancelled
53 protected boolean cancelled = false;
56 * number of exceptions left before job dies
58 int allowedServerExceptions = 3;
61 * @param allowedServerExceptions
62 * the allowedServerExceptions to set
64 public void setAllowedServerExceptions(int allowedServerExceptions)
66 this.allowedServerExceptions = allowedServerExceptions;
70 * has job been submitted to server ? if false, then no state info is
73 protected boolean submitted = false;
79 public void setJobnum(int jobnum)
86 * the submitted to set
88 public void setSubmitted(boolean submitted)
90 this.submitted = submitted;
94 * @param subjobComplete
95 * the subjobComplete to set
97 public void setSubjobComplete(boolean subjobComplete)
99 this.subjobComplete = subjobComplete;
105 public int getJobnum()
113 public String getJobId()
119 * @return the cancelled
121 public boolean isCancelled()
127 * @return the allowedServerExceptions
129 public int getAllowedServerExceptions()
131 return allowedServerExceptions;
135 * @return the submitted
137 public boolean isSubmitted()
143 * @return the subjobComplete
145 public boolean isSubjobComplete()
147 return subjobComplete;
151 * are all sub-jobs complete
153 protected boolean subjobComplete = false;
155 protected WsParamSetI preset = null;
157 protected List<ArgumentI> arguments = null;
159 protected Hashtable<String, Map> SeqNames = new Hashtable();
167 * @return true if job has completed and valid results are available
169 abstract public boolean hasResults();
173 * @return boolean true if job can be submitted.
175 public abstract boolean hasValidInput();
179 * @return true if job is running
181 abstract public boolean isRunning();
185 * @return true if job is queued
187 abstract public boolean isQueued();
191 * @return true if job has finished
193 abstract public boolean isFinished();
197 * @return true if the job failed due to some problem with the input data or
200 abstract public boolean isFailed();
204 * @return true if job failed due to an unhandled technical issue
206 abstract public boolean isBroken();
210 * @return true if there was a problem contacting the server.
212 abstract public boolean isServerError();
216 * @return true if the job has status text.
218 abstract public boolean hasStatus();
222 * @return status text for job to be displayed to user.
224 abstract public String getStatus();
226 abstract public boolean hasResponse();
228 abstract public void clearResponse();
230 abstract public String getState();
233 * generates response using the abstract service flags.
235 * @return a standard state response
237 protected String _defaultState()
244 public void setPreset(WsParamSetI jobpreset)
249 public void setArguments(List<ArgumentI> paramset)
251 arguments = paramset;
255 public boolean isPresetJob()
257 return preset!=null && arguments==null;
260 public List<ArgumentI> getArguments()
265 public WsParamSetI getPreset()
273 * update the record of the last position in the log file read for this job
277 public void setnextChunk(long nextChunk)
279 this.nextChunk = nextChunk;
282 public long getNextChunk()