/*This code was generated using the UMPLE modeling language! Date of generation: 2008/08/20 12:40:13*/ /*This class drives: RegularLegSchedule*/ package airlineMajorExample; import java.util.*; import java.sql.Time; import airlineMajorExample.json.*; public class RegularLeg { //Class datatypes //Class association variables private RegularFlight regularFlight; private Airport destination; private Airport origin; private List regularLegSchedules; //Registry of our system. AirlineMajorExampleRegistry registry = AirlineMajorExampleRegistry.getInstance(); //Constructor public RegularLeg(RegularFlight aRegularFlight, Airport aDestination, Airport aOrigin) { regularFlight = aRegularFlight; regularFlight.addRegularLeg(this); destination = aDestination; destination.addFlightsTo(this); origin = aOrigin; origin.addFlightsFrom(this); regularLegSchedules = new ArrayList(); registry.add(regularLegSchedules); } public RegularFlight getRegularFlight() { return regularFlight; } public Airport getDestination() { return destination; } public Airport getOrigin() { return origin; } public List getRegularLegSchedules() { return regularLegSchedules; } public RegularLegSchedule addRegularLegSchedule(String aDepTime, String aArrTime, int aMidnightCrossings, RegularFlightSchedule aRegularFlightSchedule, Frequency aRegsched) { RegularLegSchedule newRegularLegSchedule; newRegularLegSchedule = new RegularLegSchedule(aDepTime, aArrTime, aMidnightCrossings, this, aRegularFlightSchedule, aRegsched); if (!regularLegSchedules.contains(newRegularLegSchedule)) { registry.add(newRegularLegSchedule); regularLegSchedules.add(newRegularLegSchedule); } return newRegularLegSchedule; } public RegularLegSchedule addRegularLegSchedule( RegularLegSchedule aRegularLegSchedule) { if (!regularLegSchedules.contains(aRegularLegSchedule)) regularLegSchedules.add(aRegularLegSchedule); return aRegularLegSchedule; } /* This class does not drive RegularFlight and therefore sets the association unidirectionally.*/ public void setRegularFlight(RegularFlight aRegularFlight) { regularFlight = aRegularFlight; } /* This class does not drive Airport and therefore sets the association unidirectionally.*/ public void setDestination(Airport aDestination) { destination = aDestination; } /* This class does not drive Airport and therefore sets the association unidirectionally.*/ public void setOrigin(Airport aOrigin) { origin = aOrigin; } public void delete() { //Delete all many ends first. for (RegularLegSchedule aRegularLegSchedule : regularLegSchedules) { aRegularLegSchedule.delete(); } regularLegSchedules.clear(); //Delete all 1 ends. regularFlight.deleteRegularLeg(this); destination.deleteFlightsTo(this); origin.deleteFlightsTo(this); } public void deleteRegularLegSchedule(RegularLegSchedule aRegularLegSchedule) { if (regularLegSchedules.contains(aRegularLegSchedule)) { regularLegSchedules.remove(aRegularLegSchedule); //registry.removeObj(registry.getKey(aRegularLegSchedule)); } else //Throw an UmpleException .. to be implemented. { } } public boolean areManyEndsNull() { if (regularLegSchedules.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; } }