/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/31 09:37:17*/ /*This class drives: ShipmentLineItem*/ package ClientOrder.core; import java.util.*; import ClientOrder.*; import ClientOrder.json.*; public class ShipmentToClient { //Class datatypes private String dateShipped; private String invoiceNumber; private String totalPriceOfShipment; private String amountPaid; //Class association variables private Client client; private List shipmentLineItems; //Registry of our system. ClientOrderRegistry registry = ClientOrderRegistry.getInstance(); //Constructor public ShipmentToClient(String aDateShipped, String aInvoiceNumber, String aTotalPriceOfShipment, String aAmountPaid, Client aClient) { dateShipped = aDateShipped; invoiceNumber = aInvoiceNumber; totalPriceOfShipment = aTotalPriceOfShipment; amountPaid = aAmountPaid; client = aClient; client.addShipmentToClient(this); shipmentLineItems = new ArrayList(); registry.add(shipmentLineItems); } public boolean setDateShipped(String aDateShipped) { dateShipped = aDateShipped; return true; } public boolean setInvoiceNumber(String aInvoiceNumber) { invoiceNumber = aInvoiceNumber; return true; } public boolean setTotalPriceOfShipment(String aTotalPriceOfShipment) { totalPriceOfShipment = aTotalPriceOfShipment; return true; } public boolean setAmountPaid(String aAmountPaid) { amountPaid = aAmountPaid; return true; } public String getDateShipped() { return dateShipped; } public String getInvoiceNumber() { return invoiceNumber; } public String getTotalPriceOfShipment() { return totalPriceOfShipment; } public String getAmountPaid() { return amountPaid; } public Client getClient() { return client; } public List getShipmentLineItems() { return shipmentLineItems; } public ShipmentLineItem addShipmentLineItem(String aNumShipped, ClientOrderLineItem aClientOrderLineItem, ShipmentToClient aShipmentToClient) { ShipmentLineItem newShipmentLineItem; newShipmentLineItem = new ShipmentLineItem(aNumShipped, aClientOrderLineItem, this); if (!shipmentLineItems.contains(newShipmentLineItem)) { registry.add(newShipmentLineItem); shipmentLineItems.add(newShipmentLineItem); } return newShipmentLineItem; } public ShipmentLineItem addShipmentLineItem(ShipmentLineItem aShipmentLineItem) { if (!shipmentLineItems.contains(aShipmentLineItem)) shipmentLineItems.add(aShipmentLineItem); return aShipmentLineItem; } /* This class does not drive Client and therefore sets the association unidirectionally.*/ public void setClient(Client aClient) { client = aClient; } public void delete() { //Delete all many ends first. for (ShipmentLineItem aShipmentLineItem : shipmentLineItems) { aShipmentLineItem.delete(); } shipmentLineItems.clear(); //Delete all 1 ends. client.deleteShipmentToClient(this); } public void deleteShipmentLineItem(ShipmentLineItem aShipmentLineItem) { if (shipmentLineItems.contains(aShipmentLineItem)) { shipmentLineItems.remove(aShipmentLineItem); //registry.removeObj(registry.getKey(aShipmentLineItem)); } else //Throw an UmpleException .. to be implemented. { } } public boolean areManyEndsNull() { if (shipmentLineItems.size() == 0) { return true; } else return false; } /*********************************** * Returns the attribute list along with the * class ID in JSON format. ***********************************/ public JSONObject getAttributes() throws JSONException { JSONObject obj = new JSONObject(); obj.put("CLASS_ID", registry.getKey(this)); obj.put("dateShipped", getDateShipped()); obj.put("invoiceNumber", getInvoiceNumber()); obj.put("totalPriceOfShipment", getTotalPriceOfShipment()); obj.put("amountPaid", getAmountPaid()); return obj; } }