JobStatus.java 3.33 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
	UNKNOWN(0),			// A local NF4J code, may be set in rare cases, if synchronization with nF fails. 
bruse's avatar
bruse committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
	LOCAL(10), 			// Job has not been sent yet and is known by the local system only.
	SENT(20), 			// Job has been sent or it is assumed that it has been set before.
	PENDING(30),		// Export job has been enqueued and waits for execution
	READY_TO_RUN(31),	// Same as PENDING, but for import jobs
	APPROVE(32), 		// (?) For import jobs only. Read the nF documentation, seams to be never used.
	RUNNING(40), 		// Job is running
	APPROVE_RUNNING(41),	// (?) For import jobs only. Read the nF documentation, seams to be never used.
	FAILED(50), 		// Export job failed 
	ERROR(51),			// Same as FAILED, but for import jobs
	WARNING(52),		// For import jobs only. There has been a minor problem
	REJECT(53), 		// (?) For import jobs only. Read the nF documentation, seams to be never used.
	REJECT_RUNNING(54), 		// (?) For import jobs only. Read the nF documentation, seams to be never used.
	APPROVE_REJECT_ERROR(55),	// (?) For import jobs only. Read the nF documentation, seams to be never used.
	APPROVE_REJECT_OK(56),		// (?) For import jobs only. Read the nF documentation, seams to be never used.
	IMPORTED_WARNING(57),		// (?) For import jobs only. Read the nF documentation, seams to be never used.
	FINISHED(60), 		// Job finished
	DOWNLOAD(70);		// Export jobs only. CityGML has been download to the local file system
27
	
28
29
30
	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.";
31
32
33
34
	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.";
bruse's avatar
bruse committed
35
	public static final String WAITING_MESSAGE = "Job is waiting for a response from the remote nF instance.";
36
	
37
38
39
40
41
42
43
44
	/**
	 * 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:
45
			message = UNKNOWN_MESSAGE; break;
bruse's avatar
bruse committed
46
		case 10:
47
			message = LOCAL_MESSAGE; break;
bruse's avatar
bruse committed
48
		case 20:
49
			message = SENT_MESSAGE; break;
bruse's avatar
bruse committed
50
51
		case 30:
		case 31:
52
			message = PENDING_MESSAGE; break;
bruse's avatar
bruse committed
53
		case 40:
54
			message = RUNNING_MESSAGE; break;
bruse's avatar
bruse committed
55
56
		case 50:
		case 51:
57
			message = FAILED_MESSAGE; break;
bruse's avatar
bruse committed
58
		case 60:
59
60
61
			message = FINISHED_MESSAGE; break;
		default:
			message = "";
62
63
64
		}
	}
	
65
66
67
68
69
	/**
	 * This message describes the status or gives hints about error states. This message may come from a
	 * nF response.
	 */
	private String message;
70
	
71
72
73
74
75
	/**
	 * Sets a message for this status in order to describe the status.
	 * 
	 * @param message A message to describe this status.
	 */
76
77
78
79
	public void setMessage(String message) {
		this.message = message;
	}
	
80
81
82
	/**
	 * @return Returns a message which describes this status.
	 */
83
84
85
86
	public String getMessage() {
		return message;
	}
}