/*
 * Copyright (c) 2011, Patrik Dufresne. All rights reserved.
 * Patrik Dufresne PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.planimod.core;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.patrikdufresne.managers.ManagedObject;

@MappedSuperclass
public abstract class AbstractCalendarEvent extends ManagedObject implements TimeRange {

	/**
	 * End date property
	 */
	public static final String END_DATE = "endDate"; //$NON-NLS-1$
	
	private static final long serialVersionUID = -5828220038114866993L;
	/**
	 * Start date property
	 */
	public static final String START_DATE = "startDate"; //$NON-NLS-1$

	/**
	 * Summary property
	 */
	public static final String SUMMARY = "summary"; //$NON-NLS-1$

	/**
	 * The end date and time of this event.
	 * 
	 * @uml.property name="endDate"
	 */
	private Date endDate;

	/**
	 * The start date and time of this event.
	 * 
	 * @uml.property name="startDate"
	 */
	private Date startDate;

	/**
	 * A short description of this event.
	 * 
	 * @uml.property name="summary"
	 */
	private String summary;

	/**
	 * Getter of the property <tt>endDate</tt>
	 * 
	 * @return Returns the endDate.
	 * @uml.property name="endDate"
	 */
	@Override
	@Column(nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	public Date getEndDate() {
		return this.endDate;
	}

	/**
	 * Getter of the property <tt>startDate</tt>
	 * 
	 * @return Returns the startDate.
	 * @uml.property name="startDate"
	 */
	@Override
	@Column(nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	public Date getStartDate() {
		return this.startDate;
	}

	/**
	 * Getter of the property <tt>summary</tt>
	 * 
	 * @return Returns the summary.
	 * @uml.property name="summary"
	 */
	@Column(nullable = true)
	public String getSummary() {
		return this.summary;
	}

	/**
	 * Setter of the property <tt>endDate</tt>
	 * 
	 * @param endDate
	 *            The endDate to set.
	 * @uml.property name="endDate"
	 */
	public void setEndDate(Date endDate) {
		this.changeSupport.firePropertyChange("endDate", this.endDate, //$NON-NLS-1$
				this.endDate = endDate);
	}

	/**
	 * Setter of the property <tt>startDate</tt>
	 * 
	 * @param startDate
	 *            The startDate to set.
	 * @uml.property name="startDate"
	 */
	public void setStartDate(Date startDate) {
		this.changeSupport.firePropertyChange("startDate", this.startDate, //$NON-NLS-1$
				this.startDate = startDate);
	}

	/**
	 * Setter of the property <tt>summary</tt>
	 * 
	 * @param summary
	 *            The summary to set.
	 * @uml.property name="summary"
	 */
	public void setSummary(String summary) {
		this.changeSupport.firePropertyChange("summary", this.summary, //$NON-NLS-1$
				this.summary = summary);
	}
	
	@Override
	public String toString() {
		return "CalendarEvent [id=" + this.id + ", summary=" + this.summary + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
	}

}
