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

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

public class RdbViewGenInfos
extends java.lang.Object


Nested Class Summary
 class RdbViewGenInfos.ExtentMappingInfos
          This class is used to construct extent mapping information when calculating views (see getNonFinalClassExtent) and that will then be used to generate the appropriate union of select/from/where clauses
 
Field Summary
 boolean debug
           
 Logger logger
           
 
Method Summary
 java.util.Collection getPolymorphicClassExtent(Class classA, java.lang.String projectName, java.lang.String mapperName)
          Calculates the view representing the extent of the class.
 java.lang.String getViewName(Class clazz, java.lang.String projectName, java.lang.String mapperName)
          Get the name of the view to use when creating the extent view for a given project and for a given mapper
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public Logger logger

debug

public boolean debug
Method Detail

getViewName

public java.lang.String getViewName(Class clazz,
                                    java.lang.String projectName,
                                    java.lang.String mapperName)
Get the name of the view to use when creating the extent view for a given project and for a given mapper

Parameters:
clazz - the class fro which getting the view name
projectName - the name of the project
mapperName - the name of the mapper
Returns:
the name of the view

getPolymorphicClassExtent

public java.util.Collection getPolymorphicClassExtent(Class classA,
                                                      java.lang.String projectName,
                                                      java.lang.String mapperName)
                                               throws PException
Calculates the view representing the extent of the class. The view will be made of an union (in case of horizontal mappings) of filtered (in case of filtered and vertical mappings) tables. Elements of the extent may come from the tables on which the class is mapped or from tables on which its sub(sub...)classes are mapped. The main problem is to retrive those tables and in those tables the right columns mapping fields defined in the mother class knowing that: - different inheritance rule may me encountered (filtered, horizontal, vertical). Some will need union, some others will need selection - classes my be mapped on multiple tables, requiring joins to retrieve the needed columns - only tables columns mapping fields of the mother class should be include in the expression of the view - columns mapping the same field in different class mapping may have different names, thus requiring renaming for realizing the required unions How the view is calculated depends on whether the class is at the top of the hierarchy tree. 1) If is at the top, its extent is made of all the instances comming from its tables and those of its children (if they are mapped to other tables). 2) If it is in the middle of the tree and its inheritance rule is 'to-new-structures' then, none of its instances comes from its parents' tables, so we can apply the same algorithm 3) If it is in the middle and its inheritance rule is 'to-extended-structures', then its filter and those of its children must be used not to get instances of its parent class. In the first two cases, the view is created with the following formula: V(A) = T(A) U (U (PROJECT(ATTR(A)) T)) | T in T(SUB(A)) and T != T(A) where V(A) = view for A's extent, ATTR(A) = attributes of A, T(X) = main table for class X, SUB(A) = all sub(sub(...))classes of A In the second case, the view is created with the following formula: V(A) = (FILTER(A) AND (AND FILTER(X))) T(A) U (U (PROJECT(ATTR(A)) T(X))) | | X in SUB_F(A) and T(X)=T(A) T in T(SUB(A) - SUB_F(A)) and T != T(A) where V(A) = view for A's extent, ATTR(A) = attributes of A, T(X) = main table for class X, SUB_F(A) = all sub(sub(...))classes that is 'filter chained'* w/ A (*) 'filter chained' means that all inheritance link from A to X is a filter inheritance rule Actually, this is a simplification since a single class my be mapped to multiple tables and the extent be calculated by joining these tables. However, since the filters express conditions on the key and the key is entirely contained in a table, this does not change the principles discussed above but simply complexifies the expression of the formulae. Instead of T(A) (resp. T(X)) we will have the joins between A's (resp. X's) tables. Also, the case of abstract classes must be taken into account. If class A its extents is the union of the extents of its subclasses. This is true whether it defines or extends an inherited mapping or not. So there is no need to construct a "select from where" at its level.

Returns:
a collection of ExtentMappingInfos that must be unioned to get the extent
Throws:
PException