/*This code was generated using the UMPLE modeling language! Date of generation: 2008/07/29 14:29:19*/ /*This class drives: Booking*/ package Airline.humanResources; import java.util.*; import Airline.*; import Airline.flights.*; import Airline.json.*; public class PassangerRole extends PersonRole { //Class datatypes private String name; //Class association variables private List bookings; //Registry of our system. AirlineRegistry registry = AirlineRegistry.getInstance(); //Constructor public PassangerRole(Person aPerson, String aName) throws Exception { super(aPerson); name = aName; bookings = new ArrayList(); registry.add(bookings); } public String getName() { return name; } public List getBookings() { return bookings; } public Booking addBooking(String aSeatNumber, SpecificFlight aSpecificFlight) { Booking newBooking; newBooking = new Booking(aSeatNumber, this, aSpecificFlight); if (!bookings.contains(newBooking)) { registry.add(newBooking); bookings.add(newBooking); } return newBooking; } public Booking addBooking(Booking aBooking) { if (!bookings.contains(aBooking)) bookings.add(aBooking); return aBooking; } public void delete() { //Delete all many ends first. for (Booking aBooking : bookings) { aBooking.delete(); } bookings.clear(); } public void deleteBooking(Booking aBooking) { if (bookings.contains(aBooking)) { bookings.remove(aBooking); //registry.removeObj(registry.getKey(aBooking)); } else //Throw an UmpleException .. to be implemented. { } } public boolean areManyEndsNull() { if (bookings.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("name", getName()); return obj; } }