semorg.sql.tables
Class CompanyInternalPresentation

java.lang.Object
  extended by semorg.sql.tables.AbstractTable
      extended by semorg.sql.tables.Presentation
          extended by semorg.sql.tables.CompanyInternalPresentation
All Implemented Interfaces:
SimpleIDKey

public class CompanyInternalPresentation
extends Presentation

This class models a company internal presentation.


Field Summary
private  String companyInternalPresentationCurrentEntrantsString
          SQL query to retrieve the current number of entrants.
private static String companyInternalPresentationInsertString
          Parameterized SQL statement for inserting a company internal presentation.
private static String companyInternalPresentationUpdateString
          Parameterized SQL statement for updating a company internal presentation.
private static String createTableSQLString
          SQL statement for creating the table "publicpresentation" (if not exists).
protected  Integer maxEntrants
          The maximal number of entrants.
private  Float packagePrice
          The package prize of the company internal presentation.
private static String queryString
          SQL query to get all "company internal presentation" records from the database.
private static String tableName
          The name of the corresponding db table.
 
Fields inherited from class semorg.sql.tables.Presentation
annex, beginningDay, cancelled, city, country, duration, endingDay, endingTime, firstStartingTime, id, lastEndingTime, location, lockedIds, presentationInsertString, presentationUpdateString, seminarTypeId, startingTime, street, zipCode
 
Fields inherited from class semorg.sql.tables.AbstractTable
creationDate, modificationDate, NULL_ID
 
Constructor Summary
CompanyInternalPresentation(int id, int seminarTypeId, Integer duration, Date beginningDay, Date endingDay, Time startingTime, Time endingTime, Time firstStartingTime, Time lastEndingTime, String location, String street, String zipCode, String city, String country, String annex, boolean cancelled, Float packagePrice, Integer maxEntrants, Timestamp creationDate, Timestamp modificationDate)
          Creates an instance of the class CompanyInternalPresentation with the given parameters.
 
Method Summary
static void createCompanyInternalPresentationTable(Statement statement)
          Creates the table "companyintenalpresentation" if it does not exist.
static Vector<DBColumn> getColumns()
          Returns a vector of DBColumn instances according to the properties of the table "companyinternalpresentation".
static Vector<DBColumn> getColumnsWithSemtype()
          Returns a Vector of DBColumn objects for the current CompanyInternalPresentation instance.
static CompanyInternalPresentation getCompanyInternalPresentation(int presentationId)
          Provides for a given id the corresponding company internal presentation.
 int getCurrentEntrantsCount()
          Returns the number of the current entrants of this company internal presentation.
 Integer getMaxEntrants()
           
static CompanyInternalPresentation getNext(int currentId)
          Returns for a DB-ID the CompanyInternalPresentation instance according to the record which has the next bigger id.
 Float getPackagePrice()
           
static CompanyInternalPresentation getPrevious(int currentId)
          Returns for a DB-ID the CompanyInternalPresentation instance according to the record which has the next smaller id.
private static DistinctVector<CompanyInternalPresentation> getVector(ResultSet resultSet)
          Creates for each element in a given ResultSet instance an CompanyInternalPresentation object and returns a vector with the resulting instances.
static DistinctVector<CompanyInternalPresentation> getVectorFromDB(Vector<DBConstraint> additionalConstraints, String sortString)
          Creates a PreparedStatement instance with the given parameters, executes the query and returns a vector of CompanyInternalPresentation instances corresponding to the ResultSet of the query.
 int insertIntoDB()
          Converts the actual Presentation object into a database record and inserts it into the table presentation.
 void setMaxEntrants(Integer maxEntrants)
           
 void setPackagePrice(Float packagePrice)
           
static boolean tableOK()
          Checks if the according DB table exists.
 void updateDB()
          Converts the actual Presentation object into a database record and updates a existing record to the changes made.
 
Methods inherited from class semorg.sql.tables.Presentation
createPresentationTable, equals, getAnnex, getBeginningDay, getCity, getCountry, getDuration, getEndingDay, getEndingTime, getFirstStartingTime, getId, getLastEndingTime, getLocation, getPresentation, getPresentationVectorFromDB, getPresForSemType, getPresInstructedBy, getPresSupervisedBy, getSeminarTypeDescription, getSeminarTypeForPresId, getSeminarTypeId, getShortDescription, getStartingTime, getStreet, getZipCode, hashCode, isCancelled, removeFromDB, setAnnex, setBeginningDay, setCancelled, setCity, setCountry, setDuration, setEndingDay, setEndingTime, setFirstStartingTime, setLastEndingTime, setLocation, setSeminarTypeId, setStartingTime, setStreet, setZipCode
 
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

packagePrice

private Float packagePrice
The package prize of the company internal presentation.


maxEntrants

protected Integer maxEntrants
The maximal number of entrants.


companyInternalPresentationCurrentEntrantsString

private String companyInternalPresentationCurrentEntrantsString
SQL query to retrieve the current number of entrants.


tableName

