JobStatus.java 1.76 KB
Newer Older
1
2
3
package eu.simstadt.nf;

/**
4
 * The list of all possible export and import job states.
5
6
7
8
 * 
 * @author Marcel Bruse
 */
public enum JobStatus {
9
10
11
	UNKOWN(0), PENDING(1), RUNNING(2), FAILED(3), FINISHED(4), READY_TO_RUN(5), ERROR(6), WARNING(7), APPROVE(8),
	REJECT(9),	APPROVE_RUNNING(10), REJECT_RUNNING(11), APPROVE_REJECT_ERROR(12), APPROVE_REJECT_OK(13),
	IMPORTED_WARNING(14);
12
13
14
15
16
17
18
	
	public static final String UNKNOWN_STATUS_MESSAGE = "The state of the job is unknown.";
	public static final String PENDING_MESSAGE = "Job is pending.";
	public static final String RUNNING_MESSAGE = "Job is running.";
	public static final String FAILED_MESSAGE = "Job failed.";
	public static final String FINISHED_MESSAGE = "Job is finished.";
	
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
	/**
	 * This constructor sets messages for some states.
	 * 
	 * @param internalCode Our numerical SimStadt-internal code for the nF status codes.
	 */
	private JobStatus(int internalCode) {
		switch (internalCode) {
		case 0:
			message = UNKNOWN_STATUS_MESSAGE; break;
		case 1:
		case 5:
			message = PENDING_MESSAGE; break;
		case 2:
			message = RUNNING_MESSAGE; break;
		case 3:
		case 6:
			message = FAILED_MESSAGE; break;
		case 4:
			message = FINISHED_MESSAGE; break;
		default:
			message = "";
40
41
42
		}
	}
	
43
44
45
46
47
	/**
	 * This message describes the status or gives hints about error states. This message may come from a
	 * nF response.
	 */
	private String message;
48
	
49
50
51
52
53
	/**
	 * Sets a message for this status in order to describe the status.
	 * 
	 * @param message A message to describe this status.
	 */
54
55
56
57
	public void setMessage(String message) {
		this.message = message;
	}
	
58
59
60
	/**
	 * @return Returns a message which describes this status.
	 */
61
62
63
64
	public String getMessage() {
		return message;
	}
}