/*
 * Created on Aug 29, 2008 (C) Copyright TANDBERG Television Ltd.
 */

package com.tandbergtv.watchpoint.pmm.web.formbeans.title;

import java.util.ArrayList;
import java.util.List;

import com.tandbergtv.watchpoint.pmm.entities.IContainer;
import com.tandbergtv.watchpoint.pmm.entities.ProgressItem;
import com.tandbergtv.watchpoint.pmm.entities.Schedule;
import com.tandbergtv.watchpoint.pmm.entities.TitleListType;
import com.tandbergtv.watchpoint.pmm.web.util.CommonUtils;

/**
 * @author Vijay Silva
 */
public class TitleSchedule {

	/* The schedule represented by this bean */
	private Schedule schedule;

	/* The Progress Item History for the title associated with the schedule */
	private List<ProgressItem> progressHistory = new ArrayList<ProgressItem>();

	/* The context Id for the container associated with the schedule */
	private Long containerContextId;

	/* The container associated with the schedule */
	private IContainer container;

	/**
	 * @return the schedule
	 */
	public Schedule getSchedule() {
		return schedule;
	}

	/**
	 * @param schedule the schedule to set
	 */
	public void setSchedule(Schedule schedule) {
		this.schedule = schedule;
	}

	/**
	 * @return the progressHistory
	 */
	public List<ProgressItem> getProgressHistory() {
		return progressHistory;
	}

	/**
	 * @param progressHistory the progressHistory to set
	 */
	public void setProgressHistory(List<ProgressItem> progressHistory) {
		this.progressHistory = progressHistory;
	}

	/**
	 * @return the containerContextId
	 */
	public Long getContainerContextId() {
		return containerContextId;
	}

	/**
	 * @param containerContextId the containerContextId to set
	 */
	public void setContainerContextId(Long containerContextId) {
		this.containerContextId = containerContextId;
	}

	/**
	 * @return the container
	 */
	public IContainer getContainer() {
		return container;
	}

	/**
	 * @param container the container to set
	 */
	public void setContainer(IContainer container) {
		this.container = container;
	}

	/** Checks if progress history is available for this title and asset list */
	public boolean isProgressHistoryPresent() {
		return (this.progressHistory != null && this.progressHistory.size() > 0);
	}

	/**
	 * @return the scheduleId
	 */
	public Long getScheduleId() {
		return (schedule != null) ? schedule.getId() : null;
	}
	
	/**
	 * @return the scheduleType
	 */
	public TitleListType getScheduleType() {
		return (schedule != null) ? schedule.getType() : null;
	}

	/**
	 * @return the scheduleTypeName
	 */
	public String getScheduleTypeName() {
		return (schedule != null) ? schedule.getType().toString() : null;
	}

	/**
	 * @return the scheduleTypeKey
	 */
	public String getScheduleTypeKey() {
		return (schedule != null) ? "schedule.type." + schedule.getType() : null;
	}

	/**
	 * @return the scheduleDate
	 */
	public String getScheduleDate() {
		return (schedule != null) ? CommonUtils.formatDate(schedule.getDate()) : null;
	}

	/**
	 * Get the Name for the container
	 * 
	 * @return The Container Name
	 */
	public String getContainerName() {
		return (container != null) ? container.getContainerName() : null;
	}

}
