/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/30 13:12:54*/ /*This class drives: RWBM*/ package Warehouse.core; import java.util.*; import Warehouse.*; import Warehouse.json.*; public class RWBMMovement { //Class datatypes private double startTime; private double endTime; //Class association variables private MovementLocation to; private MovementLocation from; private BoxOrPallet movedBox; private List rWBMs; //Registry of our system. WarehouseRegistry registry = WarehouseRegistry.getInstance(); //Constructor public RWBMMovement(double aStartTime, double aEndTime, MovementLocation aTo, MovementLocation aFrom, BoxOrPallet aMovedBox) { startTime = aStartTime; endTime = aEndTime; to = aTo; to.addToMovement(this); from = aFrom; from.addToMovement(this); movedBox = aMovedBox; movedBox.addRWBMMovement(this); rWBMs = new ArrayList(); registry.add(rWBMs); } public boolean setStartTime(double aStartTime) { startTime = aStartTime; return true; } public boolean setEndTime(double aEndTime) { endTime = aEndTime; return true; } public double getStartTime() { return startTime; } public double getEndTime() { return endTime; } public MovementLocation getTo() { return to; } public MovementLocation getFrom() { return from; } public BoxOrPallet getMovedBox() { return movedBox; } public List getRWBMs() { return rWBMs; } public RWBM addRWBM(int aID, RWBMMovement aRWBMMovement) { RWBM newRWBM; newRWBM = new RWBM(aID, this); if (!rWBMs.contains(newRWBM)) { registry.add(newRWBM); rWBMs.add(newRWBM); } return newRWBM; } public RWBM addRWBM(RWBM aRWBM) { if (!rWBMs.contains(aRWBM)) rWBMs.add(aRWBM); return aRWBM; } /* This class does not drive MovementLocation and therefore sets the association unidirectionally.*/ public void setTo(MovementLocation aTo) { to = aTo; } /* This class does not drive MovementLocation and therefore sets the association unidirectionally.*/ public void setFrom(MovementLocation aFrom) { from = aFrom; } /* This class does not drive BoxOrPallet and therefore sets the association unidirectionally.*/ public void setMovedBox(BoxOrPallet aMovedBox) { movedBox = aMovedBox; } public void delete() { //Delete all many ends first. for (RWBM aRWBM : rWBMs) { aRWBM.delete(); } rWBMs.clear(); //Delete all 1 ends. to.deleteToMovement(this); from.deleteToMovement(this); movedBox.deleteRWBMMovement(this); } public void deleteRWBM(RWBM aRWBM) { if (rWBMs.contains(aRWBM)) { rWBMs.remove(aRWBM); //registry.removeObj(registry.getKey(aRWBM)); } else //Throw an UmpleException .. to be implemented. { } } public boolean areManyEndsNull() { if (rWBMs.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("startTime", getStartTime()); obj.put("endTime", getEndTime()); return obj; } }