semorg.sql.tables
Class SeminarType

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

public class SeminarType
extends AbstractTable
implements SimpleIDKey


Field Summary
protected  String audience
          The ausidence of a seminartype.
protected  Float charge
          The charge of a seminartype.
private static String conductQueryString
          Parameterized SQL statement to get a seminartypes conducted by a given lecturer.
private static String createTableSQLString
          SQL statement for creating the table "seminartype" (if not exists).
protected  String documents
          The documents of a seminartype.
protected  Integer duration
          The duration of a seminartype.
protected  int id
          The DB-ID.
static List<Integer> lockedIds
           
protected  Integer maxEntrants
          The maximal number of entrants of a seminartype.
protected  String methodology
          The methodology of a seminartype.
protected  Integer minEntrants
          The minimal number of entrants of a seminartype.
protected  String objective
          The objective of a seminartype.
private static String queryString
          SQL query to get all seminartype records from the database.
protected  String requirements
          The requirements of a seminartype.
protected  String routine
          The routine of a seminartype.
protected static String seminarTypeInsertString
          Parameterized SQL statement for inserting a data record.
protected static String seminarTypeUpdateString
          Parameterized SQL statement for updating a data record.
protected  String shortTitle
          The shortened title of a seminartype.
private static String tableName
          The name of the corresponding table in the db.
protected  String title
          The title of a seminartype.
protected  String topic
          The topic of a seminartype.
 
Fields inherited from class semorg.sql.tables.AbstractTable
creationDate, modificationDate, NULL_ID
 
Constructor Summary
SeminarType(int id, String shortTitle, String title, String objective, String methodology, String topic, String routine, Integer duration, String documents, String audience, String requirements, Float charge, Integer maxEntrants, Integer minEntrants, Timestamp creationDate, Timestamp modificationDate)
          Creates an instance of the class SeminarType with the given parameters.
 
Method Summary
static void createSeminarTypeTable(Statement statement)
          Creates the table "seminartype" if it does not exist.
 boolean equals(Object otherSeminarType)
          If the given object is an instance of the SeminarType class this method compares the id of the given and the actual object, otherwise it calls the equal-method of the AbstractTable class with the given object.
 boolean equals(SeminarType otherSeminarType)
          Compares the ids of a given object and the current one.
 String getAudience()
           
 Float getCharge()
           
static Vector<DBColumn> getColumns()
          Returns a vector of DBColumn instances according to the properties of the table corresponding to this class.
 String getDocuments()
           
 Integer getDuration()
           
 int getId()
          Returns the DB-ID of a database records.
 Integer getMaxEntrants()
           
 String getMethodology()
           
 Integer getMinEntrants()
           
static SeminarType getNext(int semTypeId)
          Returns for a DB-ID the SeminarType object according to the data record which has the next bigger id.
 String getObjective()
           
static SeminarType getPrevious(int semTypeId)
          Returns for a DB-ID the SeminarType instance according to the record which has the next smaller id.
 String getRequirements()
           
 String getRoutine()
           
static SeminarType getSeminarTypeFromDB(int semTypeId)
          Returns for a given id the corresponding SeminarType object.
static DistinctVector<SeminarType> getSemTypeConductedBy(int lecturerId)
          Returns for a given lecturer id the seminartypes whose are conducted by the lecturer corresponding to the id.
 String getShortTitle()
           
 String getTitle()
           
 String getTopic()
           
private static DistinctVector<SeminarType> getVector(ResultSet resultSet)
          Creates for each element in a given ResultSet instance an instance of this class and returns a vector with the resulting class objects.
static DistinctVector<SeminarType> getVectorFromDB(Vector<DBConstraint> additionalConstraints, String sortString)
          Creates a PreparedStatement instance with the given parameters, executes the query and returns a vector of instances of this class corresponding to the ResultSet of the query.
 int hashCode()
          Returns the id.
 int insertIntoDB()
          Converts the actual Company object into a database record and inserts it into the table "seminartype".
static void removeFromDB(Iterable selectedElements)
          Removes the given elements from the corresponding DB table .
 void setAudience(String audience)
           
 void setCharge(Float charge)
           
 void setDocuments(String documents)
           
 void setDuration(Integer duration)
           
 void setMaxEntrants(Integer maxEntrants)
           
 void setMethodology(String methodology)
           
 void setMinEntrants(Integer minEntrants)
           
 void setObjective(String objective)
           
 void setRequirements(String requirements)
           
 void setRoutine(String routine)
           
 void setShortTitle(String shortTitle)
           
 void setTitle(String title)
           
 void setTopic(String topic)
           
static boolean tableOK()
          Checks if the according DB table exists.
 void updateDB()
          Converts the actual SeminarType object into a database record and updates a existing record to the changes made.
 
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

lockedIds

public static List<Integer> lockedIds

id

protected int id
The DB-ID.


shortTitle

protected String shortTitle
The shortened title of a seminartype.


title

protected String title
The title of a seminartype.


objective

protected String objective
The objective of a seminartype.


methodology

protected String methodology
The methodology of a seminartype.


topic

protected String topic
The topic of a seminartype.


routine

protected String routine
The routine of a seminartype.


duration

protected Integer duration
The duration of a seminartype.


documents

protected String documents
The documents of a seminartype.


audience

protected String audience
The ausidence of a seminartype.


requirements

protected String requirements
The requirements of a seminartype.


charge

protected Float charge
The charge of a seminartype.


maxEntrants

protected Integer maxEntrants
The maximal number of entrants of a seminartype.


minEntrants

protected Integer minEntrants
The minimal number of entrants of a seminartype.


tableName

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


seminarTypeInsertString

