com.tekann.codegen.pda.db
Class AbstractDAO

java.lang.Object
  extended by com.tekann.codegen.pda.db.AbstractDAO
All Implemented Interfaces:
IDAO

public abstract class AbstractDAO
extends java.lang.Object
implements IDAO

Abstract DAO implementation. This class provides some useful methods to manipulate the data for a given table.
For more details you may search for Data Access Object (DAO).

Author:
Evandro Rathke

Field Summary
 java.lang.String columns
           
protected  IConnector connector
           
protected  java.lang.String creatorID
           
 java.lang.String groupBy
           
 java.lang.String orderBy
           
static int ROW_STATUS_DELETED
           
static int ROW_STATUS_NEW
           
static int ROW_STATUS_SYNCED
           
static int ROW_STATUS_UPDATED
           
 int top
           
 java.lang.String where
           
 
Constructor Summary
AbstractDAO(IConnector connector, java.lang.String creatorID)
          Constructor.
 
Method Summary
abstract  litebase.PreparedStatement buildPreparedStatement(java.lang.String query)
          Creates prepared statement.
 void clear()
          Clean table data.
protected  IDTO convertDTO(IDTO defaultDTO)
           
 int count()
          Table row counter.
 int count(java.lang.String where)
          Table row counter.
 void createIndex()
          Create table indexes.
 void dropIndex()
          Drop table indexes.
 litebase.ResultSet executeQuery(java.lang.String query)
          Execute query.
 int executeUpdate(java.lang.String query)
          Execute query.
 IConnector getConnector()
          Get the connector
 java.lang.String getCreatorID()
          Get the creator ID
 int getRowsAffected()
          Get the rows affected
abstract  boolean isSynchronizable()
          Return if the DAO has the attr column generated or not.
abstract  java.lang.String[][] loadMatrix()
          Must implement a code that return an array with the data to be shown on the grid.
 void purge()
          Purge table data.
 void setConnector(IConnector connector)
          Set the connector
 void setCreatorID(java.lang.String creatorID)
          Set the creator ID.
protected  void setRowsAffected(int rows)
          Set the rows affected
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.tekann.codegen.pda.db.IDAO
createDTO, createTable, delete, getColumnNames, getDBTableName, getPDATableName, load, save, update
 

Field Detail

ROW_STATUS_DELETED

public static final int ROW_STATUS_DELETED
See Also:
Constant Field Values

ROW_STATUS_NEW

public static final int ROW_STATUS_NEW
See Also:
Constant Field Values

ROW_STATUS_SYNCED

public static final int ROW_STATUS_SYNCED
See Also:
Constant Field Values

ROW_STATUS_UPDATED

public static final int ROW_STATUS_UPDATED
See Also:
Constant Field Values

connector

protected IConnector connector

creatorID

protected java.lang.String creatorID

where

public java.lang.String where

columns

public java.lang.String columns

orderBy

public java.lang.String orderBy

groupBy

public java.lang.String groupBy

top

public int top
Constructor Detail

AbstractDAO

public AbstractDAO(IConnector connector,
                   java.lang.String creatorID)
Constructor.

Parameters:
connector - Connector.
creatorID - Creator ID.
Method Detail

buildPreparedStatement

public abstract litebase.PreparedStatement buildPreparedStatement(java.lang.String query)
Creates prepared statement.

Parameters:
query -
Returns:
A PreparedStatement

clear

public void clear()
           throws java.lang.Exception
Clean table data.

Specified by:
clear in interface IDAO
Throws:
java.lang.Exception

purge

public void purge()
           throws java.lang.Exception
Purge table data.

Specified by:
purge in interface IDAO
Throws:
java.lang.Exception

convertDTO

protected IDTO convertDTO(IDTO defaultDTO)
                   throws java.lang.Exception
Throws:
java.lang.Exception

count

public int count()
Table row counter.

Specified by:
count in interface IDAO
Returns:
Number of rows.

count

public int count(java.lang.String where)
Table row counter.

Parameters:
where - The filter to restrict the counting operation.
Returns:
Number of rows.

createIndex

public void createIndex()
                 throws java.lang.Exception
Create table indexes.

Specified by:
createIndex in interface IDAO
Throws:
java.lang.Exception

dropIndex

public void dropIndex()
               throws java.lang.Exception
Drop table indexes.

Specified by:
dropIndex in interface IDAO
Throws:
java.lang.Exception

executeQuery

public litebase.ResultSet executeQuery(java.lang.String query)
Execute query.

Parameters:
query - Query to be executed.
Returns:
Result of query.

executeUpdate

public int executeUpdate(java.lang.String query)
Execute query.

Parameters:
query - Query to be executed.
Returns:
Result of query.

getConnector

public IConnector getConnector()
Get the connector

Returns:
An IConnector

getCreatorID

public java.lang.String getCreatorID()
Get the creator ID

Returns:
A String

setConnector

public void setConnector(IConnector connector)
Set the connector

Parameters:
connector -

setCreatorID

public void setCreatorID(java.lang.String creatorID)
Set the creator ID.

Parameters:
creatorID -

getRowsAffected

public int getRowsAffected()
Get the rows affected

Returns:
An integer

setRowsAffected

protected void setRowsAffected(int rows)
Set the rows affected

Parameters:
rows -

loadMatrix

public abstract java.lang.String[][] loadMatrix()
                                         throws java.lang.Exception
Must implement a code that return an array with the data to be shown on the grid.

Returns:
A String array
Throws:
java.lang.Exception

isSynchronizable

public abstract boolean isSynchronizable()
Return if the DAO has the attr column generated or not.

Returns:
A boolean