/*This code was generated using the UMPLE modeling language!*/ package InventoryManagement; import java.sql.Time; import java.sql.Date; import java.util.ArrayList; import java.util.Iterator; import InventoryManagement.json.*; import InventoryManagement.core.*; public class InventoryManagementFacade { // Singleton instance. private static InventoryManagementFacade theInstance; //System registry. InventoryManagementRegistry registry = InventoryManagementRegistry.getInstance(); /** * Dummy constructor */ private InventoryManagementFacade() { } /** * Returns the only instance of the Facade. * * @return */ public static InventoryManagementFacade getInstance() { if (theInstance == null) theInstance = new InventoryManagementFacade(); return theInstance; } 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 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 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 constructProduct(String aOurCode, String aDescription, String aPicture, String aOurListPricePerunit, String aNumberInInventory, String aNumberToKeepInv) { return registry.add(new Product(aOurCode, aDescription, aPicture, aOurListPricePerunit, aNumberInInventory, aNumberToKeepInv)); } public JSONObject constructProductJSON(String aOurCode, String aDescription, String aPicture, String aOurListPricePerunit, String aNumberInInventory, String aNumberToKeepInv) throws JSONException { Product contextObj = new Product(aOurCode, aDescription, aPicture, aOurListPricePerunit, aNumberInInventory, aNumberToKeepInv); 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(); } /************ * 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 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 deleteProduct(int context) { ((Product) registry.getValue(context)).delete(); registry.removeObj(context); } 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 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 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 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(); } }