/*
 * Created on Jul 30, 2008 (C) Copyright TANDBERG Television Ltd.
 */

package com.tandbergtv.watchpoint.pmm.web.title;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.tandbergtv.watchpoint.pmm.entities.Title;
import com.tandbergtv.watchpoint.pmm.web.formbeans.title.TitleForm;

/**
 * Simple Form for collecting the External Title Information and reporting the result of the import /
 * update action for the Title.
 * 
 * @author Vijay Silva
 */
public class ExternalTitleForm extends TitleForm {

	/* Serialization UID */
	private static final long serialVersionUID = 5296701851181616266L;

	/* The titles selected for batch import / sync */
	private String[] selectedTitles = new String[0];

	/* The List of titles descriptions that have failed external batch action */
	private List<Title> successfulTitles;

	/* The List of titles descriptions that have failed external action */
	private Map<String, ?> failedTitles;

	/* The operation name to display on the page */
	private String operationName;

	/**
	 * Default Constructor
	 */
	public ExternalTitleForm() {
	}

	/**
	 * @return the selectedTitles for batch actions
	 */
	public String[] getSelectedTitles() {
		return this.selectedTitles;
	}

	/**
	 * @param selectedTitles the selectedTitles to set
	 */
	public void setSelectedTitles(String[] selected) {
		this.selectedTitles = selected;
	}

	/**
	 * Sets the single title that was successfully imported. Creates a new list for the successful
	 * titles and adds this single title to that list.
	 * 
	 * @param title
	 */
	public void setTitle(Title title) {
		this.successfulTitles = new ArrayList<Title>();
		this.successfulTitles.add(title);
	}

	/**
	 * @return the successfulTitles
	 */
	public List<Title> getSuccessfulTitles() {
		return successfulTitles;
	}

	/**
	 * @param successfulTitles the successfulTitles to set
	 */
	public void setSuccessfulTitles(List<Title> successfulTitles) {
		this.successfulTitles = successfulTitles;
	}

	/**
	 * @return the failedTitles
	 */
	public Map<String, ?> getFailedTitles() {
		return failedTitles;
	}

	/**
	 * @param failedTitles the failedTitles to set
	 */
	public void setFailedTitles(Map<String, ?> failedTitles) {
		this.failedTitles = failedTitles;
	}

	/**
	 * @return the successTitleCount
	 */
	public int getSuccessCount() {
		return (this.successfulTitles != null) ? this.successfulTitles.size() : 0;
	}

	/**
	 * @return the failureTitleCount
	 */
	public int getFailureCount() {
		return (this.failedTitles != null) ? this.failedTitles.size() : 0;
	}

	/**
	 * @return the operationName
	 */
	public String getOperationName() {
		return operationName;
	}

	/**
	 * @param operationName the operationName to set
	 */
	public void setOperationName(String operationName) {
		this.operationName = operationName;
	}
}
