org.objectweb.medor.query.rdb.api
Interface RdbExpQueryLeaf

All Superinterfaces:
AnnotationsHolder, java.lang.Cloneable, FilteredQueryTree, QueryLeaf, QueryTree, RdbQueryLeaf, java.io.Serializable
All Known Implementing Classes:
BasicRdbExpQueryLeaf

public interface RdbExpQueryLeaf
extends RdbQueryLeaf, FilteredQueryTree

An RdbExpQueryLeaf is a particular type of RdbQueryLeaf for which the associated SQL query if not given as a SQL String, but is computed from an Expression (representing the filter) and from abstract information made of QualifiedTables, representing the FROM part of the SQL query.

The Medor optimizer can "reason" about RdbExpQueryLeaves, and merge several such query leaves into one if they have the same DataStore.

The life cycle of an RdbExpQueryLeaf is:

A RdbExpQueryLeaf can use a RdbAdapter to build a SQL query. The Rdb Adapter permits to manage the relational databases that are not conform to the jdbc specification.

Author:
Alexandre Lefebvre

Method Summary
 void addGroupBy(RdbExpField groupBy)
          Adds a groupBy Field.
 void addQualifiedTable(QualifiedTable qt)
          Adds a QualifiedTable to the QueryLeaf
 RdbExpField addRdbField(RdbExpField rdbField)
          Adds an RdbExpField to the RdbExpQueryLeaf.
 RdbExpField addRdbField(java.lang.String fieldName, PType type, java.lang.String colName, QualifiedTable table)
          Adds a Field to the RdbExpQueryLeaf
 boolean containsQualifiedTable(QualifiedTable qt)
          Checks if a QualifiedTable is in the list of QualifiedTables of this QueryLeaf
 java.lang.String getGroupBy()
          Returns the GROUP BY clause of the query leaf.
 java.lang.String getGroupBy(java.lang.String singleAlias)
          Returns the GROUP BY clause of the query leaf.
 RdbExpField[] getGroupByFields()
          Gets the RdbExpFields of the GroupBy Clause.
 QualifiedTable[] getQualifiedTables()
          Returns the associated QualifiedTables.
 RdbAdapter getRdbAdapter()
          It retrieves the rdb adapter.
 java.lang.String getRdbAdapterName()
          It retrieves the rdb adapter name.
 void removeQualifiedTable(QualifiedTable qt)
          Adds a QualifiedTable to the QueryLeaf
 void removeRdbField(RdbExpField rdbField)
          Adds an RdbExpField to the RdbExpQueryLeaf.
 void resetSqlRequest()
          In case the SQL query was already computed, resets it to null.
 void setNoGroupBy(boolean noGroupBy)
          Requires that the GROUP BY clause not be output by the getSqlRequest method.
 void setRdbAdapter(RdbAdapter adapter)
          It assigns the rdb adapter.
 void setRdbAdapterName(java.lang.String name)
          It assignes the rdb adapter name.
 void setRootJoinedTables(java.util.List rootjts)
           
 
Methods inherited from interface org.objectweb.medor.query.rdb.api.RdbQueryLeaf
getSelectList, getSqlRequest, getSqlRequest, isSubquery, setIsSubquery
 
Methods inherited from interface org.objectweb.medor.query.api.QueryLeaf
getDataStore
 
Methods inherited from interface org.objectweb.medor.query.api.QueryTree
getDistinct, getName, getOrderBy, getTupleStructure, setDistinct, setOrderBy
 
Methods inherited from interface org.objectweb.medor.query.api.AnnotationsHolder
getAnnotations
 
Methods inherited from interface org.objectweb.medor.query.api.FilteredQueryTree
getQueryFilter, setQueryFilter
 

Method Detail

addRdbField

public RdbExpField addRdbField(java.lang.String fieldName,
                               PType type,
                               java.lang.String colName,
                               QualifiedTable table)
                        throws QueryLeafException
Adds a Field to the RdbExpQueryLeaf

