package eu.simstadt.nf4j; /** * 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. */ protected JobStatus status; /** The id of the job. */ protected int id; /** The connection to the nF. */ protected Connector connector; /** * Every job has a status. This method returns it. 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 getId() { return id; } /** * Sets the id of this job. * * @param jobId The job id about to be set. */ public void setId(int jobId) { this.id = jobId; } /** * @return Returns the nF connector of this job. */ public Connector getConnector() { return connector; } /** * Sets the nF connector of this job. * * @param nFConnector The connector of this job. */ public void setConnector(Connector connector) { this.connector = connector; } /** * This method reads the job description, builds a job file from it and uses the connector to send the * job file to nF. You may want to implement the file building and file sending parts in the * connector in order to reuse them here. * * This method is a object oriented convenience method for NFConnector.sendXXXJobFile(). It is sensible * to have this convenience method, because it offers the API user centralized controls over the jobs * status chain without switching between job instances and connector instances. In the end, the user is * not interested in the connection to the nF, but in the job itself. */ public abstract void send() throws InvalidJobDescriptorException, FailedTransmissionException; /** * Connects to the nF and refreshes the status of this job. If there is no nF connector set, or the job id * is unkown by the nF, then 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; /** * 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); }