org.objectweb.jorm.mapper.rdb.generator
Class RdbGenInfos

java.lang.Object
  extended byorg.objectweb.jorm.mapper.rdb.generator.RdbGenInfos

public class RdbGenInfos
extends java.lang.Object

This is the root class that contains all the required information for generating Java code specific to the RDB mapping. It allows the support of all elaborated mapping rules.

Author:
P. Dechamboux, O. Lobry

Field Summary
static CommonHelper commonHelper
           
 boolean debug
           
 RdbGenRef genId
          The structure of the identifier of the related JORM object.
 java.util.Map genRefs
          The set of references defined by the generated class.
 Logger logger
           
 RdbGenTable mainTable
          The reference table used in this mapping.
 RdbMapping mapping
          The associated Mapping
 java.util.List readableColumns
          The set of all columns used to store the generated class.
 java.util.Map tables
          The set of names all tables used to store the generated class.
 
Constructor Summary
RdbGenInfos()
           
 
Method Summary
 boolean colInGenId(RdbGenColumn genCol)
          Verifies if the given column is used in the identifier of this class, which is defined by genId.
 int getColumnPosition(RdbGenColumn irgc)
          Gets the position (within [1..n] of the given column into the overall list defined into this RdbGenInfos.
 int getColumnPosition(RdbGenColumn irgc, RdbGenJoin rgj)
           
 java.util.List getConstantVisibleColumns()
           
 java.lang.String getDeleteStatement(RdbGenJoin rgj)
           
 java.lang.String getDeleteStatement(RdbGenTable rgt)
          Constructs the string representing the SQL query used to delete the part of a JORM object stored into the given table.
 java.lang.String getExistStatement()
          Constructs the string representing the SQL query used for testing the existence of a JORM object.
 java.lang.String getExtDeleteStatement(RdbGenJoin rgj)
          Constructs the string representing the SQL query used to delete the part of a JORM object stored into the given table.
 java.lang.String getFilterExpression()
          Return the filter as a string.
 Expression getFilterMedorExpression()
          Return the filter as a medor expression.
 RdbGenRef getGenId()
           
 java.lang.String getGenRefFieldName(RdbGenRef gr)
          Searches the name of the field which defines the given reference.
 RdbGenRef getGenRefOfColumn(RdbGenColumn rgc)
          Searches the RdbGenRef object, from the genRefs list, which the given column belongs to.
 RdbGenRef getGenRefOfColumn(RdbGenColumn rgc, RdbGenJoin rgj)
           
 java.util.Map getGenRefs()
           
 java.lang.String getInsertStatement(RdbGenJoin rgj)
           
 java.lang.String getInsertStatement(RdbGenTable rgt)
          Constructs the string representing the SQL query used to insert the part of a JORM object stored into the given table.
 java.lang.String getPNameIteratorSelectClause()
          Constructs the string representing the SQL query used to get the extent of a JORM class (the ID PName of all objects of this class).
 java.lang.String getPNameIteratorSelectClauseWithPrefetch()
           
 java.lang.String getPNameIteratorWhereClause()
           
 java.lang.String getPnFieldName(RdbGenColumn rgc)
          Searches the name of the field in the composite name associated with the identifier, which is mapped to the given column.
 java.util.List getReadableColumns()
           
 java.util.List getReadFromTables()
          Build the data structure representing the from clause and the joins for accessing all fields of the class.
 java.lang.String getReadSelectFields()
           
 java.lang.String getReadSelectFields(boolean aliasingWithPE)
          Build the select clause that access all fields of the class.
 java.lang.String getReadSelectFieldsAsColArray()
           
 int getReadSelectNbFields()
           
 java.lang.String getReadWhereClause()
           
 RdbGenTable getReferenceTable()
           
 java.util.List getTableCompositeGenRefs(RdbGenTable rgt)
          Computes the list of references (i.e., their definition) stored into this particular table.
 java.util.List getTableCompositeGenRefs(RdbGenTable rgt, RdbGenJoin rgj)
           
 java.util.Map getTables()
           
 java.lang.String getUpdateNullStatement(RdbGenJoin rgj)
           
 java.lang.String getUpdateNullStatement(RdbGenTable rgt)
           
 java.lang.String getUpdateStatement(RdbGenJoin rgj)
           
 java.lang.String getUpdateStatement(RdbGenTable rgt)
          Constructs the string representing the SQL query used to update the part of a JORM object stored into the given table.
 boolean hasFilter()
           
 java.lang.String setIdPnParam(java.lang.String cnfn, int idx, java.lang.String adapter, java.lang.String pstmt, boolean isSpecific)
           
 java.lang.String setIdPNParameterOperand(java.lang.String cnfn, boolean isSpecific)
          If isSpecific is true returns a String like this: ((org.objectweb.speedo.pobjects.detach.VehicleIdPNG) _pngId).pnGetName(null) else, it returns a String like that: ((PNameGetter) _pngId).pngetStringField("name", null)
 boolean updatable(RdbGenColumn rgc)
           
 boolean updatable(RdbGenColumn rgc, RdbGenJoin rgj)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tables

public java.util.Map tables
The set of names all tables used to store the generated class. It also contains the reference table that is supposed to hold the object identifier (see mainTable). Indexed by their names. < String -> RdbGenTable >


mainTable

public RdbGenTable mainTable
The reference table used in this mapping. It entirely stores the identifier of the related JORM object, as specified by variable genId.


readableColumns

public java.util.List readableColumns
The set of all columns used to store the generated class. It defines the order with which the columns will be used within all kinds of queries. This set is the union of all columns specified with each table involved in this mapping.


genId

public RdbGenRef genId
The structure of the identifier of the related JORM object.


mapping

public RdbMapping mapping
The associated Mapping


genRefs

public java.util.Map genRefs
The set of references defined by the generated class. There is one RdbGenRef object registered for each reference field, in association with its field name into this map.


logger

public Logger logger

debug

public boolean debug

commonHelper

public static CommonHelper commonHelper
Constructor Detail

RdbGenInfos

public RdbGenInfos()
Method Detail

getTables

public java.util.Map getTables()

getReferenceTable

public RdbGenTable getReferenceTable()

getReadableColumns

public java.util.List getReadableColumns()

getGenId

public RdbGenRef getGenId()

getGenRefs

public java.util.Map getGenRefs()

getTableCompositeGenRefs

public java.util.List getTableCompositeGenRefs(RdbGenTable rgt)
Computes the list of references (i.e., their definition) stored into this particular table.

Parameters:
rgt - The table for which to find the reference definitions.
Returns:
The computed list of definitions.

getTableCompositeGenRefs

public java.util.List getTableCompositeGenRefs(RdbGenTable rgt,
                                               RdbGenJoin rgj)

getColumnPosition

public int getColumnPosition(RdbGenColumn irgc)
Gets the position (within [1..n] of the given column into the overall list defined into this RdbGenInfos.

Parameters:
irgc - The column for which to search the position.
Returns:
Its position into the genColumns list. -1 if not found (BUG: should never appear).

getColumnPosition

public int getColumnPosition(RdbGenColumn irgc,
                             RdbGenJoin rgj)

getExistStatement

public java.lang.String getExistStatement()
Constructs the string representing the SQL query used for testing the existence of a JORM object.

Returns:
The query string.

getReadSelectFields

public java.lang.String getReadSelectFields()

getReadSelectFields

public java.lang.String getReadSelectFields(boolean aliasingWithPE)
Build the select clause that access all fields of the class.


getReadSelectFieldsAsColArray

public java.lang.String getReadSelectFieldsAsColArray()

getConstantVisibleColumns

public java.util.List getConstantVisibleColumns()
Returns:
a list of RdbGenColumn corresponding to constant fields

getReadSelectNbFields

public int getReadSelectNbFields()
Returns:
the number of fields accessed by the select clause of the class.

getReadFromTables

public java.util.List getReadFromTables()
Build the data structure representing the from clause and the joins for accessing all fields of the class.

Returns:

getReadWhereClause

public java.lang.String getReadWhereClause()

getPNameIteratorSelectClause

public java.lang.String getPNameIteratorSelectClause()
Constructs the string representing the SQL query used to get the extent of a JORM class (the ID PName of all objects of this class).

Returns:
The query string.

getPNameIteratorSelectClauseWithPrefetch

public java.lang.String getPNameIteratorSelectClauseWithPrefetch()

getFilterMedorExpression

public Expression getFilterMedorExpression()
Return the filter as a medor expression.


getFilterExpression

public java.lang.String getFilterExpression()
Return the filter as a string. It is a where clause.


getPNameIteratorWhereClause

public java.lang.String getPNameIteratorWhereClause()
                                             throws ExpressionException
Throws:
ExpressionException

getUpdateStatement

public java.lang.String getUpdateStatement(RdbGenTable rgt)
                                    throws PException
Constructs the string representing the SQL query used to update the part of a JORM object stored into the given table.

Parameters:
rgt - The description of the table to be modified.
Returns:
The query string.
Throws:
PException

getUpdateStatement

public java.lang.String getUpdateStatement(RdbGenJoin rgj)
                                    throws PException
Throws:
PException

getUpdateNullStatement

public java.lang.String getUpdateNullStatement(RdbGenTable rgt)
                                        throws PException
Throws:
PException

getUpdateNullStatement

public java.lang.String getUpdateNullStatement(RdbGenJoin rgj)
                                        throws PException
Throws:
PException

getInsertStatement

public java.lang.String getInsertStatement(RdbGenTable rgt)
                                    throws PException
Constructs the string representing the SQL query used to insert the part of a JORM object stored into the given table.

Parameters:
rgt - The description of the table to be modified.
Returns:
The query string.
Throws:
PException

getInsertStatement

public java.lang.String getInsertStatement(RdbGenJoin rgj)

getDeleteStatement

public java.lang.String getDeleteStatement(RdbGenTable rgt)
                                    throws PException
Constructs the string representing the SQL query used to delete the part of a JORM object stored into the given table.

Parameters:
rgt - The description of the table to be modified.
Returns:
The query string.
Throws:
PException

getDeleteStatement

public java.lang.String getDeleteStatement(RdbGenJoin rgj)
                                    throws PException
Throws:
PException

getExtDeleteStatement

public java.lang.String getExtDeleteStatement(RdbGenJoin rgj)
                                       throws PException
Constructs the string representing the SQL query used to delete the part of a JORM object stored into the given table.

Parameters:
rgj - The description of the join between the external table and the main table
Returns:
The query string.
Throws:
PException

setIdPnParam

public java.lang.String setIdPnParam(java.lang.String cnfn,
                                     int idx,
                                     java.lang.String adapter,
                                     java.lang.String pstmt,
                                     boolean isSpecific)
                              throws PException
Throws:
PException

setIdPNParameterOperand

public java.lang.String setIdPNParameterOperand(java.lang.String cnfn,
                                                boolean isSpecific)
                                         throws PException
If isSpecific is true returns a String like this: ((org.objectweb.speedo.pobjects.detach.VehicleIdPNG) _pngId).pnGetName(null) else, it returns a String like that: ((PNameGetter) _pngId).pngetStringField("name", null)

Throws:
PException

getGenRefOfColumn

public RdbGenRef getGenRefOfColumn(RdbGenColumn rgc)
Searches the RdbGenRef object, from the genRefs list, which the given column belongs to.

Parameters:
rgc - The column for which to find a RdbGenRef.
Returns:
The relevant RdbGenRef or null if none found.

getGenRefOfColumn

public RdbGenRef getGenRefOfColumn(RdbGenColumn rgc,
                                   RdbGenJoin rgj)

colInGenId

public boolean colInGenId(RdbGenColumn genCol)
Verifies if the given column is used in the identifier of this class, which is defined by genId.

Parameters:
genCol - The column for which to verify its belonging to the ID.
Returns:
true if it belongs to genId.

getGenRefFieldName

public java.lang.String getGenRefFieldName(RdbGenRef gr)
Searches the name of the field which defines the given reference.

Parameters:
gr - The reference definition.
Returns:
The relevant field name.

getPnFieldName

public java.lang.String getPnFieldName(RdbGenColumn rgc)
Searches the name of the field in the composite name associated with the identifier, which is mapped to the given column.

Parameters:
rgc - The column to search.
Returns:
The name of the mapped field.

updatable

public boolean updatable(RdbGenColumn rgc)

updatable

public boolean updatable(RdbGenColumn rgc,
                         RdbGenJoin rgj)

hasFilter

public boolean hasFilter()