/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/29 14:29:19*/ /*This class drives: RegularFlight, Person*/ package Airline.flights; import java.util.*; import java.sql.Time; import Airline.*; import Airline.humanResources.*; import Airline.json.*; public class Airline { //Class datatypes //Class association variables private List regularFlights; private List persons; //Registry of our system. AirlineRegistry registry = AirlineRegistry.getInstance(); //Constructor public Airline() { regularFlights = new ArrayList(); registry.add(regularFlights); persons = new ArrayList(); registry.add(persons); } public List getRegularFlights() { return regularFlights; } /*RegularFlight is unique with respect to Airline*/ public RegularFlight getRegularFlight(int aFlightNumber) { for (RegularFlight aRegularFlight : getRegularFlights()) { if (aRegularFlight.getFlightNumber() == aFlightNumber) return aRegularFlight; } //If the value was found, it would have been returned. return null; } public List getPersons() { return persons; } public RegularFlight addRegularFlight(Time aTime, int aFlightNumber) { RegularFlight newRegularFlight; newRegularFlight = new RegularFlight(aTime, aFlightNumber, this); if (!regularFlights.contains(newRegularFlight)) { registry.add(newRegularFlight); regularFlights.add(newRegularFlight); } return newRegularFlight; } public RegularFlight addRegularFlight(RegularFlight aRegularFlight) { if (!regularFlights.contains(aRegularFlight)) regularFlights.add(aRegularFlight); return aRegularFlight; } public Person addPerson(String aName, int aIdNumber) { Person newPerson; newPerson = new Person(aName, aIdNumber, this); if (!persons.contains(newPerson)) { registry.add(newPerson); persons.add(newPerson); } return newPerson; } public Person addPerson(Person aPerson) { if (!persons.contains(aPerson)) persons.add(aPerson); return aPerson; } public void delete() { //Delete all many ends first. for (RegularFlight aRegularFlight : regularFlights) { aRegularFlight.delete(); } regularFlights.clear(); //Delete all many ends first. for (Person aPerson : persons) { aPerson.delete(); } persons.clear(); } public void deleteRegularFlight(RegularFlight aRegularFlight) { if (regularFlights.contains(aRegularFlight)) { regularFlights.remove(aRegularFlight); //registry.removeObj(registry.getKey(aRegularFlight)); } else //Throw an UmpleException .. to be implemented. { } } public void deletePerson(Person aPerson) { if (persons.contains(aPerson)) { persons.remove(aPerson); //registry.removeObj(registry.getKey(aPerson)); } else //Throw an UmpleException .. to be implemented. { } } public boolean areManyEndsNull() { if (regularFlights.size() == 0 && persons.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; } }