/*
 * 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 java.util.ArrayList;
import java.util.Collection;

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

/**
 * Stili di mail possibili.
 */
public final class MailStyle extends MailBaseBean {
	/**
	 * Serial version UID.
	 */
	private static final long serialVersionUID = 2273641139L;
	/**
	 * Default logger.
	 */
	@SuppressWarnings("unused")
	private static Log logger = LogFactory.getLog(MailStyle.class);
	//
	// Declare entity attributes with accessor methods
	//
	/**
	 * String data type.
	 */
	private String mailStyleId;
	/**
	 * String data type.
	 */
	private String mailStyleDescription;
	/**
	 * String data type.
	 */
	private String mailStyleHeader;
	/**
	 * String data type.
	 */
	private String mailStyleFooter;
	//
	// entity child attribute declarations
	//
	/**
	 * Riferimento all'entity list: MailTemplate. Ogni occorrenza in questa
	 * entity rappresenta una mail inviabile tramite il sistema SkyCon.
	 */
	private Collection<MailTemplate> theMailTemplate = new ArrayList<MailTemplate>();

	//
	// Constructor declaration
	//
	/**
	 * Costruttore vuoto per MailStyle. Istanzia un nuovo MailStyle
	 * completamente vuoto.
	 */
	public MailStyle() {
		super();
	}
	//
	// getters and setters
	//

	/**
	 * @return the mailStyleId
	 */
	public String getMailStyleId() {
		return mailStyleId;
	}

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

	/**
	 * @return the mailStyleDescription
	 */
	public String getMailStyleDescription() {
		return mailStyleDescription;
	}

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

	/**
	 * @return the mailStyleHeader
	 */
	public String getMailStyleHeader() {
		return mailStyleHeader;
	}

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

	/**
	 * @return the mailStyleFooter
	 */
	public String getMailStyleFooter() {
		return mailStyleFooter;
	}

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

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

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

	public void afterPropertiesSet() throws Exception {
		setMailStyleId(getBeanName());
		setMailStyleHeader(StringUtils.trimToEmpty(getMailStyleHeader()));
		setMailStyleFooter(StringUtils.trimToEmpty(getMailStyleFooter()));
		if (logger.isInfoEnabled()) {
			logger.info("Defined mail style: " + this);
		}
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "MailStyle [mailStyleId=" + mailStyleId
				+ ", mailStyleDescription=" + mailStyleDescription
				+ "]";
	}

}
