/*This code was generated using the UMPLE modeling language!*/

package MailOrderSystem;

import java.sql.Time;
import java.sql.Date;
import java.util.ArrayList;
import java.util.Iterator;
import MailOrderSystem.json.*;
import MailOrderSystem.core.*;

public class MailOrderSystemFacade {
  // Singleton instance.
  private static MailOrderSystemFacade theInstance;

  //System registry.
  MailOrderSystemRegistry registry = MailOrderSystemRegistry.getInstance();

  /**
   * Dummy constructor
   */
  private MailOrderSystemFacade() {
  }

  /**
   * Returns the only instance of the Facade.
   * 
   * @return
   */
  public static MailOrderSystemFacade getInstance() {
    if (theInstance == null)
      theInstance = new MailOrderSystemFacade();
    return theInstance;
  }

  public int constructOrderFromClient(String aOurOrderNumber,
    String aDatePlaced, String aClientsPurchaseOrder,
    String aCreditCardToCharge, int aClient) {
    return registry.add(new OrderFromClient(aOurOrderNumber, aDatePlaced,
      aClientsPurchaseOrder, aCreditCardToCharge, (Client) registry
        .getValue(aClient)));
  }

  public JSONObject constructOrderFromClientJSON(String aOurOrderNumber,
    String aDatePlaced, String aClientsPurchaseOrder,
    String aCreditCardToCharge, int aClient) throws JSONException {
    OrderFromClient contextObj =
      new OrderFromClient(aOurOrderNumber, aDatePlaced, aClientsPurchaseOrder,
        aCreditCardToCharge, (Client) registry.getValue(aClient));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setOurOrderNumberInOrderFromClient(int context,
    String aOurOrderNumber) {
    return ((OrderFromClient) registry.getValue(context))
      .setOurOrderNumber(aOurOrderNumber);
  }

  public boolean setDatePlacedInOrderFromClient(int context, String aDatePlaced) {
    return ((OrderFromClient) registry.getValue(context))
      .setDatePlaced(aDatePlaced);
  }

  public boolean setClientsPurchaseOrderInOrderFromClient(int context,
    String aClientsPurchaseOrder) {
    return ((OrderFromClient) registry.getValue(context))
      .setClientsPurchaseOrder(aClientsPurchaseOrder);
  }

  public boolean setCreditCardToChargeInOrderFromClient(int context,
    String aCreditCardToCharge) {
    return ((OrderFromClient) registry.getValue(context))
      .setCreditCardToCharge(aCreditCardToCharge);
  }

  public String getOurOrderNumberFromOrderFromClient(int context) {
    return ((OrderFromClient) registry.getValue(context)).getOurOrderNumber();
  }

  public String getDatePlacedFromOrderFromClient(int context) {
    return ((OrderFromClient) registry.getValue(context)).getDatePlaced();
  }

  public String getClientsPurchaseOrderFromOrderFromClient(int context) {
    return ((OrderFromClient) registry.getValue(context))
      .getClientsPurchaseOrder();
  }

  public String getCreditCardToChargeFromOrderFromClient(int context) {
    return ((OrderFromClient) registry.getValue(context))
      .getCreditCardToCharge();
  }

  public int getClientFromOrderFromClient(int context) {
    return registry.getKey(((OrderFromClient) registry.getValue(context))
      .getClient());
  }

  public JSONObject getClientFromOrderFromClientJSON(int context)
    throws JSONException {
    return ((OrderFromClient) registry.getValue(context)).getClient()
      .getAttributes();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getClientOrderLineItemsFromOrderFromClient(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (ClientOrderLineItem obj : ((OrderFromClient) registry
      .getValue(context)).getClientOrderLineItems()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int getSalesPersonFromOrderFromClient(int context) {
    return registry.getKey(((OrderFromClient) registry.getValue(context))
      .getSalesPerson());
  }

  public JSONObject getSalesPersonFromOrderFromClientJSON(int context)
    throws JSONException {
    return ((OrderFromClient) registry.getValue(context)).getSalesPerson()
      .getAttributes();
  }

  public int addClientOrderLineItemToOrderFromClient(int context,
    String aNumberOrdered, String aPricePerUnitCharged, int aOrderFromClient,
    int aProduct) throws Exception {
    return registry.getKey(((OrderFromClient) registry.getValue(context))
      .addClientOrderLineItem(aNumberOrdered, aPricePerUnitCharged,
        (OrderFromClient) registry.getValue(aOrderFromClient),
        (Product) registry.getValue(aProduct)));
  }

  public JSONObject addClientOrderLineItemToOrderFromClientJSON(int context,
    String aNumberOrdered, String aPricePerUnitCharged, int aOrderFromClient,
    int aProduct) throws JSONException, Exception {
    return ((OrderFromClient) registry.getValue(context))
      .addClientOrderLineItem(aNumberOrdered, aPricePerUnitCharged,
        (OrderFromClient) registry.getValue(aOrderFromClient),
        (Product) registry.getValue(aProduct)).getAttributes();
  }

  public int addClientOrderLineItemToOrderFromClientOnly(int context,
    int aClientOrderLineItem) throws Exception {
    return registry.getKey(((OrderFromClient) registry.getValue(context))
      .addClientOrderLineItem((ClientOrderLineItem) registry
        .getValue(aClientOrderLineItem)));
  }

  public JSONObject addClientOrderLineItemToOrderFromClientOnlyJSON(
    int context, int aClientOrderLineItem) throws JSONException, Exception {
    return ((OrderFromClient) registry.getValue(context))
      .addClientOrderLineItem(
        (ClientOrderLineItem) registry.getValue(aClientOrderLineItem))
      .getAttributes();
  }

  public void setClientInOrderFromClient(int context, int aClient)
    throws Exception {
    ((OrderFromClient) registry.getValue(context)).setClient((Client) registry
      .getValue(aClient));
  }

  public void setSalesPersonInOrderFromClient(int context, int aSalesPerson)
    throws Exception {
    ((OrderFromClient) registry.getValue(context))
      .setSalesPerson((SalesPerson) registry.getValue(aSalesPerson));
  }

  public void deleteOrderFromClient(int context) {
    ((OrderFromClient) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteClientOrderLineItemFromOrderFromClient(int context,
    int aClientOrderLineItem) {
    ((OrderFromClient) registry.getValue(context))
      .deleteClientOrderLineItem((ClientOrderLineItem) registry
        .getValue(aClientOrderLineItem));
  }

  public void deleteSalesPersonFromOrderFromClient(int context, int aSalesPerson) {
    ((OrderFromClient) registry.getValue(context))
      .deleteSalesPerson((SalesPerson) registry.getValue(aSalesPerson));
  }

  public JSONObject getAttributesOfOrderFromClient(int context)
    throws JSONException {
    return ((OrderFromClient) registry.getValue(context)).getAttributes();
  }

  public int constructProduct(String aOurCode, String aDescription,
    String aPicture, String aOurListPricePerunit, String aNumberInInventory,
    String aNumberToKeepInv, int aProductCategory) {
    return registry.add(new Product(aOurCode, aDescription, aPicture,
      aOurListPricePerunit, aNumberInInventory, aNumberToKeepInv,
      (ProductCategory) registry.getValue(aProductCategory)));
  }

  public JSONObject constructProductJSON(String aOurCode, String aDescription,
    String aPicture, String aOurListPricePerunit, String aNumberInInventory,
    String aNumberToKeepInv, int aProductCategory) throws JSONException {
    Product contextObj =
      new Product(aOurCode, aDescription, aPicture, aOurListPricePerunit,
        aNumberInInventory, aNumberToKeepInv, (ProductCategory) registry
          .getValue(aProductCategory));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setOurCodeInProduct(int context, String aOurCode) {
    return ((Product) registry.getValue(context)).setOurCode(aOurCode);
  }

  public boolean setDescriptionInProduct(int context, String aDescription) {
    return ((Product) registry.getValue(context)).setDescription(aDescription);
  }

  public boolean setPictureInProduct(int context, String aPicture) {
    return ((Product) registry.getValue(context)).setPicture(aPicture);
  }

  public boolean setOurListPricePerunitInProduct(int context,
    String aOurListPricePerunit) {
    return ((Product) registry.getValue(context))
      .setOurListPricePerunit(aOurListPricePerunit);
  }

  public boolean setNumberInInventoryInProduct(int context,
    String aNumberInInventory) {
    return ((Product) registry.getValue(context))
      .setNumberInInventory(aNumberInInventory);
  }

  public boolean setNumberToKeepInvInProduct(int context,
    String aNumberToKeepInv) {
    return ((Product) registry.getValue(context))
      .setNumberToKeepInv(aNumberToKeepInv);
  }

  public String getOurCodeFromProduct(int context) {
    return ((Product) registry.getValue(context)).getOurCode();
  }

  public String getDescriptionFromProduct(int context) {
    return ((Product) registry.getValue(context)).getDescription();
  }

  public String getPictureFromProduct(int context) {
    return ((Product) registry.getValue(context)).getPicture();
  }

  public String getOurListPricePerunitFromProduct(int context) {
    return ((Product) registry.getValue(context)).getOurListPricePerunit();
  }

  public String getNumberInInventoryFromProduct(int context) {
    return ((Product) registry.getValue(context)).getNumberInInventory();
  }

  public String getNumberToKeepInvFromProduct(int context) {
    return ((Product) registry.getValue(context)).getNumberToKeepInv();
  }

  public int getProductCategoryFromProduct(int context) {
    return registry.getKey(((Product) registry.getValue(context))
      .getProductCategory());
  }

  public JSONObject getProductCategoryFromProductJSON(int context)
    throws JSONException {
    return ((Product) registry.getValue(context)).getProductCategory()
      .getAttributes();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getClientOrderLineItemsFromProduct(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (ClientOrderLineItem obj : ((Product) registry.getValue(context))
      .getClientOrderLineItems()) {
      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 getProductSourcesFromProduct(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (ProductSource obj : ((Product) registry.getValue(context))
      .getProductSources()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addClientOrderLineItemToProduct(int context,
    String aNumberOrdered, String aPricePerUnitCharged, int aOrderFromClient,
    int aProduct) throws Exception {
    return registry.getKey(((Product) registry.getValue(context))
      .addClientOrderLineItem(aNumberOrdered, aPricePerUnitCharged,
        (OrderFromClient) registry.getValue(aOrderFromClient),
        (Product) registry.getValue(aProduct)));
  }

  public JSONObject addClientOrderLineItemToProductJSON(int context,
    String aNumberOrdered, String aPricePerUnitCharged, int aOrderFromClient,
    int aProduct) throws JSONException, Exception {
    return ((Product) registry.getValue(context)).addClientOrderLineItem(
      aNumberOrdered, aPricePerUnitCharged,
      (OrderFromClient) registry.getValue(aOrderFromClient),
      (Product) registry.getValue(aProduct)).getAttributes();
  }

  public int addClientOrderLineItemToProductOnly(int context,
    int aClientOrderLineItem) throws Exception {
    return registry.getKey(((Product) registry.getValue(context))
      .addClientOrderLineItem((ClientOrderLineItem) registry
        .getValue(aClientOrderLineItem)));
  }

  public JSONObject addClientOrderLineItemToProductOnlyJSON(int context,
    int aClientOrderLineItem) throws JSONException, Exception {
    return ((Product) registry.getValue(context)).addClientOrderLineItem(
      (ClientOrderLineItem) registry.getValue(aClientOrderLineItem))
      .getAttributes();
  }

  public int addProductSourceToProduct(int context, String aSupplierCode,
    String aAdvertisedCostPerUnit, int aProduct, int aSupplier)
    throws Exception {
    return registry.getKey(((Product) registry.getValue(context))
      .addProductSource(aSupplierCode, aAdvertisedCostPerUnit,
        (Product) registry.getValue(aProduct), (Supplier) registry
          .getValue(aSupplier)));
  }

  public JSONObject addProductSourceToProductJSON(int context,
    String aSupplierCode, String aAdvertisedCostPerUnit, int aProduct,
    int aSupplier) throws JSONException, Exception {
    return ((Product) registry.getValue(context)).addProductSource(
      aSupplierCode, aAdvertisedCostPerUnit,
      (Product) registry.getValue(aProduct),
      (Supplier) registry.getValue(aSupplier)).getAttributes();
  }

  public int addProductSourceToProductOnly(int context, int aProductSource)
    throws Exception {
    return registry.getKey(((Product) registry.getValue(context))
      .addProductSource((ProductSource) registry.getValue(aProductSource)));
  }

  public JSONObject addProductSourceToProductOnlyJSON(int context,
    int aProductSource) throws JSONException, Exception {
    return ((Product) registry.getValue(context)).addProductSource(
      (ProductSource) registry.getValue(aProductSource)).getAttributes();
  }

  public void setProductCategoryInProduct(int context, int aProductCategory)
    throws Exception {
    ((Product) registry.getValue(context))
      .setProductCategory((ProductCategory) registry.getValue(aProductCategory));
  }

  public void deleteProduct(int context) {
    ((Product) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteClientOrderLineItemFromProduct(int context,
    int aClientOrderLineItem) {
    ((Product) registry.getValue(context))
      .deleteClientOrderLineItem((ClientOrderLineItem) registry
        .getValue(aClientOrderLineItem));
  }

  public void deleteProductSourceFromProduct(int context, int aProductSource) {
    ((Product) registry.getValue(context))
      .deleteProductSource((ProductSource) registry.getValue(aProductSource));
  }

  public JSONObject getAttributesOfProduct(int context) throws JSONException {
    return ((Product) registry.getValue(context)).getAttributes();
  }

  public int constructSalesPerson(String aName) {
    return registry.add(new SalesPerson(aName));
  }

  public JSONObject constructSalesPersonJSON(String aName) throws JSONException {
    SalesPerson contextObj = new SalesPerson(aName);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setNameInSalesPerson(int context, String aName) {
    return ((SalesPerson) registry.getValue(context)).setName(aName);
  }

  public String getNameFromSalesPerson(int context) {
    return ((SalesPerson) registry.getValue(context)).getName();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getOrderFromClientsFromSalesPerson(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (OrderFromClient obj : ((SalesPerson) registry.getValue(context))
      .getOrderFromClients()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addOrderFromClientToSalesPerson(int context,
    String aOurOrderNumber, String aDatePlaced, String aClientsPurchaseOrder,
    String aCreditCardToCharge, int aClient) throws Exception {
    return registry.getKey(((SalesPerson) registry.getValue(context))
      .addOrderFromClient(aOurOrderNumber, aDatePlaced, aClientsPurchaseOrder,
        aCreditCardToCharge, (Client) registry.getValue(aClient)));
  }

  public JSONObject addOrderFromClientToSalesPersonJSON(int context,
    String aOurOrderNumber, String aDatePlaced, String aClientsPurchaseOrder,
    String aCreditCardToCharge, int aClient) throws JSONException, Exception {
    return ((SalesPerson) registry.getValue(context)).addOrderFromClient(
      aOurOrderNumber, aDatePlaced, aClientsPurchaseOrder, aCreditCardToCharge,
      (Client) registry.getValue(aClient)).getAttributes();
  }

  public int addOrderFromClientToSalesPersonOnly(int context,
    int aOrderFromClient) throws Exception {
    return registry
      .getKey(((SalesPerson) registry.getValue(context))
        .addOrderFromClient((OrderFromClient) registry
          .getValue(aOrderFromClient)));
  }

  public JSONObject addOrderFromClientToSalesPersonOnlyJSON(int context,
    int aOrderFromClient) throws JSONException, Exception {
    return ((SalesPerson) registry.getValue(context)).addOrderFromClient(
      (OrderFromClient) registry.getValue(aOrderFromClient)).getAttributes();
  }

  public void deleteSalesPerson(int context) {
    ((SalesPerson) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteOrderFromClientFromSalesPerson(int context,
    int aOrderFromClient) {
    ((SalesPerson) registry.getValue(context))
      .deleteOrderFromClient((OrderFromClient) registry
        .getValue(aOrderFromClient));
  }

  public JSONObject getAttributesOfSalesPerson(int context)
    throws JSONException {
    return ((SalesPerson) registry.getValue(context)).getAttributes();
  }

  public int constructClientOrderLineItem(String aNumberOrdered,
    String aPricePerUnitCharged, int aOrderFromClient, int aProduct) {
    return registry.add(new ClientOrderLineItem(aNumberOrdered,
      aPricePerUnitCharged, (OrderFromClient) registry
        .getValue(aOrderFromClient), (Product) registry.getValue(aProduct)));
  }

  public JSONObject constructClientOrderLineItemJSON(String aNumberOrdered,
    String aPricePerUnitCharged, int aOrderFromClient, int aProduct)
    throws JSONException {
    ClientOrderLineItem contextObj =
      new ClientOrderLineItem(aNumberOrdered, aPricePerUnitCharged,
        (OrderFromClient) registry.getValue(aOrderFromClient),
        (Product) registry.getValue(aProduct));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setNumberOrderedInClientOrderLineItem(int context,
    String aNumberOrdered) {
    return ((ClientOrderLineItem) registry.getValue(context))
      .setNumberOrdered(aNumberOrdered);
  }

  public boolean setPricePerUnitChargedInClientOrderLineItem(int context,
    String aPricePerUnitCharged) {
    return ((ClientOrderLineItem) registry.getValue(context))
      .setPricePerUnitCharged(aPricePerUnitCharged);
  }

  public String getNumberOrderedFromClientOrderLineItem(int context) {
    return ((ClientOrderLineItem) registry.getValue(context))
      .getNumberOrdered();
  }

  public String getPricePerUnitChargedFromClientOrderLineItem(int context) {
    return ((ClientOrderLineItem) registry.getValue(context))
      .getPricePerUnitCharged();
  }

  public int getOrderFromClientFromClientOrderLineItem(int context) {
    return registry.getKey(((ClientOrderLineItem) registry.getValue(context))
      .getOrderFromClient());
  }

  public JSONObject getOrderFromClientFromClientOrderLineItemJSON(int context)
    throws JSONException {
    return ((ClientOrderLineItem) registry.getValue(context))
      .getOrderFromClient().getAttributes();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getShipmentLineItemsFromClientOrderLineItem(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (ShipmentLineItem obj : ((ClientOrderLineItem) registry
      .getValue(context)).getShipmentLineItems()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int getProductFromClientOrderLineItem(int context) {
    return registry.getKey(((ClientOrderLineItem) registry.getValue(context))
      .getProduct());
  }

  public JSONObject getProductFromClientOrderLineItemJSON(int context)
    throws JSONException {
    return ((ClientOrderLineItem) registry.getValue(context)).getProduct()
      .getAttributes();
  }

  public int addShipmentLineItemToClientOrderLineItem(int context,
    String aNumShipped, int aClientOrderLineItem, int aShipmentToClient)
    throws Exception {
    return registry.getKey(((ClientOrderLineItem) registry.getValue(context))
      .addShipmentLineItem(aNumShipped, (ClientOrderLineItem) registry
        .getValue(aClientOrderLineItem), (ShipmentToClient) registry
        .getValue(aShipmentToClient)));
  }

  public JSONObject addShipmentLineItemToClientOrderLineItemJSON(int context,
    String aNumShipped, int aClientOrderLineItem, int aShipmentToClient)
    throws JSONException, Exception {
    return ((ClientOrderLineItem) registry.getValue(context))
      .addShipmentLineItem(aNumShipped,
        (ClientOrderLineItem) registry.getValue(aClientOrderLineItem),
        (ShipmentToClient) registry.getValue(aShipmentToClient))
      .getAttributes();
  }

  public int addShipmentLineItemToClientOrderLineItemOnly(int context,
    int aShipmentLineItem) throws Exception {
    return registry.getKey(((ClientOrderLineItem) registry.getValue(context))
      .addShipmentLineItem((ShipmentLineItem) registry
        .getValue(aShipmentLineItem)));
  }

  public JSONObject addShipmentLineItemToClientOrderLineItemOnlyJSON(
    int context, int aShipmentLineItem) throws JSONException, Exception {
    return ((ClientOrderLineItem) registry.getValue(context))
      .addShipmentLineItem(
        (ShipmentLineItem) registry.getValue(aShipmentLineItem))
      .getAttributes();
  }

  public void setOrderFromClientInClientOrderLineItem(int context,
    int aOrderFromClient) throws Exception {
    ((ClientOrderLineItem) registry.getValue(context))
      .setOrderFromClient((OrderFromClient) registry.getValue(aOrderFromClient));
  }

  public void setProductInClientOrderLineItem(int context, int aProduct)
    throws Exception {
    ((ClientOrderLineItem) registry.getValue(context))
      .setProduct((Product) registry.getValue(aProduct));
  }

  public void deleteClientOrderLineItem(int context) {
    ((ClientOrderLineItem) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteShipmentLineItemFromClientOrderLineItem(int context,
    int aShipmentLineItem) {
    ((ClientOrderLineItem) registry.getValue(context))
      .deleteShipmentLineItem((ShipmentLineItem) registry
        .getValue(aShipmentLineItem));
  }

  public JSONObject getAttributesOfClientOrderLineItem(int context)
    throws JSONException {
    return ((ClientOrderLineItem) registry.getValue(context)).getAttributes();
  }

  public int constructShipmentLineItem(String aNumShipped,
    int aClientOrderLineItem, int aShipmentToClient) {
    return registry.add(new ShipmentLineItem(aNumShipped,
      (ClientOrderLineItem) registry.getValue(aClientOrderLineItem),
      (ShipmentToClient) registry.getValue(aShipmentToClient)));
  }

  public JSONObject constructShipmentLineItemJSON(String aNumShipped,
    int aClientOrderLineItem, int aShipmentToClient) throws JSONException {
    ShipmentLineItem contextObj =
      new ShipmentLineItem(aNumShipped, (ClientOrderLineItem) registry
        .getValue(aClientOrderLineItem), (ShipmentToClient) registry
        .getValue(aShipmentToClient));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setNumShippedInShipmentLineItem(int context, String aNumShipped) {
    return ((ShipmentLineItem) registry.getValue(context))
      .setNumShipped(aNumShipped);
  }

  public String getNumShippedFromShipmentLineItem(int context) {
    return ((ShipmentLineItem) registry.getValue(context)).getNumShipped();
  }

  public int getClientOrderLineItemFromShipmentLineItem(int context) {
    return registry.getKey(((ShipmentLineItem) registry.getValue(context))
      .getClientOrderLineItem());
  }

  public JSONObject getClientOrderLineItemFromShipmentLineItemJSON(int context)
    throws JSONException {
    return ((ShipmentLineItem) registry.getValue(context))
      .getClientOrderLineItem().getAttributes();
  }

  public int getShipmentToClientFromShipmentLineItem(int context) {
    return registry.getKey(((ShipmentLineItem) registry.getValue(context))
      .getShipmentToClient());
  }

  public JSONObject getShipmentToClientFromShipmentLineItemJSON(int context)
    throws JSONException {
    return ((ShipmentLineItem) registry.getValue(context))
      .getShipmentToClient().getAttributes();
  }

  public void setClientOrderLineItemInShipmentLineItem(int context,
    int aClientOrderLineItem) throws Exception {
    ((ShipmentLineItem) registry.getValue(context))
      .setClientOrderLineItem((ClientOrderLineItem) registry
        .getValue(aClientOrderLineItem));
  }

  public void setShipmentToClientInShipmentLineItem(int context,
    int aShipmentToClient) throws Exception {
    ((ShipmentLineItem) registry.getValue(context))
      .setShipmentToClient((ShipmentToClient) registry
        .getValue(aShipmentToClient));
  }

  public void deleteShipmentLineItem(int context) {
    ((ShipmentLineItem) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfShipmentLineItem(int context)
    throws JSONException {
    return ((ShipmentLineItem) registry.getValue(context)).getAttributes();
  }

  public int constructShipmentToClient(String aDateShipped,
    String aInvoiceNumber, String aTotalPriceOfShipment, String aAmountPaid,
    int aClient) {
    return registry.add(new ShipmentToClient(aDateShipped, aInvoiceNumber,
      aTotalPriceOfShipment, aAmountPaid, (Client) registry.getValue(aClient)));
  }

  public JSONObject constructShipmentToClientJSON(String aDateShipped,
    String aInvoiceNumber, String aTotalPriceOfShipment, String aAmountPaid,
    int aClient) throws JSONException {
    ShipmentToClient contextObj =
      new ShipmentToClient(aDateShipped, aInvoiceNumber, aTotalPriceOfShipment,
        aAmountPaid, (Client) registry.getValue(aClient));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setDateShippedInShipmentToClient(int context,
    String aDateShipped) {
    return ((ShipmentToClient) registry.getValue(context))
      .setDateShipped(aDateShipped);
  }

  public boolean setInvoiceNumberInShipmentToClient(int context,
    String aInvoiceNumber) {
    return ((ShipmentToClient) registry.getValue(context))
      .setInvoiceNumber(aInvoiceNumber);
  }

  public boolean setTotalPriceOfShipmentInShipmentToClient(int context,
    String aTotalPriceOfShipment) {
    return ((ShipmentToClient) registry.getValue(context))
      .setTotalPriceOfShipment(aTotalPriceOfShipment);
  }

  public boolean setAmountPaidInShipmentToClient(int context, String aAmountPaid) {
    return ((ShipmentToClient) registry.getValue(context))
      .setAmountPaid(aAmountPaid);
  }

  public String getDateShippedFromShipmentToClient(int context) {
    return ((ShipmentToClient) registry.getValue(context)).getDateShipped();
  }

  public String getInvoiceNumberFromShipmentToClient(int context) {
    return ((ShipmentToClient) registry.getValue(context)).getInvoiceNumber();
  }

  public String getTotalPriceOfShipmentFromShipmentToClient(int context) {
    return ((ShipmentToClient) registry.getValue(context))
      .getTotalPriceOfShipment();
  }

  public String getAmountPaidFromShipmentToClient(int context) {
    return ((ShipmentToClient) registry.getValue(context)).getAmountPaid();
  }

  public int getClientFromShipmentToClient(int context) {
    return registry.getKey(((ShipmentToClient) registry.getValue(context))
      .getClient());
  }

  public JSONObject getClientFromShipmentToClientJSON(int context)
    throws JSONException {
    return ((ShipmentToClient) registry.getValue(context)).getClient()
      .getAttributes();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getShipmentLineItemsFromShipmentToClient(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (ShipmentLineItem obj : ((ShipmentToClient) registry.getValue(context))
      .getShipmentLineItems()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addShipmentLineItemToShipmentToClient(int context,
    String aNumShipped, int aClientOrderLineItem, int aShipmentToClient)
    throws Exception {
    return registry.getKey(((ShipmentToClient) registry.getValue(context))
      .addShipmentLineItem(aNumShipped, (ClientOrderLineItem) registry
        .getValue(aClientOrderLineItem), (ShipmentToClient) registry
        .getValue(aShipmentToClient)));
  }

  public JSONObject addShipmentLineItemToShipmentToClientJSON(int context,
    String aNumShipped, int aClientOrderLineItem, int aShipmentToClient)
    throws JSONException, Exception {
    return ((ShipmentToClient) registry.getValue(context)).addShipmentLineItem(
      aNumShipped,
      (ClientOrderLineItem) registry.getValue(aClientOrderLineItem),
      (ShipmentToClient) registry.getValue(aShipmentToClient)).getAttributes();
  }

  public int addShipmentLineItemToShipmentToClientOnly(int context,
    int aShipmentLineItem) throws Exception {
    return registry.getKey(((ShipmentToClient) registry.getValue(context))
      .addShipmentLineItem((ShipmentLineItem) registry
        .getValue(aShipmentLineItem)));
  }

  public JSONObject addShipmentLineItemToShipmentToClientOnlyJSON(int context,
    int aShipmentLineItem) throws JSONException, Exception {
    return ((ShipmentToClient) registry.getValue(context)).addShipmentLineItem(
      (ShipmentLineItem) registry.getValue(aShipmentLineItem)).getAttributes();
  }

  public void setClientInShipmentToClient(int context, int aClient)
    throws Exception {
    ((ShipmentToClient) registry.getValue(context)).setClient((Client) registry
      .getValue(aClient));
  }

  public void deleteShipmentToClient(int context) {
    ((ShipmentToClient) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteShipmentLineItemFromShipmentToClient(int context,
    int aShipmentLineItem) {
    ((ShipmentToClient) registry.getValue(context))
      .deleteShipmentLineItem((ShipmentLineItem) registry
        .getValue(aShipmentLineItem));
  }

  public JSONObject getAttributesOfShipmentToClient(int context)
    throws JSONException {
    return ((ShipmentToClient) registry.getValue(context)).getAttributes();
  }

  public int constructProductCategory(String aName) {
    return registry.add(new ProductCategory(aName));
  }

  public JSONObject constructProductCategoryJSON(String aName)
    throws JSONException {
    ProductCategory contextObj = new ProductCategory(aName);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setNameInProductCategory(int context, String aName) {
    return ((ProductCategory) registry.getValue(context)).setName(aName);
  }

  public String getNameFromProductCategory(int context) {
    return ((ProductCategory) registry.getValue(context)).getName();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getProductsFromProductCategory(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (Product obj : ((ProductCategory) registry.getValue(context))
      .getProducts()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addProductToProductCategory(int context, String aOurCode,
    String aDescription, String aPicture, String aOurListPricePerunit,
    String aNumberInInventory, String aNumberToKeepInv, int aProductCategory)
    throws Exception {
    return registry.getKey(((ProductCategory) registry.getValue(context))
      .addProduct(aOurCode, aDescription, aPicture, aOurListPricePerunit,
        aNumberInInventory, aNumberToKeepInv, (ProductCategory) registry
          .getValue(aProductCategory)));
  }

  public JSONObject addProductToProductCategoryJSON(int context,
    String aOurCode, String aDescription, String aPicture,
    String aOurListPricePerunit, String aNumberInInventory,
    String aNumberToKeepInv, int aProductCategory) throws JSONException,
    Exception {
    return ((ProductCategory) registry.getValue(context)).addProduct(aOurCode,
      aDescription, aPicture, aOurListPricePerunit, aNumberInInventory,
      aNumberToKeepInv, (ProductCategory) registry.getValue(aProductCategory))
      .getAttributes();
  }

  public int addProductToProductCategoryOnly(int context, int aProduct)
    throws Exception {
    return registry.getKey(((ProductCategory) registry.getValue(context))
      .addProduct((Product) registry.getValue(aProduct)));
  }

  public JSONObject addProductToProductCategoryOnlyJSON(int context,
    int aProduct) throws JSONException, Exception {
    return ((ProductCategory) registry.getValue(context)).addProduct(
      (Product) registry.getValue(aProduct)).getAttributes();
  }

  public void deleteProductCategory(int context) {
    ((ProductCategory) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteProductFromProductCategory(int context, int aProduct) {
    ((ProductCategory) registry.getValue(context))
      .deleteProduct((Product) registry.getValue(aProduct));
  }

  public JSONObject getAttributesOfProductCategory(int context)
    throws JSONException {
    return ((ProductCategory) registry.getValue(context)).getAttributes();
  }

  public int constructReceivedLineItem(String aNumberReceived,
    String aActualCostPerUnit, int aReceivedDelivery, int aSupplierOrderLineItem) {
    return registry.add(new ReceivedLineItem(aNumberReceived,
      aActualCostPerUnit, (ReceivedDelivery) registry
        .getValue(aReceivedDelivery), (SupplierOrderLineItem) registry
        .getValue(aSupplierOrderLineItem)));
  }

  public JSONObject constructReceivedLineItemJSON(String aNumberReceived,
    String aActualCostPerUnit, int aReceivedDelivery, int aSupplierOrderLineItem)
    throws JSONException {
    ReceivedLineItem contextObj =
      new ReceivedLineItem(aNumberReceived, aActualCostPerUnit,
        (ReceivedDelivery) registry.getValue(aReceivedDelivery),
        (SupplierOrderLineItem) registry.getValue(aSupplierOrderLineItem));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setNumberReceivedInReceivedLineItem(int context,
    String aNumberReceived) {
    return ((ReceivedLineItem) registry.getValue(context))
      .setNumberReceived(aNumberReceived);
  }

  public boolean setActualCostPerUnitInReceivedLineItem(int context,
    String aActualCostPerUnit) {
    return ((ReceivedLineItem) registry.getValue(context))
      .setActualCostPerUnit(aActualCostPerUnit);
  }

  public String getNumberReceivedFromReceivedLineItem(int context) {
    return ((ReceivedLineItem) registry.getValue(context)).getNumberReceived();
  }

  public String getActualCostPerUnitFromReceivedLineItem(int context) {
    return ((ReceivedLineItem) registry.getValue(context))
      .getActualCostPerUnit();
  }

  public int getReceivedDeliveryFromReceivedLineItem(int context) {
    return registry.getKey(((ReceivedLineItem) registry.getValue(context))
      .getReceivedDelivery());
  }

  public JSONObject getReceivedDeliveryFromReceivedLineItemJSON(int context)
    throws JSONException {
    return ((ReceivedLineItem) registry.getValue(context))
      .getReceivedDelivery().getAttributes();
  }

  public int getSupplierOrderLineItemFromReceivedLineItem(int context) {
    return registry.getKey(((ReceivedLineItem) registry.getValue(context))
      .getSupplierOrderLineItem());
  }

  public JSONObject getSupplierOrderLineItemFromReceivedLineItemJSON(int context)
    throws JSONException {
    return ((ReceivedLineItem) registry.getValue(context))
      .getSupplierOrderLineItem().getAttributes();
  }

  public void setReceivedDeliveryInReceivedLineItem(int context,
    int aReceivedDelivery) throws Exception {
    ((ReceivedLineItem) registry.getValue(context))
      .setReceivedDelivery((ReceivedDelivery) registry
        .getValue(aReceivedDelivery));
  }

  public void setSupplierOrderLineItemInReceivedLineItem(int context,
    int aSupplierOrderLineItem) throws Exception {
    ((ReceivedLineItem) registry.getValue(context))
      .setSupplierOrderLineItem((SupplierOrderLineItem) registry
        .getValue(aSupplierOrderLineItem));
  }

  public void deleteReceivedLineItem(int context) {
    ((ReceivedLineItem) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public JSONObject getAttributesOfReceivedLineItem(int context)
    throws JSONException {
    return ((ReceivedLineItem) registry.getValue(context)).getAttributes();
  }

  public int constructSupplierOrderLineItem(String aNumberOrdered,
    String aDateExpected, int aProductSource, int aOrderToSupplier) {
    return registry.add(new SupplierOrderLineItem(aNumberOrdered,
      aDateExpected, (ProductSource) registry.getValue(aProductSource),
      (OrderToSupplier) registry.getValue(aOrderToSupplier)));
  }

  public JSONObject constructSupplierOrderLineItemJSON(String aNumberOrdered,
    String aDateExpected, int aProductSource, int aOrderToSupplier)
    throws JSONException {
    SupplierOrderLineItem contextObj =
      new SupplierOrderLineItem(aNumberOrdered, aDateExpected,
        (ProductSource) registry.getValue(aProductSource),
        (OrderToSupplier) registry.getValue(aOrderToSupplier));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setNumberOrderedInSupplierOrderLineItem(int context,
    String aNumberOrdered) {
    return ((SupplierOrderLineItem) registry.getValue(context))
      .setNumberOrdered(aNumberOrdered);
  }

  public boolean setDateExpectedInSupplierOrderLineItem(int context,
    String aDateExpected) {
    return ((SupplierOrderLineItem) registry.getValue(context))
      .setDateExpected(aDateExpected);
  }

  public String getNumberOrderedFromSupplierOrderLineItem(int context) {
    return ((SupplierOrderLineItem) registry.getValue(context))
      .getNumberOrdered();
  }

  public String getDateExpectedFromSupplierOrderLineItem(int context) {
    return ((SupplierOrderLineItem) registry.getValue(context))
      .getDateExpected();
  }

  public int getProductSourceFromSupplierOrderLineItem(int context) {
    return registry.getKey(((SupplierOrderLineItem) registry.getValue(context))
      .getProductSource());
  }

  public JSONObject getProductSourceFromSupplierOrderLineItemJSON(int context)
    throws JSONException {
    return ((SupplierOrderLineItem) registry.getValue(context))
      .getProductSource().getAttributes();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getReceivedLineItemsFromSupplierOrderLineItem(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (ReceivedLineItem obj : ((SupplierOrderLineItem) registry
      .getValue(context)).getReceivedLineItems()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int getOrderToSupplierFromSupplierOrderLineItem(int context) {
    return registry.getKey(((SupplierOrderLineItem) registry.getValue(context))
      .getOrderToSupplier());
  }

  public JSONObject getOrderToSupplierFromSupplierOrderLineItemJSON(int context)
    throws JSONException {
    return ((SupplierOrderLineItem) registry.getValue(context))
      .getOrderToSupplier().getAttributes();
  }

  public int addReceivedLineItemToSupplierOrderLineItem(int context,
    String aNumberReceived, String aActualCostPerUnit, int aReceivedDelivery,
    int aSupplierOrderLineItem) throws Exception {
    return registry.getKey(((SupplierOrderLineItem) registry.getValue(context))
      .addReceivedLineItem(aNumberReceived, aActualCostPerUnit,
        (ReceivedDelivery) registry.getValue(aReceivedDelivery),
        (SupplierOrderLineItem) registry.getValue(aSupplierOrderLineItem)));
  }

  public JSONObject addReceivedLineItemToSupplierOrderLineItemJSON(int context,
    String aNumberReceived, String aActualCostPerUnit, int aReceivedDelivery,
    int aSupplierOrderLineItem) throws JSONException, Exception {
    return ((SupplierOrderLineItem) registry.getValue(context))
      .addReceivedLineItem(aNumberReceived, aActualCostPerUnit,
        (ReceivedDelivery) registry.getValue(aReceivedDelivery),
        (SupplierOrderLineItem) registry.getValue(aSupplierOrderLineItem))
      .getAttributes();
  }

  public int addReceivedLineItemToSupplierOrderLineItemOnly(int context,
    int aReceivedLineItem) throws Exception {
    return registry.getKey(((SupplierOrderLineItem) registry.getValue(context))
      .addReceivedLineItem((ReceivedLineItem) registry
        .getValue(aReceivedLineItem)));
  }

  public JSONObject addReceivedLineItemToSupplierOrderLineItemOnlyJSON(
    int context, int aReceivedLineItem) throws JSONException, Exception {
    return ((SupplierOrderLineItem) registry.getValue(context))
      .addReceivedLineItem(
        (ReceivedLineItem) registry.getValue(aReceivedLineItem))
      .getAttributes();
  }

  public void setProductSourceInSupplierOrderLineItem(int context,
    int aProductSource) throws Exception {
    ((SupplierOrderLineItem) registry.getValue(context))
      .setProductSource((ProductSource) registry.getValue(aProductSource));
  }

  public void setOrderToSupplierInSupplierOrderLineItem(int context,
    int aOrderToSupplier) throws Exception {
    ((SupplierOrderLineItem) registry.getValue(context))
      .setOrderToSupplier((OrderToSupplier) registry.getValue(aOrderToSupplier));
  }

  public void deleteSupplierOrderLineItem(int context) {
    ((SupplierOrderLineItem) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteReceivedLineItemFromSupplierOrderLineItem(int context,
    int aReceivedLineItem) {
    ((SupplierOrderLineItem) registry.getValue(context))
      .deleteReceivedLineItem((ReceivedLineItem) registry
        .getValue(aReceivedLineItem));
  }

  public JSONObject getAttributesOfSupplierOrderLineItem(int context)
    throws JSONException {
    return ((SupplierOrderLineItem) registry.getValue(context)).getAttributes();
  }

  public int constructReceivedDelivery(String aNumberReceived,
    String aActualCostPerUnit, int aSupplier) {
    return registry.add(new ReceivedDelivery(aNumberReceived,
      aActualCostPerUnit, (Supplier) registry.getValue(aSupplier)));
  }

  public JSONObject constructReceivedDeliveryJSON(String aNumberReceived,
    String aActualCostPerUnit, int aSupplier) throws JSONException {
    ReceivedDelivery contextObj =
      new ReceivedDelivery(aNumberReceived, aActualCostPerUnit,
        (Supplier) registry.getValue(aSupplier));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setNumberReceivedInReceivedDelivery(int context,
    String aNumberReceived) {
    return ((ReceivedDelivery) registry.getValue(context))
      .setNumberReceived(aNumberReceived);
  }

  public boolean setActualCostPerUnitInReceivedDelivery(int context,
    String aActualCostPerUnit) {
    return ((ReceivedDelivery) registry.getValue(context))
      .setActualCostPerUnit(aActualCostPerUnit);
  }

  public String getNumberReceivedFromReceivedDelivery(int context) {
    return ((ReceivedDelivery) registry.getValue(context)).getNumberReceived();
  }

  public String getActualCostPerUnitFromReceivedDelivery(int context) {
    return ((ReceivedDelivery) registry.getValue(context))
      .getActualCostPerUnit();
  }

  public int getSupplierFromReceivedDelivery(int context) {
    return registry.getKey(((ReceivedDelivery) registry.getValue(context))
      .getSupplier());
  }

  public JSONObject getSupplierFromReceivedDeliveryJSON(int context)
    throws JSONException {
    return ((ReceivedDelivery) registry.getValue(context)).getSupplier()
      .getAttributes();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getReceivedLineItemsFromReceivedDelivery(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (ReceivedLineItem obj : ((ReceivedDelivery) registry.getValue(context))
      .getReceivedLineItems()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addReceivedLineItemToReceivedDelivery(int context,
    String aNumberReceived, String aActualCostPerUnit, int aReceivedDelivery,
    int aSupplierOrderLineItem) throws Exception {
    return registry.getKey(((ReceivedDelivery) registry.getValue(context))
      .addReceivedLineItem(aNumberReceived, aActualCostPerUnit,
        (ReceivedDelivery) registry.getValue(aReceivedDelivery),
        (SupplierOrderLineItem) registry.getValue(aSupplierOrderLineItem)));
  }

  public JSONObject addReceivedLineItemToReceivedDeliveryJSON(int context,
    String aNumberReceived, String aActualCostPerUnit, int aReceivedDelivery,
    int aSupplierOrderLineItem) throws JSONException, Exception {
    return ((ReceivedDelivery) registry.getValue(context)).addReceivedLineItem(
      aNumberReceived, aActualCostPerUnit,
      (ReceivedDelivery) registry.getValue(aReceivedDelivery),
      (SupplierOrderLineItem) registry.getValue(aSupplierOrderLineItem))
      .getAttributes();
  }

  public int addReceivedLineItemToReceivedDeliveryOnly(int context,
    int aReceivedLineItem) throws Exception {
    return registry.getKey(((ReceivedDelivery) registry.getValue(context))
      .addReceivedLineItem((ReceivedLineItem) registry
        .getValue(aReceivedLineItem)));
  }

  public JSONObject addReceivedLineItemToReceivedDeliveryOnlyJSON(int context,
    int aReceivedLineItem) throws JSONException, Exception {
    return ((ReceivedDelivery) registry.getValue(context)).addReceivedLineItem(
      (ReceivedLineItem) registry.getValue(aReceivedLineItem)).getAttributes();
  }

  public void setSupplierInReceivedDelivery(int context, int aSupplier)
    throws Exception {
    ((ReceivedDelivery) registry.getValue(context))
      .setSupplier((Supplier) registry.getValue(aSupplier));
  }

  public void deleteReceivedDelivery(int context) {
    ((ReceivedDelivery) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteReceivedLineItemFromReceivedDelivery(int context,
    int aReceivedLineItem) {
    ((ReceivedDelivery) registry.getValue(context))
      .deleteReceivedLineItem((ReceivedLineItem) registry
        .getValue(aReceivedLineItem));
  }

  public JSONObject getAttributesOfReceivedDelivery(int context)
    throws JSONException {
    return ((ReceivedDelivery) registry.getValue(context)).getAttributes();
  }

  public int constructSupplier(String aId, String aName, String aAddress) {
    return registry.add(new Supplier(aId, aName, aAddress));
  }

  public JSONObject constructSupplierJSON(String aId, String aName,
    String aAddress) throws JSONException {
    Supplier contextObj = new Supplier(aId, aName, aAddress);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setIdInSupplier(int context, String aId) {
    return ((Supplier) registry.getValue(context)).setId(aId);
  }

  public boolean setNameInSupplier(int context, String aName) {
    return ((Supplier) registry.getValue(context)).setName(aName);
  }

  public boolean setAddressInSupplier(int context, String aAddress) {
    return ((Supplier) registry.getValue(context)).setAddress(aAddress);
  }

  public String getIdFromSupplier(int context) {
    return ((Supplier) registry.getValue(context)).getId();
  }

  public String getNameFromSupplier(int context) {
    return ((Supplier) registry.getValue(context)).getName();
  }

  public String getAddressFromSupplier(int context) {
    return ((Supplier) registry.getValue(context)).getAddress();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getProductSourcesFromSupplier(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (ProductSource obj : ((Supplier) registry.getValue(context))
      .getProductSources()) {
      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 getOrderToSuppliersFromSupplier(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (OrderToSupplier obj : ((Supplier) registry.getValue(context))
      .getOrderToSuppliers()) {
      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 getReceivedDeliverysFromSupplier(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (ReceivedDelivery obj : ((Supplier) registry.getValue(context))
      .getReceivedDeliverys()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addProductSourceToSupplier(int context, String aSupplierCode,
    String aAdvertisedCostPerUnit, int aProduct, int aSupplier)
    throws Exception {
    return registry.getKey(((Supplier) registry.getValue(context))
      .addProductSource(aSupplierCode, aAdvertisedCostPerUnit,
        (Product) registry.getValue(aProduct), (Supplier) registry
          .getValue(aSupplier)));
  }

  public JSONObject addProductSourceToSupplierJSON(int context,
    String aSupplierCode, String aAdvertisedCostPerUnit, int aProduct,
    int aSupplier) throws JSONException, Exception {
    return ((Supplier) registry.getValue(context)).addProductSource(
      aSupplierCode, aAdvertisedCostPerUnit,
      (Product) registry.getValue(aProduct),
      (Supplier) registry.getValue(aSupplier)).getAttributes();
  }

  public int addProductSourceToSupplierOnly(int context, int aProductSource)
    throws Exception {
    return registry.getKey(((Supplier) registry.getValue(context))
      .addProductSource((ProductSource) registry.getValue(aProductSource)));
  }

  public JSONObject addProductSourceToSupplierOnlyJSON(int context,
    int aProductSource) throws JSONException, Exception {
    return ((Supplier) registry.getValue(context)).addProductSource(
      (ProductSource) registry.getValue(aProductSource)).getAttributes();
  }

  public int addOrderToSupplierToSupplier(int context, String aPoNumber,
    String aDateOrdered, int aSupplier) throws Exception {
    return registry.getKey(((Supplier) registry.getValue(context))
      .addOrderToSupplier(aPoNumber, aDateOrdered, (Supplier) registry
        .getValue(aSupplier)));
  }

  public JSONObject addOrderToSupplierToSupplierJSON(int context,
    String aPoNumber, String aDateOrdered, int aSupplier) throws JSONException,
    Exception {
    return ((Supplier) registry.getValue(context)).addOrderToSupplier(
      aPoNumber, aDateOrdered, (Supplier) registry.getValue(aSupplier))
      .getAttributes();
  }

  public int addOrderToSupplierToSupplierOnly(int context, int aOrderToSupplier)
    throws Exception {
    return registry
      .getKey(((Supplier) registry.getValue(context))
        .addOrderToSupplier((OrderToSupplier) registry
          .getValue(aOrderToSupplier)));
  }

  public JSONObject addOrderToSupplierToSupplierOnlyJSON(int context,
    int aOrderToSupplier) throws JSONException, Exception {
    return ((Supplier) registry.getValue(context)).addOrderToSupplier(
      (OrderToSupplier) registry.getValue(aOrderToSupplier)).getAttributes();
  }

  public int addReceivedDeliveryToSupplier(int context, String aNumberReceived,
    String aActualCostPerUnit, int aSupplier) throws Exception {
    return registry.getKey(((Supplier) registry.getValue(context))
      .addReceivedDelivery(aNumberReceived, aActualCostPerUnit,
        (Supplier) registry.getValue(aSupplier)));
  }

  public JSONObject addReceivedDeliveryToSupplierJSON(int context,
    String aNumberReceived, String aActualCostPerUnit, int aSupplier)
    throws JSONException, Exception {
    return ((Supplier) registry.getValue(context)).addReceivedDelivery(
      aNumberReceived, aActualCostPerUnit,
      (Supplier) registry.getValue(aSupplier)).getAttributes();
  }

  public int addReceivedDeliveryToSupplierOnly(int context,
    int aReceivedDelivery) throws Exception {
    return registry.getKey(((Supplier) registry.getValue(context))
      .addReceivedDelivery((ReceivedDelivery) registry
        .getValue(aReceivedDelivery)));
  }

  public JSONObject addReceivedDeliveryToSupplierOnlyJSON(int context,
    int aReceivedDelivery) throws JSONException, Exception {
    return ((Supplier) registry.getValue(context)).addReceivedDelivery(
      (ReceivedDelivery) registry.getValue(aReceivedDelivery)).getAttributes();
  }

  public void deleteSupplier(int context) {
    ((Supplier) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteProductSourceFromSupplier(int context, int aProductSource) {
    ((Supplier) registry.getValue(context))
      .deleteProductSource((ProductSource) registry.getValue(aProductSource));
  }

  public void deleteOrderToSupplierFromSupplier(int context,
    int aOrderToSupplier) {
    ((Supplier) registry.getValue(context))
      .deleteOrderToSupplier((OrderToSupplier) registry
        .getValue(aOrderToSupplier));
  }

  public void deleteReceivedDeliveryFromSupplier(int context,
    int aReceivedDelivery) {
    ((Supplier) registry.getValue(context))
      .deleteReceivedDelivery((ReceivedDelivery) registry
        .getValue(aReceivedDelivery));
  }

  public JSONObject getAttributesOfSupplier(int context) throws JSONException {
    return ((Supplier) registry.getValue(context)).getAttributes();
  }

  public int constructOrderToSupplier(String aPoNumber, String aDateOrdered,
    int aSupplier) {
    return registry.add(new OrderToSupplier(aPoNumber, aDateOrdered,
      (Supplier) registry.getValue(aSupplier)));
  }

  public JSONObject constructOrderToSupplierJSON(String aPoNumber,
    String aDateOrdered, int aSupplier) throws JSONException {
    OrderToSupplier contextObj =
      new OrderToSupplier(aPoNumber, aDateOrdered, (Supplier) registry
        .getValue(aSupplier));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setPoNumberInOrderToSupplier(int context, String aPoNumber) {
    return ((OrderToSupplier) registry.getValue(context))
      .setPoNumber(aPoNumber);
  }

  public boolean setDateOrderedInOrderToSupplier(int context,
    String aDateOrdered) {
    return ((OrderToSupplier) registry.getValue(context))
      .setDateOrdered(aDateOrdered);
  }

  public String getPoNumberFromOrderToSupplier(int context) {
    return ((OrderToSupplier) registry.getValue(context)).getPoNumber();
  }

  public String getDateOrderedFromOrderToSupplier(int context) {
    return ((OrderToSupplier) registry.getValue(context)).getDateOrdered();
  }

  public int getSupplierFromOrderToSupplier(int context) {
    return registry.getKey(((OrderToSupplier) registry.getValue(context))
      .getSupplier());
  }

  public JSONObject getSupplierFromOrderToSupplierJSON(int context)
    throws JSONException {
    return ((OrderToSupplier) registry.getValue(context)).getSupplier()
      .getAttributes();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getSupplierOrderLineItemsFromOrderToSupplier(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (SupplierOrderLineItem obj : ((OrderToSupplier) registry
      .getValue(context)).getSupplierOrderLineItems()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addSupplierOrderLineItemToOrderToSupplier(int context,
    String aNumberOrdered, String aDateExpected, int aProductSource,
    int aOrderToSupplier) throws Exception {
    return registry.getKey(((OrderToSupplier) registry.getValue(context))
      .addSupplierOrderLineItem(aNumberOrdered, aDateExpected,
        (ProductSource) registry.getValue(aProductSource),
        (OrderToSupplier) registry.getValue(aOrderToSupplier)));
  }

  public JSONObject addSupplierOrderLineItemToOrderToSupplierJSON(int context,
    String aNumberOrdered, String aDateExpected, int aProductSource,
    int aOrderToSupplier) throws JSONException, Exception {
    return ((OrderToSupplier) registry.getValue(context))
      .addSupplierOrderLineItem(aNumberOrdered, aDateExpected,
        (ProductSource) registry.getValue(aProductSource),
        (OrderToSupplier) registry.getValue(aOrderToSupplier)).getAttributes();
  }

  public int addSupplierOrderLineItemToOrderToSupplierOnly(int context,
    int aSupplierOrderLineItem) throws Exception {
    return registry.getKey(((OrderToSupplier) registry.getValue(context))
      .addSupplierOrderLineItem((SupplierOrderLineItem) registry
        .getValue(aSupplierOrderLineItem)));
  }

  public JSONObject addSupplierOrderLineItemToOrderToSupplierOnlyJSON(
    int context, int aSupplierOrderLineItem) throws JSONException, Exception {
    return ((OrderToSupplier) registry.getValue(context))
      .addSupplierOrderLineItem(
        (SupplierOrderLineItem) registry.getValue(aSupplierOrderLineItem))
      .getAttributes();
  }

  public void setSupplierInOrderToSupplier(int context, int aSupplier)
    throws Exception {
    ((OrderToSupplier) registry.getValue(context))
      .setSupplier((Supplier) registry.getValue(aSupplier));
  }

  public void deleteOrderToSupplier(int context) {
    ((OrderToSupplier) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteSupplierOrderLineItemFromOrderToSupplier(int context,
    int aSupplierOrderLineItem) {
    ((OrderToSupplier) registry.getValue(context))
      .deleteSupplierOrderLineItem((SupplierOrderLineItem) registry
        .getValue(aSupplierOrderLineItem));
  }

  public JSONObject getAttributesOfOrderToSupplier(int context)
    throws JSONException {
    return ((OrderToSupplier) registry.getValue(context)).getAttributes();
  }

  public int constructProductSource(String aSupplierCode,
    String aAdvertisedCostPerUnit, int aProduct, int aSupplier) {
    return registry.add(new ProductSource(aSupplierCode,
      aAdvertisedCostPerUnit, (Product) registry.getValue(aProduct),
      (Supplier) registry.getValue(aSupplier)));
  }

  public JSONObject constructProductSourceJSON(String aSupplierCode,
    String aAdvertisedCostPerUnit, int aProduct, int aSupplier)
    throws JSONException {
    ProductSource contextObj =
      new ProductSource(aSupplierCode, aAdvertisedCostPerUnit,
        (Product) registry.getValue(aProduct), (Supplier) registry
          .getValue(aSupplier));
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setSupplierCodeInProductSource(int context,
    String aSupplierCode) {
    return ((ProductSource) registry.getValue(context))
      .setSupplierCode(aSupplierCode);
  }

  public boolean setAdvertisedCostPerUnitInProductSource(int context,
    String aAdvertisedCostPerUnit) {
    return ((ProductSource) registry.getValue(context))
      .setAdvertisedCostPerUnit(aAdvertisedCostPerUnit);
  }

  public String getSupplierCodeFromProductSource(int context) {
    return ((ProductSource) registry.getValue(context)).getSupplierCode();
  }

  public String getAdvertisedCostPerUnitFromProductSource(int context) {
    return ((ProductSource) registry.getValue(context))
      .getAdvertisedCostPerUnit();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getSupplierOrderLineItemsFromProductSource(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (SupplierOrderLineItem obj : ((ProductSource) registry
      .getValue(context)).getSupplierOrderLineItems()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int getProductFromProductSource(int context) {
    return registry.getKey(((ProductSource) registry.getValue(context))
      .getProduct());
  }

  public JSONObject getProductFromProductSourceJSON(int context)
    throws JSONException {
    return ((ProductSource) registry.getValue(context)).getProduct()
      .getAttributes();
  }

  public int getSupplierFromProductSource(int context) {
    return registry.getKey(((ProductSource) registry.getValue(context))
      .getSupplier());
  }

  public JSONObject getSupplierFromProductSourceJSON(int context)
    throws JSONException {
    return ((ProductSource) registry.getValue(context)).getSupplier()
      .getAttributes();
  }

  public int addSupplierOrderLineItemToProductSource(int context,
    String aNumberOrdered, String aDateExpected, int aProductSource,
    int aOrderToSupplier) throws Exception {
    return registry.getKey(((ProductSource) registry.getValue(context))
      .addSupplierOrderLineItem(aNumberOrdered, aDateExpected,
        (ProductSource) registry.getValue(aProductSource),
        (OrderToSupplier) registry.getValue(aOrderToSupplier)));
  }

  public JSONObject addSupplierOrderLineItemToProductSourceJSON(int context,
    String aNumberOrdered, String aDateExpected, int aProductSource,
    int aOrderToSupplier) throws JSONException, Exception {
    return ((ProductSource) registry.getValue(context))
      .addSupplierOrderLineItem(aNumberOrdered, aDateExpected,
        (ProductSource) registry.getValue(aProductSource),
        (OrderToSupplier) registry.getValue(aOrderToSupplier)).getAttributes();
  }

  public int addSupplierOrderLineItemToProductSourceOnly(int context,
    int aSupplierOrderLineItem) throws Exception {
    return registry.getKey(((ProductSource) registry.getValue(context))
      .addSupplierOrderLineItem((SupplierOrderLineItem) registry
        .getValue(aSupplierOrderLineItem)));
  }

  public JSONObject addSupplierOrderLineItemToProductSourceOnlyJSON(
    int context, int aSupplierOrderLineItem) throws JSONException, Exception {
    return ((ProductSource) registry.getValue(context))
      .addSupplierOrderLineItem(
        (SupplierOrderLineItem) registry.getValue(aSupplierOrderLineItem))
      .getAttributes();
  }

  public void setProductInProductSource(int context, int aProduct)
    throws Exception {
    ((ProductSource) registry.getValue(context)).setProduct((Product) registry
      .getValue(aProduct));
  }

  public void setSupplierInProductSource(int context, int aSupplier)
    throws Exception {
    ((ProductSource) registry.getValue(context))
      .setSupplier((Supplier) registry.getValue(aSupplier));
  }

  public void deleteProductSource(int context) {
    ((ProductSource) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteSupplierOrderLineItemFromProductSource(int context,
    int aSupplierOrderLineItem) {
    ((ProductSource) registry.getValue(context))
      .deleteSupplierOrderLineItem((SupplierOrderLineItem) registry
        .getValue(aSupplierOrderLineItem));
  }

  public JSONObject getAttributesOfProductSource(int context)
    throws JSONException {
    return ((ProductSource) registry.getValue(context)).getAttributes();
  }

  public int constructClient(String aNumber, String aName, String aAddress,
    String aPhone, String aCreditLimit) {
    return registry.add(new Client(aNumber, aName, aAddress, aPhone,
      aCreditLimit));
  }

  public JSONObject constructClientJSON(String aNumber, String aName,
    String aAddress, String aPhone, String aCreditLimit) throws JSONException {
    Client contextObj =
      new Client(aNumber, aName, aAddress, aPhone, aCreditLimit);
    registry.add(contextObj);
    return contextObj.getAttributes();
  }

  public boolean setNumberInClient(int context, String aNumber) {
    return ((Client) registry.getValue(context)).setNumber(aNumber);
  }

  public boolean setNameInClient(int context, String aName) {
    return ((Client) registry.getValue(context)).setName(aName);
  }

  public boolean setAddressInClient(int context, String aAddress) {
    return ((Client) registry.getValue(context)).setAddress(aAddress);
  }

  public boolean setPhoneInClient(int context, String aPhone) {
    return ((Client) registry.getValue(context)).setPhone(aPhone);
  }

  public boolean setCreditLimitInClient(int context, String aCreditLimit) {
    return ((Client) registry.getValue(context)).setCreditLimit(aCreditLimit);
  }

  public String getNumberFromClient(int context) {
    return ((Client) registry.getValue(context)).getNumber();
  }

  public String getNameFromClient(int context) {
    return ((Client) registry.getValue(context)).getName();
  }

  public String getAddressFromClient(int context) {
    return ((Client) registry.getValue(context)).getAddress();
  }

  public String getPhoneFromClient(int context) {
    return ((Client) registry.getValue(context)).getPhone();
  }

  public String getCreditLimitFromClient(int context) {
    return ((Client) registry.getValue(context)).getCreditLimit();
  }

  /************
   * Method returns an iterator to the list of id's of the elements involved in this list.
   ***************/
  public Iterator getOrderFromClientsFromClient(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (OrderFromClient obj : ((Client) registry.getValue(context))
      .getOrderFromClients()) {
      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 getShipmentToClientsFromClient(int context) {
    ArrayList listOfIDs = new ArrayList();
    for (ShipmentToClient obj : ((Client) registry.getValue(context))
      .getShipmentToClients()) {
      listOfIDs.add(registry.getKey(obj));
    }
    return listOfIDs.iterator();
  }

  public int addOrderFromClientToClient(int context, String aOurOrderNumber,
    String aDatePlaced, String aClientsPurchaseOrder,
    String aCreditCardToCharge, int aClient) throws Exception {
    return registry.getKey(((Client) registry.getValue(context))
      .addOrderFromClient(aOurOrderNumber, aDatePlaced, aClientsPurchaseOrder,
        aCreditCardToCharge, (Client) registry.getValue(aClient)));
  }

  public JSONObject addOrderFromClientToClientJSON(int context,
    String aOurOrderNumber, String aDatePlaced, String aClientsPurchaseOrder,
    String aCreditCardToCharge, int aClient) throws JSONException, Exception {
    return ((Client) registry.getValue(context)).addOrderFromClient(
      aOurOrderNumber, aDatePlaced, aClientsPurchaseOrder, aCreditCardToCharge,
      (Client) registry.getValue(aClient)).getAttributes();
  }

  public int addOrderFromClientToClientOnly(int context, int aOrderFromClient)
    throws Exception {
    return registry
      .getKey(((Client) registry.getValue(context))
        .addOrderFromClient((OrderFromClient) registry
          .getValue(aOrderFromClient)));
  }

  public JSONObject addOrderFromClientToClientOnlyJSON(int context,
    int aOrderFromClient) throws JSONException, Exception {
    return ((Client) registry.getValue(context)).addOrderFromClient(
      (OrderFromClient) registry.getValue(aOrderFromClient)).getAttributes();
  }

  public int addShipmentToClientToClient(int context, String aDateShipped,
    String aInvoiceNumber, String aTotalPriceOfShipment, String aAmountPaid,
    int aClient) throws Exception {
    return registry.getKey(((Client) registry.getValue(context))
      .addShipmentToClient(aDateShipped, aInvoiceNumber, aTotalPriceOfShipment,
        aAmountPaid, (Client) registry.getValue(aClient)));
  }

  public JSONObject addShipmentToClientToClientJSON(int context,
    String aDateShipped, String aInvoiceNumber, String aTotalPriceOfShipment,
    String aAmountPaid, int aClient) throws JSONException, Exception {
    return ((Client) registry.getValue(context)).addShipmentToClient(
      aDateShipped, aInvoiceNumber, aTotalPriceOfShipment, aAmountPaid,
      (Client) registry.getValue(aClient)).getAttributes();
  }

  public int addShipmentToClientToClientOnly(int context, int aShipmentToClient)
    throws Exception {
    return registry.getKey(((Client) registry.getValue(context))
      .addShipmentToClient((ShipmentToClient) registry
        .getValue(aShipmentToClient)));
  }

  public JSONObject addShipmentToClientToClientOnlyJSON(int context,
    int aShipmentToClient) throws JSONException, Exception {
    return ((Client) registry.getValue(context)).addShipmentToClient(
      (ShipmentToClient) registry.getValue(aShipmentToClient)).getAttributes();
  }

  public void deleteClient(int context) {
    ((Client) registry.getValue(context)).delete();
    registry.removeObj(context);
  }

  public void deleteOrderFromClientFromClient(int context, int aOrderFromClient) {
    ((Client) registry.getValue(context))
      .deleteOrderFromClient((OrderFromClient) registry
        .getValue(aOrderFromClient));
  }

  public void deleteShipmentToClientFromClient(int context,
    int aShipmentToClient) {
    ((Client) registry.getValue(context))
      .deleteShipmentToClient((ShipmentToClient) registry
        .getValue(aShipmentToClient));
  }

  public JSONObject getAttributesOfClient(int context) throws JSONException {
    return ((Client) registry.getValue(context)).getAttributes();
  }
}