org.objectweb.medor.optim.jorm
Class JormFlatten2Rdb
- RewriteRule
public class JormFlatten2Rdb
This rules transforms a QueryTree built on top of JORM Extents into
a QueryTree built on top of RdbExpQueryLeaves.
The initial QueryTree can be a JORM Extent, or composed of one QueryNode
with one or several JORM Extent. The FlattenQueryTree rewriting rule can
produce such a QueryTree.
The resulting QueryTree always has a SelectProject node on top of the
RdbExpQueryLeaf, in case of CalculatedFields (for example the PName).
- S. Chassande-Barrioz
Expression | getDecode(PNameField pnf, BasicRdbExpQueryLeaf leaf, boolean add) - Create an expression to decode a PName.
|
QueryTreeField | getField(String fieldname, PType type, JormExtent extent, BasicRdbExpQueryLeaf leaf, boolean add) - Adds a field in a leaf if it is not already present.
|
QueryTreeField | getField(String fieldname, JormExtent extent, BasicRdbExpQueryLeaf leaf, boolean add) - Shortcut to the
getField(String, PType, JormExtent, BasicRdbExpQueryLeaf, boolean)
method.
|
QueryTreeField | getField(Field old, BasicRdbExpQueryLeaf leaf, boolean add) - Is a shorcut to the
getField(String, PType, JormExtent, BasicRdbExpQueryLeaf, boolean)
method.
|
JormFlatten2Rdb.RdbJormExtentMapping | getMapping(int i) - Retrieves the RdbJormExtentMapping at the position i the packet.
|
JormFlatten2Rdb.RdbJormExtentMapping | getMapping(JormExtent je) - Retrieves the RdbJormExtentMapping at the position i the packet.
|
QueryTree | rewrite(QueryTree qt, QueryNode parent)
|
Expression | updateFieldOfExpression(Expression e, BasicRdbExpQueryLeaf leaf, boolean add) - Replaces the uses of the old fields of extents by fields of a leaf.
|
JormFlatten2Rdb
public JormFlatten2Rdb()
getDecode
public Expression getDecode(PNameField pnf,
BasicRdbExpQueryLeaf leaf,
boolean add)
throws MedorException
Create an expression to decode a PName.
pnf
- is the PNameField linked to JormExtent which is the old
representation of the PName.leaf
- is the leaf which contains the field of the NameDef. It the
fields do not exist then they are created.
- an expression to decode a PName.
MedorException
- if the NameDef is not supported or if the a field
can not be created in the leaf.
getField
public QueryTreeField getField(String fieldname,
PType type,
JormExtent extent,
BasicRdbExpQueryLeaf leaf,
boolean add)
throws MedorException
Adds a field in a leaf if it is not already present.
fieldname
- is the field name of the expected field.type
- is the jorm type of expected field.extent
- is the extent containing the old version of the expected
field.leaf
- is the leaf which must contain the expected field after the
the method calladd
- indicates whether the field should be added to the leaf
- the expected field
MedorException
- if no old field is not available on the extent
or if no mapping is available for the field.
getField
public QueryTreeField getField(String fieldname,
JormExtent extent,
BasicRdbExpQueryLeaf leaf,
boolean add)
throws MedorException
Shortcut to the
getField(String, PType, JormExtent, BasicRdbExpQueryLeaf, boolean)
method.
The field type is calculated looking for the field in the JORM meta
information.
MedorException
- if the field is not found in the JORM meta
information or if an error occurs during the real getField call.
getField
public QueryTreeField getField(Field old,
BasicRdbExpQueryLeaf leaf,
boolean add)
throws MedorException
Is a shorcut to the
getField(String, PType, JormExtent, BasicRdbExpQueryLeaf, boolean)
method.
The fieldname, the type and the extent values are calculated from the
old Field.
old
- the old field
MedorException
- if an error occurs during the real getField call.
getMapping
public JormFlatten2Rdb.RdbJormExtentMapping getMapping(int i)
Retrieves the RdbJormExtentMapping at the position i the packet.
i
- is position of the expected RdbJormExtentMapping
- a RdbJormExtentMapping (never null).
getMapping
public JormFlatten2Rdb.RdbJormExtentMapping getMapping(JormExtent je)
Retrieves the RdbJormExtentMapping at the position i the packet.
je
- is the jorm extent which the mapping is expected
- a RdbJormExtentMapping (never null).
updateFieldOfExpression
public Expression updateFieldOfExpression(Expression e,
BasicRdbExpQueryLeaf leaf,
boolean add)
throws MedorException,
ExpressionException
Replaces the uses of the old fields of extents by fields of a leaf.
The PNameField uses are replaced by the corresponding equality between
fields of the name(single or composite).
e
- the expression to updateleaf
- is the field containing the new field.add
- indicates whether the Field should be added (it is projected)
or not (it is only in the Filter).
- the updated expression (Never null).
MedorException
- if it is not possible to fetch a new field in the
leaf or if the PName equality are malformed