com.tekann.codegen.pda.db
Class AbstractDAO

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

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

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
static boolean cleanOnExecute
           
 java.lang.String columns
           
 java.lang.String groupBy
           
 java.lang.String orderBy
           
 totalcross.util.Vector tableJoins
           
 int top
           
 java.lang.String where
          Used to load/delete data.
 
Fields inherited from interface com.tekann.codegen.pda.db.RowIteratorValues
ROW_STATUS_DELETED, ROW_STATUS_NEW, ROW_STATUS_NONE, ROW_STATUS_SYNCED, ROW_STATUS_UPDATED
 
Constructor Summary
AbstractDAO(IConnector connector, java.lang.String creatorID)
          Constructor.
 
Method Summary
 litebase.PreparedStatement buildPreparedStatement(java.lang.String query)
           
 void clear()
          Clean table data.
 int count()
          Table row counter.
 int count(java.lang.String where)
          Table row counter.
 void createIndex()
          Create table indexes.
 void drop()
          Drop the table.
 void dropIndex()
          Drop table indexes.
 litebase.ResultSet executeQuery(java.lang.String query)
          Execute query.
 int executeUpdate(java.lang.String query)
          Execute query.
 java.lang.String getColumns()
          Return table columns separate by comma.
 int getColumnType(java.lang.String column)
          Return type of column.
 IConnector getConnector()
          Get the connector
 java.lang.String getCreatorID()
          Get the creator ID
 int getRowsAffected()
          Get the rows affected
 java.lang.String getWhereToClean()
          Where used to delete the data when this DAO is Local/Remote.
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 setColumns(java.lang.String columns)
          Set columns value.
 void setConnector(IConnector connector)
          Set the connector
 void setCreatorID(java.lang.String applicationID)
          Set the creator ID.
 void setPreparedStatementValues(java.lang.Object[] values, java.lang.String[] columns)
          Setter for the prepared statement.
 java.lang.String toXML()
          XML representation for DAO object.
 
Methods inherited from class java.lang.Object
equals, 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, save, update, update
 

Field Detail

where

public java.lang.String where
Used to load/delete data.


columns

public java.lang.String columns

orderBy

public java.lang.String orderBy

groupBy

public java.lang.String groupBy

tableJoins

public totalcross.util.Vector tableJoins

top

public int top

cleanOnExecute

public static boolean cleanOnExecute
Constructor Detail

AbstractDAO

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

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

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

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.

Specified by:
executeQuery in interface IDAO
Parameters:
query - Query to be executed.
Returns:
Result of query.

executeUpdate

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

Specified by:
executeUpdate in interface IDAO
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 applicationID)
Set the creator ID.

Parameters:
applicationID -

getRowsAffected

public int getRowsAffected()
Get the rows affected

Returns:
An integer

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

toXML

public java.lang.String toXML()
Description copied from interface: IDAO
XML representation for DAO object.

Specified by:
toXML in interface IDAO
Returns:

getColumns

public java.lang.String getColumns()
Description copied from interface: IDAO
Return table columns separate by comma.

Specified by:
getColumns in interface IDAO
Returns:

setColumns

public void setColumns(java.lang.String columns)
Description copied from interface: IDAO
Set columns value.

Specified by:
setColumns in interface IDAO

getWhereToClean

public java.lang.String getWhereToClean()
                                 throws java.lang.Exception
Where used to delete the data when this DAO is Local/Remote.
It is used to delete data in the DefaultDataHandler.deleteAllData(IDAO[] daos) throws Exception;

Throws:
java.lang.Exception

drop

public void drop()
          throws java.lang.Exception
Description copied from interface: IDAO
Drop the table.

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

setPreparedStatementValues

public void setPreparedStatementValues(java.lang.Object[] values,
                                       java.lang.String[] columns)
Setter for the prepared statement.


getColumnType

public int getColumnType(java.lang.String column)
Return type of column.

Parameters:
column -
Returns:
Throws:
totalcross.sys.InvalidNumberException

buildPreparedStatement

public litebase.PreparedStatement buildPreparedStatement(java.lang.String query)