update author list in license for (JAL-826)
[jalview.git] / src / jalview / ws / jws2 / JWs2Job.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.jws2;
19
20 import compbio.metadata.JobStatus;
21
22 import jalview.ws.AWsJob;
23
24 /**
25  * job status processing for JWS2 jobs.
26  * 
27  * @author JimP
28  * 
29  */
30 public abstract class JWs2Job extends AWsJob
31 {
32   JobStatus status = null;
33
34   public void setjobStatus(JobStatus jobStatus)
35   {
36     status = jobStatus;
37     // update flags
38   }
39
40   /*
41    * (non-Javadoc)
42    * 
43    * @see jalview.ws.AWsJob#clearResponse()
44    */
45   @Override
46   public void clearResponse()
47   {
48     status = null;
49   }
50
51   /*
52    * (non-Javadoc)
53    * 
54    * @see jalview.ws.AWsJob#getState()
55    */
56   @Override
57   public String getState()
58   {
59     return status == null ? ("Unknown") : status.toString();
60   }
61
62   /*
63    * (non-Javadoc)
64    * 
65    * @see jalview.ws.AWsJob#hasResponse()
66    */
67   @Override
68   public boolean hasResponse()
69   {
70     // TODO Auto-generated method stub
71     return status != null;
72   }
73
74   /*
75    * StringBuffer statusBuffer = null; (non-Javadoc)
76    * 
77    * @see jalview.ws.AWsJob#getStatus()
78    * 
79    * @Override public String getStatus() { return statusBuffer.toString(); }
80    * (non-Javadoc)
81    * 
82    * @see jalview.ws.AWsJob#hasStatus()
83    * 
84    * @Override public boolean hasStatus() { return statusBuffer!=null; }
85    */
86
87   /*
88    * (non-Javadoc)
89    * 
90    * @see jalview.ws.AWsJob#isBroken()
91    */
92   @Override
93   public boolean isBroken()
94   {
95     return status == null ? false : status.equals(status.UNDEFINED);
96   }
97
98   /*
99    * (non-Javadoc)
100    * 
101    * @see jalview.ws.AWsJob#isFailed()
102    */
103   @Override
104   public boolean isFailed()
105   {
106     return status == null ? false : status.equals(status.FAILED);
107   }
108
109   /*
110    * (non-Javadoc)
111    * 
112    * @see jalview.ws.AWsJob#isFinished()
113    */
114   @Override
115   public boolean isFinished()
116   {
117     return status == null ? false : status.equals(status.FINISHED);
118   }
119
120   /*
121    * (non-Javadoc)
122    * 
123    * @see jalview.ws.AWsJob#isQueued()
124    */
125   @Override
126   public boolean isQueued()
127   {
128     return status == null ? false : status.equals(status.SUBMITTED)
129             || status.equals(status.PENDING);
130   }
131
132   /*
133    * (non-Javadoc)
134    * 
135    * @see jalview.ws.AWsJob#isRunning()
136    */
137   @Override
138   public boolean isRunning()
139   {
140     // TODO Auto-generated method stub
141     return status != null
142             && (status.equals(status.RUNNING) || status
143                     .equals(status.STARTED));
144   }
145
146   /*
147    * (non-Javadoc)
148    * 
149    * @see jalview.ws.AWsJob#isServerError()
150    */
151   @Override
152   public boolean isServerError()
153   {
154     // server errors are raised as exceptions on the service method calls.
155     return status == null ? false : false; // status.equals(status.FAILED);
156   }
157
158 }