All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class JBMSTours.Group

java.lang.Object
   |
   +----JBMSTours.Group

public class Group
extends Object
Look at the Source.

Basic class for tracking the customer group. BuildATour constructs the group objects. Stored as relational data in database.

Cloudscape automatically generates the integer value in the group_id column (DEFAULT AUTOINCREMENT); this class uses the resetGroupIdToAutoincrementValue method to find out what that value was and to assign it to this.groupId.


Variable Index

 o address
The address to contact the group's main person.
 o city_id
The city_id from which the group's trip will start.
 o mainPerson
The id of the main person in the group.
 o numberAdults
The number of adults in the group.
 o numberKids
The number of children in the group.
 o phone
The phone number for contacting the group's main person.

Constructor Index

 o Group()
Create a new group, initializing it to have no members.
 o Group(int)
Create a new group with only a group_id.
 o Group(int, int, int, int, int, String, double)
Constructs a group object.
 o Group(Integer, Integer, Integer, Integer, Integer, Integer, Integer, String, String, Short, BigDecimal, BigDecimal)
Constructs a group object from columns in the Groups table.
 o Group(ResultSet)
Constructs a group object from a row in a result set.

Method Index

 o addMainPersonToGroup(Connection, Person)
Add a the MainPerson to a group in the database.
 o addToGroup(Connection, Person)
Add a person to a group in the database.
 o addToRunning(BigDecimal)
Add to the amount of money the group has spent.
 o getAddress()
Return the group's address.
 o getAvailableFunds()
Return the group's available funds.
 o getCityName(Connection)
Get the name of the group's city.
 o getCityOrigin(Connection)
Get group's city of origin.
 o getGroup(Connection, int)
Get a group from the database given the identifier for it.
 o getGroupId()
Return the id for the group
 o getInfo(Connection)
Returns data about the group as a string..
 o getLevel()
 o getNumberPeople()
Return the number of people in the group.
 o getNumberRooms()
Return the number of rooms needed for the group.
 o getPeopleInGroup(Connection)
Returns a string listing all the people in the group.
 o getPhone()
Return contact phone number for the group.
 o getSeats(Connection)
Get the number of seats needed by the group.
 o getWelcomeMessage(Connection)
Returns a welcome message for the Group
 o insertGroup(Connection)
Write group info to the database.
 o prepareStatements(Connection)
Prepares some of the PreparedStatements for this class.
 o prepareStaticStatements(Connection)
Prepares all the static PreparedStatements for this classs.
 o resetGroupIdToAutoincrementValue(Connection)
Get info about the last AUTOINCREMENT value inserted into the Groups table, and assign that number to this group as its groupId.
 o setAddress(String)
Set the group's address.
 o setPhone(String)
Set the group's phone.
 o toString(Connection)
Convert the object to a string.
 o updateEntireGroup(Connection)
Update group info to the database (everything but group_id).
 o updateRunningTotal(Connection)
Update the running total for the group in the database

Variables

 o numberKids
 public int numberKids
The number of children in the group. Stored in the number_kids column.

 o numberAdults
 public int numberAdults
The number of adults in the group. Stored in the number_adults column.

 o mainPerson
 public int mainPerson
The id of the main person in the group. Stored in the main_person column.

 o address
 public String address
The address to contact the group's main person. Stored in the address column.

 o phone
 public String phone
The phone number for contacting the group's main person. Stored in the phone column.

 o city_id
 public int city_id
The city_id from which the group's trip will start. Stored in the city_id column.

Constructors

 o Group
 public Group()
Create a new group, initializing it to have no members.

 o Group
 public Group(int id)
Create a new group with only a group_id.

 o Group
 public Group(int id,
              int k,
              int a,
              int rooms,
              int cid,
              String level,
              double abudget)
Constructs a group object.

Parameters:
id - The group_id.
k - Number of kids in the group.
a - Number of adults in the group.
id2 - The person_id of the main person in the group.
rooms - The number of rooms needed by the group in a hotel.
acity - The id of the city where the group is from.
level - How the group wants to travel: first class, standard, or economy.
abudget - How much money the group wants to spend.
 o Group
 public Group(Integer gid,
              Integer nk,
              Integer na,
              Integer np,
              Integer mp,
              Integer nr,
              Integer cid,
              String ad,
              String ph,
              Short l,
              BigDecimal bud,
              BigDecimal rt)
Constructs a group object from columns in the Groups table. Uses all objects as parameters to make it easy for Cloudscape to find the signature in a SQL-J statement.

Parameters:
id - The group_id.
k - Number of kids in the group.
a - Number of adults in the group.
np - Number of people
mp - The person_id of the main person in the group.
nr - The number of rooms needed by the group in a hotel.
acity - The id of the city where the group is from.
address - The group's address
ph - the group's phone number
l - How the group wants to travel: first class, standard, or economy.
abudget - How much money the group wants to spend.
rt - How much money the group has spent so far on the tour.
 o Group
 public Group(ResultSet rs) throws SQLException
Constructs a group object from a row in a result set.

Parameters:
rs - a row in a a ResultSet (of select * from Groups)
Throws: SQLException
thrown on database access failure.

Methods

 o getGroup
 public static Group getGroup(Connection conn,
                              int id) throws SQLException
Get a group from the database given the identifier for it.

Parameters:
conn - the connection to the database.
id - the id for the group to load.
Returns:
Group the group from the database.
Throws: SQLException
thrown on database access failure.
 o getInfo
 public String getInfo(Connection conn) throws SQLException
