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