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

import javax.persistence.Entity;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.NamedQueries;
import org.hibernate.annotations.NamedQuery;

import com.patrikdufresne.managers.ManagedObject;

/**
 * A qualification represent a position known by an employee.
 * 
 * @author Patrik Dufresne
 * 
 */
@Entity
@NamedQueries({ @NamedQuery(name = "getQualificationTableByPositions", query = "SELECT E, Po, Se "
		+ "FROM Qualification Q JOIN Q.employee as E JOIN Q.position as Po JOIN Po.section as Se "
		+ "WHERE Q.position in :positions AND E.archivedDate is null") })
public class Qualification extends ManagedObject {

	/**
	 * Employee property.
	 */
	public static final String EMPLOYEE = "employee"; //$NON-NLS-1$
	/**
	 * Position property
	 */
	public static final String POSITION = "position"; //$NON-NLS-1$
	private static final long serialVersionUID = -7961409326939904862L;

	private Employee employee;

	private Position position;

	/**
	 * Getter of the property <tt>employee</tt>
	 * 
	 * @return Returns the employee.
	 */
	@ManyToOne(optional = false)
	public Employee getEmployee() {
		return this.employee;
	}

	/**
	 * Getter of the property <tt>position</tt>
	 * 
	 * @return Returns the position.
	 */
	@ManyToOne(optional = false)
	public Position getPosition() {
		return this.position;
	}

	/**
	 * Setter of the property <tt>employee</tt>
	 * 
	 * @param employee
	 *            The employee to set.
	 */
	public void setEmployee(Employee employee) {
		this.changeSupport.firePropertyChange(EMPLOYEE, this.employee,
				this.employee = employee);
	}

	/**
	 * Setter of the property <tt>position</tt>
	 * 
	 * @param position
	 *            The position to set.
	 */
	public void setPosition(Position position) {
		this.changeSupport.firePropertyChange(POSITION, this.position,
				this.position = position);
	}

	@Override
	public String toString() {
		return "Qualification [position=" + this.position //$NON-NLS-1$
				+ ", employee=" + this.employee + "]"; //$NON-NLS-1$ //$NON-NLS-2$
	}

}
