/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/30 13:12:55*/ /*This class drives: DeliverOrShipmentBOM*/ package Warehouse.core; import java.util.*; import java.sql.Time; import Warehouse.*; import Warehouse.json.*; public class Truck { //Class datatypes private int registerNum; private Boolean isWaiting; //Class association variables private List deliverOrShipmentBOMs; //Registry of our system. WarehouseRegistry registry = WarehouseRegistry.getInstance(); //Constructor public Truck(int aRegisterNum, Boolean aIsWaiting) { registerNum = aRegisterNum; isWaiting = aIsWaiting; deliverOrShipmentBOMs = new ArrayList(); registry.add(deliverOrShipmentBOMs); } public boolean setRegisterNum(int aRegisterNum) { registerNum = aRegisterNum; return true; } public boolean setIsWaiting(Boolean aIsWaiting) { isWaiting = aIsWaiting; return true; } public int getRegisterNum() { return registerNum; } public Boolean getIsWaiting() { return isWaiting; } public List getDeliverOrShipmentBOMs() { return deliverOrShipmentBOMs; } public DeliverOrShipmentBOM addDeliverOrShipmentBOM( double aStartTimeLoadOrUnload, double aEndTimeExpected, Truck aTruck) { DeliverOrShipmentBOM newDeliverOrShipmentBOM; newDeliverOrShipmentBOM = new DeliverOrShipmentBOM(aStartTimeLoadOrUnload, aEndTimeExpected, this); if (!deliverOrShipmentBOMs.contains(newDeliverOrShipmentBOM)) { registry.add(newDeliverOrShipmentBOM); deliverOrShipmentBOMs.add(newDeliverOrShipmentBOM); } return newDeliverOrShipmentBOM; } public DeliverOrShipmentBOM addDeliverOrShipmentBOM( DeliverOrShipmentBOM aDeliverOrShipmentBOM) { if (!deliverOrShipmentBOMs.contains(aDeliverOrShipmentBOM)) deliverOrShipmentBOMs.add(aDeliverOrShipmentBOM); return aDeliverOrShipmentBOM; } public void delete() { //Delete all many ends first. for (DeliverOrShipmentBOM aDeliverOrShipmentBOM : deliverOrShipmentBOMs) { aDeliverOrShipmentBOM.delete(); } deliverOrShipmentBOMs.clear(); } public void deleteDeliverOrShipmentBOM( DeliverOrShipmentBOM aDeliverOrShipmentBOM) { if (deliverOrShipmentBOMs.contains(aDeliverOrShipmentBOM)) { deliverOrShipmentBOMs.remove(aDeliverOrShipmentBOM); //registry.removeObj(registry.getKey(aDeliverOrShipmentBOM)); } else //Throw an UmpleException .. to be implemented. { } } public boolean areManyEndsNull() { if (deliverOrShipmentBOMs.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("registerNum", getRegisterNum()); obj.put("isWaiting", getIsWaiting()); return obj; } }