JAL-3878 Refactoring SeqAnnotationServiceCalcWorker.
[jalview.git] / src / jalview / ws2 / WSJobStatus.java
1 package jalview.ws2;
2
3 public enum WSJobStatus
4 {
5   /** Job has invalid parameters and cannot be started. */
6   INVALID,
7   /** Job is ready to be submitted. */
8   READY,
9   /** Job has been submitted and awaits processing. */
10   SUBMITTED,
11   /** Job has been queued for execution. */
12   QUEUED,
13   /** Job is running. */
14   RUNNING,
15   /** Job has finished with no errors. */
16   FINISHED, BROKEN,
17   /** Job has finished with errors. */
18   FAILED,
19   /** Job cannot be processed or completed due to server error. */
20   SERVER_ERROR,
21   /** Job has been cancelled. */
22   CANCELLED,
23   /** Status cannot be determined. */
24   UNKNOWN;
25
26   public boolean isSubmitted()
27   {
28     switch (this)
29     {
30     case SUBMITTED:
31     case QUEUED:
32     case RUNNING:
33     case FINISHED:
34     case BROKEN:
35     case FAILED:
36     case CANCELLED:
37       return true;
38     case SERVER_ERROR:
39     case INVALID:
40     case READY:
41     default:
42       return false;
43     }
44   }
45
46   public boolean isCancelled()
47   {
48     return this == WSJobStatus.CANCELLED;
49   }
50
51   public boolean isDone()
52   {
53     switch (this)
54     {
55     case FINISHED:
56     case BROKEN:
57     case FAILED:
58     case SERVER_ERROR:
59     case CANCELLED:
60       return true;
61     case INVALID:
62     case READY:
63     case SUBMITTED:
64     case QUEUED:
65     case RUNNING:
66     default:
67       return false;
68     }
69   }
70
71   public boolean isFailed()
72   {
73     switch (this)
74     {
75     case INVALID:
76     case BROKEN:
77     case FAILED:
78     case SERVER_ERROR:
79       return true;
80     case READY:
81     case SUBMITTED:
82     case QUEUED:
83     case RUNNING:
84     case FINISHED:
85     case CANCELLED:
86     default:
87       return false;
88     }
89   }
90
91   public boolean isRunning()
92   {
93     return this == WSJobStatus.RUNNING;
94   }
95
96   public boolean isQueuing()
97   {
98     return this == WSJobStatus.SUBMITTED || this == WSJobStatus.QUEUED;
99   }
100   
101   public boolean isCompleted()
102   {
103     return this == WSJobStatus.FINISHED;
104   }
105 }