JobStatus.java 2.07 KB
Newer Older
1
package eu.simstadt.nf4j;
2
3

/**
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), LOCAL(1), SENT(2), PENDING(3), RUNNING(4), FAILED(5), FINISHED(6), READY_TO_RUN(7), ERROR(8),
	WARNING(9),	APPROVE(10), REJECT(11), APPROVE_RUNNING(12), REJECT_RUNNING(13), APPROVE_REJECT_ERROR(14),
	APPROVE_REJECT_OK(15), IMPORTED_WARNING(16);
12
	
13
14
15
	public static final String UNKNOWN_MESSAGE = "The state of the job is unknown.";
	public static final String LOCAL_MESSAGE = "The job is known locally only. It has not been sent yet.";
	public static final String SENT_MESSAGE = "The job has been sent, is enqueued at the nF and has a job id.";
16
17
18
19
20
	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.";
	
21
22
23
24
25
26
27
28
	/**
	 * 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:
29
			message = UNKNOWN_MESSAGE; break;
30
		case 1:
31
			message = LOCAL_MESSAGE; break;
32
		case 2:
33
			message = SENT_MESSAGE; break;
34
		case 3:
35
36
		case 7:
			message = PENDING_MESSAGE; break;
37
		case 4:
38
39
40
41
42
			message = RUNNING_MESSAGE; break;
		case 5:
		case 8:
			message = FAILED_MESSAGE; break;
		case 6:
43
44
45
			message = FINISHED_MESSAGE; break;
		default:
			message = "";
46
47
48
		}
	}
	
49
50
51
52
53
	/**
	 * This message describes the status or gives hints about error states. This message may come from a
	 * nF response.
	 */
	private String message;
54
	
55
56
57
58
59
	/**
	 * Sets a message for this status in order to describe the status.
	 * 
	 * @param message A message to describe this status.
	 */
60
61
62
63
	public void setMessage(String message) {
		this.message = message;
	}
	
64
65
66
	/**
	 * @return Returns a message which describes this status.
	 */
67
68
69
70
	public String getMessage() {
		return message;
	}
}