private static String tableName
The name of the corresponding db table.


queryString

private static String queryString
SQL query to get all "company internal presentation" records from the database. (delives also the inherited attributes)


companyInternalPresentationInsertString

private static String companyInternalPresentationInsertString
Parameterized SQL statement for inserting a company internal presentation.


companyInternalPresentationUpdateString

private static String companyInternalPresentationUpdateString
Parameterized SQL statement for updating a company internal presentation.


createTableSQLString

private static String createTableSQLString
SQL statement for creating the table "publicpresentation" (if not exists).

Constructor Detail

CompanyInternalPresentation

public CompanyInternalPresentation(int id,
                                   int seminarTypeId,
                                   Integer duration,
                                   Date beginningDay,
                                   Date endingDay,
                                   Time startingTime,
                                   Time endingTime,
                                   Time firstStartingTime,
                                   Time lastEndingTime,
                                   String location,
                                   String street,
                                   String zipCode,
                                   String city,
                                   String country,
                                   String annex,
                                   boolean cancelled,
                                   Float packagePrice,
                                   Integer maxEntrants,
                                   Timestamp creationDate,
                                   Timestamp modificationDate)
                            throws SQLException
Creates an instance of the class CompanyInternalPresentation with the given parameters.

Throws:
SQLException
Method Detail

getVector

private static DistinctVector<CompanyInternalPresentation> getVector(ResultSet resultSet)
Creates for each element in a given ResultSet instance an CompanyInternalPresentation object and returns a vector with the resulting instances.

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

getVectorFromDB

public static DistinctVector<CompanyInternalPresentation> getVectorFromDB(Vector<DBConstraint> additionalConstraints,
                                                                          String sortString)
                                                                   throws SQLException
Creates a PreparedStatement instance with the given parameters, executes the query and returns a vector of CompanyInternalPresentation 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 CompanyInternalPresentation 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)

createCompanyInternalPresentationTable

public static void createCompanyInternalPresentationTable(Statement statement)
                                                   throws SQLException
Creates the table "companyintenalpresentation" 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
Description copied from class: Presentation
Converts the actual Presentation object into a database record and inserts it into the table presentation. Furthermore this method queries the auto-generated id, sets the appropriate property Presentation.id and returns the id. If a country or annex has been inserted into the form, this method also inserts the concerning properties into the table "enumeration" for later use. Finally it fires a TableChanged-EventListener to update the UI.

Overrides:
insertIntoDB in class Presentation
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 hasn't been generated, or the PreparedStatement instance can't be created or executed etc.

updateDB

public void updateDB()
              throws SQLException
Description copied from class: Presentation
Converts the actual Presentation object into a database record and updates a existing record to the changes made. If a country or annex has been inserted into the form, this method also inserts the concerning properties into the table "enumeration" for later use. Finally it fires a TableChanged-EventListener to update the UI.

Overrides:
updateDB in class Presentation
Throws:
SQLException - If the PreparedStatement instance can't be created or executed, this exception is thrown.

getColumns

public static Vector<DBColumn> getColumns()
Returns a vector of DBColumn instances according to the properties of the table "companyinternalpresentation". Note that this function maps the names of the database columns to the names of the GUI tables.

Returns:
the vector of DBColumn instances.
See Also:
AbstractTable.getColumns(String tableAbbreviation)

getColumnsWithSemtype

public static Vector<DBColumn> getColumnsWithSemtype()
Returns a Vector of DBColumn objects for the current CompanyInternalPresentation instance.

Note that the second element in the vector gets replaced by a DBColumn which contains the shortened title of the corresponding SeminarType.


getNext

public static CompanyInternalPresentation getNext(int currentId)
Returns for a DB-ID the CompanyInternalPresentation instance according to the record which has the next bigger id.

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

getPrevious

public static CompanyInternalPresentation getPrevious(int currentId)
Returns for a DB-ID the CompanyInternalPresentation instance according to the record which has the next smaller id.

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

getCompanyInternalPresentation

public static CompanyInternalPresentation getCompanyInternalPresentation(int presentationId)
                                                                  throws SQLException
Provides for a given id the corresponding company internal presentation.

Parameters:
presentationId - the id of a presentation
Returns:
DistinctVector instance containing all CompanyInternalPresentation instances which meets the conditions mentioned above.
Throws:
SQLException - If the creation, manipulation, execution or closing of a PreparedStatement instance used for querying the database fails.

getCurrentEntrantsCount

public int getCurrentEntrantsCount()
                            throws SQLException
Returns the number of the current entrants of this company internal presentation.

Returns:
number of current entrants.
Throws:
SQLException - If the creation, manipulation, execution or closing of a PreparedStatement instance used for querying the database fails. Of if the database delivers a empty result set.

getMaxEntrants

public Integer getMaxEntrants()

setMaxEntrants

public void setMaxEntrants(Integer maxEntrants)

getPackagePrice

public Float getPackagePrice()

setPackagePrice

public void setPackagePrice(Float packagePrice)