1
2
3
4
5
6
7
8
9
10
11 package org.astrogrid.jes.jobscheduler.impl.groovy;
12
13
14 import org.astrogrid.applications.beans.v1.cea.castor.types.ExecutionPhase;
15
16 import java.util.ArrayList;
17 import java.util.List;
18
19 /*** Enumeration type, represents possible states an activity may be in.
20 * @author Noel Winstanley nw@jb.man.ac.uk 26-Jul-2004
21 *
22 */
23 public class Status {
24
25 public Status() {
26 };
27
28 /*** Construct a new Status
29 *
30 */
31 private Status(String status) {
32 super();
33 this.status = status;
34 }
35
36
37 public static final Status UNSTARTED = new Status("UNSTARTED");
38
39 public static final Status START = new Status("START");
40
41 public static final Status STARTED = new Status("STARTED");
42
43 public static final Status FINISH = new Status("FINISH");
44
45 public static final Status FINISHED = new Status("FINISHED");
46
47 public static final Status ERROR = new Status("ERROR");
48
49 public static final Status ERRED = new Status("ERRED");
50
51 public static ExecutionPhase toPhase(Status status) {
52 if (status.equals(Status.UNSTARTED)) {
53 return ExecutionPhase.PENDING;
54 }
55 if (status.equals(Status.START)) {
56 return ExecutionPhase.INITIALIZING;
57 }
58 if (status.equals(Status.STARTED)) {
59 return ExecutionPhase.RUNNING;
60 }
61 if (status.equals(Status.FINISH)) {
62 return ExecutionPhase.RUNNING;
63 }
64 if (status.equals(Status.FINISHED)) {
65 return ExecutionPhase.COMPLETED;
66 }
67 if (status.equals(Status.ERROR)) {
68 return ExecutionPhase.ERROR;
69 }
70 if (status.equals(Status.ERRED)) {
71 return ExecutionPhase.ERROR;
72 }
73 return ExecutionPhase.UNKNOWN;
74 }
75
76 static final List allStatus;
77 static {
78 allStatus = new ArrayList();
79 allStatus.add(UNSTARTED);
80 allStatus.add(START);
81 allStatus.add(STARTED);
82 allStatus.add(FINISH);
83 allStatus.add(FINISHED);
84 allStatus.add(ERROR);
85 allStatus.add(ERRED);
86 }
87
88 private String status;
89
90 public boolean equals(Object o) {
91 Status other = (Status)o;
92 return this.status.equals(other.status);
93 }
94
95 public String getName() {
96 return status;
97 }
98
99 public String toString() {
100 StringBuffer buffer = new StringBuffer();
101 buffer.append("[Status:");
102 buffer.append(status);
103 buffer.append("]");
104 return buffer.toString();
105 }
106 }
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138