/*This code was generated using the UMPLE modeling language!
 Date of generation: 2008/07/30 12:30:06*/
/*This class drives: */

package BankingSystem.core.humanResources;

import BankingSystem.*;
import BankingSystem.core.intangableResources.*;
import BankingSystem.core.tangableResources.*;
import BankingSystem.json.*;

public class Employee extends PersonRole {
  //Class datatypes

  //Class association variables
  private Manager manager;

  private Division division;

  //Registry of our system.
  BankingSystemRegistry registry = BankingSystemRegistry.getInstance();

  //Constructor
  public Employee(Person aPerson, Division aDivision) {
    super(aPerson);

    division = aDivision;
    division.addEmployee(this);

  }

  public Manager getManager() {
    return manager;
  }

  public Division getDivision() {
    return division;
  }

  /* This class does not drive Manager and therefore sets the association unidirectionally.*/
  public void setManager(Manager aManager) {
    manager = aManager;
  }

  /* This class does not drive Division and therefore sets the association unidirectionally.*/
  public void setDivision(Division aDivision) {
    division = aDivision;
  }

  public void delete() {
    //Delete all 1 ends.
    manager.deleteEmployee(this);
    division.deleteEmployee(this);
  }

  public void deleteManager(Manager aManager) {

    if (aManager.equals(manager)) {
      manager = null;

      registry.removeObj(registry.getKey(aManager));
    } else
    //Throw an UmpleException .. to be implemented.
    {
    }
  }

  public boolean areManyEndsNull() {
    return true;
  }

  /***********************************
   * Returns the attribute list along with the  
   * class ID in JSON format.
   ***********************************/
  public JSONObject getAttributes() throws JSONException {
    JSONObject obj = new JSONObject();
    obj.put("CLASS_ID", registry.getKey(this));
    return obj;
  }

}