/*This code was generated using the UMPLE modeling language!*/

package Warehouse;

import java.sql.Time;
import java.sql.Date;
import java.util.ArrayList;
import java.util.Iterator;
import Warehouse.json.*;
import Warehouse.core.*;

public class WarehouseFacade {
  // Singleton instance.
  private static WarehouseFacade theInstance;

  //System registry.
  WarehouseRegistry registry = WarehouseRegistry.getInstance();

  /**
   * Dummy constructor
   */
  private WarehouseFacade() {
  }

  /**
   * Returns the only instance of the Facade.
   * 
   * @return
   */
  public static WarehouseFacade getInstance() {
    if (theInstance == null)
      theInstance = new WarehouseFacade();
    return theInstance;
  }

  public int constructRWBMMovement(double aStartTime, double aEndTime, int aTo,
    int aFrom, int aMovedBox) {
    return registry.add(new RWBMMovement(aStartTime, aEndTime,
      (MovementLocation) registry.getValue(aTo), (MovementLocation) registry
        .getValue(aFrom), (BoxOrPallet) registry.getValue(aMovedBox)));
  }

  public JSONObject constructRWBMMovementJSON(double aStartTime,
    double aEndTime, int aTo, int aFrom, int aMovedBox) throws JSONException {
    RWBMMovement contextObj =
      new RWBMMovement(aStartTime, aEndTime, (MovementLocation) registry
        .getValue(aTo), (MovementLocation) registry.getValue(aFrom),
        (BoxOrPallet) registry.getValue(aMovedBox));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setStartTimeInRWBMMovement(int context, double aStartTime) {
    return ((RWBMMovement) registry.getValue(context)).setStartTime(aStartTime);
  }

  public boolean setEndTimeInRWBMMovement(int context, double aEndTime) {
    return ((RWBMMovement) registry.getValue(context)).setEndTime(aEndTime);
  }

  public double getStartTimeFromRWBMMovement(int context) {
    return ((RWBMMovement) registry.getValue(context)).getStartTime();
  }

  public double getEndTimeFromRWBMMovement(int context) {
    return ((RWBMMovement) registry.getValue(context)).getEndTime();
  }

  public int getToFromRWBMMovement(int context) {
    return registry.getKey(((RWBMMovement) registry.getValue(context)).getTo());
  }

  public JSONObject getToFromRWBMMovementJSON(int context) throws JSONException {
    return ((RWBMMovement) registry.getValue(context)).getTo().getAttributes();
  }

  public int getFromFromRWBMMovement(int context) {
    return registry.getKey(((RWBMMovement) registry.getValue(context))
      .getFrom());
  }

  public JSONObject getFromFromRWBMMovementJSON(int context)
    throws JSONException {
    return ((RWBMMovement) registry.getValue(context)).getFrom()
      .getAttributes();
  }

  public int getMovedBoxFromRWBMMovement(int context) {
    return registry.getKey(((RWBMMovement) registry.getValue(context))
      .getMovedBox());
  }

  public JSONObject getMovedBoxFromRWBMMovementJSON(int context)
    throws JSONException {
    return ((RWBMMovement) registry.getValue(context)).getMovedBox()
      .getAttributes();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getRWBMsFromRWBMMovement(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (RWBM obj : ((RWBMMovement) registry.getValue(context)).getRWBMs()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addRWBMToRWBMMovement(int context, int aID, int aRWBMMovement)
    throws Exception {
    return registry.getKey(((RWBMMovement) registry.getValue(context)).addRWBM(
      aID, (RWBMMovement) registry.getValue(aRWBMMovement)));
  }

  public JSONObject addRWBMToRWBMMovementJSON(int context, int aID,
    int aRWBMMovement) throws JSONException, Exception {
    return ((RWBMMovement) registry.getValue(context)).addRWBM(aID,
      (RWBMMovement) registry.getValue(aRWBMMovement)).getAttributes();
  }

  public int addRWBMToRWBMMovementOnly(int context, int aRWBM) throws Exception {
    return registry.getKey(((RWBMMovement) registry.getValue(context))
      .addRWBM((RWBM) registry.getValue(aRWBM)));
  }

  public JSONObject addRWBMToRWBMMovementOnlyJSON(int context, int aRWBM)
    throws JSONException, Exception {
    return ((RWBMMovement) registry.getValue(context)).addRWBM(
      (RWBM) registry.getValue(aRWBM)).getAttributes();
  }

  public void setToInRWBMMovement(int context, int aTo) throws Exception {
    ((RWBMMovement) registry.getValue(context))
      .setTo((MovementLocation) registry.getValue(aTo));
  }

  public void setFromInRWBMMovement(int context, int aFrom) throws Exception {
    ((RWBMMovement) registry.getValue(context))
      .setFrom((MovementLocation) registry.getValue(aFrom));
  }

  public void setMovedBoxInRWBMMovement(int context, int aMovedBox)
    throws Exception {
    ((RWBMMovement) registry.getValue(context))
      .setMovedBox((BoxOrPallet) registry.getValue(aMovedBox));
  }

  public void deleteRWBMMovement(int context) {
    ((RWBMMovement) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteRWBMFromRWBMMovement(int context, int aRWBM) {
    ((RWBMMovement) registry.getValue(context)).deleteRWBM((RWBM) registry
      .getValue(aRWBM));
  }

  public JSONObject getAttributesOfRWBMMovement(int context)
    throws JSONException {
    return ((RWBMMovement) registry.getValue(context)).getAttributes();
  }

  public int constructItem(double aValue, int aHazardID, int aBreakability,
    int aBoxOrPallet) {
    return registry.add(new Item(aValue, aHazardID, aBreakability,
      (BoxOrPallet) registry.getValue(aBoxOrPallet)));
  }

  public JSONObject constructItemJSON(double aValue, int aHazardID,
    int aBreakability, int aBoxOrPallet) throws JSONException {
    Item contextObj =
      new Item(aValue, aHazardID, aBreakability, (BoxOrPallet) registry
        .getValue(aBoxOrPallet));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setValueInItem(int context, double aValue) {
    return ((Item) registry.getValue(context)).setValue(aValue);
  }

  public boolean setHazardIDInItem(int context, int aHazardID) {
    return ((Item) registry.getValue(context)).setHazardID(aHazardID);
  }

  public boolean setBreakabilityInItem(int context, int aBreakability) {
    return ((Item) registry.getValue(context)).setBreakability(aBreakability);
  }

  public double getValueFromItem(int context) {
    return ((Item) registry.getValue(context)).getValue();
  }

  public int getHazardIDFromItem(int context) {
    return ((Item) registry.getValue(context)).getHazardID();
  }

  public int getBreakabilityFromItem(int context) {
    return ((Item) registry.getValue(context)).getBreakability();
  }

  public int getBoxOrPalletFromItem(int context) {
    return registry
      .getKey(((Item) registry.getValue(context)).getBoxOrPallet());
  }

  public JSONObject getBoxOrPalletFromItemJSON(int context)
    throws JSONException {
    return ((Item) registry.getValue(context)).getBoxOrPallet().getAttributes();
  }

  public void setBoxOrPalletInItem(int context, int aBoxOrPallet)
    throws Exception {
    ((Item) registry.getValue(context)).setBoxOrPallet((BoxOrPallet) registry
      .getValue(aBoxOrPallet));
  }

  public void deleteItem(int context) {
    ((Item) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfItem(int context) throws JSONException {
    return ((Item) registry.getValue(context)).getAttributes();
  }

  public int constructBoxOrPallet(int aRFIDTagNumber, double aLengthINmm,
    double aWidthINmm, double aHeightINmm, double aWeightINkg,
    String aContentType) {
    return registry.add(new BoxOrPallet(aRFIDTagNumber, aLengthINmm,
      aWidthINmm, aHeightINmm, aWeightINkg, aContentType));
  }

  public JSONObject constructBoxOrPalletJSON(int aRFIDTagNumber,
    double aLengthINmm, double aWidthINmm, double aHeightINmm,
    double aWeightINkg, String aContentType) throws JSONException {
    BoxOrPallet contextObj =
      new BoxOrPallet(aRFIDTagNumber, aLengthINmm, aWidthINmm, aHeightINmm,
        aWeightINkg, aContentType);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setRFIDTagNumberInBoxOrPallet(int context, int aRFIDTagNumber) {
    return ((BoxOrPallet) registry.getValue(context))
      .setRFIDTagNumber(aRFIDTagNumber);
  }

  public boolean setLengthINmmInBoxOrPallet(int context, double aLengthINmm) {
    return ((BoxOrPallet) registry.getValue(context))
      .setLengthINmm(aLengthINmm);
  }

  public boolean setWidthINmmInBoxOrPallet(int context, double aWidthINmm) {
    return ((BoxOrPallet) registry.getValue(context)).setWidthINmm(aWidthINmm);
  }

  public boolean setHeightINmmInBoxOrPallet(int context, double aHeightINmm) {
    return ((BoxOrPallet) registry.getValue(context))
      .setHeightINmm(aHeightINmm);
  }

  public boolean setWeightINkgInBoxOrPallet(int context, double aWeightINkg) {
    return ((BoxOrPallet) registry.getValue(context))
      .setWeightINkg(aWeightINkg);
  }

  public boolean setContentTypeInBoxOrPallet(int context, String aContentType) {
    return ((BoxOrPallet) registry.getValue(context))
      .setContentType(aContentType);
  }

  public int getRFIDTagNumberFromBoxOrPallet(int context) {
    return ((BoxOrPallet) registry.getValue(context)).getRFIDTagNumber();
  }

  public double getLengthINmmFromBoxOrPallet(int context) {
    return ((BoxOrPallet) registry.getValue(context)).getLengthINmm();
  }

  public double getWidthINmmFromBoxOrPallet(int context) {
    return ((BoxOrPallet) registry.getValue(context)).getWidthINmm();
  }

  public double getHeightINmmFromBoxOrPallet(int context) {
    return ((BoxOrPallet) registry.getValue(context)).getHeightINmm();
  }

  public double getWeightINkgFromBoxOrPallet(int context) {
    return ((BoxOrPallet) registry.getValue(context)).getWeightINkg();
  }

  public String getContentTypeFromBoxOrPallet(int context) {
    return ((BoxOrPallet) registry.getValue(context)).getContentType();
  }

  public int getSlotSetFromBoxOrPallet(int context) {
    return registry.getKey(((BoxOrPallet) registry.getValue(context))
      .getSlotSet());
  }

  public JSONObject getSlotSetFromBoxOrPalletJSON(int context)
    throws JSONException {
    return ((BoxOrPallet) registry.getValue(context)).getSlotSet()
      .getAttributes();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getRWBMMovementsFromBoxOrPallet(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (RWBMMovement obj : ((BoxOrPallet) registry.getValue(context))
      .getRWBMMovements()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getDeliverOrShipmentBOMsFromBoxOrPallet(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (DeliverOrShipmentBOM obj : ((BoxOrPallet) registry.getValue(context))
      .getDeliverOrShipmentBOMs()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getItemsFromBoxOrPallet(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (Item obj : ((BoxOrPallet) registry.getValue(context)).getItems()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addRWBMMovementToBoxOrPallet(int context, double aStartTime,
    double aEndTime, int aTo, int aFrom, int aMovedBox) throws Exception {
    return registry.getKey(((BoxOrPallet) registry.getValue(context))
      .addRWBMMovement(aStartTime, aEndTime, (MovementLocation) registry
        .getValue(aTo), (MovementLocation) registry.getValue(aFrom),
        (BoxOrPallet) registry.getValue(aMovedBox)));
  }

  public JSONObject addRWBMMovementToBoxOrPalletJSON(int context,
    double aStartTime, double aEndTime, int aTo, int aFrom, int aMovedBox)
    throws JSONException, Exception {
    return ((BoxOrPallet) registry.getValue(context)).addRWBMMovement(
      aStartTime, aEndTime, (MovementLocation) registry.getValue(aTo),
      (MovementLocation) registry.getValue(aFrom),
      (BoxOrPallet) registry.getValue(aMovedBox)).getAttributes();
  }

  public int addRWBMMovementToBoxOrPalletOnly(int context, int aRWBMMovement)
    throws Exception {
    return registry.getKey(((BoxOrPallet) registry.getValue(context))
      .addRWBMMovement((RWBMMovement) registry.getValue(aRWBMMovement)));
  }

  public JSONObject addRWBMMovementToBoxOrPalletOnlyJSON(int context,
    int aRWBMMovement) throws JSONException, Exception {
    return ((BoxOrPallet) registry.getValue(context)).addRWBMMovement(
      (RWBMMovement) registry.getValue(aRWBMMovement)).getAttributes();
  }

  public int addDeliverOrShipmentBOMToBoxOrPallet(int context,
    double aStartTimeLoadOrUnload, double aEndTimeExpected, int aTruck)
    throws Exception {
    return registry.getKey(((BoxOrPallet) registry.getValue(context))
      .addDeliverOrShipmentBOM(aStartTimeLoadOrUnload, aEndTimeExpected,
        (Truck) registry.getValue(aTruck)));
  }

  public JSONObject addDeliverOrShipmentBOMToBoxOrPalletJSON(int context,
    double aStartTimeLoadOrUnload, double aEndTimeExpected, int aTruck)
    throws JSONException, Exception {
    return ((BoxOrPallet) registry.getValue(context)).addDeliverOrShipmentBOM(
      aStartTimeLoadOrUnload, aEndTimeExpected,
      (Truck) registry.getValue(aTruck)).getAttributes();
  }

  public int addDeliverOrShipmentBOMToBoxOrPalletOnly(int context,
    int aDeliverOrShipmentBOM) throws Exception {
    return registry.getKey(((BoxOrPallet) registry.getValue(context))
      .addDeliverOrShipmentBOM((DeliverOrShipmentBOM) registry
        .getValue(aDeliverOrShipmentBOM)));
  }

  public JSONObject addDeliverOrShipmentBOMToBoxOrPalletOnlyJSON(int context,
    int aDeliverOrShipmentBOM) throws JSONException, Exception {
    return ((BoxOrPallet) registry.getValue(context)).addDeliverOrShipmentBOM(
      (DeliverOrShipmentBOM) registry.getValue(aDeliverOrShipmentBOM))
      .getAttributes();
  }

  public int addItemToBoxOrPallet(int context, double aValue, int aHazardID,
    int aBreakability, int aBoxOrPallet) throws Exception {
    return registry.getKey(((BoxOrPallet) registry.getValue(context)).addItem(
      aValue, aHazardID, aBreakability, (BoxOrPallet) registry
        .getValue(aBoxOrPallet)));
  }

  public JSONObject addItemToBoxOrPalletJSON(int context, double aValue,
    int aHazardID, int aBreakability, int aBoxOrPallet) throws JSONException,
    Exception {
    return ((BoxOrPallet) registry.getValue(context)).addItem(aValue,
      aHazardID, aBreakability, (BoxOrPallet) registry.getValue(aBoxOrPallet))
      .getAttributes();
  }

  public int addItemToBoxOrPalletOnly(int context, int aItem) throws Exception {
    return registry.getKey(((BoxOrPallet) registry.getValue(context))
      .addItem((Item) registry.getValue(aItem)));
  }

  public JSONObject addItemToBoxOrPalletOnlyJSON(int context, int aItem)
    throws JSONException, Exception {
    return ((BoxOrPallet) registry.getValue(context)).addItem(
      (Item) registry.getValue(aItem)).getAttributes();
  }

  public void setSlotSetInBoxOrPallet(int context, int aSlotSet)
    throws Exception {
    ((BoxOrPallet) registry.getValue(context)).setSlotSet((SlotSet) registry
      .getValue(aSlotSet));
  }

  public void deleteBoxOrPallet(int context) {
    ((BoxOrPallet) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteSlotSetFromBoxOrPallet(int context, int aSlotSet) {
    ((BoxOrPallet) registry.getValue(context)).deleteSlotSet((SlotSet) registry
      .getValue(aSlotSet));
  }

  public void deleteRWBMMovementFromBoxOrPallet(int context, int aRWBMMovement) {
    ((BoxOrPallet) registry.getValue(context))
      .deleteRWBMMovement((RWBMMovement) registry.getValue(aRWBMMovement));
  }

  public void deleteDeliverOrShipmentBOMFromBoxOrPallet(int context,
    int aDeliverOrShipmentBOM) {
    ((BoxOrPallet) registry.getValue(context))
      .deleteDeliverOrShipmentBOM((DeliverOrShipmentBOM) registry
        .getValue(aDeliverOrShipmentBOM));
  }

  public void deleteItemFromBoxOrPallet(int context, int aItem) {
    ((BoxOrPallet) registry.getValue(context)).deleteItem((Item) registry
      .getValue(aItem));
  }

  public JSONObject getAttributesOfBoxOrPallet(int context)
    throws JSONException {
    return ((BoxOrPallet) registry.getValue(context)).getAttributes();
  }

  public int constructRWBM(int aID, int aRWBMMovement) {
    return registry.add(new RWBM(aID, (RWBMMovement) registry
      .getValue(aRWBMMovement)));
  }

  public JSONObject constructRWBMJSON(int aID, int aRWBMMovement)
    throws JSONException {
    RWBM contextObj =
      new RWBM(aID, (RWBMMovement) registry.getValue(aRWBMMovement));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setIDInRWBM(int context, int aID) {
    return ((RWBM) registry.getValue(context)).setID(aID);
  }

  public int getIDFromRWBM(int context) {
    return ((RWBM) registry.getValue(context)).getID();
  }

  public int getRWBMMovementFromRWBM(int context) {
    return registry.getKey(((RWBM) registry.getValue(context))
      .getRWBMMovement());
  }

  public JSONObject getRWBMMovementFromRWBMJSON(int context)
    throws JSONException {
    return ((RWBM) registry.getValue(context)).getRWBMMovement()
      .getAttributes();
  }

  public void setRWBMMovementInRWBM(int context, int aRWBMMovement)
    throws Exception {
    ((RWBM) registry.getValue(context)).setRWBMMovement((RWBMMovement) registry
      .getValue(aRWBMMovement));
  }

  public void deleteRWBM(int context) {
    ((RWBM) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfRWBM(int context) throws JSONException {
    return ((RWBM) registry.getValue(context)).getAttributes();
  }

  public int constructTruck(int aRegisterNum, Boolean aIsWaiting) {
    return registry.add(new Truck(aRegisterNum, aIsWaiting));
  }

  public JSONObject constructTruckJSON(int aRegisterNum, Boolean aIsWaiting)
    throws JSONException {
    Truck contextObj = new Truck(aRegisterNum, aIsWaiting);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setRegisterNumInTruck(int context, int aRegisterNum) {
    return ((Truck) registry.getValue(context)).setRegisterNum(aRegisterNum);
  }

  public boolean setIsWaitingInTruck(int context, Boolean aIsWaiting) {
    return ((Truck) registry.getValue(context)).setIsWaiting(aIsWaiting);
  }

  public int getRegisterNumFromTruck(int context) {
    return ((Truck) registry.getValue(context)).getRegisterNum();
  }

  public Boolean getIsWaitingFromTruck(int context) {
    return ((Truck) registry.getValue(context)).getIsWaiting();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getDeliverOrShipmentBOMsFromTruck(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (DeliverOrShipmentBOM obj : ((Truck) registry.getValue(context))
      .getDeliverOrShipmentBOMs()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addDeliverOrShipmentBOMToTruck(int context,
    double aStartTimeLoadOrUnload, double aEndTimeExpected, int aTruck)
    throws Exception {
    return registry.getKey(((Truck) registry.getValue(context))
      .addDeliverOrShipmentBOM(aStartTimeLoadOrUnload, aEndTimeExpected,
        (Truck) registry.getValue(aTruck)));
  }

  public JSONObject addDeliverOrShipmentBOMToTruckJSON(int context,
    double aStartTimeLoadOrUnload, double aEndTimeExpected, int aTruck)
    throws JSONException, Exception {
    return ((Truck) registry.getValue(context)).addDeliverOrShipmentBOM(
      aStartTimeLoadOrUnload, aEndTimeExpected,
      (Truck) registry.getValue(aTruck)).getAttributes();
  }

  public int addDeliverOrShipmentBOMToTruckOnly(int context,
    int aDeliverOrShipmentBOM) throws Exception {
    return registry.getKey(((Truck) registry.getValue(context))
      .addDeliverOrShipmentBOM((DeliverOrShipmentBOM) registry
        .getValue(aDeliverOrShipmentBOM)));
  }

  public JSONObject addDeliverOrShipmentBOMToTruckOnlyJSON(int context,
    int aDeliverOrShipmentBOM) throws JSONException, Exception {
    return ((Truck) registry.getValue(context)).addDeliverOrShipmentBOM(
      (DeliverOrShipmentBOM) registry.getValue(aDeliverOrShipmentBOM))
      .getAttributes();
  }

  public void deleteTruck(int context) {
    ((Truck) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteDeliverOrShipmentBOMFromTruck(int context,
    int aDeliverOrShipmentBOM) {
    ((Truck) registry.getValue(context))
      .deleteDeliverOrShipmentBOM((DeliverOrShipmentBOM) registry
        .getValue(aDeliverOrShipmentBOM));
  }

  public JSONObject getAttributesOfTruck(int context) throws JSONException {
    return ((Truck) registry.getValue(context)).getAttributes();
  }

  public int constructRow(int aDepth, int aNumber) {
    return registry.add(new Row(aDepth, aNumber));
  }

  public JSONObject constructRowJSON(int aDepth, int aNumber)
    throws JSONException {
    Row contextObj = new Row(aDepth, aNumber);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setDepthInRow(int context, int aDepth) {
    return ((Row) registry.getValue(context)).setDepth(aDepth);
  }

  public boolean setNumberInRow(int context, int aNumber) {
    return ((Row) registry.getValue(context)).setNumber(aNumber);
  }

  public int getDepthFromRow(int context) {
    return ((Row) registry.getValue(context)).getDepth();
  }

  public int getNumberFromRow(int context) {
    return ((Row) registry.getValue(context)).getNumber();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getLevelsFromRow(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (Level obj : ((Row) registry.getValue(context)).getLevels()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addLevelToRow(int context, int aHeight, int aNumber, int aRow)
    throws Exception {
    return registry.getKey(((Row) registry.getValue(context)).addLevel(aHeight,
      aNumber, (Row) registry.getValue(aRow)));
  }

  public JSONObject addLevelToRowJSON(int context, int aHeight, int aNumber,
    int aRow) throws JSONException, Exception {
    return ((Row) registry.getValue(context)).addLevel(aHeight, aNumber,
      (Row) registry.getValue(aRow)).getAttributes();
  }

  public int addLevelToRowOnly(int context, int aLevel) throws Exception {
    return registry.getKey(((Row) registry.getValue(context))
      .addLevel((Level) registry.getValue(aLevel)));
  }

  public JSONObject addLevelToRowOnlyJSON(int context, int aLevel)
    throws JSONException, Exception {
    return ((Row) registry.getValue(context)).addLevel(
      (Level) registry.getValue(aLevel)).getAttributes();
  }

  public void deleteRow(int context) {
    ((Row) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteLevelFromRow(int context, int aLevel) {
    ((Row) registry.getValue(context)).deleteLevel((Level) registry
      .getValue(aLevel));
  }

  public JSONObject getAttributesOfRow(int context) throws JSONException {
    return ((Row) registry.getValue(context)).getAttributes();
  }

  public int constructSlot(int aNumber, double aWidth, int aSlotSet, int aLevel) {
    return registry.add(new Slot(aNumber, aWidth, (SlotSet) registry
      .getValue(aSlotSet), (Level) registry.getValue(aLevel)));
  }

  public JSONObject constructSlotJSON(int aNumber, double aWidth, int aSlotSet,
    int aLevel) throws JSONException {
    Slot contextObj =
      new Slot(aNumber, aWidth, (SlotSet) registry.getValue(aSlotSet),
        (Level) registry.getValue(aLevel));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setNumberInSlot(int context, int aNumber) {
    return ((Slot) registry.getValue(context)).setNumber(aNumber);
  }

  public boolean setWidthInSlot(int context, double aWidth) {
    return ((Slot) registry.getValue(context)).setWidth(aWidth);
  }

  public int getNumberFromSlot(int context) {
    return ((Slot) registry.getValue(context)).getNumber();
  }

  public double getWidthFromSlot(int context) {
    return ((Slot) registry.getValue(context)).getWidth();
  }

  public int getSlotSetFromSlot(int context) {
    return registry.getKey(((Slot) registry.getValue(context)).getSlotSet());
  }

  public JSONObject getSlotSetFromSlotJSON(int context) throws JSONException {
    return ((Slot) registry.getValue(context)).getSlotSet().getAttributes();
  }

  public int getLevelFromSlot(int context) {
    return registry.getKey(((Slot) registry.getValue(context)).getLevel());
  }

  public JSONObject getLevelFromSlotJSON(int context) throws JSONException {
    return ((Slot) registry.getValue(context)).getLevel().getAttributes();
  }

  public void setSlotSetInSlot(int context, int aSlotSet) throws Exception {
    ((Slot) registry.getValue(context)).setSlotSet((SlotSet) registry
      .getValue(aSlotSet));
  }

  public void setLevelInSlot(int context, int aLevel) throws Exception {
    ((Slot) registry.getValue(context)).setLevel((Level) registry
      .getValue(aLevel));
  }

  public void deleteSlot(int context) {
    ((Slot) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfSlot(int context) throws JSONException {
    return ((Slot) registry.getValue(context)).getAttributes();
  }

  public int constructLevel(int aHeight, int aNumber, int aRow) {
    return registry.add(new Level(aHeight, aNumber, (Row) registry
      .getValue(aRow)));
  }

  public JSONObject constructLevelJSON(int aHeight, int aNumber, int aRow)
    throws JSONException {
    Level contextObj =
      new Level(aHeight, aNumber, (Row) registry.getValue(aRow));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setHeightInLevel(int context, int aHeight) {
    return ((Level) registry.getValue(context)).setHeight(aHeight);
  }

  public boolean setNumberInLevel(int context, int aNumber) {
    return ((Level) registry.getValue(context)).setNumber(aNumber);
  }

  public int getHeightFromLevel(int context) {
    return ((Level) registry.getValue(context)).getHeight();
  }

  public int getNumberFromLevel(int context) {
    return ((Level) registry.getValue(context)).getNumber();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getSlotsFromLevel(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (Slot obj : ((Level) registry.getValue(context)).getSlots()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int getRowFromLevel(int context) {
    return registry.getKey(((Level) registry.getValue(context)).getRow());
  }

  public JSONObject getRowFromLevelJSON(int context) throws JSONException {
    return ((Level) registry.getValue(context)).getRow().getAttributes();
  }

  public int addSlotToLevel(int context, int aNumber, double aWidth,
    int aSlotSet, int aLevel) throws Exception {
    return registry.getKey(((Level) registry.getValue(context)).addSlot(
      aNumber, aWidth, (SlotSet) registry.getValue(aSlotSet), (Level) registry
        .getValue(aLevel)));
  }

  public JSONObject addSlotToLevelJSON(int context, int aNumber, double aWidth,
    int aSlotSet, int aLevel) throws JSONException, Exception {
    return ((Level) registry.getValue(context)).addSlot(aNumber, aWidth,
      (SlotSet) registry.getValue(aSlotSet), (Level) registry.getValue(aLevel))
      .getAttributes();
  }

  public int addSlotToLevelOnly(int context, int aSlot) throws Exception {
    return registry.getKey(((Level) registry.getValue(context))
      .addSlot((Slot) registry.getValue(aSlot)));
  }

  public JSONObject addSlotToLevelOnlyJSON(int context, int aSlot)
    throws JSONException, Exception {
    return ((Level) registry.getValue(context)).addSlot(
      (Slot) registry.getValue(aSlot)).getAttributes();
  }

  public void setRowInLevel(int context, int aRow) throws Exception {
    ((Level) registry.getValue(context)).setRow((Row) registry.getValue(aRow));
  }

  public void deleteLevel(int context) {
    ((Level) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteSlotFromLevel(int context, int aSlot) {
    ((Level) registry.getValue(context)).deleteSlot((Slot) registry
      .getValue(aSlot));
  }

  public JSONObject getAttributesOfLevel(int context) throws JSONException {
    return ((Level) registry.getValue(context)).getAttributes();
  }

  public int constructSlotSet() {
    return registry.add(new SlotSet());
  }

  public JSONObject constructSlotSetJSON() throws JSONException {
    SlotSet contextObj = new SlotSet();
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public int getBoxOrPalletFromSlotSet(int context) {
    return registry.getKey(((SlotSet) registry.getValue(context))
      .getBoxOrPallet());
  }

  public JSONObject getBoxOrPalletFromSlotSetJSON(int context)
    throws JSONException {
    return ((SlotSet) registry.getValue(context)).getBoxOrPallet()
      .getAttributes();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getSlotsFromSlotSet(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (Slot obj : ((SlotSet) registry.getValue(context)).getSlots()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addSlotToSlotSet(int context, int aNumber, double aWidth,
    int aSlotSet, int aLevel) throws Exception {
    return registry.getKey(((SlotSet) registry.getValue(context)).addSlot(
      aNumber, aWidth, (SlotSet) registry.getValue(aSlotSet), (Level) registry
        .getValue(aLevel)));
  }

  public JSONObject addSlotToSlotSetJSON(int context, int aNumber,
    double aWidth, int aSlotSet, int aLevel) throws JSONException, Exception {
    return ((SlotSet) registry.getValue(context)).addSlot(aNumber, aWidth,
      (SlotSet) registry.getValue(aSlotSet), (Level) registry.getValue(aLevel))
      .getAttributes();
  }

  public int addSlotToSlotSetOnly(int context, int aSlot) throws Exception {
    return registry.getKey(((SlotSet) registry.getValue(context))
      .addSlot((Slot) registry.getValue(aSlot)));
  }

  public JSONObject addSlotToSlotSetOnlyJSON(int context, int aSlot)
    throws JSONException, Exception {
    return ((SlotSet) registry.getValue(context)).addSlot(
      (Slot) registry.getValue(aSlot)).getAttributes();
  }

  public void setBoxOrPalletInSlotSet(int context, int aBoxOrPallet)
    throws Exception {
    ((SlotSet) registry.getValue(context))
      .setBoxOrPallet((BoxOrPallet) registry.getValue(aBoxOrPallet));
  }

  public void deleteSlotSet(int context) {
    ((SlotSet) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteBoxOrPalletFromSlotSet(int context, int aBoxOrPallet) {
    ((SlotSet) registry.getValue(context))
      .deleteBoxOrPallet((BoxOrPallet) registry.getValue(aBoxOrPallet));
  }

  public void deleteSlotFromSlotSet(int context, int aSlot) {
    ((SlotSet) registry.getValue(context)).deleteSlot((Slot) registry
      .getValue(aSlot));
  }

  public JSONObject getAttributesOfSlotSet(int context) throws JSONException {
    return ((SlotSet) registry.getValue(context)).getAttributes();
  }

  public int constructDeliverOrShipmentBOM(double aStartTimeLoadOrUnload,
    double aEndTimeExpected, int aTruck) {
    return registry.add(new DeliverOrShipmentBOM(aStartTimeLoadOrUnload,
      aEndTimeExpected, (Truck) registry.getValue(aTruck)));
  }

  public JSONObject constructDeliverOrShipmentBOMJSON(
    double aStartTimeLoadOrUnload, double aEndTimeExpected, int aTruck)
    throws JSONException {
    DeliverOrShipmentBOM contextObj =
      new DeliverOrShipmentBOM(aStartTimeLoadOrUnload, aEndTimeExpected,
        (Truck) registry.getValue(aTruck));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setStartTimeLoadOrUnloadInDeliverOrShipmentBOM(int context,
    double aStartTimeLoadOrUnload) {
    return ((DeliverOrShipmentBOM) registry.getValue(context))
      .setStartTimeLoadOrUnload(aStartTimeLoadOrUnload);
  }

  public boolean setEndTimeExpectedInDeliverOrShipmentBOM(int context,
    double aEndTimeExpected) {
    return ((DeliverOrShipmentBOM) registry.getValue(context))
      .setEndTimeExpected(aEndTimeExpected);
  }

  public double getStartTimeLoadOrUnloadFromDeliverOrShipmentBOM(int context) {
    return ((DeliverOrShipmentBOM) registry.getValue(context))
      .getStartTimeLoadOrUnload();
  }

  public double getEndTimeExpectedFromDeliverOrShipmentBOM(int context) {
    return ((DeliverOrShipmentBOM) registry.getValue(context))
      .getEndTimeExpected();
  }

  public int getTruckFromDeliverOrShipmentBOM(int context) {
    return registry.getKey(((DeliverOrShipmentBOM) registry.getValue(context))
      .getTruck());
  }

  public JSONObject getTruckFromDeliverOrShipmentBOMJSON(int context)
    throws JSONException {
    return ((DeliverOrShipmentBOM) registry.getValue(context)).getTruck()
      .getAttributes();
  }

  public int getSentThroughFromDeliverOrShipmentBOM(int context) {
    return registry.getKey(((DeliverOrShipmentBOM) registry.getValue(context))
      .getSentThrough());
  }

  public JSONObject getSentThroughFromDeliverOrShipmentBOMJSON(int context)
    throws JSONException {
    return ((DeliverOrShipmentBOM) registry.getValue(context)).getSentThrough()
      .getAttributes();
  }

  public int getArriveAtFromDeliverOrShipmentBOM(int context) {
    return registry.getKey(((DeliverOrShipmentBOM) registry.getValue(context))
      .getArriveAt());
  }

  public JSONObject getArriveAtFromDeliverOrShipmentBOMJSON(int context)
    throws JSONException {
    return ((DeliverOrShipmentBOM) registry.getValue(context)).getArriveAt()
      .getAttributes();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getBoxOrPalletsFromDeliverOrShipmentBOM(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (BoxOrPallet obj : ((DeliverOrShipmentBOM) registry.getValue(context))
      .getBoxOrPallets()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addBoxOrPalletToDeliverOrShipmentBOM(int context,
    int aRFIDTagNumber, double aLengthINmm, double aWidthINmm,
    double aHeightINmm, double aWeightINkg, String aContentType)
    throws Exception {
    return registry.getKey(((DeliverOrShipmentBOM) registry.getValue(context))
      .addBoxOrPallet(aRFIDTagNumber, aLengthINmm, aWidthINmm, aHeightINmm,
        aWeightINkg, aContentType));
  }

  public JSONObject addBoxOrPalletToDeliverOrShipmentBOMJSON(int context,
    int aRFIDTagNumber, double aLengthINmm, double aWidthINmm,
    double aHeightINmm, double aWeightINkg, String aContentType)
    throws JSONException, Exception {
    return ((DeliverOrShipmentBOM) registry.getValue(context)).addBoxOrPallet(
      aRFIDTagNumber, aLengthINmm, aWidthINmm, aHeightINmm, aWeightINkg,
      aContentType).getAttributes();
  }

  public int addBoxOrPalletToDeliverOrShipmentBOMOnly(int context,
    int aBoxOrPallet) throws Exception {
    return registry.getKey(((DeliverOrShipmentBOM) registry.getValue(context))
      .addBoxOrPallet((BoxOrPallet) registry.getValue(aBoxOrPallet)));
  }

  public JSONObject addBoxOrPalletToDeliverOrShipmentBOMOnlyJSON(int context,
    int aBoxOrPallet) throws JSONException, Exception {
    return ((DeliverOrShipmentBOM) registry.getValue(context)).addBoxOrPallet(
      (BoxOrPallet) registry.getValue(aBoxOrPallet)).getAttributes();
  }

  public void setTruckInDeliverOrShipmentBOM(int context, int aTruck)
    throws Exception {
    ((DeliverOrShipmentBOM) registry.getValue(context))
      .setTruck((Truck) registry.getValue(aTruck));
  }

  public void setSentThroughInDeliverOrShipmentBOM(int context, int aSentThrough)
    throws Exception {
    ((DeliverOrShipmentBOM) registry.getValue(context))
      .setSentThrough((LoadingGate) registry.getValue(aSentThrough));
  }

  public void setArriveAtInDeliverOrShipmentBOM(int context, int aArriveAt)
    throws Exception {
    ((DeliverOrShipmentBOM) registry.getValue(context))
      .setArriveAt((LoadingGate) registry.getValue(aArriveAt));
  }

  public void deleteDeliverOrShipmentBOM(int context) {
    ((DeliverOrShipmentBOM) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteSentThroughFromDeliverOrShipmentBOM(int context,
    int aLoadingGate) {
    ((DeliverOrShipmentBOM) registry.getValue(context))
      .deleteSentThrough((LoadingGate) registry.getValue(aLoadingGate));
  }

  public void deleteArriveAtFromDeliverOrShipmentBOM(int context,
    int aLoadingGate) {
    ((DeliverOrShipmentBOM) registry.getValue(context))
      .deleteArriveAt((LoadingGate) registry.getValue(aLoadingGate));
  }

  public void deleteBoxOrPalletFromDeliverOrShipmentBOM(int context,
    int aBoxOrPallet) {
    ((DeliverOrShipmentBOM) registry.getValue(context))
      .deleteBoxOrPallet((BoxOrPallet) registry.getValue(aBoxOrPallet));
  }

  public JSONObject getAttributesOfDeliverOrShipmentBOM(int context)
    throws JSONException {
    return ((DeliverOrShipmentBOM) registry.getValue(context)).getAttributes();
  }

  public int constructLoadingGate(int aNumber) {
    return registry.add(new LoadingGate(aNumber));
  }

  public JSONObject constructLoadingGateJSON(int aNumber) throws JSONException {
    LoadingGate contextObj = new LoadingGate(aNumber);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setNumberInLoadingGate(int context, int aNumber) {
    return ((LoadingGate) registry.getValue(context)).setNumber(aNumber);
  }

  public int getNumberFromLoadingGate(int context) {
    return ((LoadingGate) registry.getValue(context)).getNumber();
  }

  public void deleteLoadingGate(int context) {
    ((LoadingGate) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfLoadingGate(int context)
    throws JSONException {
    return ((LoadingGate) registry.getValue(context)).getAttributes();
  }

  public int constructMovementLocation() {
    return registry.add(new MovementLocation());
  }

  public JSONObject constructMovementLocationJSON() throws JSONException {
    MovementLocation contextObj = new MovementLocation();
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getToMovementsFromMovementLocation(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (RWBMMovement obj : ((MovementLocation) registry.getValue(context))
      .getToMovements()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getFromMovementsFromMovementLocation(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (RWBMMovement obj : ((MovementLocation) registry.getValue(context))
      .getFromMovements()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addToMovementToMovementLocation(int context, double aStartTime,
    double aEndTime, int aTo, int aFrom, int aMovedBox) throws Exception {
    return registry.getKey(((MovementLocation) registry.getValue(context))
      .addToMovement(aStartTime, aEndTime, (MovementLocation) registry
        .getValue(aTo), (MovementLocation) registry.getValue(aFrom),
        (BoxOrPallet) registry.getValue(aMovedBox)));
  }

  public JSONObject addToMovementToMovementLocationJSON(int context,
    double aStartTime, double aEndTime, int aTo, int aFrom, int aMovedBox)
    throws JSONException, Exception {
    return ((MovementLocation) registry.getValue(context)).addToMovement(
      aStartTime, aEndTime, (MovementLocation) registry.getValue(aTo),
      (MovementLocation) registry.getValue(aFrom),
      (BoxOrPallet) registry.getValue(aMovedBox)).getAttributes();
  }

  public int addToMovementToMovementLocationOnly(int context, int aToMovement)
    throws Exception {
    return registry.getKey(((MovementLocation) registry.getValue(context))
      .addToMovement((RWBMMovement) registry.getValue(aToMovement)));
  }

  public JSONObject addToMovementToMovementLocationOnlyJSON(int context,
    int aToMovement) throws JSONException, Exception {
    return ((MovementLocation) registry.getValue(context)).addToMovement(
      (RWBMMovement) registry.getValue(aToMovement)).getAttributes();
  }

  public int addFromMovementToMovementLocation(int context, double aStartTime,
    double aEndTime, int aTo, int aFrom, int aMovedBox) throws Exception {
    return registry.getKey(((MovementLocation) registry.getValue(context))
      .addFromMovement(aStartTime, aEndTime, (MovementLocation) registry
        .getValue(aTo), (MovementLocation) registry.getValue(aFrom),
        (BoxOrPallet) registry.getValue(aMovedBox)));
  }

  public JSONObject addFromMovementToMovementLocationJSON(int context,
    double aStartTime, double aEndTime, int aTo, int aFrom, int aMovedBox)
    throws JSONException, Exception {
    return ((MovementLocation) registry.getValue(context)).addFromMovement(
      aStartTime, aEndTime, (MovementLocation) registry.getValue(aTo),
      (MovementLocation) registry.getValue(aFrom),
      (BoxOrPallet) registry.getValue(aMovedBox)).getAttributes();
  }

  public int addFromMovementToMovementLocationOnly(int context,
    int aFromMovement) throws Exception {
    return registry.getKey(((MovementLocation) registry.getValue(context))
      .addFromMovement((RWBMMovement) registry.getValue(aFromMovement)));
  }

  public JSONObject addFromMovementToMovementLocationOnlyJSON(int context,
    int aFromMovement) throws JSONException, Exception {
    return ((MovementLocation) registry.getValue(context)).addFromMovement(
      (RWBMMovement) registry.getValue(aFromMovement)).getAttributes();
  }

  public void deleteMovementLocation(int context) {
    ((MovementLocation) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteToMovementFromMovementLocation(int context,
    int aRWBMMovement) {
    ((MovementLocation) registry.getValue(context))
      .deleteToMovement((RWBMMovement) registry.getValue(aRWBMMovement));
  }

  public void deleteFromMovementFromMovementLocation(int context,
    int aRWBMMovement) {
    ((MovementLocation) registry.getValue(context))
      .deleteFromMovement((RWBMMovement) registry.getValue(aRWBMMovement));
  }

  public JSONObject getAttributesOfMovementLocation(int context)
    throws JSONException {
    return ((MovementLocation) registry.getValue(context)).getAttributes();
  }
}