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

import com.patrikdufresne.managers.ManagerException;

/**
 * Exception raised when an handle error occurred within the generate planif
 * process.
 * 
 * @author Patrik Dufresne
 */
public class GeneratePlanifException extends ManagerException {

    /**
     * Reason code to identify an operation being cancel by user.
     */
    public static final int CANCEL_BY_USER = 2;

    /**
     * The problem is unfeasible.
     */
    public static final int UNFEASIBLE = 4;

    /**
     * Reason code to identify an employee being locked on a task for which he
     * is not qualied or available. The employee must be unlocked to generate a
     * planif.
     * <p>
     * Should be raised with an employee and a task.
     */
    public static final int EMPLOYEE_LOCKED_UNAVAIL_OR_UNQUALIFY = 1;

    /**
     * Reason code raised when an employee with preferred seniority can't work
     * on it's preferred team.
     * <p>
     * Should be raised with an employee and a team.
     */
    public static final int EMPLOYEE_PREFERRED_SENIORITY = 3;

    /**
     * Reason code raised when the problem is not feasible from the start. This
     * is most probably due to an employee locked on conflicting task or team.
     */
    public static final int STARTING_UNFEASIBLE = 5;

    /**
	 * 
	 */
    private static final long serialVersionUID = 1L;

    private Employee employee;

    private int reason;

    private Task task;

    private Team team;

    public GeneratePlanifException(String message, int reason) {
        this(message, reason, null, null, null);
    }

    /**
     * Create a new exception with the reason specified.
     * 
     * @param message the detail message.
     * @param reason the reason.
     * @param employee the related employee or null
     * @param task the related task or null
     */
    public GeneratePlanifException(String message, int reason, Employee employee,
            Task task) {
        this(message, reason, employee, task, null);
    }

    public GeneratePlanifException(String message, int reason, Employee employee,
            Task task, Team team) {
        super(message);
        this.reason = reason;
        this.employee = employee;
        this.task = task;
        this.team = team;
    }

    public GeneratePlanifException(String message, int reason, Employee employee,
            Team team) {
        this(message, reason, employee, null, team);
    }

    /**
     * Return the related employee or null if not set
     * 
     * @return
     */
    public Employee getEmployee() {
        return this.employee;
    }

    /**
     * Return the exception reason.
     * 
     * @return
     */
    public int getReason() {
        return this.reason;
    }

    /**
     * Return the related task or null is not set
     * 
     * @return
     */
    public Task getTask() {
        return this.task;
    }

    public Team getTeam() {
        return this.team;
    }
}
