Jalview 2.6 source licence
[jalview.git] / src / jalview / ws / jws2 / JWs2Job.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
3  * Copyright (C) 2010 J Procter, AM Waterhouse, 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  * @author JimP
27  *
28  */
29 public abstract class JWs2Job extends AWsJob
30 {
31   JobStatus status=null;
32   public void setjobStatus(JobStatus jobStatus)
33   {
34     status = jobStatus;
35     // update flags
36   }
37
38   /* (non-Javadoc)
39    * @see jalview.ws.AWsJob#clearResponse()
40    */
41   @Override
42   public void clearResponse()
43   {
44     status = null;
45   }
46
47   /* (non-Javadoc)
48    * @see jalview.ws.AWsJob#getState()
49    */
50   @Override
51   public String getState()
52   {
53     return status==null ? ("Unknown") : status.toString();
54   }
55   /* (non-Javadoc)
56    * @see jalview.ws.AWsJob#hasResponse()
57    */
58   @Override
59   public boolean hasResponse()
60   {
61     // TODO Auto-generated method stub
62     return status!=null;
63   }
64   /*
65   StringBuffer statusBuffer = null;
66   * (non-Javadoc)
67   * @see jalview.ws.AWsJob#getStatus()
68    *
69   @Override
70   public String getStatus()
71   {
72     return statusBuffer.toString();
73   }
74   * (non-Javadoc)
75    * @see jalview.ws.AWsJob#hasStatus()
76    *
77   @Override
78   public boolean hasStatus()
79   {
80     return statusBuffer!=null;
81   }
82 */
83
84   /* (non-Javadoc)
85    * @see jalview.ws.AWsJob#isBroken()
86    */
87   @Override
88   public boolean isBroken()
89   {
90     return status==null ? false : status.equals(status.UNDEFINED);
91   }
92
93   /* (non-Javadoc)
94    * @see jalview.ws.AWsJob#isFailed()
95    */
96   @Override
97   public boolean isFailed()
98   {
99     return status==null ? false : status.equals(status.FAILED);
100   }
101
102   /* (non-Javadoc)
103    * @see jalview.ws.AWsJob#isFinished()
104    */
105   @Override
106   public boolean isFinished()
107   {
108     return status==null ? false : status.equals(status.FINISHED);
109   }
110
111   /* (non-Javadoc)
112    * @see jalview.ws.AWsJob#isQueued()
113    */
114   @Override
115   public boolean isQueued()
116   {
117     return status==null ? false : status.equals(status.SUBMITTED) || status.equals(status.PENDING);
118   }
119
120   /* (non-Javadoc)
121    * @see jalview.ws.AWsJob#isRunning()
122    */
123   @Override
124   public boolean isRunning()
125   {
126     // TODO Auto-generated method stub
127     return status!=null && (status.equals(status.RUNNING) || status.equals(status.STARTED));
128   }
129
130   /* (non-Javadoc)
131    * @see jalview.ws.AWsJob#isServerError()
132    */
133   @Override
134   public boolean isServerError()
135   {
136     // server errors are raised as exceptions on the service method calls.  
137     return status==null ? false : false; // status.equals(status.FAILED);
138   }
139
140 }