/**
 * Copyright 2016, RadiantBlue Technologies, Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 **/
package model.job;

import java.util.ArrayList;
import java.util.List;

import model.job.result.ResultType;

import org.joda.time.DateTime;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Defines a Job in the Piazza system.
 * 
 * A Job is uniquely identified by a Job ID. This is the primary key used for
 * lookup in the Jobs collection.
 * 
 * Additional Metadata is also stored with a job, such as who submitted the job,
 * what their API key is, and when the Job was submitted.
 * 
 * Job Status and Progress are also tracked and can be reliably used to
 * determine what the current status of the job is as it passes throughout the
 * Piazza system.
 * 
 * @author Patrick.Doody
 * 
 */
@JsonInclude(Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class Job {
	public String jobId;
	public PiazzaJobType jobType;
	@JsonIgnore
	public DateTime submitted;
	public String submitterApiKey;
	public String status;
	public JobProgress progress = new JobProgress();
	public List<JobProgress> history = new ArrayList<JobProgress>();
	public ResultType result;

	public String getJobId() {
		return jobId;
	}

	public void setJobId(String jobId) {
		this.jobId = jobId;
	}

	@JsonProperty("submitted")
	public String getSubmittedString() {
		// Defaults to ISO8601
		return submitted.toString();
	}

	@JsonProperty("submitted")
	public void setSubmittedString(String submitted) {
		this.submitted = new DateTime(submitted);
	}

	public PiazzaJobType getJobType() {
		return jobType;
	}
	
	public ResultType getResult() {
		return result;
	}
}

@@ -718,16 +718,89 @@
 ultType;
+%0Aimport model.request.PiazzaJobRequest;%0Aimport model.status.StatusUpdate;
 %0A%0Aimport
@@ -2007,16 +2007,294 @@
 esult;%0A%0A
+%09public Job() %7B%0A%0A%09%7D%0A%0A%09public Job(PiazzaJobRequest request, String jobId) %7B%0A%09%09Job job = new Job();%0A%09%09job.setJobId(jobId);%0A%09%09job.jobType = request.jobType;%0A%09%09job.submitterApiKey = request.apiKey;%0A%09%09job.status = StatusUpdate.STATUS_SUBMITTED;%0A%09%09job.submitted = new DateTime();%0A%09%7D%0A%0A
 %09public 
@@ -2709,17 +2709,16 @@
 ype;%0A%09%7D%0A
-%09
 %0A%09public

Add Job constructor - inflate from Job Request