/**
 * ProgressItem.java
 * Created Apr 22, 2008
 * Copyright (c) TANDBERG Television 2007-2008
 */
package com.tandbergtv.watchpoint.pmm.entities;

import java.util.Date;

/**
 * A progress item represents an instance of a title that is being processed. Each progress item
 * contains a timestamp of the event in the title's lifecycle, a status string and value. If the 
 * event was generated by a workflow process, its id is stored as well.
 * 
 * Since titles may belong to collections such as playlists and pitch schedules, the progress also
 * maintains an optional relationship to the collection.
 * 
 * The progress items associated with a title ordered by time constitute its entire history 
 * in the system.
 * 
 * @author Sahil Verma
 */
public class ProgressItem {
	
	private Long id;
	
	private String name;
	
	private String value;
	
	private Boolean isSuccess;
	
	private Long titleId;
	
	private Long assetListId;
	
	private Date timestamp;
	
	private String titleVersion;
	
	private String sourceComponentName;
	
	private String sourceEntityName;
	
	private String sourceId;
	
	/**
	 * Creates a ProgressItem
	 */
	protected ProgressItem() {
	}

	/**
	 * Creates a ProgressItem
	 * 
	 * @param name
	 * @param value
	 * @param title
	 * @param titleRevision
	 * @param sourceComponentName
	 * @param sourceEntityName
	 * @param sourceId
	 */
	public ProgressItem(String name, String value, long titleId,
			String titleVersion, String sourceComponentName,
			String sourceEntityName, String sourceId) {
		this.name = name;
		this.value = value;
		this.titleId = titleId;
		this.timestamp = new Date();
		this.isSuccess = true;
		this.titleVersion = titleVersion;
		this.sourceComponentName = sourceComponentName;
		this.sourceEntityName = sourceEntityName;
		this.sourceId = sourceId;
	}

	/**
	 * @return the id
	 */
	public Long getId() {
		return this.id;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return this.name;
	}

	/**
	 * @return the value
	 */
	public String getValue() {
		return this.value;
	}

	/**
	 * @param value the value to set
	 */
	public void setValue(String value) {
		this.value = value;
	}

	/**
	 * @return the isSuccess
	 */
	public Boolean getIsSuccess() {
		return this.isSuccess;
	}

	/**
	 * @param isSuccess the isSuccess to set
	 */
	public void setIsSuccess(Boolean isSuccess) {
		this.isSuccess = isSuccess;
	}

	/**
	 * @return the titleId
	 */
	public Long getTitleId() {
		return this.titleId;
	}

	/**
	 * @return the assetListId
	 */
	public Long getAssetListId() {
		return this.assetListId;
	}

	/**
	 * @param assetListId the assetListId to set
	 */
	public void setAssetListId(Long assetListId) {
		this.assetListId = assetListId;
	}

	/**
	 * @return the timestamp
	 */
	public Date getTimestamp() {
		return this.timestamp;
	}

	/**
	 * @param timestamp
	 */
	public void setTimestamp(Date timestamp) {
		this.timestamp = timestamp;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return "[" + id + "] " + name;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((this.id == null) ? 0 : this.id.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof ProgressItem))
			return false;
		final ProgressItem other = (ProgressItem) obj;
		if (this.id == null) {
			if (other.id != null)
				return false;
		} else if (!this.id.equals(other.id))
			return false;
		return true;
	}

	/**
	 * @return the titleRevision
	 */
	public String getTitleRevision() {
		return titleVersion;
	}

	/**
	 * @param titleRevision the titleRevision to set
	 */
	public void setTitleVersion(String titleVersion) {
		this.titleVersion = titleVersion;
	}

	/**
	 * @return the sourceComponentName
	 */
	public String getSourceComponentName() {
		return sourceComponentName;
	}

	/**
	 * @param sourceComponentName the sourceComponentName to set
	 */
	public void setSourceComponentName(String sourceComponentName) {
		this.sourceComponentName = sourceComponentName;
	}

	/**
	 * @return the sourceEntityName
	 */
	public String getSourceEntityName() {
		return sourceEntityName;
	}

	/**
	 * @param sourceEntityName the sourceEntityName to set
	 */
	public void setSourceEntityName(String sourceEntityName) {
		this.sourceEntityName = sourceEntityName;
	}

	/**
	 * @return the sourceId
	 */
	public String getSourceId() {
		return sourceId;
	}

	/**
	 * @param sourceId the sourceId to set
	 */
	public void setSourceId(String sourceId) {
		this.sourceId = sourceId;
	}
}
