/*This code was generated using the UMPLE modeling language!*/ package hotel; import java.sql.Time; import java.sql.Date; import java.util.ArrayList; import java.util.Iterator; import hotel.json.*; import hotel.core.*; public class HotelFacade { // Singleton instance. private static HotelFacade theInstance; //System registry. HotelRegistry registry = HotelRegistry.getInstance(); /** * Dummy constructor */ private HotelFacade() { } /** * Returns the only instance of the Facade. * * @return */ public static HotelFacade getInstance() { if (theInstance == null) theInstance = new HotelFacade(); return theInstance; } public int constructHotelCompany(String aName) { return registry.add(new HotelCompany(aName)); } public JSONObject constructHotelCompanyJSON(String aName) throws JSONException { HotelCompany contextObj = new HotelCompany(aName); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setNameInHotelCompany(int context, String aName) { return ((HotelCompany) registry.getValue(context)).setName(aName); } public String getNameFromHotelCompany(int context) { return ((HotelCompany) registry.getValue(context)).getName(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getOwnssFromHotelCompany(int context) { ArrayList listOfIDs = new ArrayList(); for (Hotel obj : ((HotelCompany) registry.getValue(context)).getOwnss()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addOwnsToHotelCompany(int context, String aName, String aAddress, int aHotelCompany) throws Exception { return registry.getKey(((HotelCompany) registry.getValue(context)).addOwns( aName, aAddress, (HotelCompany) registry.getValue(aHotelCompany))); } public JSONObject addOwnsToHotelCompanyJSON(int context, String aName, String aAddress, int aHotelCompany) throws JSONException, Exception { return ((HotelCompany) registry.getValue(context)).addOwns(aName, aAddress, (HotelCompany) registry.getValue(aHotelCompany)).getAttributes(); } public int addOwnsToHotelCompanyOnly(int context, int aOwns) throws Exception { return registry.getKey(((HotelCompany) registry.getValue(context)) .addOwns((Hotel) registry.getValue(aOwns))); } public JSONObject addOwnsToHotelCompanyOnlyJSON(int context, int aOwns) throws JSONException, Exception { return ((HotelCompany) registry.getValue(context)).addOwns( (Hotel) registry.getValue(aOwns)).getAttributes(); } public void deleteHotelCompany(int context) { ((HotelCompany) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteOwnsFromHotelCompany(int context, int aHotel) { ((HotelCompany) registry.getValue(context)).deleteOwns((Hotel) registry .getValue(aHotel)); } public JSONObject getAttributesOfHotelCompany(int context) throws JSONException { return ((HotelCompany) registry.getValue(context)).getAttributes(); } public int constructEvent(String aStartDate, String aEndDate, String aStartTime, String aEndTime, String aBedroomsRequired, String aCreditCardToBill, int aBooking, int aPerson, String aDescription) { return registry .add(new Event(aStartDate, aEndDate, aStartTime, aEndTime, aBedroomsRequired, aCreditCardToBill, (Booking) registry .getValue(aBooking), (Person) registry.getValue(aPerson), aDescription)); } public JSONObject constructEventJSON(String aStartDate, String aEndDate, String aStartTime, String aEndTime, String aBedroomsRequired, String aCreditCardToBill, int aBooking, int aPerson, String aDescription) throws JSONException { Event contextObj = new Event(aStartDate, aEndDate, aStartTime, aEndTime, aBedroomsRequired, aCreditCardToBill, (Booking) registry.getValue(aBooking), (Person) registry.getValue(aPerson), aDescription); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setDescriptionInEvent(int context, String aDescription) { return ((Event) registry.getValue(context)).setDescription(aDescription); } public String getDescriptionFromEvent(int context) { return ((Event) registry.getValue(context)).getDescription(); } public void deleteEvent(int context) { ((Event) registry.getValue(context)).delete(); registry.removeObj(context); } public JSONObject getAttributesOfEvent(int context) throws JSONException { return ((Event) registry.getValue(context)).getAttributes(); } public int constructSuite() { return registry.add(new Suite()); } public JSONObject constructSuiteJSON() throws JSONException { Suite contextObj = new Suite(); registry.add(contextObj); return contextObj.getAttributes(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getRentableSpacesFromSuite(int context) { ArrayList listOfIDs = new ArrayList(); for (RentableSpace obj : ((Suite) registry.getValue(context)) .getRentableSpaces()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addRentableSpaceToSuite(int context, String aCostPerDay, String aFloorArea, int aHotel, int aSuite) throws Exception { return registry.getKey(((Suite) registry.getValue(context)) .addRentableSpace(aCostPerDay, aFloorArea, (Hotel) registry .getValue(aHotel), (Suite) registry.getValue(aSuite))); } public JSONObject addRentableSpaceToSuiteJSON(int context, String aCostPerDay, String aFloorArea, int aHotel, int aSuite) throws JSONException, Exception { return ((Suite) registry.getValue(context)).addRentableSpace(aCostPerDay, aFloorArea, (Hotel) registry.getValue(aHotel), (Suite) registry.getValue(aSuite)).getAttributes(); } public int addRentableSpaceToSuiteOnly(int context, int aRentableSpace) throws Exception { return registry.getKey(((Suite) registry.getValue(context)) .addRentableSpace((RentableSpace) registry.getValue(aRentableSpace))); } public JSONObject addRentableSpaceToSuiteOnlyJSON(int context, int aRentableSpace) throws JSONException, Exception { return ((Suite) registry.getValue(context)).addRentableSpace( (RentableSpace) registry.getValue(aRentableSpace)).getAttributes(); } public void deleteSuite(int context) { ((Suite) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteRentableSpaceFromSuite(int context, int aRentableSpace) { ((Suite) registry.getValue(context)) .deleteRentableSpace((RentableSpace) registry.getValue(aRentableSpace)); } public JSONObject getAttributesOfSuite(int context) throws JSONException { return ((Suite) registry.getValue(context)).getAttributes(); } public int constructMeetingRoom(String aCostPerDay, String aFloorArea, int aHotel, int aSuite, String aName, String aMaxSeatingCapacity) { return registry.add(new MeetingRoom(aCostPerDay, aFloorArea, (Hotel) registry.getValue(aHotel), (Suite) registry.getValue(aSuite), aName, aMaxSeatingCapacity)); } public JSONObject constructMeetingRoomJSON(String aCostPerDay, String aFloorArea, int aHotel, int aSuite, String aName, String aMaxSeatingCapacity) throws JSONException { MeetingRoom contextObj = new MeetingRoom(aCostPerDay, aFloorArea, (Hotel) registry .getValue(aHotel), (Suite) registry.getValue(aSuite), aName, aMaxSeatingCapacity); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setNameInMeetingRoom(int context, String aName) { return ((MeetingRoom) registry.getValue(context)).setName(aName); } public boolean setMaxSeatingCapacityInMeetingRoom(int context, String aMaxSeatingCapacity) { return ((MeetingRoom) registry.getValue(context)) .setMaxSeatingCapacity(aMaxSeatingCapacity); } public String getNameFromMeetingRoom(int context) { return ((MeetingRoom) registry.getValue(context)).getName(); } public String getMaxSeatingCapacityFromMeetingRoom(int context) { return ((MeetingRoom) registry.getValue(context)).getMaxSeatingCapacity(); } public void deleteMeetingRoom(int context) { ((MeetingRoom) registry.getValue(context)).delete(); registry.removeObj(context); } public JSONObject getAttributesOfMeetingRoom(int context) throws JSONException { return ((MeetingRoom) registry.getValue(context)).getAttributes(); } public int constructHotelBedroom(String aCostPerDay, String aFloorArea, int aHotel, int aSuite, String aRoomNumber, String aQualityLevel, String aIsSmoking) { return registry.add(new HotelBedroom(aCostPerDay, aFloorArea, (Hotel) registry.getValue(aHotel), (Suite) registry.getValue(aSuite), aRoomNumber, aQualityLevel, aIsSmoking)); } public JSONObject constructHotelBedroomJSON(String aCostPerDay, String aFloorArea, int aHotel, int aSuite, String aRoomNumber, String aQualityLevel, String aIsSmoking) throws JSONException { HotelBedroom contextObj = new HotelBedroom(aCostPerDay, aFloorArea, (Hotel) registry .getValue(aHotel), (Suite) registry.getValue(aSuite), aRoomNumber, aQualityLevel, aIsSmoking); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setRoomNumberInHotelBedroom(int context, String aRoomNumber) { return ((HotelBedroom) registry.getValue(context)) .setRoomNumber(aRoomNumber); } public boolean setQualityLevelInHotelBedroom(int context, String aQualityLevel) { return ((HotelBedroom) registry.getValue(context)) .setQualityLevel(aQualityLevel); } public boolean setIsSmokingInHotelBedroom(int context, String aIsSmoking) { return ((HotelBedroom) registry.getValue(context)).setIsSmoking(aIsSmoking); } public String getRoomNumberFromHotelBedroom(int context) { return ((HotelBedroom) registry.getValue(context)).getRoomNumber(); } public String getQualityLevelFromHotelBedroom(int context) { return ((HotelBedroom) registry.getValue(context)).getQualityLevel(); } public String getIsSmokingFromHotelBedroom(int context) { return ((HotelBedroom) registry.getValue(context)).getIsSmoking(); } public void deleteHotelBedroom(int context) { ((HotelBedroom) registry.getValue(context)).delete(); registry.removeObj(context); } public JSONObject getAttributesOfHotelBedroom(int context) throws JSONException { return ((HotelBedroom) registry.getValue(context)).getAttributes(); } public int constructRentableSpace(String aCostPerDay, String aFloorArea, int aHotel, int aSuite) { return registry.add(new RentableSpace(aCostPerDay, aFloorArea, (Hotel) registry.getValue(aHotel), (Suite) registry.getValue(aSuite))); } public JSONObject constructRentableSpaceJSON(String aCostPerDay, String aFloorArea, int aHotel, int aSuite) throws JSONException { RentableSpace contextObj = new RentableSpace(aCostPerDay, aFloorArea, (Hotel) registry .getValue(aHotel), (Suite) registry.getValue(aSuite)); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setCostPerDayInRentableSpace(int context, String aCostPerDay) { return ((RentableSpace) registry.getValue(context)) .setCostPerDay(aCostPerDay); } public boolean setFloorAreaInRentableSpace(int context, String aFloorArea) { return ((RentableSpace) registry.getValue(context)) .setFloorArea(aFloorArea); } public String getCostPerDayFromRentableSpace(int context) { return ((RentableSpace) registry.getValue(context)).getCostPerDay(); } public String getFloorAreaFromRentableSpace(int context) { return ((RentableSpace) registry.getValue(context)).getFloorArea(); } public int getHotelFromRentableSpace(int context) { return registry.getKey(((RentableSpace) registry.getValue(context)) .getHotel()); } public JSONObject getHotelFromRentableSpaceJSON(int context) throws JSONException { return ((RentableSpace) registry.getValue(context)).getHotel() .getAttributes(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getBookingsFromRentableSpace(int context) { ArrayList listOfIDs = new ArrayList(); for (Booking obj : ((RentableSpace) registry.getValue(context)) .getBookings()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int getSuiteFromRentableSpace(int context) { return registry.getKey(((RentableSpace) registry.getValue(context)) .getSuite()); } public JSONObject getSuiteFromRentableSpaceJSON(int context) throws JSONException { return ((RentableSpace) registry.getValue(context)).getSuite() .getAttributes(); } public int addBookingToRentableSpace(int context, String aStartDate, String aEndDate, String aStartTime, String aEndTime, String aBedroomsRequired, String aCreditCardToBill, int aBooking, int aPerson) throws Exception { return registry.getKey(((RentableSpace) registry.getValue(context)) .addBooking(aStartDate, aEndDate, aStartTime, aEndTime, aBedroomsRequired, aCreditCardToBill, (Booking) registry .getValue(aBooking), (Person) registry.getValue(aPerson))); } public JSONObject addBookingToRentableSpaceJSON(int context, String aStartDate, String aEndDate, String aStartTime, String aEndTime, String aBedroomsRequired, String aCreditCardToBill, int aBooking, int aPerson) throws JSONException, Exception { return ((RentableSpace) registry.getValue(context)).addBooking(aStartDate, aEndDate, aStartTime, aEndTime, aBedroomsRequired, aCreditCardToBill, (Booking) registry.getValue(aBooking), (Person) registry.getValue(aPerson)).getAttributes(); } public int addBookingToRentableSpaceOnly(int context, int aBooking) throws Exception { return registry.getKey(((RentableSpace) registry.getValue(context)) .addBooking((Booking) registry.getValue(aBooking))); } public JSONObject addBookingToRentableSpaceOnlyJSON(int context, int aBooking) throws JSONException, Exception { return ((RentableSpace) registry.getValue(context)).addBooking( (Booking) registry.getValue(aBooking)).getAttributes(); } public void setHotelInRentableSpace(int context, int aHotel) throws Exception { ((RentableSpace) registry.getValue(context)).setHotel((Hotel) registry .getValue(aHotel)); } public void setSuiteInRentableSpace(int context, int aSuite) throws Exception { ((RentableSpace) registry.getValue(context)).setSuite((Suite) registry .getValue(aSuite)); } public void deleteRentableSpace(int context) { ((RentableSpace) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteBookingFromRentableSpace(int context, int aBooking) { ((RentableSpace) registry.getValue(context)) .deleteBooking((Booking) registry.getValue(aBooking)); } public JSONObject getAttributesOfRentableSpace(int context) throws JSONException { return ((RentableSpace) registry.getValue(context)).getAttributes(); } public int constructHotel(String aName, String aAddress, int aHotelCompany) { return registry.add(new Hotel(aName, aAddress, (HotelCompany) registry .getValue(aHotelCompany))); } public JSONObject constructHotelJSON(String aName, String aAddress, int aHotelCompany) throws JSONException { Hotel contextObj = new Hotel(aName, aAddress, (HotelCompany) registry .getValue(aHotelCompany)); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setNameInHotel(int context, String aName) { return ((Hotel) registry.getValue(context)).setName(aName); } public boolean setAddressInHotel(int context, String aAddress) { return ((Hotel) registry.getValue(context)).setAddress(aAddress); } public String getNameFromHotel(int context) { return ((Hotel) registry.getValue(context)).getName(); } public String getAddressFromHotel(int context) { return ((Hotel) registry.getValue(context)).getAddress(); } public int getHotelCompanyFromHotel(int context) { return registry.getKey(((Hotel) registry.getValue(context)) .getHotelCompany()); } public JSONObject getHotelCompanyFromHotelJSON(int context) throws JSONException { return ((Hotel) registry.getValue(context)).getHotelCompany() .getAttributes(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getRentableSpacesFromHotel(int context) { ArrayList listOfIDs = new ArrayList(); for (RentableSpace obj : ((Hotel) registry.getValue(context)) .getRentableSpaces()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addRentableSpaceToHotel(int context, String aCostPerDay, String aFloorArea, int aHotel, int aSuite) throws Exception { return registry.getKey(((Hotel) registry.getValue(context)) .addRentableSpace(aCostPerDay, aFloorArea, (Hotel) registry .getValue(aHotel), (Suite) registry.getValue(aSuite))); } public JSONObject addRentableSpaceToHotelJSON(int context, String aCostPerDay, String aFloorArea, int aHotel, int aSuite) throws JSONException, Exception { return ((Hotel) registry.getValue(context)).addRentableSpace(aCostPerDay, aFloorArea, (Hotel) registry.getValue(aHotel), (Suite) registry.getValue(aSuite)).getAttributes(); } public int addRentableSpaceToHotelOnly(int context, int aRentableSpace) throws Exception { return registry.getKey(((Hotel) registry.getValue(context)) .addRentableSpace((RentableSpace) registry.getValue(aRentableSpace))); } public JSONObject addRentableSpaceToHotelOnlyJSON(int context, int aRentableSpace) throws JSONException, Exception { return ((Hotel) registry.getValue(context)).addRentableSpace( (RentableSpace) registry.getValue(aRentableSpace)).getAttributes(); } public void setHotelCompanyInHotel(int context, int aHotelCompany) throws Exception { ((Hotel) registry.getValue(context)) .setHotelCompany((HotelCompany) registry.getValue(aHotelCompany)); } public void deleteHotel(int context) { ((Hotel) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteRentableSpaceFromHotel(int context, int aRentableSpace) { ((Hotel) registry.getValue(context)) .deleteRentableSpace((RentableSpace) registry.getValue(aRentableSpace)); } public JSONObject getAttributesOfHotel(int context) throws JSONException { return ((Hotel) registry.getValue(context)).getAttributes(); } public int constructBooking(String aStartDate, String aEndDate, String aStartTime, String aEndTime, String aBedroomsRequired, String aCreditCardToBill, int aBooking, int aPerson) { return registry.add(new Booking(aStartDate, aEndDate, aStartTime, aEndTime, aBedroomsRequired, aCreditCardToBill, (Booking) registry .getValue(aBooking), (Person) registry.getValue(aPerson))); } public JSONObject constructBookingJSON(String aStartDate, String aEndDate, String aStartTime, String aEndTime, String aBedroomsRequired, String aCreditCardToBill, int aBooking, int aPerson) throws JSONException { Booking contextObj = new Booking(aStartDate, aEndDate, aStartTime, aEndTime, aBedroomsRequired, aCreditCardToBill, (Booking) registry .getValue(aBooking), (Person) registry.getValue(aPerson)); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setStartDateInBooking(int context, String aStartDate) { return ((Booking) registry.getValue(context)).setStartDate(aStartDate); } public boolean setEndDateInBooking(int context, String aEndDate) { return ((Booking) registry.getValue(context)).setEndDate(aEndDate); } public boolean setStartTimeInBooking(int context, String aStartTime) { return ((Booking) registry.getValue(context)).setStartTime(aStartTime); } public boolean setEndTimeInBooking(int context, String aEndTime) { return ((Booking) registry.getValue(context)).setEndTime(aEndTime); } public boolean setBedroomsRequiredInBooking(int context, String aBedroomsRequired) { return ((Booking) registry.getValue(context)) .setBedroomsRequired(aBedroomsRequired); } public boolean setCreditCardToBillInBooking(int context, String aCreditCardToBill) { return ((Booking) registry.getValue(context)) .setCreditCardToBill(aCreditCardToBill); } public String getStartDateFromBooking(int context) { return ((Booking) registry.getValue(context)).getStartDate(); } public String getEndDateFromBooking(int context) { return ((Booking) registry.getValue(context)).getEndDate(); } public String getStartTimeFromBooking(int context) { return ((Booking) registry.getValue(context)).getStartTime(); } public String getEndTimeFromBooking(int context) { return ((Booking) registry.getValue(context)).getEndTime(); } public String getBedroomsRequiredFromBooking(int context) { return ((Booking) registry.getValue(context)).getBedroomsRequired(); } public String getCreditCardToBillFromBooking(int context) { return ((Booking) registry.getValue(context)).getCreditCardToBill(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getItemOnBillsFromBooking(int context) { ArrayList listOfIDs = new ArrayList(); for (ItemOnBill obj : ((Booking) registry.getValue(context)) .getItemOnBills()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getSubsidiaryBookingsFromBooking(int context) { ArrayList listOfIDs = new ArrayList(); for (Booking obj : ((Booking) registry.getValue(context)) .getSubsidiaryBookings()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int getBookingFromBooking(int context) { return registry.getKey(((Booking) registry.getValue(context)).getBooking()); } public JSONObject getBookingFromBookingJSON(int context) throws JSONException { return ((Booking) registry.getValue(context)).getBooking().getAttributes(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getRentableSpacesFromBooking(int context) { ArrayList listOfIDs = new ArrayList(); for (RentableSpace obj : ((Booking) registry.getValue(context)) .getRentableSpaces()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int getPersonFromBooking(int context) { return registry.getKey(((Booking) registry.getValue(context)).getPerson()); } public JSONObject getPersonFromBookingJSON(int context) throws JSONException { return ((Booking) registry.getValue(context)).getPerson().getAttributes(); } public int addItemOnBillToBooking(int context, String aDescription, String aCharge, int aBooking) throws Exception { return registry.getKey(((Booking) registry.getValue(context)) .addItemOnBill(aDescription, aCharge, (Booking) registry .getValue(aBooking))); } public JSONObject addItemOnBillToBookingJSON(int context, String aDescription, String aCharge, int aBooking) throws JSONException, Exception { return ((Booking) registry.getValue(context)).addItemOnBill(aDescription, aCharge, (Booking) registry.getValue(aBooking)).getAttributes(); } public int addItemOnBillToBookingOnly(int context, int aItemOnBill) throws Exception { return registry.getKey(((Booking) registry.getValue(context)) .addItemOnBill((ItemOnBill) registry.getValue(aItemOnBill))); } public JSONObject addItemOnBillToBookingOnlyJSON(int context, int aItemOnBill) throws JSONException, Exception { return ((Booking) registry.getValue(context)).addItemOnBill( (ItemOnBill) registry.getValue(aItemOnBill)).getAttributes(); } public int addSubsidiaryBookingToBooking(int context, String aStartDate, String aEndDate, String aStartTime, String aEndTime, String aBedroomsRequired, String aCreditCardToBill, int aBooking, int aPerson) throws Exception { return registry.getKey(((Booking) registry.getValue(context)) .addSubsidiaryBooking(aStartDate, aEndDate, aStartTime, aEndTime, aBedroomsRequired, aCreditCardToBill, (Booking) registry .getValue(aBooking), (Person) registry.getValue(aPerson))); } public JSONObject addSubsidiaryBookingToBookingJSON(int context, String aStartDate, String aEndDate, String aStartTime, String aEndTime, String aBedroomsRequired, String aCreditCardToBill, int aBooking, int aPerson) throws JSONException, Exception { return ((Booking) registry.getValue(context)).addSubsidiaryBooking( aStartDate, aEndDate, aStartTime, aEndTime, aBedroomsRequired, aCreditCardToBill, (Booking) registry.getValue(aBooking), (Person) registry.getValue(aPerson)).getAttributes(); } public int addSubsidiaryBookingToBookingOnly(int context, int aSubsidiaryBooking) throws Exception { return registry.getKey(((Booking) registry.getValue(context)) .addSubsidiaryBooking((Booking) registry.getValue(aSubsidiaryBooking))); } public JSONObject addSubsidiaryBookingToBookingOnlyJSON(int context, int aSubsidiaryBooking) throws JSONException, Exception { return ((Booking) registry.getValue(context)).addSubsidiaryBooking( (Booking) registry.getValue(aSubsidiaryBooking)).getAttributes(); } public int addRentableSpaceToBooking(int context, String aCostPerDay, String aFloorArea, int aHotel, int aSuite) throws Exception { return registry.getKey(((Booking) registry.getValue(context)) .addRentableSpace(aCostPerDay, aFloorArea, (Hotel) registry .getValue(aHotel), (Suite) registry.getValue(aSuite))); } public JSONObject addRentableSpaceToBookingJSON(int context, String aCostPerDay, String aFloorArea, int aHotel, int aSuite) throws JSONException, Exception { return ((Booking) registry.getValue(context)).addRentableSpace(aCostPerDay, aFloorArea, (Hotel) registry.getValue(aHotel), (Suite) registry.getValue(aSuite)).getAttributes(); } public int addRentableSpaceToBookingOnly(int context, int aRentableSpace) throws Exception { return registry.getKey(((Booking) registry.getValue(context)) .addRentableSpace((RentableSpace) registry.getValue(aRentableSpace))); } public JSONObject addRentableSpaceToBookingOnlyJSON(int context, int aRentableSpace) throws JSONException, Exception { return ((Booking) registry.getValue(context)).addRentableSpace( (RentableSpace) registry.getValue(aRentableSpace)).getAttributes(); } public void setBookingInBooking(int context, int aBooking) throws Exception { ((Booking) registry.getValue(context)).setBooking((Booking) registry .getValue(aBooking)); } public void setPersonInBooking(int context, int aPerson) throws Exception { ((Booking) registry.getValue(context)).setPerson((Person) registry .getValue(aPerson)); } public void deleteBooking(int context) { ((Booking) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteItemOnBillFromBooking(int context, int aItemOnBill) { ((Booking) registry.getValue(context)) .deleteItemOnBill((ItemOnBill) registry.getValue(aItemOnBill)); } public void deleteSubsidiaryBookingFromBooking(int context, int aBooking) { ((Booking) registry.getValue(context)) .deleteSubsidiaryBooking((Booking) registry.getValue(aBooking)); } public void deleteRentableSpaceFromBooking(int context, int aRentableSpace) { ((Booking) registry.getValue(context)) .deleteRentableSpace((RentableSpace) registry.getValue(aRentableSpace)); } public JSONObject getAttributesOfBooking(int context) throws JSONException { return ((Booking) registry.getValue(context)).getAttributes(); } public int constructPerson(String aName, String aAddress) { return registry.add(new Person(aName, aAddress)); } public JSONObject constructPersonJSON(String aName, String aAddress) throws JSONException { Person contextObj = new Person(aName, aAddress); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setNameInPerson(int context, String aName) { return ((Person) registry.getValue(context)).setName(aName); } public boolean setAddressInPerson(int context, String aAddress) { return ((Person) registry.getValue(context)).setAddress(aAddress); } public String getNameFromPerson(int context) { return ((Person) registry.getValue(context)).getName(); } public String getAddressFromPerson(int context) { return ((Person) registry.getValue(context)).getAddress(); } /************ * Method returns an iterator to the list of id's of the elements involved in this list. ***************/ public Iterator getBookingsFromPerson(int context) { ArrayList listOfIDs = new ArrayList(); for (Booking obj : ((Person) registry.getValue(context)).getBookings()) { listOfIDs.add(registry.getKey(obj)); } return listOfIDs.iterator(); } public int addBookingToPerson(int context, String aStartDate, String aEndDate, String aStartTime, String aEndTime, String aBedroomsRequired, String aCreditCardToBill, int aBooking, int aPerson) throws Exception { return registry.getKey(((Person) registry.getValue(context)).addBooking( aStartDate, aEndDate, aStartTime, aEndTime, aBedroomsRequired, aCreditCardToBill, (Booking) registry.getValue(aBooking), (Person) registry.getValue(aPerson))); } public JSONObject addBookingToPersonJSON(int context, String aStartDate, String aEndDate, String aStartTime, String aEndTime, String aBedroomsRequired, String aCreditCardToBill, int aBooking, int aPerson) throws JSONException, Exception { return ((Person) registry.getValue(context)).addBooking(aStartDate, aEndDate, aStartTime, aEndTime, aBedroomsRequired, aCreditCardToBill, (Booking) registry.getValue(aBooking), (Person) registry.getValue(aPerson)).getAttributes(); } public int addBookingToPersonOnly(int context, int aBooking) throws Exception { return registry.getKey(((Person) registry.getValue(context)) .addBooking((Booking) registry.getValue(aBooking))); } public JSONObject addBookingToPersonOnlyJSON(int context, int aBooking) throws JSONException, Exception { return ((Person) registry.getValue(context)).addBooking( (Booking) registry.getValue(aBooking)).getAttributes(); } public void deletePerson(int context) { ((Person) registry.getValue(context)).delete(); registry.removeObj(context); } public void deleteBookingFromPerson(int context, int aBooking) { ((Person) registry.getValue(context)).deleteBooking((Booking) registry .getValue(aBooking)); } public JSONObject getAttributesOfPerson(int context) throws JSONException { return ((Person) registry.getValue(context)).getAttributes(); } public int constructItemOnBill(String aDescription, String aCharge, int aBooking) { return registry.add(new ItemOnBill(aDescription, aCharge, (Booking) registry.getValue(aBooking))); } public JSONObject constructItemOnBillJSON(String aDescription, String aCharge, int aBooking) throws JSONException { ItemOnBill contextObj = new ItemOnBill(aDescription, aCharge, (Booking) registry .getValue(aBooking)); registry.add(contextObj); return contextObj.getAttributes(); } public boolean setDescriptionInItemOnBill(int context, String aDescription) { return ((ItemOnBill) registry.getValue(context)) .setDescription(aDescription); } public boolean setChargeInItemOnBill(int context, String aCharge) { return ((ItemOnBill) registry.getValue(context)).setCharge(aCharge); } public String getDescriptionFromItemOnBill(int context) { return ((ItemOnBill) registry.getValue(context)).getDescription(); } public String getChargeFromItemOnBill(int context) { return ((ItemOnBill) registry.getValue(context)).getCharge(); } public int getBookingFromItemOnBill(int context) { return registry.getKey(((ItemOnBill) registry.getValue(context)) .getBooking()); } public JSONObject getBookingFromItemOnBillJSON(int context) throws JSONException { return ((ItemOnBill) registry.getValue(context)).getBooking() .getAttributes(); } public void setBookingInItemOnBill(int context, int aBooking) throws Exception { ((ItemOnBill) registry.getValue(context)).setBooking((Booking) registry .getValue(aBooking)); } public void deleteItemOnBill(int context) { ((ItemOnBill) registry.getValue(context)).delete(); registry.removeObj(context); } public JSONObject getAttributesOfItemOnBill(int context) throws JSONException { return ((ItemOnBill) registry.getValue(context)).getAttributes(); } }