semorg.sql.tables
Class PublicPresentation

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

public class PublicPresentation
extends Presentation

Models a public presentation.


Field Summary
private  Float cancelFee
          The cancel fee of a public presentation.
private  String coopPartner
          The name of the co-operation partner.
private static String createTableSQLString
          SQL statement for creating the table "publicpresentation" (if not exists).
private  String publicPresentationCurrentEntrantsString
          The number of current entrants of a public presentation.
private static String publicPresentationInsertString
          Parameterized SQL statement for inserting a public presentation.
private static String publicPresentationUpdateString
          Parameterized SQL statement for updating a public presentation.
private static String queryString
          SQL query to get all "public 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
PublicPresentation(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, String coopPartner, Float cancelFee, Timestamp creationDate, Timestamp modificationDate)
          Creates an instance of the class PublicPresentation with the given parameters.
 
Method Summary
static void createPublicPresentationTable(Statement statement)
          Creates the table "publicpresentation" if it does not exist.
 Float getCancelFee()
           
static Vector<DBColumn> getColumns()
          Returns a vector of DBColumn instances according to the properties of the table "publicpresentation".
static Vector<DBColumn> getColumnsWithSemtype()
          Returns a Vector of DBColumn objects for the current PublicPresentation instance.
 String getCoopPartner()
           
 int getCurrentEntrantsCount()
          Returns the number of the current entrants of this public presentation.
static PublicPresentation getNext(int currentId)
          Returns for a DB-ID the PublicPresentation instance according to the record which has the next bigger id.
static PublicPresentation getPrevious(int currentId)
          Returns for a DB-ID the PublicPresentation instance according to the record which has the next smaller id.
static PublicPresentation getPublicPresentation(int presentationId)
          Provides for a given id the corresponding public presentation.
private static DistinctVector<PublicPresentation> getVector(ResultSet resultSet)
          Creates for each element in a given ResultSet instance an PublicPresentation object and returns a vector with the resulting PublicPresentation instances.
static DistinctVector<PublicPresentation> getVectorFromDB(Vector<DBConstraint> additionalConstraints, String sortString)
          Creates a PreparedStatement instance with the given parameters, executes the query and returns a vector of PublicPresentation 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 setCancelFee(Float cancelFee)
           
 void setCoopPartner(String coopPartner)
           
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

coopPartner

private String coopPartner
The name of the co-operation partner.


cancelFee

private Float cancelFee
The cancel fee of a public presentation.


publicPresentationCurrentEntrantsString

private String publicPresentationCurrentEntrantsString
The number of current entrants of a public presentation.


tableName

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


queryString

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


publicPresentationInsertString

private static String publicPresentationInsertString
Parameterized SQL statement for inserting a public presentation.


publicPresentationUpdateString

private static String publicPresentationUpdateString
Parameterized SQL statement for updating a public presentation.


createTableSQLString

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

Constructor Detail

PublicPresentation

public PublicPresentation(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,
                          String coopPartner,
                          Float cancelFee,
                          Timestamp creationDate,
                          Timestamp modificationDate)
                   throws SQLException
Creates an instance of the class PublicPresentation with the given parameters.

Throws:
SQLException
Method Detail

getVector

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

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

getVectorFromDB

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

createPublicPresentationTable

public static void createPublicPresentationTable(Statement statement)
                                          throws SQLException
Creates the table "publicpresentation" 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 "publicpresentation". 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 PublicPresentation instance.

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


getCoopPartner

public String getCoopPartner()

setCoopPartner

public void setCoopPartner(String coopPartner)

getCancelFee

public Float getCancelFee()

setCancelFee

public void setCancelFee(Float cancelFee)

getNext

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

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

getPrevious

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

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

getPublicPresentation

public static PublicPresentation getPublicPresentation(int presentationId)
                                                throws SQLException
Provides for a given id the corresponding public presentation.

Parameters:
presentationId - the id of a presentation
Returns:
DistinctVector instance containing all PublicPresentation 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 public 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.