de.janrufmonitor.repository.db
Class AbstractCallDatabaseHandler

java.lang.Object
  extended by de.janrufmonitor.repository.db.AbstractDatabaseHandler
      extended by de.janrufmonitor.repository.db.AbstractCallDatabaseHandler
All Implemented Interfaces:
ICallDatabaseHandler, IDatabaseHandler
Direct Known Subclasses:
HsqldbCallDatabaseHandler

public abstract class AbstractCallDatabaseHandler
extends AbstractDatabaseHandler
implements ICallDatabaseHandler

This abstract class can be used as base class for a database related call managers. It contains methods for database creation and prepared statements for call manager handling.

Author:
Thilo Brandt

Field Summary
 
Fields inherited from class de.janrufmonitor.repository.db.AbstractDatabaseHandler
commit_count, m_con, m_logger, m_preparedStatements
 
Constructor Summary
AbstractCallDatabaseHandler(String driver, String connection, String user, String password, boolean initialize)
           
 
Method Summary
protected  void addPreparedStatements()
          Connects to the database specified in the constructor.
protected abstract  int buildCallCount(IFilter[] filters)
          Counts the calls withe a proper database query.
protected abstract  ICallList buildCallList(IFilter[] filters)
          Create the call list from a query of the database.
protected abstract  ICallList buildCallList(IFilter[] filters, int count, int offset)
          Create the call list from a query of the database.
protected  void createTables()
          Creates the database table.
 void deleteCallList(ICallList cl)
          Deletes all calls in the submitted call list.
 int getCallCount(IFilter[] filters)
          Counts the number of calls belonging to the filters obejct.
 ICallList getCallList(IFilter[] filters)
          Fetches the calls by the applied filters from the database
 ICallList getCallList(IFilter[] filters, int count, int offset)
          Fetches the calls by the applied filters from the database
 void setCallList(ICallList cl)
          Sets all calls in the submitted list to the database.
 void updateCallList(ICallList cl)
          Updates all calls in the submitted list.
 
Methods inherited from class de.janrufmonitor.repository.db.AbstractDatabaseHandler
commit, connect, createAttributes, deleteAttributes, disconnect, getRuntime, getStatement, isConnected, isInitializing, isKeepAlive, rollback, setCommitCount, setInitializing, setKeepAlive, updateAttributes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.janrufmonitor.repository.db.IDatabaseHandler
commit, connect, disconnect, isConnected, isKeepAlive, rollback, setCommitCount, setKeepAlive
 

Constructor Detail

AbstractCallDatabaseHandler

public AbstractCallDatabaseHandler(String driver,
                                   String connection,
                                   String user,
                                   String password,
                                   boolean initialize)
Method Detail

createTables

protected void createTables()
                     throws SQLException
Description copied from class: AbstractDatabaseHandler
Creates the database table.

Specified by:
createTables in class AbstractDatabaseHandler
Throws:
SQLException

addPreparedStatements

protected void addPreparedStatements()
                              throws SQLException
Connects to the database specified in the constructor. Tables and prepared statements are created if teh initialize flag was set.

Specified by:
addPreparedStatements in class AbstractDatabaseHandler
Throws:
SQLException - is thrown, if any exception on the db level occurs.
ClassNotFoundException - is thrown, if the db driver could not be loaded.

setCallList

public void setCallList(ICallList cl)
                 throws SQLException
Sets all calls in the submitted list to the database.

Specified by:
setCallList in interface ICallDatabaseHandler
Parameters:
cl -
Throws:
SQLException

updateCallList

public void updateCallList(ICallList cl)
                    throws SQLException
Updates all calls in the submitted list. The select criterion of teh call is its UUID.

Specified by:
updateCallList in interface ICallDatabaseHandler
Parameters:
cl -
Throws:
SQLException

deleteCallList

public void deleteCallList(ICallList cl)
                    throws SQLException
Deletes all calls in the submitted call list.

Specified by:
deleteCallList in interface ICallDatabaseHandler
Parameters:
cl -
Throws:
SQLException

getCallList

public ICallList getCallList(IFilter[] filters)
                      throws SQLException
Fetches the calls by the applied filters from the database

Specified by:
getCallList in interface ICallDatabaseHandler
Parameters:
filters - filters applied to the result
Returns:
Throws:
SQLException

getCallList

public ICallList getCallList(IFilter[] filters,
                             int count,
                             int offset)
                      throws SQLException
Fetches the calls by the applied filters from the database

Specified by:
getCallList in interface ICallDatabaseHandler
Parameters:
filters - filters applied to the result
Returns:
Throws:
SQLException

getCallCount

public int getCallCount(IFilter[] filters)
                 throws SQLException
Counts the number of calls belonging to the filters obejct.

Specified by:
getCallCount in interface ICallDatabaseHandler
Parameters:
filters - filters applied to the result
Returns:
Throws:
SQLException

buildCallCount

protected abstract int buildCallCount(IFilter[] filters)
                               throws SQLException
Counts the calls withe a proper database query.

Parameters:
filters - filters applied to the result
Returns:
number of calls belonging to the filters
Throws:
SQLException

buildCallList

protected abstract ICallList buildCallList(IFilter[] filters)
                                    throws SQLException
Create the call list from a query of the database. This abstract method must be implemented by all CallDatabaseHandler.

Parameters:
filters - filters applied to the result
Returns:
Throws:
SQLException

buildCallList

protected abstract ICallList buildCallList(IFilter[] filters,
                                           int count,
                                           int offset)
                                    throws SQLException
Create the call list from a query of the database. This abstract method must be implemented by all CallDatabaseHandler.

Parameters:
filters - filters applied to the result
Returns:
Throws:
SQLException


Copyright © 2010 by Thilo Brandt. All Rights Reserved.