protected static String seminarTypeInsertString
Parameterized SQL statement for inserting a data record.


createTableSQLString

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


seminarTypeUpdateString

protected static String seminarTypeUpdateString
Parameterized SQL statement for updating a data record.


queryString

private static String queryString
SQL query to get all seminartype records from the database.


conductQueryString

private static String conductQueryString
Parameterized SQL statement to get a seminartypes conducted by a given lecturer.

Constructor Detail

SeminarType

public SeminarType(int id,
                   String shortTitle,
                   String title,
                   String objective,
                   String methodology,
                   String topic,
                   String routine,
                   Integer duration,
                   String documents,
                   String audience,
                   String requirements,
                   Float charge,
                   Integer maxEntrants,
                   Integer minEntrants,
                   Timestamp creationDate,
                   Timestamp modificationDate)
Creates an instance of the class SeminarType with the given parameters.

Method Detail

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)

createSeminarTypeTable

public static void createSeminarTypeTable(Statement statement)
                                   throws SQLException
Creates the table "seminartype" 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
Converts the actual Company object into a database record and inserts it into the table "seminartype". Furthermore this method queries the auto-generated id, sets the appropriate property id and returns the id. Finally it fires a TableChanged-EventListener to update the UI.

Returns:
the auto-generated id of the inserted data record.
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 etc.

updateDB

public void updateDB()
              throws SQLException
Converts the actual SeminarType object into a database record and updates a existing record to the changes made. Finally it fires a TableChanged-EventListener to update the UI.

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

removeFromDB

public static void removeFromDB(Iterable selectedElements)
                         throws SQLException
Removes the given elements from the corresponding DB table . Due to the FK connections (with an ON-DELETE-cascade) this method fires several TableChanged-Events to update the UI.

Parameters:
selectedElements - the elements, which should be deleted from the database.
Throws:
SQLException - Throws a SQL exception if the Statement instance can't be created or executed.

getVector

private static DistinctVector<SeminarType> getVector(ResultSet resultSet)
Creates for each element in a given ResultSet instance an instance of this class and returns a vector with the resulting class objects.

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

getVectorFromDB

public static DistinctVector<SeminarType> getVectorFromDB(Vector<DBConstraint> additionalConstraints,
                                                          String sortString)
                                                   throws SQLException
Creates a PreparedStatement instance with the given parameters, executes the query and returns a vector of instances of this class 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 instances.
Throws:
SQLException - if the PreparedStatement can't be created or the execution of the query fails.

getSeminarTypeFromDB

public static SeminarType getSeminarTypeFromDB(int semTypeId)
                                        throws SQLException
Returns for a given id the corresponding SeminarType object.

Parameters:
semTypeId - the DB-ID of the wanted SeminarType object
Returns:
SeminarType object corresponding to the given id or null if the data record does not exist.
Throws:
SQLException - if the PreparedStatement can't be created or the execution of the query fails.

getColumns

public static Vector<DBColumn> getColumns()
Returns a vector of DBColumn instances according to the properties of the table corresponding to this class.

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

getAudience

public String getAudience()

setAudience

public void setAudience(String audience)

getCharge

public Float getCharge()

setCharge

public void setCharge(Float charge)

getDocuments

public String getDocuments()

setDocuments

public void setDocuments(String documents)

getDuration

public Integer getDuration()

setDuration

public void setDuration(Integer duration)

getMaxEntrants

public Integer getMaxEntrants()

setMaxEntrants

public void setMaxEntrants(Integer maxEntrants)

getMethodology

public String getMethodology()

setMethodology

public void setMethodology(String methodology)

getMinEntrants

public Integer getMinEntrants()

setMinEntrants

public void setMinEntrants(Integer minEntrants)

getObjective

public String getObjective()

setObjective

public void setObjective(String objective)

getRequirements

public String getRequirements()

setRequirements

public void setRequirements(String requirements)

getRoutine

public String getRoutine()

setRoutine

public void setRoutine(String routine)

getShortTitle

public String getShortTitle()

setShortTitle

public void setShortTitle(String shortTitle)

getTitle

public String getTitle()

setTitle

public void setTitle(String title)

getTopic

public String getTopic()

setTopic

public void setTopic(String topic)

getId

public int getId()
Description copied from interface: SimpleIDKey
Returns the DB-ID of a database records.

Specified by:
getId in interface SimpleIDKey

getNext

public static SeminarType getNext(int semTypeId)
Returns for a DB-ID the SeminarType object according to the data record which has the next bigger id.

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

getPrevious

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

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

getSemTypeConductedBy

public static DistinctVector<SeminarType> getSemTypeConductedBy(int lecturerId)
                                                         throws SQLException
Returns for a given lecturer id the seminartypes whose are conducted by the lecturer corresponding to the id.

Parameters:
lecturerId - the id of the lecturer of interest
Returns:
Vector containing the SeminarType instances.
Throws:
SQLException - if the PreparedStatement can't be created or the execution of the query fails.

hashCode

public int hashCode()
Returns the id.

Overrides:
hashCode in class Object

equals

public boolean equals(SeminarType otherSeminarType)
Compares the ids of a given object and the current one.

Parameters:
otherSeminarType - object to be compared with the actual object.
Returns:
true if the id of the given object and the actual object are the same, false otherwise.

equals

public boolean equals(Object otherSeminarType)
If the given object is an instance of the SeminarType class this method compares the id of the given and the actual object, otherwise it calls the equal-method of the AbstractTable class with the given object.

Overrides:
equals in class Object
Parameters:
otherSeminarType - object to be compared with the actual object.
Returns:
true if the id of the given object and the actual object are the same, false otherwise.