Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## semorg.sql.tables
Class CompanyBooking

    java.lang.Object
      semorg.sql.tables.AbstractTable
          semorg.sql.tables.Booking
              semorg.sql.tables.CompanyBooking

All Implemented Interfaces:
  SimpleIDKey

    public class CompanyBooking

extends Booking

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

### presentationId

    private int presentationId

  The id of the presantation booked by the company.

### companyId

    private int companyId

  The id of the company which booked the presentation.

### tableName

    private static String tableName

  The name of the corresponding table in the db.

### queryString

    private static String queryString

  SQL query to get all companybooking records from the database. (delives also the inherited attributes)

### companyBookingInsertString

    private static String companyBookingInsertString

  SQL query to insert a companybooking record.

### companyBookingUpdateString

    private static String companyBookingUpdateString

  SQL query to update a companybooking record.

### createTableSQLString

    private static String createTableSQLString

  SQL statement for creating the table "companybooking" (if not exists).

Constructor Detail

### CompanyBooking

    public CompanyBooking(int id,
                          Date enrolled,
                          Date confirmed,
                          Date billed,
                          Date signedOff,
                          Date messaged,
                          int presentationId,
                          int companyId,
                          Timestamp creationDate,
                          Timestamp modificationDate)
                   throws SQLException

  Creates an instance of the class Client with the given parameters.

  Throws:
    `SQLException`

Method Detail

### getVector

    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.

  Parameters:
    `resultSet` - given ResultSet instance.
  Returns:
    a DistinctVector instance filled with the created CompanyBooking instances.

### getVectorFromDB

    public static DistinctVector<CompanyBooking> getVectorFromDB(Vector<DBConstraint> additionalConstraints,
                                                                 String sortString)
                                                          throws SQLException

  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.

  Parameters:
    `additionalConstraints` - additional conditions of the WHERE-clause
    `sortString` - sort string with the following structure `ORDER BY attribute [ASC|DSC]`
  Returns:
    a DistinctVector instance filled with the created CompanyBooking instances.
  Throws:
    `SQLException` - if the PreparedStatement can't be created or the execution of the query fails.

### tableOK

    public static boolean tableOK()

  Checks if the according DB table exists.

  Returns:
    `true`, if the table is ok, `false` otherwise.
  See Also:
    `AbstractTable.tableOK(String)`

### createCompanyBookingTable

    public static void createCompanyBookingTable(Statement statement)
                                          throws SQLException

  Creates the table "companybooking" if it does not exist.

  Parameters:
    `statement` - instance of the class Statement, which is used for executing the SQL statement `createTableSQLString`.
  Throws:
    `SQLException` - If the execution of the given statement with the query `createTableSQLString` or its closing fails.

### insertIntoDB

    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.

  Overrides:
    `insertIntoDB` in class `Booking`
  Returns:
    the auto-generated id of the inserted tupel.
  Throws:
    `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.
  See Also:
    `Booking.insertIntoDB()`

### updateDB

    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.

  Overrides:
    `updateDB` in class `Booking`
  Throws:
    `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.
  See Also:
    `Person.updateDB()`

### getColumns

    public static Vector<DBColumn> getColumns()

  Returns a vector of `DBColumn` instances according to the properties of the tables "companybooking".

  Returns:
    the vector of DBColumn instances according to the properties of the class CompanyBooking.
  See Also:
    `AbstractTable.getColumns(String tableAbbreviation)`

### getNext

    public static CompanyBooking getNext(int currentId)

  Returns for a DB-ID the CompanyBooking instance according to the record which has the next bigger id.

  Parameters:
    `currentId` - the key of the current record
  Returns:
    the CompanyBooking instance corresponding to the next record in the table "companytbooking" or if it does not exist the CompanyBooking instance with the smallest id.
  See Also:
    `AbstractTable.getNext(String, DBColumn, int)`

### getPrevious

    public static CompanyBooking getPrevious(int currentId)

  Returns for a DB-ID the CompanyBooking instance according to the record which has the next smaller id.

  Parameters:
    `currentId` - the key of the current record
  Returns:
    the CompanyBooking instance corresponding to the previous record in the table "companybooking" or if it does not exist the CompanyBooking instance with the biggest id.
  See Also:
    `AbstractTable.getPrevious(String, DBColumn, int)`

### getCompanyId

    public int getCompanyId()

### setCompanyId

    public void setCompanyId(int companyId)

### getPresentationId

    public int getPresentationId()

### setPresentationId

    public void setPresentationId(int presentationId)

### getBookingsOfCompany

    public static DistinctVector<CompanyBooking> getBookingsOfCompany(int companyId)
                                                               throws SQLException

  Returns all bookings of a company according to the given compony id.

  Parameters:
    `companyId` - the id of a company
  Returns:
    a DistinctVector instance filled with all CompanyBooking instances corresponding to the company with the given id.
  Throws:
    `SQLException` - if the creation or execution of the database query fails.

### getBookingsForPresentation

    public static DistinctVector<CompanyBooking> getBookingsForPresentation(int presentationId)
                                                                     throws SQLException

  Returns all bookings for a presentation for a given presentation id.

  Parameters:
    `presentationId` - the id of a presentation
  Returns:
    a DistinctVector instance filled with all CompanyBooking instances corresponding to the presentation with the given id.
  Throws:
    `SQLException` - if the creation or execution of the database query fails.

### getCompanyBooking

    public static CompanyBooking getCompanyBooking(int bookingId)
                                            throws SQLException

  Returns a CompanyBooking instance for a given id of a companybooking record.

  Parameters:
    `bookingId` - the id of the wanted CompanyBooking instance
  Returns:
    a CompanyBooking object correspoding to the given id.
  Throws:
    `SQLException` - if the creating or executing of database query fails.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD