2f036bfc48591a3b624cc3dee6c8579bef9f8a3c
[jalview.git] / src / jalview / ws / AWsJob.java
1 package jalview.ws;
2
3 /**
4  * Generic properties for an individual job within a Web Service Client thread.
5  * Derived from jalview web services version 1 statuses, and revised for Jws2.
6  */
7
8 public abstract class AWsJob
9 {
10   protected int jobnum = 0;
11
12   protected String jobId;
13
14   /**
15    * @param jobId the jobId to set
16    */
17   public void setJobId(String jobId)
18   {
19     this.jobId = jobId;
20   }
21
22   /**
23    * has job been cancelled
24    */
25   protected boolean cancelled = false;
26
27   /**
28    * number of exceptions left before job dies
29    */
30   int allowedServerExceptions = 3;
31
32   /**
33    * @param allowedServerExceptions the allowedServerExceptions to set
34    */
35   public void setAllowedServerExceptions(int allowedServerExceptions)
36   {
37     this.allowedServerExceptions = allowedServerExceptions;
38   }
39
40   /**
41    * has job been submitted to server ? if false, then no state info is
42    * available.
43    */
44   protected boolean submitted = false;
45
46   /**
47    * @param jobnum the jobnum to set
48    */
49   public void setJobnum(int jobnum)
50   {
51     this.jobnum = jobnum;
52   }
53
54   /**
55    * @param submitted the submitted to set
56    */
57   public void setSubmitted(boolean submitted)
58   {
59     this.submitted = submitted;
60   }
61
62   /**
63    * @param subjobComplete the subjobComplete to set
64    */
65   public void setSubjobComplete(boolean subjobComplete)
66   {
67     this.subjobComplete = subjobComplete;
68   }
69
70   /**
71    * @return the jobnum
72    */
73   public int getJobnum()
74   {
75     return jobnum;
76   }
77
78   /**
79    * @return the jobId
80    */
81   public String getJobId()
82   {
83     return jobId;
84   }
85
86   /**
87    * @return the cancelled
88    */
89   public boolean isCancelled()
90   {
91     return cancelled;
92   }
93
94   /**
95    * @return the allowedServerExceptions
96    */
97   public int getAllowedServerExceptions()
98   {
99     return allowedServerExceptions;
100   }
101
102   /**
103    * @return the submitted
104    */
105   public boolean isSubmitted()
106   {
107     return submitted;
108   }
109
110   /**
111    * @return the subjobComplete
112    */
113   public boolean isSubjobComplete()
114   {
115     return subjobComplete;
116   }
117
118   /**
119    * are all sub-jobs complete
120    */
121   protected boolean subjobComplete = false;
122
123   public AWsJob()
124   {
125   }
126
127   /**
128    * 
129    * @return true if job has completed and valid results are available
130    */
131   abstract public boolean hasResults();
132
133   /**
134    * 
135    * @return boolean true if job can be submitted.
136    */
137   public abstract boolean hasValidInput();
138
139   /**
140    * 
141    * @return true if job is running
142    */
143   abstract public boolean isRunning();
144
145   /**
146    * 
147    * @return true if job is queued
148    */
149   abstract public boolean isQueued();
150
151   /**
152    * 
153    * @return true if job has finished
154    */
155   abstract public boolean isFinished();
156
157   /**
158    * 
159    * @return true if the job failed due to some problem with the input data or
160    *         parameters.
161    */
162   abstract public boolean isFailed();
163
164   /**
165    * 
166    * @return true if job failed due to an unhandled technical issue
167    */
168   abstract public boolean isBroken();
169
170   /**
171    * 
172    * @return true if there was a problem contacting the server.
173    */
174   abstract public boolean isServerError();
175
176   /**
177    * 
178    * @return true if the job has status text.
179    */
180   abstract public boolean hasStatus();
181
182   /**
183    * 
184    * @return status text for job to be displayed to user.
185    */
186   abstract public String getStatus();
187
188   abstract public boolean hasResponse();
189   abstract public void clearResponse();
190   abstract public String getState();
191   /**
192    * generates response using the abstract service flags.
193    * @return a standard state response 
194    */
195   protected String _defaultState() {
196     
197     String state = "";
198     return state;
199   }
200 }