|
||||||||||
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.ClientBooking
public class ClientBooking
Models the booking of a presentation by a client.
Field Summary | |
---|---|
private static String |
clientBookingInsertString
SQL query to insert a clientbooking record. |
private static String |
clientBookingUpdateString
SQL query to update a clientbooking record. |
private int |
clientId
The id of the client who booked the presentation. |
private static String |
createTableSQLString
SQL statement for creating the table "clientbooking" (if not exists). |
private int |
debitorId
The of the debitor for a client booking. |
private int |
presentationId
The id of the presantation booked by the client. |
private static String |
queryString
SQL query to get all clientbooking records from the database. |
private int |
substituteId
The id of substitute for a client. |
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 | |
---|---|
ClientBooking(int id,
Date enrolled,
Date confirmed,
Date billed,
Date signedOff,
Date messaged,
int presentationId,
int clientId,
int debitorId,
int substituteId,
Timestamp creationDate,
Timestamp modificationDate)
Creates an instance of the class Client with the given parameters. |
Method Summary | |
---|---|
static void |
createClientBookingTable(Statement statement)
Creates the table "clientbooking" if it does not exist. |
static DistinctVector<ClientBooking> |
getBookingsForPresentation(int presentationId)
Returns all bookings for a presentation for a given presentation id. |
static DistinctVector<ClientBooking> |
getBookingsOfClient(int clientId)
Returns all bookings of a client according to the given client id. |
static ClientBooking |
getClientBooking(int bookingId)
Returns a ClientBooking instance for a given id of a clientbooking record. |
int |
getClientId()
|
static Vector<DBColumn> |
getColumns()
Returns a vector of DBColumn instances according to
the properties of the tables "clientbooking". |
int |
getDebitorId()
|
static ClientBooking |
getNext(int currentId)
Returns for a DB-ID the ClientBooking instance according to the record which has the next bigger id. |
int |
getPresentationId()
|
static ClientBooking |
getPrevious(int currentId)
Returns for a DB-ID the ClientBooking instance according to the record which has the next smaller id. |
String |
getSubstituteDescription()
Returns the first- and the lastname of the substitute for a ClientBooking. |
int |
getSubstituteId()
|
private static DistinctVector<ClientBooking> |
getVector(ResultSet resultSet)
Creates for each element in a given ResultSet instance an ClientBooking object and returns a vector with the resulting ClientBooking instances. |
static DistinctVector<ClientBooking> |
getVectorFromDB(Vector<DBConstraint> additionalConstraints,
String sortString)
Creates a PreparedStatement instance with the given parameters, executes the query and returns a vector of ClientBooking instances corresponding to the ResultSet of the query. |
int |
insertIntoDB()
Inserts a clientbooking record into the db. |
void |
setClientId(int clientId)
|
void |
setDebitorId(int debitorId)
|
void |
setPresentationId(int presentationId)
|
void |
setSubstituteId(int substituteId)
|
static boolean |
tableOK()
Checks if the according DB table exists. |
void |
updateDB()
Updates a clientbooking 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 clientId
private int debitorId
private int substituteId
private static String tableName
private static String queryString
private static String clientBookingInsertString
private static String clientBookingUpdateString
private static String createTableSQLString
Constructor Detail |
---|
public ClientBooking(int id, Date enrolled, Date confirmed, Date billed, Date signedOff, Date messaged, int presentationId, int clientId, int debitorId, int substituteId, Timestamp creationDate, Timestamp modificationDate) throws SQLException
SQLException
Method Detail |
---|
public String getSubstituteDescription()
firstname + " " + lastname
or the empty string if
no substitute exists.private static DistinctVector<ClientBooking> getVector(ResultSet resultSet)
resultSet
- given ResultSet instance.
public static DistinctVector<ClientBooking> 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 createClientBookingTable(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 clientbooking record into the db.
To do so, it first inserts a record into the table "booking", secondly a record into the table "clientbooking". 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 clientbooking record in the database.
To do so, it firstly updates the corresponding record in the "booking" table and secondly the record in the "clientbooking" 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 "clientbooking".
AbstractTable.getColumns(String tableAbbreviation)
public static ClientBooking getClientBooking(int bookingId) throws SQLException
bookingId
- the id of the wanted ClientBooking instance
SQLException
- if the creating or executing of database query fails.public static ClientBooking getNext(int currentId)
currentId
- the key of the current record
AbstractTable.getNext(String, DBColumn, int)
public static ClientBooking getPrevious(int currentId)
currentId
- the key of the current record
AbstractTable.getPrevious(String, DBColumn, int)
public int getClientId()
public void setClientId(int clientId)
public int getDebitorId()
public void setDebitorId(int debitorId)
public int getPresentationId()
public void setPresentationId(int presentationId)
public static DistinctVector<ClientBooking> getBookingsOfClient(int clientId) throws SQLException
clientId
- the id of a client
SQLException
- if the creation or execution of the database query fails.public static DistinctVector<ClientBooking> getBookingsForPresentation(int presentationId) throws SQLException
presentationId
- the id of a presentation
SQLException
- if the creation or execution of the database query fails.public int getSubstituteId()
public void setSubstituteId(int substituteId)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |