package com.planimod.core;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;

import com.patrikdufresne.managers.ArchivableObject;

/**
 * The Employee class represent a physical person that has qualification and may
 * fill a position.
 */
@Entity
public class Employee extends ArchivableObject {
	/**
	 * Firstname property
	 */
	public static final String FIRSTNAME = "firstname"; //$NON-NLS-1$
	/**
	 * Hire date property
	 */
	public static final String HIRE_DATE = "hireDate";//$NON-NLS-1$
	/**
	 * Lastname property
	 */
	public static final String LASTNAME = "lastname";//$NON-NLS-1$
	/**
	 * Preferencial seniority property
	 */
	public static final String PREFERENCIAL_SENIORITY = "preferencialSeniority";//$NON-NLS-1$
	/**
	 * Ref id property
	 */
	public static final String REFID = "refId"; //$NON-NLS-1$
	/**
	 * 
	 */
	private static final long serialVersionUID = 1645082586972364175L;

	/**
	 * Define the employee's first name.
	 * 
	 */
	private String firstname;

	/**
	 * Define the employee hire date.
	 * 
	 */
	private Date hireDate;

	/**
	 * Define the employee's lastname.
	 * 
	 */
	private String lastname;

	/**
	 * 
	 */
	private boolean preferencialSeniority;

	/**
	 * A reference number to the employee.
	 * 
	 */
	private String refId;

	/**
	 * Create a new employee.
	 */
	public Employee() {

	}

	/**
	 * Getter of the property <tt>Firstname</tt>
	 * 
	 * @return Returns the firstname.
	 */
	@Column(nullable = true)
	public String getFirstname() {
		return this.firstname;
	}

	/**
	 * Getter of the property <tt>hireDate</tt>
	 * 
	 * @return Returns the hireDate.
	 */
	@Column(nullable = true)
	public Date getHireDate() {
		return this.hireDate;
	}

	/**
	 * Getter of the property <tt>Lastname</tt>
	 * 
	 * @return Returns the lastname.
	 */
	@Column(nullable = true)
	public String getLastname() {
		return this.lastname;
	}

	/**
	 * Getter of the property <tt>preferencialSeniority</tt>
	 * 
	 * @return Returns the preferencialSeniority.
	 */
	@Column(nullable = false)
	public boolean getPreferencialSeniority() {
		return this.preferencialSeniority;
	}

	/**
	 * Getter of the property <tt>refId</tt>
	 * 
	 * @return Returns the refId.
	 */
	@Column(unique = true, nullable = true)
	public String getRefId() {
		return this.refId;
	}

	/**
	 * Setter of the property <tt>Firstname</tt>
	 * 
	 * @param Firstname
	 *            The firstname to set.
	 */
	public void setFirstname(String firstname) {
		this.changeSupport.firePropertyChange(FIRSTNAME, this.firstname,
				this.firstname = firstname);
	}

	/**
	 * Setter of the property <tt>hireDate</tt>
	 * 
	 * @param hireDate
	 *            The hireDate to set.
	 */
	public void setHireDate(Date hireDate) {
		this.changeSupport.firePropertyChange(HIRE_DATE, this.hireDate,
				this.hireDate = hireDate);
	}

	/**
	 * Setter of the property <tt>Lastname</tt>
	 * 
	 * @param Lastname
	 *            The lastname to set.
	 */
	public void setLastname(String lastname) {
		this.changeSupport.firePropertyChange(LASTNAME, this.lastname,
				this.lastname = lastname);
	}

	/**
	 * Setter of the property <tt>preferencialSeniority</tt>
	 * 
	 * @param preferencialSeniority
	 *            The preferencialSeniority to set.
	 * @uml.property name="preferencialSeniority"
	 */
	public void setPreferencialSeniority(boolean preferencialSeniority) {
		this.changeSupport.firePropertyChange(PREFERENCIAL_SENIORITY,
				this.preferencialSeniority,
				this.preferencialSeniority = preferencialSeniority);
	}

	/**
	 * Setter of the property <tt>refId</tt>
	 * 
	 * @param refId
	 *            The refId to set.
	 * @uml.property name="refId"
	 */

	public void setRefId(String refId) {
		this.changeSupport.firePropertyChange(REFID, this.refId,
				this.refId = refId);
	}

	@Override
	public String toString() {
		return "Employee [id=" + this.id //$NON-NLS-1$
				+ ", refId=" + this.refId //$NON-NLS-1$
				+ ", name=" //$NON-NLS-1$ 
				+ this.firstname + " " + this.lastname + "]"; //$NON-NLS-1$ //$NON-NLS-2$
	}

}
