update author list in license for (JAL-826)
[jalview.git] / src / jalview / ws / AWsJob.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3  * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle
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 of the License, or (at your option) any later version.
10  * 
11  * Jalview is distributed in the hope that it will be useful, but 
12  * WITHOUT ANY WARRANTY; without even the implied warranty 
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14  * PURPOSE.  See the GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 package jalview.ws;
19
20 /**
21  * Generic properties for an individual job within a Web Service Client thread.
22  * Derived from jalview web services version 1 statuses, and revised for Jws2.
23  */
24
25 public abstract class AWsJob
26 {
27   protected int jobnum = 0;
28
29   protected String jobId;
30
31   /**
32    * @param jobId
33    *          the jobId to set
34    */
35   public void setJobId(String jobId)
36   {
37     this.jobId = jobId;
38   }
39
40   /**
41    * has job been cancelled
42    */
43   protected boolean cancelled = false;
44
45   /**
46    * number of exceptions left before job dies
47    */
48   int allowedServerExceptions = 3;
49
50   /**
51    * @param allowedServerExceptions
52    *          the allowedServerExceptions to set
53    */
54   public void setAllowedServerExceptions(int allowedServerExceptions)
55   {
56     this.allowedServerExceptions = allowedServerExceptions;
57   }
58
59   /**
60    * has job been submitted to server ? if false, then no state info is
61    * available.
62    */
63   protected boolean submitted = false;
64
65   /**
66    * @param jobnum
67    *          the jobnum to set
68    */
69   public void setJobnum(int jobnum)
70   {
71     this.jobnum = jobnum;
72   }
73
74   /**
75    * @param submitted
76    *          the submitted to set
77    */
78   public void setSubmitted(boolean submitted)
79   {
80     this.submitted = submitted;
81   }
82
83   /**
84    * @param subjobComplete
85    *          the subjobComplete to set
86    */
87   public void setSubjobComplete(boolean subjobComplete)
88   {
89     this.subjobComplete = subjobComplete;
90   }
91
92   /**
93    * @return the jobnum
94    */
95   public int getJobnum()
96   {
97     return jobnum;
98   }
99
100   /**
101    * @return the jobId
102    */
103   public String getJobId()
104   {
105     return jobId;
106   }
107
108   /**
109    * @return the cancelled
110    */
111   public boolean isCancelled()
112   {
113     return cancelled;
114   }
115
116   /**
117    * @return the allowedServerExceptions
118    */
119   public int getAllowedServerExceptions()
120   {
121     return allowedServerExceptions;
122   }
123
124   /**
125    * @return the submitted
126    */
127   public boolean isSubmitted()
128   {
129     return submitted;
130   }
131
132   /**
133    * @return the subjobComplete
134    */
135   public boolean isSubjobComplete()
136   {
137     return subjobComplete;
138   }
139
140   /**
141    * are all sub-jobs complete
142    */
143   protected boolean subjobComplete = false;
144
145   public AWsJob()
146   {
147   }
148
149   /**
150    * 
151    * @return true if job has completed and valid results are available
152    */
153   abstract public boolean hasResults();
154
155   /**
156    * 
157    * @return boolean true if job can be submitted.
158    */
159   public abstract boolean hasValidInput();
160
161   /**
162    * 
163    * @return true if job is running
164    */
165   abstract public boolean isRunning();
166
167   /**
168    * 
169    * @return true if job is queued
170    */
171   abstract public boolean isQueued();
172
173   /**
174    * 
175    * @return true if job has finished
176    */
177   abstract public boolean isFinished();
178
179   /**
180    * 
181    * @return true if the job failed due to some problem with the input data or
182    *         parameters.
183    */
184   abstract public boolean isFailed();
185
186   /**
187    * 
188    * @return true if job failed due to an unhandled technical issue
189    */
190   abstract public boolean isBroken();
191
192   /**
193    * 
194    * @return true if there was a problem contacting the server.
195    */
196   abstract public boolean isServerError();
197
198   /**
199    * 
200    * @return true if the job has status text.
201    */
202   abstract public boolean hasStatus();
203
204   /**
205    * 
206    * @return status text for job to be displayed to user.
207    */
208   abstract public String getStatus();
209
210   abstract public boolean hasResponse();
211
212   abstract public void clearResponse();
213
214   abstract public String getState();
215
216   /**
217    * generates response using the abstract service flags.
218    * 
219    * @return a standard state response
220    */
221   protected String _defaultState()
222   {
223
224     String state = "";
225     return state;
226   }
227 }