/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/30 13:12:55*/ /*This class drives: BoxOrPallet, Slot*/ package Warehouse.core; import java.util.*; import Warehouse.*; import Warehouse.json.*; public class SlotSet extends MovementLocation { //Class datatypes //Class association variables private BoxOrPallet boxOrPallet; private List slots; //Registry of our system. WarehouseRegistry registry = WarehouseRegistry.getInstance(); //Constructor public SlotSet() { super(); slots = new ArrayList(); registry.add(slots); } public BoxOrPallet getBoxOrPallet() { return boxOrPallet; } public List getSlots() { return slots; } public Slot addSlot(int aNumber, double aWidth, SlotSet aSlotSet, Level aLevel) { Slot newSlot; newSlot = new Slot(aNumber, aWidth, this, aLevel); if (!slots.contains(newSlot)) { registry.add(newSlot); slots.add(newSlot); } return newSlot; } public Slot addSlot(Slot aSlot) { if (!slots.contains(aSlot)) slots.add(aSlot); return aSlot; } /* This class does not drive BoxOrPallet and therefore sets the association unidirectionally.*/ public void setBoxOrPallet(BoxOrPallet aBoxOrPallet) { boxOrPallet = aBoxOrPallet; } public void delete() { //Delete all many ends first. for (Slot aSlot : slots) { aSlot.delete(); } slots.clear(); //Delete all 1 ends. boxOrPallet.deleteSlotSet(this); } public void deleteBoxOrPallet(BoxOrPallet aBoxOrPallet) { if (aBoxOrPallet.equals(boxOrPallet)) { boxOrPallet = null; registry.removeObj(registry.getKey(aBoxOrPallet)); } else //Throw an UmpleException .. to be implemented. { } } public void deleteSlot(Slot aSlot) { if (slots.contains(aSlot)) { slots.remove(aSlot); //registry.removeObj(registry.getKey(aSlot)); } else //Throw an UmpleException .. to be implemented. { } } public boolean areManyEndsNull() { if (slots.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)); return obj; } }