Returns data about the group as a string..

Parameters:
conn - the connection to the database.
Returns:
String object information about the Group
Throws: SQLException
thrown on database access failure.
 o insertGroup
 public int insertGroup(Connection conn) throws SQLException
Write group info to the database.

Parameters:
conn - the connection to the database.
Returns:
the number of rows inserted (expected to be 1).
Throws: SQLException
thrown if database access fails.
 o updateEntireGroup
 public int updateEntireGroup(Connection conn) throws SQLException
Update group info to the database (everything but group_id).

Parameters:
conn - the connection to the database.
Returns:
the number of rows updated (expected to be 1).
Throws: SQLException
thrown if database access fails.
 o updateRunningTotal
 public int updateRunningTotal(Connection conn) throws SQLException
Update the running total for the group in the database

Parameters:
conn - the connection to the database.
Returns:
the number of rows inserted (expected to be 1).
Throws: SQLException
thrown if database access fails.
 o resetGroupIdToAutoincrementValue
 public int resetGroupIdToAutoincrementValue(Connection conn) throws SQLException
Get info about the last AUTOINCREMENT value inserted into the Groups table, and assign that number to this group as its groupId.

Parameters:
conn - the connection to the database.
Returns:
the last AUTOINCREMENT value (the group_id for the group).
Throws: SQLException
thrown if database access fails.
 o addMainPersonToGroup
 public int addMainPersonToGroup(Connection conn,
                                 Person p) throws SQLException
Add a the MainPerson to a group in the database. Updates the mainPerson variable and inserts the person into the PEOPLE table and also into Groups_People. Also updates the main_person field in the Groups table.

Parameters:
conn - the connection to the database.
p - the person to add.
Returns:
the number of rows inserted (expected to be 2).
Throws: SQLException
thrown if database access fails.
 o addToGroup
 public int addToGroup(Connection conn,
                       Person p) throws SQLException
Add a person to a group in the database. Inserts the person into the PEOPLE table and also into Groups_People.

Parameters:
conn - the connection to the database.
p - the person to add.
Returns:
the number of rows inserted (expected to be 2).
Throws: SQLException
thrown if database access fails.
 o getPeopleInGroup
 public String getPeopleInGroup(Connection conn) throws SQLException
Returns a string listing all the people in the group.

Parameters:
conn - the connection to the database.
Returns:
a string concatenating the names of people in the group.
Throws: SQLException
thrown if database access fails.
 o getSeats
 public int getSeats(Connection conn) throws SQLException
Get the number of seats needed by the group. This is the number of people in the group over the age of 2.

Parameters:
conn - the connection to the database.
Returns:
number of seats needed
Throws: SQLException
thrown on database access failure.
 o getCityOrigin
 public City getCityOrigin(Connection conn) throws SQLException
Get group's city of origin.

Parameters:
conn - the connection to the database.
Returns:
City the group's city of origin.
Throws: SQLException
thrown on database access failure.
 o getCityName
 public String getCityName(Connection conn) throws SQLException
Get the name of the group's city.

Parameters:
conn - the connection to the database.
Returns:
name of the group's city of origin.
Throws: SQLException
thrown on database access failure.
 o getWelcomeMessage
 public String getWelcomeMessage(Connection conn) throws SQLException
Returns a welcome message for the Group

Parameters:
conn - the connection to the database.
Throws: SQLException
thrown on database access failure.
 o addToRunning
 public void addToRunning(BigDecimal cost)
Add to the amount of money the group has spent.

Parameters:
cost - amount of money to add to the total spent.
 o setAddress
 public void setAddress(String add)
Set the group's address.

Parameters:
addres - The address of the main person in the group.
 o setPhone
 public void setPhone(String fone)
Set the group's phone.

Parameters:
fone - The phone number of the main person in the group.
 o getAvailableFunds
 public BigDecimal getAvailableFunds()
Return the group's available funds. This is the budget less the current total spent.

Returns:
the available funds.
 o getAddress
 public String getAddress()
Return the group's address.

Returns:
the address.
 o getPhone
 public String getPhone()
Return contact phone number for the group.

Returns:
phone.
 o getGroupId
 public int getGroupId()
Return the id for the group

Returns:
the id for the group
 o getLevel
 public short getLevel()
Returns:
the level of travel.
 o getNumberRooms
 public int getNumberRooms()
Return the number of rooms needed for the group.

Returns:
the number of rooms.
 o getNumberPeople
 public int getNumberPeople()
Return the number of people in the group.

Returns:
the number of people.
 o toString
 public String toString(Connection conn) throws SQLException
Convert the object to a string. Supplies the group Id and originating city.

Parameters:
Conn - Connection to the database
Returns:
string for the group object.
Throws: SQLException
thrown on database access failure.
 o prepareStatements
 public boolean prepareStatements(Connection conn) throws SQLException
Prepares some of the PreparedStatements for this class.

Returns:
boolean if statements are prepared without error
Throws: SQLException
If there is a SQL error
 o prepareStaticStatements
 public static boolean prepareStaticStatements(Connection conn) throws SQLException
Prepares all the static PreparedStatements for this classs. This method is called by static methods.

Returns:
boolean if statements are prepared without error
Throws: SQLException
If there is a SQL error

All Packages  Class Hierarchy  This Package  Previous  Next  Index