|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsemorg.sql.tables.AbstractTable
semorg.sql.tables.Booking
semorg.sql.tables.CompanyBooking
public class CompanyBooking
Models the booking of a presentation by a company.
Field Summary | |
---|---|
private static String |
companyBookingInsertString
SQL query to insert a companybooking record. |
private static String |
companyBookingUpdateString
SQL query to update a companybooking record. |
private int |
companyId
The id of the company which booked the presentation. |
private static String |
createTableSQLString
SQL statement for creating the table "companybooking" (if not exists). |
private int |
presentationId
The id of the presantation booked by the company. |
private static String |
queryString
SQL query to get all companybooking records from the database. |
private static String |
tableName
The name of the corresponding table in the db. |
Fields inherited from class semorg.sql.tables.Booking |
---|
billed, bookingInsertString, bookingUpdateString, confirmed, enrolled, id, lockedIds, messaged, signedOff |
Fields inherited from class semorg.sql.tables.AbstractTable |
---|
creationDate, modificationDate, NULL_ID |
Constructor Summary | |
---|---|
CompanyBooking(int id,
Date enrolled,
Date confirmed,
Date billed,
Date signedOff,
Date messaged,
int presentationId,
int companyId,
Timestamp creationDate,
Timestamp modificationDate)
Creates an instance of the class Client with the given parameters. |
Method Summary | |
---|---|
static void |
createCompanyBookingTable(Statement statement)
Creates the table "companybooking" if it does not exist. |
static DistinctVector<CompanyBooking> |
getBookingsForPresentation(int presentationId)
Returns all bookings for a presentation for a given presentation id. |
static DistinctVector<CompanyBooking> |
getBookingsOfCompany(int companyId)
Returns all bookings of a company according to the given compony id. |
static Vector<DBColumn> |
getColumns()
Returns a vector of DBColumn instances according to
the properties of the tables "companybooking". |
static CompanyBooking |
getCompanyBooking(int bookingId)
Returns a CompanyBooking instance for a given id of a companybooking record. |
int |
getCompanyId()
|
static CompanyBooking |
getNext(int currentId)
Returns for a DB-ID the CompanyBooking instance according to the record which has the next bigger id. |
int |
getPresentationId()
|
static CompanyBooking |
getPrevious(int currentId)
Returns for a DB-ID the CompanyBooking instance according to the record which has the next smaller id. |
private static DistinctVector<CompanyBooking> |
getVector(ResultSet resultSet)
Creates for each element in a given ResultSet instance an CompanyBooking object and returns a vector with the resulting CompanyBooking instances. |
static DistinctVector<CompanyBooking> |
getVectorFromDB(Vector<DBConstraint> additionalConstraints,
String sortString)
Creates a PreparedStatement instance with the given parameters, executes the query and returns a vector of CompanyBooking instances corresponding to the ResultSet of the query. |
int |
insertIntoDB()
Inserts a companybooking record into the db. |
void |
setCompanyId(int companyId)
|
void |
setPresentationId(int presentationId)
|
static boolean |
tableOK()
Checks if the according DB table exists. |
void |
updateDB()
Updates a companybooking record in the database. |
Methods inherited from class semorg.sql.tables.Booking |
---|
createBookingTable, equals, getBilled, getConfirmed, getEnrolled, getId, getMessaged, getSignedOff, hashCode, removeFromDB, setBilled, setConfirmed, setEnrolled, setMessaged, setSignedOff |
Methods inherited from class semorg.sql.tables.AbstractTable |
---|
addDBTableChangedListener, createExtendedQueryString, fireTableChangedEvent, getColumns, getCreationDate, getModificationDate, getNext, getPrevious, removeDBTableChangedListener, setModificationDate, tableOK |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private int presentationId
private int companyId
private static String tableName
private static String queryString
private static String companyBookingInsertString
private static String companyBookingUpdateString
private static String createTableSQLString
Constructor Detail |
---|
public CompanyBooking(int id, Date enrolled, Date confirmed, Date billed, Date signedOff, Date messaged, int presentationId, int companyId, Timestamp creationDate, Timestamp modificationDate) throws SQLException
SQLException
Method Detail |
---|
private static DistinctVector<CompanyBooking> getVector(ResultSet resultSet)
resultSet
- given ResultSet instance.
public static DistinctVector<CompanyBooking> getVectorFromDB(Vector<DBConstraint> additionalConstraints, String sortString) throws SQLException
additionalConstraints
- additional conditions of the WHERE-clausesortString
- sort string with the following structure
ORDER BY attribute [ASC|DSC]
SQLException
- if the PreparedStatement can't be created or the
execution of the query fails.public static boolean tableOK()
true
, if the table is ok, false
otherwise.AbstractTable.tableOK(String)
public static void createCompanyBookingTable(Statement statement) throws SQLException
statement
- instance of the class Statement, which is used for
executing the SQL statement createTableSQLString
.
SQLException
- If the execution of the given statement with the query
createTableSQLString
or its closing fails.public int insertIntoDB() throws SQLException
Inserts a companybooking record into the db.
To do so, it first inserts a record into the table "booking", secondly a record into the table "companybooking". These two records are linked by a PK-FK-association.
Finally it fires a TableChanged-Event-Listener to update the UI.
insertIntoDB
in class Booking
SQLException
- If the auto-generated id can't resolved from the db, i.e.
it hasnt been generated, or the PreparedStatement
instance can't be created or executed, this exception is
thrown.Booking.insertIntoDB()
public void updateDB() throws SQLException
Updates a companybooking record in the database.
To do so, it firstly updates the corresponding record in the "booking" table and secondly the record in the "companybooking" table.
Finally it fires a TableChanged-Event-Listener to update the UI.
updateDB
in class Booking
SQLException
- If the auto-generated id can't resolved from the db, i.e.
it hasnt been generated, or the PreparedStatement
instance can't be created or executed, this exception is
thrown.Person.updateDB()
public static Vector<DBColumn> getColumns()
DBColumn
instances according to
the properties of the tables "companybooking".
AbstractTable.getColumns(String tableAbbreviation)
public static CompanyBooking getNext(int currentId)
currentId
- the key of the current record
AbstractTable.getNext(String, DBColumn, int)
public static CompanyBooking getPrevious(int currentId)
currentId
- the key of the current record
AbstractTable.getPrevious(String, DBColumn, int)
public int getCompanyId()
public void setCompanyId(int companyId)
public int getPresentationId()
public void setPresentationId(int presentationId)
public static DistinctVector<CompanyBooking> getBookingsOfCompany(int companyId) throws SQLException
companyId
- the id of a company
SQLException
- if the creation or execution of the database query fails.public static DistinctVector<CompanyBooking> getBookingsForPresentation(int presentationId) throws SQLException
presentationId
- the id of a presentation
SQLException
- if the creation or execution of the database query fails.public static CompanyBooking getCompanyBooking(int bookingId) throws SQLException
bookingId
- the id of the wanted CompanyBooking instance
SQLException
- if the creating or executing of database query fails.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |