All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class JBMSTours.serializabletypes.Tour

java.lang.Object
   |
   +----JBMSTours.serializabletypes.Tour

public class Tour
extends Object
implements Externalizable
Look at the Source.

Basic class for building a customer tour. This is a two-city tour (first city of three is user's home city). Main client application BuildATour constructs the object. A tour consists of a Group, three cities, three dates of travel, two Customer Flights and a two HotelStays. A Tour gets stored in the CustomizedTours table.


Variable Index

 o begin
first date of travel (home city to first city).
 o city1
first city (home city), transient (not stored).
 o city1Name
 o city2
second city (middle city), transient (not stored).
 o city2Name
 o city3
third city (destination city), transient (not stored).
 o city3Name
 o cityId1
 o cityId2
 o cityId3
 o currentClassVersion
 o ECONOMYTOURLEVEL
 o end
final date of travel (second city to home city).
 o FIRSTCLASSTOURLEVEL
 o middle
second date of travel (first city to second city).
 o myflight
 o myflight2
 o myflight3
 o myGroup
Group taking the tour, transient (not stored).
 o myGroupId
 o myStay
 o secondStay
 o STANDARDTOURLEVEL

Constructor Index

 o Tour()
No arg constructer required.
 o Tour(Group, City, City, City, Date, Date, Date)
Constructs a two-city tour object.

Method Index

 o buildTheTour(Connection)
Fills out the objects that are part of the tour.
 o equals(Object)
Good Cloudscape practice requires us to override equals and hashCode from Object.
 o findANewHotelStay(Connection, int, BigDecimal)
Allows you to alter the tour to change one hotel stay for another one.
 o getAverageCostPerDayPerPerson(Connection)
Returns average cost of the tour per person, per day.
 o getCity1(Connection)
Gets the first city (home city).
 o getCity2(Connection)
Gets the first city visited (second city).
 o getCity3(Connection)
Gets the second city visited (third city).
 o getCustomerFlight1()
Returns the first CustomerFlight object (flight from home city to first city in tour).
 o getCustomerFlight2()
Returns the second CustomerFlight object (flight from home city to first city in tour).
 o getCustomerFlight3()
Returns the third CustomerFlight object (flight from home city to first city in tour).
 o getFlight1()
Returns the first Flight object (flight from home city to first city in tour).
 o getFlight2()
Returns the second Flight object (flight from home city to first city in tour).
 o getFlight3()
Returns the third Flight object (flight from home city to first city in tour).
 o getGroup(Connection)
Accessor method for the group.
 o getHotel1(Connection)
Returns the first Hotel in the tour.
 o getHotel2(Connection)
Returns the second Hotel in the tour.
 o getJavaFieldForLevel(short)
Gets the name of the static field in this class corresponding to short representing the level of the tour.
 o getLevel(Connection)
Returns the "level" of the tour (first class, standard, or economy).
 o getShortForLevel(String)
Gets the short corresponding to the String representing the tour level.
 o getSQLJFieldForLevel(short)
Gets the SQL-J version of the name of the static field in this class corresponding to short representing the level of the tour.
 o getStay1()
Returns the first HotelStay object (HotelStay in first city in tour).
 o getStay2()
Returns the first HotelStay object (HotelStay in first city in tour).
 o getStringForLevel(short)
Gets the String corresponding for the short level value.
 o getTotalCost()
Returns the total cost of the tour (cost of three flights for all group members and two hotel stays).
 o getTotalMilesTraveled()
Returns total miles traveled (the mileage of all three flights)
 o getTourInfo(Connection)
 o hashCode()
Good Cloudscape practice erquires us to override equals and hashCode from Object.
 o printTourInfo(Connection)
Prints information about the tour.
 o printWelcomeGroup(Connection)
Prints a welcome message.
 o readExternal(ObjectInput)
 o storeInDatabase(Connection)
Stores the tour as an object in the CustomizedTours table.
 o temporarilyDowngradeTourLevel(short)
Go down a level in the tour for booking reasons.
 o temporarilyUpgradeTourLevel(short)
Go up a level in the tour for booking reasons.
 o toString()
Get a string value for the tour.
 o writeExternal(ObjectOutput)

Variables

 o city1
 protected transient City city1
first city (home city), transient (not stored). Store id only.

 o cityId1
 protected int cityId1
 o city1Name
 protected String city1Name
 o city2
 protected transient City city2
second city (middle city), transient (not stored). Store id only.

 o cityId2
 protected int cityId2
 o city2Name
 protected String city2Name
 o city3
 protected transient City city3
third city (destination city), transient (not stored). Store id only.

 o cityId3
 protected int cityId3
 o city3Name
 protected String city3Name
 o begin
 public Date begin
first date of travel (home city to first city).

 o middle
 public Date middle
second date of travel (first city to second city).

 o end
 public Date end
final date of travel (second city to home city).

 o myflight
 protected CustomerFlight myflight
 o myflight2
 protected CustomerFlight myflight2
 o myflight3
 protected CustomerFlight myflight3
 o myStay
 protected HotelStay myStay
 o secondStay
 protected HotelStay secondStay
 o myGroup
 protected transient Group myGroup
Group taking the tour, transient (not stored). Store id only.

 o myGroupId
 protected int myGroupId
 o ECONOMYTOURLEVEL
 public static final short ECONOMYTOURLEVEL
 o STANDARDTOURLEVEL
 public static final short STANDARDTOURLEVEL
 o FIRSTCLASSTOURLEVEL
 public static final short FIRSTCLASSTOURLEVEL
 o currentClassVersion
 protected static final int currentClassVersion

Constructors

 o Tour
 public Tour()
No arg constructer required. All externalizable objects need a no arg constructor. This one is only used when reading the object in.

 o Tour
 public Tour(Group agroup,
             City one,
             City two,
             City three,
             Date date1,
             Date date2,
             Date date3)
Constructs a two-city tour object.

Parameters:
agroup - The group taking the tour.
one - The group's home city.
two - The first city on the tour.
three - The second city on the tour.
date1 - The date the group travels to the first city.
date2 - The date the group travels to the second city.
date3 - The date the group returns home.

Methods

 o buildTheTour
 public void buildTheTour(Connection conn) throws SQLException, CityChoiceException, BudgetException, AvailabilityException
Fills out the objects that are part of the tour. Dynamically builds and stores flight objects based on cities of travel. Suggests flights based on dates and cities of travel; books flights; suggests hotels; books hotels. Tracks the cost.

Parameters:
conn - Connection to the db.
Throws: SQLException
Thrown if there is a SQL error.
Throws: CityChoiceException
Thrown if if can't build tour to requested cities.
Throws: AvailabilityException
if the tour can't find any available hotels or flights
Throws: BudgetException
if the tour can't be made within budget
 o findANewHotelStay
 public void findANewHotelStay(Connection conn,
                               int old_hotel_id,
                               BigDecimal old_cost) throws BudgetException, AvailabilityException, SQLException
Allows you to alter the tour to change one hotel stay for another one. (does not automatically update the CustomizedTours table).

Parameters:
conn - Connection to the db.
Throws: SQLException
Thrown if there is a SQL error.
Throws: AvailabilityException
if the tour can't find any available hotels or flights
Throws: BudgetException
if the tour can't be made within budget
 o printWelcomeGroup
 public void printWelcomeGroup(Connection conn) throws SQLException
Prints a welcome message.

Parameters:
conn - Connection to the db.
Throws: SQLException
Thrown if there is a SQL error.
 o printTourInfo
 public void printTourInfo(Connection conn) throws SQLException
Prints information about the tour.

Parameters:
conn - Connection to the db.
Throws: SQLException
Thrown if there is a SQL error.
 o getTourInfo
 public String getTourInfo(Connection conn) throws SQLException
Parameters:
conn - Connection to the db.
Throws: SQLException
Thrown if there is a SQL error.
 o storeInDatabase
 public void storeInDatabase(Connection conn) throws SQLException
Stores the tour as an object in the CustomizedTours table. Transient fields are not stored.

Uses query INSERT INTO CUSTOMIZEDTOURS VALUES (?, ?)

Parameters:
conn - Connection to the db.
Throws: SQLException
Thrown if there is a SQL error.
 o toString
 public String toString()
Get a string value for the tour.

Overrides:
toString in class Object
 o getCustomerFlight1
 public CustomerFlight getCustomerFlight1()
Returns the first CustomerFlight object (flight from home city to first city in tour).

Returns:
CustomerFlight first flight in the tour.
See Also:
CustomerFlight
 o getFlight1
 public Flight getFlight1()
Returns the first Flight object (flight from home city to first city in tour). The Flight object (flight information without specific date and number of seat information) is a field in the CustomerFlight object.

See Also:
Flight, OneStopFlight, TransferFlight
 o getCustomerFlight2
 public CustomerFlight getCustomerFlight2()
Returns the second CustomerFlight object (flight from home city to first city in tour).

See Also:
CustomerFlight
 o getFlight2
 public Flight getFlight2()
Returns the second Flight object (flight from home city to first city in tour). The Flight object (flight information without specific date and number of seat information) is a field in the CustomerFlight object.

See Also:
Flight, OneStopFlight, TransferFlight
 o getCustomerFlight3
 public CustomerFlight getCustomerFlight3()
Returns the third CustomerFlight object (flight from home city to first city in tour).

See Also:
CustomerFlight
 o getFlight3
 public Flight getFlight3()
Returns the third Flight object (flight from home city to first city in tour). The Flight object (flight information without specific date and number of seat information) is a field in the CustomerFlight object.

See Also:
Flight, OneStopFlight, TransferFlight
 o getStay1
 public HotelStay getStay1()
Returns the first HotelStay object (HotelStay in first city in tour).

See Also:
HotelStay
 o getStay2
 public HotelStay getStay2()
Returns the first HotelStay object (HotelStay in first city in tour).

See Also:
HotelStay
 o getHotel1
 public Hotel getHotel1(Connection conn) throws SQLException
Returns the first Hotel in the tour. Hotel is a field in the HotelStay object.

Parameters:
conn - connection to the database.
Throws: SQLException
Thrown if there is a SQL error.
See Also:
Hotel
 o getHotel2
 public Hotel getHotel2(Connection conn) throws SQLException
Returns the second Hotel in the tour. Hotel is a field in the HotelStay object.

Parameters:
conn - connection to the database.
Throws: SQLException
Thrown if there is a SQL error.
See Also:
Hotel
 o getTotalCost
 public BigDecimal getTotalCost()
Returns the total cost of the tour (cost of three flights for all group members and two hotel stays).

 o getLevel
 public String getLevel(Connection conn) throws SQLException
Returns the "level" of the tour (first class, standard, or economy).

Parameters:
conn - Connection to the database
Throws: SQLException
Thrown if there is a SQL error.
 o getAverageCostPerDayPerPerson
 public BigDecimal getAverageCostPerDayPerPerson(Connection conn) throws SQLException
Returns average cost of the tour per person, per day.

Parameters:
conn - Connection to the database
Throws: SQLException
Thrown if there is a SQL error.
 o getTotalMilesTraveled
 public int getTotalMilesTraveled()
Returns total miles traveled (the mileage of all three flights)

 o writeExternal
 public void writeExternal(ObjectOutput out) throws IOException
 o readExternal
 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
 o getCity1
 public City getCity1(Connection conn) throws SQLException
Gets the first city (home city).

Parameters:
conn - Connection to the database
Returns:
City home city
Throws: SQLException
Thrown if there is a SQL error.
 o getCity2
 public City getCity2(Connection conn) throws SQLException
Gets the first city visited (second city).

Parameters:
conn - Connection to the database
Returns:
City second city
Throws: SQLException
Thrown if there is a SQL error.
 o getCity3
 public City getCity3(Connection conn) throws SQLException
Gets the second city visited (third city).

Parameters:
conn - Connection to the database
Returns:
City third city
Throws: SQLException
Thrown if there is a SQL error.
 o getGroup
 public Group getGroup(Connection conn) throws SQLException
Accessor method for the group. If we have the group object, just return it. If we don't have it, find it and return it.

Parameters:
conn - Connection
Returns:
Group The Tour's Group field.
Throws: SQLException
Thrown if there is a SQL error.
 o getStringForLevel
 public static String getStringForLevel(short level)
Gets the String corresponding for the short level value.

Parameters:
level - the short representing the level of the tour
Returns:
String the corresponding String (e.g., "economy", "first class", etc.)
 o getShortForLevel
 public static short getShortForLevel(String level)
Gets the short corresponding to the String representing the tour level.

Parameters:
level - the String representing the level of the tour (e.g., "first class", etc.)
 o getJavaFieldForLevel
 public static String getJavaFieldForLevel(short level)
Gets the name of the static field in this class corresponding to short representing the level of the tour.

Parameters:
level - the short representing the level of the tour
Returns:
String fullname of the Java field
 o getSQLJFieldForLevel
 public static String getSQLJFieldForLevel(short level)
Gets the SQL-J version of the name of the static field in this class corresponding to short representing the level of the tour.

Parameters:
level - the short representing the level of the tour
Returns:
String fullname of the Java field
 o temporarilyDowngradeTourLevel
 public static short temporarilyDowngradeTourLevel(short level)
Go down a level in the tour for booking reasons.

Parameters:
level - the short representing the desired level of the tour
Returns:
short the desired level-1 if the level is greater than 1; otherwise, the desired level
 o temporarilyUpgradeTourLevel
 public static short temporarilyUpgradeTourLevel(short level)
Go up a level in the tour for booking reasons.

Parameters:
level - the short representing the desired level of the tour
Returns:
short the desired level+1 if the level is less than 3; otherwise, the desired level
 o equals
 public boolean equals(Object o)
Good Cloudscape practice requires us to override equals and hashCode from Object.

Returns:
boolean if the objects are equal
Overrides:
equals in class Object
 o hashCode
 public int hashCode()
Good Cloudscape practice erquires us to override equals and hashCode from Object.

Overrides:
hashCode in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index