Parameters:
fieldName - is the name of the Field to be added.
type - is the PTyme of the Field to be added.
colName - is the name of the column in the associated QualifiedTable.
table - is the QualifiedTable from which the Field is to be created.
Returns:
the created RdbExpField.
Throws:
QueryLeafException - if the QualifiedTable is not in the set of QualifiedTables associatged with the current RdbExpQueryLeaf.

addRdbField

public RdbExpField addRdbField(RdbExpField rdbField)
                        throws QueryLeafException
Adds an RdbExpField to the RdbExpQueryLeaf. The QueryLeaf associated to the RdbExpField becomes the current RdbExpQueryLeaf.

Parameters:
rdbField - is the RdbField to be added.
Throws:
QueryLeafException

removeRdbField

public void removeRdbField(RdbExpField rdbField)
                    throws QueryLeafException
Adds an RdbExpField to the RdbExpQueryLeaf. The QueryLeaf associated to the RdbExpField becomes the current RdbExpQueryLeaf.

Parameters:
rdbField - is the RdbField to be added.
Throws:
QueryLeafException

addGroupBy

public void addGroupBy(RdbExpField groupBy)
                throws QueryLeafException
Adds a groupBy Field. This RdbExpField must be in The TupleStructure of this QueryLeaf Object.

Parameters:
groupBy - : RdbExpField
Throws:
QueryLeafException - if this RdbExpField doesn't appears in the list of the fields which will be projected in Select clause

getGroupByFields

public RdbExpField[] getGroupByFields()
Gets the RdbExpFields of the GroupBy Clause. It returns null if there is no Result Grouping

Returns:
an array of RdbExpField

getQualifiedTables

public QualifiedTable[] getQualifiedTables()
Returns the associated QualifiedTables.

Returns:
the array of associated QualifiedTables.

addQualifiedTable

public void addQualifiedTable(QualifiedTable qt)
Adds a QualifiedTable to the QueryLeaf

Parameters:
qt - the QualifiedTable to be added

removeQualifiedTable

public void removeQualifiedTable(QualifiedTable qt)
                          throws MedorException
Adds a QualifiedTable to the QueryLeaf

Parameters:
qt - the QualifiedTable to be added
Throws:
MedorException - if the QualifiedTable in not in the current leaf.

containsQualifiedTable

public boolean containsQualifiedTable(QualifiedTable qt)
Checks if a QualifiedTable is in the list of QualifiedTables of this QueryLeaf

Parameters:
qt - the QualifiedTable to be tested
Returns:
true if qt is in the list of QualifiedTables for this QueryLeaf

setRdbAdapterName

public void setRdbAdapterName(java.lang.String name)
It assignes the rdb adapter name. The RdbAdapter is used to adapte the sql queries to a relational database


getRdbAdapterName

public java.lang.String getRdbAdapterName()
It retrieves the rdb adapter name. The RdbAdapter is used to adapte the sql queries to a relational database


setRdbAdapter

public void setRdbAdapter(RdbAdapter adapter)
It assigns the rdb adapter. The RdbAdapter is used to adapt sql queries to a relational database


getRdbAdapter

public RdbAdapter getRdbAdapter()
It retrieves the rdb adapter. The RdbAdapter is used to adapt sql queries to a relational database


setRootJoinedTables

public void setRootJoinedTables(java.util.List rootjts)

resetSqlRequest

public void resetSqlRequest()
In case the SQL query was already computed, resets it to null.


setNoGroupBy

public void setNoGroupBy(boolean noGroupBy)
Requires that the GROUP BY clause not be output by the getSqlRequest method.

Parameters:
noGroupBy - is true if no GROUP BY clause should be output (false by default).

getGroupBy

public java.lang.String getGroupBy()
Returns the GROUP BY clause of the query leaf.

Returns:
the GROUP BY clause of the query leaf.

getGroupBy

public java.lang.String getGroupBy(java.lang.String singleAlias)
Returns the GROUP BY clause of the query leaf.

Returns:
the GROUP BY clause of the query leaf.