/**
 * DistributionSchedule.java
 * Created Apr 22, 2008
 * Copyright (c) TANDBERG Television 2007-2008
 */
package com.tandbergtv.watchpoint.pmm.entities;

import java.util.Date;

import com.tandbergtv.watchpoint.pmm.entities.event.AssetListEvent;
import com.tandbergtv.watchpoint.pmm.entities.event.AssetListEventType;

/**
 * A distribution schedule is a collection of titles which are intended to be sent to a downstream
 * partner by the intended pitch date.
 * 
 * @author Sahil Verma
 */
public class DistributionSchedule extends Schedule {
	
	protected transient String partner;
	
	/**
	 * Creates a DistributionSchedule
	 */
	public DistributionSchedule() {
	}

	/**
	 * Creates a DistributionSchedule
	 * 
	 * @param contextID
	 * @param pitchDate
	 */
	public DistributionSchedule(Long contextID, Date pitchDate) {
		super(null, pitchDate);
		this.contextID = contextID;
	}
	
	/**
	 * Creates a DistributionSchedule
	 * 
	 * @param contextID
	 * @param pitchDate
	 */
	public DistributionSchedule(Long sourcePartnerID, Long contextID, Date pitchDate) {
		super(sourcePartnerID, pitchDate);
		this.contextID = contextID;
	}
	
	/**
	 * Returns the date by which all the assets must be sent downstream
	 * 
	 * @return
	 */
	public Date getPitchDate() {
		return this.date;
	}

	/**
	 * @param pitchDate the pitchDate to set
	 */
	public void setPitchDate(Date pitchDate) {
		setDate(pitchDate);
		fireEvent(new AssetListEvent(this, this, AssetListEventType.UPDATED));
	}

	/**
	 * Gets the destination partner name
	 * 
	 * @return the partner
	 */
	public String getPartner() {
		return this.partner;
	}

	/**
	 * Sets the destination partner
	 * 
	 * @param partner the partner to set
	 */
	public void setPartner(String partner) {
		this.partner = partner;
	}

	/* (non-Javadoc)
	 * @see com.tandbergtv.watchpoint.pmm.entities.Schedule#getType()
	 */
	public TitleListType getType() {
		return TitleListType.PITCH;
	}

	/* (non-Javadoc)
	 * @see com.tandbergtv.watchpoint.pmm.entities.AssetList#toString()
	 */
	public String toString() {
		return super.toString() + ", pitch date " + getPitchDate();
	}
}
