|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.objectweb.medor.lib.BasicTupleStructure | +--org.objectweb.medor.query.lib.BasicQueryTree | +--org.objectweb.medor.query.rdb.lib.BasicRdbExpQueryLeaf
This class represents a QueryLeaf that maps onto a relational database store. It implements the case where the relational query is provided as a set of QualifiedTables and an Expression representing the filter.
Field Summary | |
protected boolean |
debug
|
protected Logger |
log
|
Fields inherited from class org.objectweb.medor.query.lib.BasicQueryTree |
distinct, indexes, name, orderfields |
Fields inherited from class org.objectweb.medor.lib.BasicTupleStructure |
fields, name2field |
Constructor Summary | |
BasicRdbExpQueryLeaf(DataStore ds,
QualifiedTable[] from,
java.lang.String nodeName)
Constructs a BasicRdbExpQueryLeaf from an Expression and a set of QualifiedTables. |
|
BasicRdbExpQueryLeaf(DataStore ds,
java.lang.String nodeName)
|
Method Summary | |
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 name,
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 |
DataStore |
getDataStore()
|
boolean |
getDistinct()
Tests whether the results should be distinct or not. |
protected java.lang.String |
getFromList()
Builds the FROM clause of the query (without "FROM"). |
RdbExpField |
getGroupByField()
Gets the RdbExpField of the GroupBy Clause. |
java.lang.String |
getName()
It returns the name of the query tree. |
protected java.lang.String |
getQualifiedFieldName(RdbExpField field)
Builds the qualified name of a RdbExpField. |
QualifiedTable[] |
getQualifiedTables()
Returns the associated QualifiedTables. |
Expression |
getQueryFilter()
Retrieves the filter associated to the RbdQueryLeaf. |
RdbAdapter |
getRdbAdapter()
It retrieves the rdb adapter. |
java.lang.String |
getRdbAdapterName()
It retrieves the rdb adapter name. |
java.lang.String |
getSelectList(java.lang.String selectList,
java.util.ArrayList selectFields,
boolean qualified)
Builds the SELECT clause of the query (without "SELECT"). |
java.lang.String |
getSqlRequest(ParameterOperand[] pos)
Returns the associated SQL query. |
java.lang.String |
getSqlRequest(ParameterOperand[] pos,
java.util.ArrayList selectFields)
Builds and returns the SQL query as a String corresponding to the current RdbExpQueryLeaf. |
TupleStructure |
getTupleStructure()
Returns the TupleStructure associated to the QueryTree. |
boolean |
isSubquery()
Is the current query leaf a subquery (in particular for the case of aggregates). |
void |
removeQualifiedTable(QualifiedTable qt)
Adds a QualifiedTable to the QueryLeaf |
void |
removeRdbField(RdbExpField rdbField)
Adds an RdbExpField to the RdbExpQueryLeaf. |
void |
setDistinct(boolean d)
Indicates whether evaluating the QueryTree should return unique results (duplicate elimination) or not. |
void |
setGroupBy(RdbExpField groupBy)
Sets the groupBy Field. |
void |
setIsSubquery(boolean subquery)
Indicates whether the current RdbExpQueryLeaf is a subquery of another Rdb query leaf (in particular in the case of subqueries). |
void |
setQueryFilter(Expression exp)
Sets the filter associated to the RbdQueryLeaf. |
void |
setRdbAdapter(RdbAdapter adapter)
|
void |
setRdbAdapterName(java.lang.String an)
It assignes the rdb adapter name. |
void |
setRootJoinedTables(java.util.List rootjts)
|
Methods inherited from class org.objectweb.medor.query.lib.BasicQueryTree |
clone, getOrderBy, setOrderBy |
Methods inherited from class org.objectweb.medor.lib.BasicTupleStructure |
contains, contains, getField, getField, getFieldRank, getFields, getSize |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.objectweb.medor.query.rdb.api.RdbExpQueryLeaf |
setRdbAdapter |
Methods inherited from interface org.objectweb.medor.query.api.QueryTree |
getOrderBy, setOrderBy |
Methods inherited from interface org.objectweb.medor.api.TupleStructure |
contains, contains, getField, getField, getFieldRank, getFields, getSize |
Methods inherited from interface org.objectweb.medor.api.Cloneable |
clone |
Field Detail |
protected Logger log
protected boolean debug
Constructor Detail |
public BasicRdbExpQueryLeaf(DataStore ds, QualifiedTable[] from, java.lang.String nodeName) throws QueryLeafException
The SQL request (string) will be calculated.
ds
- is the DataStore associated to the QueryLeaf to be createdfrom
- is the array of QualifiedTables associated to the QueryLeaf
to be created
QueryLeafException
- if the QualifiedTables have all the same
names, and in this case also the same aliases.public BasicRdbExpQueryLeaf(DataStore ds, java.lang.String nodeName)
Method Detail |
public void setRdbAdapterName(java.lang.String an)
RdbExpQueryLeaf
setRdbAdapterName
in interface RdbExpQueryLeaf
public java.lang.String getRdbAdapterName()
RdbExpQueryLeaf
getRdbAdapterName
in interface RdbExpQueryLeaf
public void setRdbAdapter(RdbAdapter adapter)
public RdbAdapter getRdbAdapter()
RdbExpQueryLeaf
getRdbAdapter
in interface RdbExpQueryLeaf
public java.lang.String getName()
QueryTree
getName
in interface QueryTree
getName
in class BasicQueryTree
public void setRootJoinedTables(java.util.List rootjts)
setRootJoinedTables
in interface RdbExpQueryLeaf
public RdbExpField addRdbField(java.lang.String name, PType type, java.lang.String colName, QualifiedTable table) throws QueryLeafException
addRdbField
in interface RdbExpQueryLeaf
name
- 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.
QueryLeafException
- if the QualifiedTable is not in the
set of QualifiedTables associatged with the current RdbExpQueryLeaf.public void addQualifiedTable(QualifiedTable qt)
RdbExpQueryLeaf
addQualifiedTable
in interface RdbExpQueryLeaf
qt
- the QualifiedTable to be addedpublic void removeQualifiedTable(QualifiedTable qt) throws MedorException
RdbExpQueryLeaf
removeQualifiedTable
in interface RdbExpQueryLeaf
qt
- the QualifiedTable to be added
MedorException
- if the QualifiedTable in not in the current leaf.public boolean containsQualifiedTable(QualifiedTable qt)
RdbExpQueryLeaf
containsQualifiedTable
in interface RdbExpQueryLeaf
qt
- the QualifiedTable to be tested
public RdbExpField addRdbField(RdbExpField rdbField) throws QueryLeafException
addRdbField
in interface RdbExpQueryLeaf
rdbField
- is the RdbField to be added.
QueryLeafException
public void removeRdbField(RdbExpField rdbField) throws QueryLeafException
RdbExpQueryLeaf
removeRdbField
in interface RdbExpQueryLeaf
rdbField
- is the RdbField to be added.
QueryLeafException
public java.lang.String getSqlRequest(ParameterOperand[] pos) throws MedorException
RdbQueryLeaf
In the case of an RdbExpQueryLeaf, the query is computed.
getSqlRequest
in interface RdbQueryLeaf
MedorException
- in the case of RdbExpQueryLeaves if the
SQL request cannot be computed from the associated Expressionpublic java.lang.String getSqlRequest(ParameterOperand[] pos, java.util.ArrayList selectFields) throws MedorException
The SQL query is computed from the provided RdbExpFields (SELECT clause), QualifiedTables (FROM clause) and Expression (WHERE clause).
getSqlRequest
in interface RdbQueryLeaf
MedorException
- in the case of RdbExpQueryLeaves if the
SQL request cannot be computed from the associated Expressionpublic void setQueryFilter(Expression exp)
This filter is represented by an Expression. Unlike the filter of a QueryNode, is applies to its own Fields, instead of the Fields of its children.
setQueryFilter
in interface FilteredQueryTree
exp
- is the Medor Expression representing the filter to be applied
to the relational source tables.Expression
public Expression getQueryFilter()
getQueryFilter
in interface FilteredQueryTree
Expression
public QualifiedTable[] getQualifiedTables()
getQualifiedTables
in interface RdbExpQueryLeaf
public DataStore getDataStore()
getDataStore
in interface QueryLeaf
public TupleStructure getTupleStructure()
QueryTree
getTupleStructure
in interface QueryTree
getTupleStructure
in class BasicQueryTree
public boolean getDistinct()
QueryTree
getDistinct
in interface QueryTree
getDistinct
in class BasicQueryTree
public void setDistinct(boolean d)
QueryTree
The default should be that duplicates are not eliminated (distinct is false).
setDistinct
in interface QueryTree
setDistinct
in class BasicQueryTree
d
- is true if duplicates should be eliminated, false
otherwise.public void setGroupBy(RdbExpField groupBy) throws QueryLeafException
RdbExpQueryLeaf
setGroupBy
in interface RdbExpQueryLeaf
groupBy
- : RdbExpField
QueryLeafException
- if this RdbExpField don't appears in
the list of the fields which will be projected in Select clausepublic RdbExpField getGroupByField()
RdbExpQueryLeaf
getGroupByField
in interface RdbExpQueryLeaf
public void setIsSubquery(boolean subquery)
RdbQueryLeaf
The default value is false.
setIsSubquery
in interface RdbQueryLeaf
subquery
- is true when the current RdbExpQueryLeaf is a subquery
of another Rdb query leaf/node, false otherwise.public boolean isSubquery()
RdbQueryLeaf
isSubquery
in interface RdbQueryLeaf
public java.lang.String getSelectList(java.lang.String selectList, java.util.ArrayList selectFields, boolean qualified)
getSelectList
in interface RdbQueryLeaf
selectList
- is the start of the SELECT clause to which the list
of qualified columns is appended.
protected java.lang.String getQualifiedFieldName(RdbExpField field)
field
- is the RdbExpField for which the qualified name is built.
protected java.lang.String getFromList()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |