org.objectweb.jorm.comp.generator.rdb
Class RdbBindingMOP

java.lang.Object
  |
  +--org.objectweb.jorm.comp.generator.lib.CommonHelper
        |
        +--org.objectweb.jorm.comp.generator.rdb.RdbCommonHelper
              |
              +--org.objectweb.jorm.comp.generator.rdb.RdbBindingMOP
All Implemented Interfaces:
Loggable, MOP

public class RdbBindingMOP
extends RdbCommonHelper
implements MOP

This class implements the BindingMOP interface in order to specialize the generation of the PBinding for the relationnal database spport.

Author:
Inner Class Summary
 class RdbBindingMOP.ColDesc
           
 class RdbBindingMOP.ColInfo
           
 
Inner classes inherited from class org.objectweb.jorm.comp.generator.lib.CommonHelper
CommonHelper.PNGDesc
 
Fields inherited from class org.objectweb.jorm.comp.generator.rdb.RdbCommonHelper
adapter
 
Fields inherited from class org.objectweb.jorm.comp.generator.lib.CommonHelper
logger, loggerFactory, PN_GET_TYPES
 
Constructor Summary
RdbBindingMOP(RdbAdpater _adapter)
           
 
Method Summary
 java.util.ArrayList getColInfo(Class moc, CompilerParameter cp)
          It build an arraylist providing information over the column where the class is mapped.
 java.util.ArrayList getColumnListOfRead(Class moc, CompilerParameter cp)
          This method provides the name of the column where the fiels of the class passed as parameter are mapped.
 java.lang.String getExistRequest(Class moc, CompilerParameter cp, int pngspe)
           
 java.util.ArrayList getNameDefColInfo(Class moc, NameDef nd, java.lang.String fieldname, java.lang.String pnamevar, CompilerParameter cp, boolean canBeFieldName, java.util.ArrayList res, java.util.ArrayList cilist)
          it build an array list of colinfo from the namedef passed as parameter.
 int getPnameIndexForUpdateRequest(Class moc, java.util.ArrayList colinfolist, CompilerParameter cp)
          Compute the start index for the pname setter in the case of an update request.
 java.lang.String getPreparedSetter(PType type, int index, java.lang.String value)
           
 java.lang.String getPreparedSetter(RdbBindingMOP.ColInfo ci, RdbBindingMOP.ColDesc o, int index, int specific)
          build a setter used to initialize a prepared statement.
 java.lang.String getReadRequest(Class co, java.util.ArrayList cols, CompilerParameter cp, int pngspe)
          It build an sql request used to read instance of the class co.
 java.lang.String[] getTemplateLibraries()
           
 java.lang.String getWriteCreateRequest(Class moc, java.util.ArrayList colsinfolist, CompilerParameter cp)
          Build a prepared request for a write create action.
 java.lang.String getWriteRemoveRequest(Class moc, java.util.ArrayList colinfolist, CompilerParameter cp)
          Build a prepared request for a write remove action.
 java.lang.String getWriteUpdateRequest(Class moc, java.util.ArrayList colinfolist, CompilerParameter cp)
          Build a prepared request for a write update action.
 void initContext(org.apache.velocity.context.Context ctx)
           
 
Methods inherited from class org.objectweb.jorm.comp.generator.rdb.RdbCommonHelper
getColumnName, getSqlGet
 
Methods inherited from class org.objectweb.jorm.comp.generator.lib.CommonHelper
canBeNullValue, containsCompositeName, containsCompositeReference, containsGenClassRef, containsReference, containsSerializedField, getCompositeNameDefEntries, getFQNOfCompositeName, getLogger, getLoggerFactory, getPaGetMethod, getPaSetMethod, getPNameDecodeFunction, getPNameEncodeFunction, getPNameGetterGetFunction, getPNGTypes, getPrimitiveElement, getProjectionField, getPType, getPTypeBigDecimal, getPTypeBoolean, getPTypeByte, getPTypeByteArray, getPTypeChar, getPTypeCharArray, getPTypeDate, getPTypeDouble, getPTypeFloat, getPTypeInt, getPTypeLong, getPTypeOboolean, getPTypeObyte, getPTypeOchar, getPTypeOdouble, getPTypeOfloat, getPTypeOint, getPTypeOlong, getPTypeOshort, getPTypeReference, getPTypeSerialized, getPTypeShort, getPTypeString, getSchemaName, isClass, isClassRef, isCompositeName, isFieldName, isGenClassRef, isHiddenField, isPrimitiveElement, isReference, isSerializedField, isSerializedType, isValidString, iterateCompositeName, iterateCompositeReference, setLogger, setLoggerFactory, upperFL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RdbBindingMOP

public RdbBindingMOP(RdbAdpater _adapter)
Method Detail

initContext

public void initContext(org.apache.velocity.context.Context ctx)
Specified by:
initContext in interface MOP

getTemplateLibraries

public java.lang.String[] getTemplateLibraries()
Specified by:
getTemplateLibraries in interface MOP

getColumnListOfRead

public java.util.ArrayList getColumnListOfRead(Class moc,
                                               CompilerParameter cp)
                                        throws java.lang.Exception
This method provides the name of the column where the fiels of the class passed as parameter are mapped.
Returns:
an array list that provides the columns name as string.

getReadRequest

public java.lang.String getReadRequest(Class co,
                                       java.util.ArrayList cols,
                                       CompilerParameter cp,
                                       int pngspe)
                                throws java.lang.Exception
It build an sql request used to read instance of the class co.
Returns:
an iterator over all the possible request (generic png, specific png)

getExistRequest

public java.lang.String getExistRequest(Class moc,
                                        CompilerParameter cp,
                                        int pngspe)
                                 throws java.lang.Exception

getColInfo

public java.util.ArrayList getColInfo(Class moc,
                                      CompilerParameter cp)
                               throws java.lang.Exception
It build an arraylist providing information over the column where the class is mapped. These informations are customized for the write operation. The array list contains a set of colinfo. The structure of a colinfo instance is the following : case 1 : a primitive field colname case specific_accessor generic_accessor nil fieldname case 2 : a ref single colname case specific_accessor generic_accessor encode_function fieldname case 3 : a ref composite (the field is a ref toward a jorm object identified with a composite pname. This pname is mapped over several columns) nil case specific_accessor generic_accessor nil fieldname colname1 case pnamegetterspecific1 pnamegettergeneric1 nil fieldname colname2 case pnamegetterspecific2 pnamegettergeneric2 nil fieldname ... case 4 : pname of the class (this is a single pname) colname case nill nil encode_function nil case 5 : pname of the class (this is a composite pname) colname1 case pnamegetterspecific1 pnamegettergeneric1 nil nil colname2 case pnamegetterspecific2 pnamegettergeneric2 nil nil ...

getWriteCreateRequest

public java.lang.String getWriteCreateRequest(Class moc,
                                              java.util.ArrayList colsinfolist,
                                              CompilerParameter cp)
                                       throws java.lang.Exception
Build a prepared request for a write create action. This method is used by the pbinding generator to build the write request.
Parameters:
moc - the meta class object
colslist - an arraylist of structured colinfo.

getWriteRemoveRequest

public java.lang.String getWriteRemoveRequest(Class moc,
                                              java.util.ArrayList colinfolist,
                                              CompilerParameter cp)
                                       throws java.lang.Exception
Build a prepared request for a write remove action. This method is used by the pbinding generator to build the write request.
Parameters:
moc - the meta class object
colslist - an arraylist of structured colinfo.

getWriteUpdateRequest

public java.lang.String getWriteUpdateRequest(Class moc,
                                              java.util.ArrayList colinfolist,
                                              CompilerParameter cp)
                                       throws java.lang.Exception
Build a prepared request for a write update action. This method is used by the pbinding generator to build the write request.
Parameters:
moc - the meta class object
colslist - an arraylist of structured colinfo.

getPnameIndexForUpdateRequest

public int getPnameIndexForUpdateRequest(Class moc,
                                         java.util.ArrayList colinfolist,
                                         CompilerParameter cp)
Compute the start index for the pname setter in the case of an update request. This index is used to generate a setter for the prepared statement of the update request.
Parameters:
moc - the meta class object
colinfolist - an arraylist of structured colinfo.

getNameDefColInfo

public java.util.ArrayList getNameDefColInfo(Class moc,
                                             NameDef nd,
                                             java.lang.String fieldname,
                                             java.lang.String pnamevar,
                                             CompilerParameter cp,
                                             boolean canBeFieldName,
                                             java.util.ArrayList res,
                                             java.util.ArrayList cilist)
                                      throws java.lang.Exception
it build an array list of colinfo from the namedef passed as parameter. This pname can be a single or a composite one.

getPreparedSetter

public java.lang.String getPreparedSetter(RdbBindingMOP.ColInfo ci,
                                          RdbBindingMOP.ColDesc o,
                                          int index,
                                          int specific)
                                   throws PExceptionProtocol
build a setter used to initialize a prepared statement.
Parameters:
ci - the colinfo describing a list of col desc
cl - a collumn description
index - the index of the setter
specific - - in the case of a primitive field, a single ref or a pn single : specific says if the setter function is build from a specific accessor or a generic one. (0 : specific acc / 1 : generic accessor) - in the case of a composite pname of a composite reference specific says if the setter function is build from a specific pnamegetter or a generic one. (0 : specific png / 1 : generic png)
Returns:
a string such as setInt(2, fn) where 2 is the index and fn the function to retreive the value.

getPreparedSetter

public java.lang.String getPreparedSetter(PType type,
                                          int index,
                                          java.lang.String value)
                                   throws PExceptionProtocol