package eu.simstadt.nf; import java.util.Objects; /** * Export jobs are requests for CityGML models. Every valid export job has an id and a status. * * @author Marcel Bruse */ public class ExportJob extends Job { /** * Initializes a new export job instance with unknown state. This is a convenient method. * * @return Returns a new export job instance with unknown state. */ public static ExportJob getUnkownInstance() { return new ExportJob(JobStatus.UNKOWN); } /** * This constructor forces the job to have a defined state. * * @param status */ public ExportJob(JobStatus status) { super(status); } /** * Sets the status of this job depending on the given nF status code. nF status codes will be sent * to you in http responses. * * @param statusCode The nF status code for this job. */ @Override public void setStatusForCode(int statusCode) { switch (statusCode) { case 0: setStatus(JobStatus.PENDING); break; case 10: setStatus(JobStatus.RUNNING); break; case 20: setStatus(JobStatus.FAILED); break; case 30: setStatus(JobStatus.FINISHED); break; default: setStatus(JobStatus.UNKOWN); } } /** * @return Returns true, if the job is definitely done. False, otherwise. */ public boolean isFinished() { return Objects.nonNull(getStatus()) && getStatus().equals(JobStatus.FINISHED); } }