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