org.objectweb.telosys.dal.dataset
Class SQLDataSetDefinition

java.lang.Object
  extended byorg.objectweb.telosys.common.TelosysObject
      extended byorg.objectweb.telosys.dal.dataset.SQLDataSetDefinition
All Implemented Interfaces:
java.io.Serializable

public class SQLDataSetDefinition
extends TelosysObject
implements java.io.Serializable

The "definition" for a SQLDataSet
It contains the SQL request that will be used to load the SQLDataSet

See Also:
Serialized Form

Constructor Summary
SQLDataSetDefinition(java.lang.String sSqlSelectRequest)
          Constructor for a full SQL request in a single string.
SQLDataSetDefinition(java.lang.String sSqlSelectRequest, int[] paramTypes)
          Constructor for full SQL request in a single string, with parameters.
SQLDataSetDefinition(java.lang.String sSqlSelect, java.lang.String sSqlFrom, java.lang.String sSqlWhere, java.lang.String sSqlOption)
          Constructor.
SQLDataSetDefinition(java.lang.String sSqlSelect, java.lang.String sSqlFrom, java.lang.String sSqlWhere, java.lang.String sSqlOption, int[] paramTypes)
          Constructor.
 
Method Summary
 void alterWhere(Criteria criterias)
          Changes the initial SQL where clause using criteria to build the new WHERE clause dynamicaly NB: if the SQLDataSet definition is static, this method cannot be used ( throws a TelosysRuntimeException )
 java.lang.Object[] castParameters(java.lang.String[] strParams)
          Casts all the given parameters from String to the appropriate type
 int getDatabaseId()
           
 int getFirstRowForPage(int iPage)
          Return the first row of the given page (calculated with "lines per page")
 java.lang.String getFullSqlCount()
          Return the full SQL request for count(*)
 java.lang.String getFullSqlSelect()
          Return the full SQL request to retrieve data
 int getLastRowForPage(int iPage)
          Return the last row of the given page (calculated with "lines per page")
 int getLinesPerPage()
           
 int getMaxRows()
           
 int getNbParams()
          Return the number of parameters expected to execute the SQL request
 java.lang.String getParametersTypes()
          Returns a string containing all the parameters types (to be used as a debug information)
 java.lang.String getSqlFrom()
           
 java.lang.String getSqlOption()
           
 java.lang.String getSqlSelect()
           
 java.lang.String getSqlWhere()
           
 void setDatabaseId(int v)
          Set the id of the database to use
 void setLinesPerPage(int v)
          Set the number of lines per page (cannot exceeded the maximum number of rows)
 void setMaxRows(int v)
          Set the maximum number of rows
 
Methods inherited from class org.objectweb.telosys.common.TelosysObject
error, error, error, getFlagTrace, info, setFlagTrace, trace, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLDataSetDefinition

public SQLDataSetDefinition(java.lang.String sSqlSelectRequest)
Constructor for a full SQL request in a single string. NB: With this constructor, the WHERE clause cannot be dynamic ( alterWhere cannot be used )

Parameters:
sSqlSelectRequest -

SQLDataSetDefinition

public SQLDataSetDefinition(java.lang.String sSqlSelectRequest,
                            int[] paramTypes)
Constructor for full SQL request in a single string, with parameters. NB: With this constructor, the WHERE clause cannot be dynamic ( alterWhere cannot be used )

Parameters:
sSqlSelectRequest -
paramTypes -

SQLDataSetDefinition

public SQLDataSetDefinition(java.lang.String sSqlSelect,
                            java.lang.String sSqlFrom,
                            java.lang.String sSqlWhere,
                            java.lang.String sSqlOption)
Constructor. The WHERE clause is potentially dynamic ( alterWhere can be used )

Parameters:
sSqlSelect -
sSqlFrom -
sSqlWhere -
sSqlOption -

SQLDataSetDefinition

public SQLDataSetDefinition(java.lang.String sSqlSelect,
                            java.lang.String sSqlFrom,
                            java.lang.String sSqlWhere,
                            java.lang.String sSqlOption,
                            int[] paramTypes)
Constructor. The WHERE clause is potentially dynamic ( alterWhere can be used )

Parameters:
sSqlSelect -
sSqlFrom -
sSqlWhere -
sSqlOption -
paramTypes -
Method Detail

alterWhere

public void alterWhere(Criteria criterias)
Changes the initial SQL where clause using criteria to build the new WHERE clause dynamicaly NB: if the SQLDataSet definition is static, this method cannot be used ( throws a TelosysRuntimeException )

Parameters:
criterias -

setMaxRows

public void setMaxRows(int v)
Set the maximum number of rows

Parameters:
v -

setLinesPerPage

public void setLinesPerPage(int v)
Set the number of lines per page (cannot exceeded the maximum number of rows)

Parameters:
v -

setDatabaseId

public void setDatabaseId(int v)
Set the id of the database to use

Parameters:
v -

getSqlSelect

public java.lang.String getSqlSelect()
Returns:
the "SELECT part" of the SQL request

getSqlWhere

public java.lang.String getSqlWhere()
Returns:
the "WHERE part" of the SQL request

getSqlFrom

public java.lang.String getSqlFrom()
Returns:
the "FROM part" of the SQL request

getSqlOption

public java.lang.String getSqlOption()
Returns:
the "OPTIONAL part" of the SQL request

getNbParams

public int getNbParams()
Return the number of parameters expected to execute the SQL request

Returns:
: number of parameters expected

getLinesPerPage

public int getLinesPerPage()
Returns:
number of lines per page

getMaxRows

public int getMaxRows()
Returns:
maximum number of rows

getDatabaseId

public int getDatabaseId()
Returns:
id of the database to use

getParametersTypes

public java.lang.String getParametersTypes()
Returns a string containing all the parameters types (to be used as a debug information)

Returns:

getFullSqlCount

public java.lang.String getFullSqlCount()
Return the full SQL request for count(*)

Returns:
: SQL request

getFullSqlSelect

public java.lang.String getFullSqlSelect()
Return the full SQL request to retrieve data

Returns:
: SQL request

getFirstRowForPage

public int getFirstRowForPage(int iPage)
Return the first row of the given page (calculated with "lines per page")

Parameters:
iPage - : page number (from 1 to N )
Returns:
: the row number ( from 1 to N )

getLastRowForPage

public int getLastRowForPage(int iPage)
Return the last row of the given page (calculated with "lines per page")

Parameters:
iPage - : page number (from 1 to N )
Returns:
: the row number ( from 1 to N )

castParameters

public java.lang.Object[] castParameters(java.lang.String[] strParams)
                                  throws TelosysException
Casts all the given parameters from String to the appropriate type

Parameters:
strParams - array of String parameters
Returns:
array of instances of classes corresponding to the expected parameters types
Throws:
TelosysException