/*
 * Copyright 2009-2010 The MICE Project Team.
 * Licensed under the MICE s.r.l.
 * End User License Agreement
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.micegroup.it/voila/license.html
 */
package it.mice.voila.runtime.mail.beans;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * Associazione tra template e mail selectors. Stabilisce i destinatari di una mail.
 */
public final class SelectorPerTemplate extends MailBaseBean {
	/**
	 * Serial version UID.
	 */
	private static final long serialVersionUID = 2938628599L;
	/**
	 * Default logger.
	 */
	@SuppressWarnings("unused")
	private static Log logger = LogFactory.getLog(SelectorPerTemplate.class);
	
	public static final String SELECTOR_TO = "TO";
	public static final String SELECTOR_CC = "CC";
	public static final String SELECTOR_BCC = "BCC";

	//
	// Declare entity attributes with accessor methods
	//
	/**
	 * String data type. I possibili valori ammessi per la proprietà sono:
	 * <dl>
	 * <dt>TO</dt>
	 * <dd>- TO</dd>
	 * <dt>CC</dt>
	 * <dd>- CC</dd>
	 * <dt>BCC</dt>
	 * <dd>- BCC</dd>
	 * </dl>
	 */
	private String tipoSelector;
	//
	// entity parent attribute declaration
	//
	/**
	 * Riferimento all'entity: MailSelector. Ogni occorrenza in questa entity sa selezionare indirizzi emails
	 * da un contesto dinamico del processo attualmente in esecuzione nel sistema.
	 */
	private MailSelector theMailSelector;
	/**
	 * Riferimento all'entity: MailTemplate. Ogni occorrenza in questa entity rappresenta una mail inviabile
	 * tramite il sistema SkyCon.
	 */
	private MailTemplate theMailTemplate;

	/**
	 * Useful fields that store checked information of the element in a list.
	 */
	private boolean checked = false;

	//
	// Constructor declaration
	//
	/**
	 * Costruttore vuoto per SelectorPerTemplate. Istanzia un nuovo SelectorPerTemplate completamente vuoto.
	 */
	public SelectorPerTemplate() {
		super();
	}
	//
	// getters and setters
	//
	/**
	 * @return the tipoSelector
	 */
	public String getTipoSelector() {
		return tipoSelector;
	}


	/**
	 * @param tipoSelector the tipoSelector to set
	 */
	public void setTipoSelector(String tipoSelector) {
		this.tipoSelector = tipoSelector;
	}


	/**
	 * @return the theMailSelector
	 */
	public MailSelector getTheMailSelector() {
		return theMailSelector;
	}


	/**
	 * @param theMailSelector the theMailSelector to set
	 */
	public void setTheMailSelector(MailSelector theMailSelector) {
		this.theMailSelector = theMailSelector;
	}


	/**
	 * @return the theMailTemplate
	 */
	public MailTemplate getTheMailTemplate() {
		return theMailTemplate;
	}


	/**
	 * @param theMailTemplate the theMailTemplate to set
	 */
	public void setTheMailTemplate(MailTemplate theMailTemplate) {
		this.theMailTemplate = theMailTemplate;
	}

	//
	// other methods
	//
	public boolean isToSelector() {
		return SELECTOR_TO.equals(getTipoSelector());
	}
	public boolean isCcSelector() {
		return SELECTOR_CC.equals(getTipoSelector());
	}
	public boolean isBccSelector() {
		return SELECTOR_BCC.equals(getTipoSelector());
	}

	public void afterPropertiesSet() throws Exception {
	}

	public void setChecked(boolean checked) {
		this.checked = checked;
	}
	
	public boolean isChecked() {
		return checked;
	}
}
