Job.java 2.38 KB
Newer Older
1
package eu.simstadt.nf4j;
2

3
4
import java.util.Objects;

5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 * This job class bundles the three attributes of every nF job: Id, status and last job related nF (error) message.  
 * 
 * @author Marcel Bruse
 */
public abstract class Job {
	
	/** The status of the job. There are different states for export and import jobs. */
	private JobStatus status;
	
	/** The id of the job. */
	private int jobId;
	
18
19
20
	/** The connection to the nF. */
	private NFConnector<?, ?> nFConnector;
	
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
	/**
	 * This constructor forces the job to have a defined state.
	 * 
	 * @param status The initial status of this job.
	 */
	public Job(JobStatus status) {
		this.status = status;
	}
	
	/**
	 * Every job has it's status. Look up the different possible values in the JobStatus enumeration.
	 * 
	 * @return Returns the status of this job.
	 */
	public JobStatus getStatus() {
		return status;
	}
	
	/**
	 * Lets you set the status of this job.
	 * 
	 * @param status The status of this job.
	 */
	protected void setStatus(JobStatus status) {
		this.status = status;
	}
	
	/**
	 * @return Returns the id of this job.
	 */
	public int getJobId() {
		return jobId;
	}
	
	/**
	 * Sets the id of this job.
	 * 
	 * @param jobId The job id about to be set.
	 */
	public void setJobId(int jobId) {
		this.jobId = jobId;
	}
	
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
	/**
	 * @return Returns the nF connector of this job.
	 */
	public NFConnector<?, ?> getNFConnector() {
		return nFConnector;
	}

	/**
	 * Sets the nF connector of this job.
	 * 
	 * @param nFConnector The connector of this job.
	 */
	public void setNFConnector(NFConnector<?, ?> nFConnector) {
		this.nFConnector = nFConnector;
	}
	
	/**
	 * Connects to the nF and refreshes the status of this job. If there is no nF connector set,
	 * this operation will throw a FailedTransmissionException.
	 * 
	 * @throws FailedTransmissionException If the connection to the nF is broken you will get some of this. 
	 */
	public abstract void updateStatus() throws FailedTransmissionException;
	
88
89
90
91
92
93
94
95
96
97
	/**
	 * Sets the status of this job depending on the given nF status code. nF status codes will be sent
	 * to you in http responses. Export jobs and import jobs have different states. Consider this fact
	 * in your implementation.
	 *  
	 * @param statusCode The nF status code for this job.
	 */
	public abstract void setStatusForCode(int statusCode);
	
}