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.
-
begin
- first date of travel (home city to first city).
-
city1
- first city (home city), transient (not stored).
-
city1Name
-
-
city2
- second city (middle city), transient (not stored).
-
city2Name
-
-
city3
- third city (destination city), transient (not stored).
-
city3Name
-
-
cityId1
-
-
cityId2
-
-
cityId3
-
-
currentClassVersion
-
-
ECONOMYTOURLEVEL
-
-
end
- final date of travel (second city to home city).
-
FIRSTCLASSTOURLEVEL
-
-
middle
- second date of travel (first city to second city).
-
myflight
-
-
myflight2
-
-
myflight3
-
-
myGroup
- Group taking the tour, transient (not stored).
-
myGroupId
-
-
myStay
-
-
secondStay
-
-
STANDARDTOURLEVEL
-
-
Tour()
- No arg constructer required.
-
Tour(Group, City, City, City, Date, Date, Date)
- Constructs a two-city tour object.
-
buildTheTour(Connection)
- Fills out the objects that are part of the tour.
-
equals(Object)
- Good Cloudscape practice requires us to override equals and hashCode
from Object.
-
findANewHotelStay(Connection, int, BigDecimal)
- Allows you to alter the tour to change one hotel stay for another one.
-
getAverageCostPerDayPerPerson(Connection)
- Returns average cost of the tour per person, per day.
-
getCity1(Connection)
- Gets the first city (home city).
-
getCity2(Connection)
- Gets the first city visited (second city).
-
getCity3(Connection)
- Gets the second city visited (third city).
-
getCustomerFlight1()
- Returns the first CustomerFlight object (flight from home city
to first city in tour).
-
getCustomerFlight2()
- Returns the second CustomerFlight object (flight from home city
to first city in tour).
-
getCustomerFlight3()
- Returns the third CustomerFlight object (flight from home city
to first city in tour).
-
getFlight1()
- Returns the first Flight object (flight from home city
to first city in tour).
-
getFlight2()
- Returns the second Flight object (flight from home city
to first city in tour).
-
getFlight3()
- Returns the third Flight object (flight from home city
to first city in tour).
-
getGroup(Connection)
-
Accessor method for the group.
-
getHotel1(Connection)
- Returns the first Hotel in the tour.
-
getHotel2(Connection)
- Returns the second Hotel in the tour.
-
getJavaFieldForLevel(short)
- Gets the name of the static field in this class corresponding to short representing
the level of the tour.
-
getLevel(Connection)
- Returns the "level" of the tour (first class, standard, or economy).
-
getShortForLevel(String)
- Gets the short corresponding to the String representing the tour level.
-
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.
-
getStay1()
- Returns the first HotelStay object (HotelStay in
first city in tour).
-
getStay2()
- Returns the first HotelStay object (HotelStay in
first city in tour).
-
getStringForLevel(short)
- Gets the String corresponding for the short level value.
-
getTotalCost()
- Returns the total cost of the tour
(cost of three flights for all group members and two hotel stays).
-
getTotalMilesTraveled()
- Returns total miles traveled (the mileage of all three flights)
-
getTourInfo(Connection)
-
-
hashCode()
- Good Cloudscape practice erquires us to override equals and hashCode
from Object.
-
printTourInfo(Connection)
- Prints information about the tour.
-
printWelcomeGroup(Connection)
- Prints a welcome message.
-
readExternal(ObjectInput)
-
-
storeInDatabase(Connection)
- Stores the tour as an object in the CustomizedTours table.
-
temporarilyDowngradeTourLevel(short)
- Go down a level in the tour for booking reasons.
-
temporarilyUpgradeTourLevel(short)
- Go up a level in the tour for booking reasons.
-
toString()
- Get a string value for the tour.
-
writeExternal(ObjectOutput)
-
city1
protected transient City city1
- first city (home city), transient (not stored). Store id only.
cityId1
protected int cityId1
city1Name
protected String city1Name
city2
protected transient City city2
- second city (middle city), transient (not stored). Store id only.
cityId2
protected int cityId2
city2Name
protected String city2Name
city3
protected transient City city3
- third city (destination city), transient (not stored). Store id only.
cityId3
protected int cityId3
city3Name
protected String city3Name
begin
public Date begin
- first date of travel (home city to first city).
middle
public Date middle
- second date of travel (first city to second city).
end
public Date end
- final date of travel (second city to home city).
myflight
protected CustomerFlight myflight
myflight2
protected CustomerFlight myflight2
myflight3
protected CustomerFlight myflight3
myStay
protected HotelStay myStay
secondStay
protected HotelStay secondStay
myGroup
protected transient Group myGroup
- Group taking the tour, transient (not stored). Store id only.
myGroupId
protected int myGroupId
ECONOMYTOURLEVEL
public static final short ECONOMYTOURLEVEL
STANDARDTOURLEVEL
public static final short STANDARDTOURLEVEL
FIRSTCLASSTOURLEVEL
public static final short FIRSTCLASSTOURLEVEL
currentClassVersion
protected static final int currentClassVersion
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.
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.
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
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
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.
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.
getTourInfo
public String getTourInfo(Connection conn) throws SQLException
- Parameters:
- conn - Connection to the db.
- Throws: SQLException
- Thrown if there is a SQL error.
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.
toString
public String toString()
- Get a string value for the tour.
- Overrides:
- toString in class Object
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
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
getCustomerFlight2
public CustomerFlight getCustomerFlight2()
- Returns the second CustomerFlight object (flight from home city
to first city in tour).
- See Also:
- CustomerFlight
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
getCustomerFlight3
public CustomerFlight getCustomerFlight3()
- Returns the third CustomerFlight object (flight from home city
to first city in tour).
- See Also:
- CustomerFlight
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
getStay1
public HotelStay getStay1()
- Returns the first HotelStay object (HotelStay in
first city in tour).
- See Also:
- HotelStay
getStay2
public HotelStay getStay2()
- Returns the first HotelStay object (HotelStay in
first city in tour).
- See Also:
- HotelStay
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
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
getTotalCost
public BigDecimal getTotalCost()
- Returns the total cost of the tour
(cost of three flights for all group members and two hotel stays).
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.
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.
getTotalMilesTraveled
public int getTotalMilesTraveled()
- Returns total miles traveled (the mileage of all three flights)
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
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.
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.
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.
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.
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.)
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.)
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
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
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
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
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
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