org.objectweb.medor.query.rdb.lib
Class AggregateRdbQueryNode

java.lang.Object
  extended byBasicCloneable
      extended byorg.objectweb.medor.lib.BasicTupleStructure
          extended byorg.objectweb.medor.query.lib.BasicQueryTree
              extended byorg.objectweb.medor.query.lib.BasicQueryNode
                  extended byorg.objectweb.medor.query.lib.Nest
                      extended byorg.objectweb.medor.query.rdb.lib.AggregateRdbQueryNode
All Implemented Interfaces:
AnnotationsHolder, java.lang.Cloneable, Cloneable, FilteredQueryTree, NestQueryNode, QueryLeaf, QueryNode, QueryTree, RdbQueryLeaf, java.io.Serializable, TupleStructure

public class AggregateRdbQueryNode
extends Nest
implements RdbQueryLeaf, NestQueryNode

This class represents a QueryLeaf which contains aggregate functions.

It is built on top of a RbdQueryLeaf.

See Also:
Serialized Form

Field Summary
protected  DataStore ds
           
protected  RdbExpField groupByField
           
protected  java.lang.String query
           
protected  RdbExpQueryLeaf subRdbQL
           
 
Fields inherited from class org.objectweb.medor.query.lib.Nest
myGroupByFields, nestedField, theGroupByFields
 
Fields inherited from class org.objectweb.medor.query.lib.BasicQueryNode
children, filter, indexes, inner, tupleLoader
 
Fields inherited from class org.objectweb.medor.query.lib.BasicQueryTree
annotations, distinct, name, orderfields
 
Fields inherited from class org.objectweb.medor.lib.BasicTupleStructure
fields, logger, name2field
 
Constructor Summary
AggregateRdbQueryNode()
           
AggregateRdbQueryNode(QueryTreeField[] groupedFields, java.lang.String groupedFieldName, QueryTreeField[] groupByFields, BasicRdbExpQueryLeaf subQL, DataStore ds, java.lang.String nodeName)
          Constructs a RDB QueryNode for an aggregation.
 
Method Summary
 java.lang.Object clone(java.lang.Object clone, java.util.Map obj2clone)
           
 DataStore getDataStore()
           
 Expression getQueryFilter()
          Redefines getQueryFilter using the filter of the subquery.
 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, java.util.ArrayList al, boolean rangeStartAt, boolean rangeSize)
          Returns the associated SQL queryn giving the list of SELECT fields as an input parameter.
 java.lang.String getSqlRequest(ParameterOperand[] pos, boolean rangeStartAt, boolean rangeSize)
          Builds and returns the SQL query as a String corresponding to the current RdbExpQueryLeaf.
 boolean isSubquery()
          Is the current query leaf a subquery (in particular for the case of aggregates).
 void setIsSubquery(boolean subquery)
          Indicates whether the current RdbExpQueryLeaf is a subquery of another Rdb query leaf (in particular in the case of subqueries).
 
Methods inherited from class org.objectweb.medor.query.lib.Nest
getNestedField, getNestingField, getNestingFields, getType, replaceNestedField, replaceNestingField, setQueryFilter
 
Methods inherited from class org.objectweb.medor.query.lib.BasicQueryNode
addCalculatedField, addChild, addField, addPropagatedField, getChildren, getFieldName, getTupleLoader, isOuter, removeField, replace, setOuter, setTupleLoader, updateCalculatedField, updateChildren, updatePropagatedField
 
Methods inherited from class org.objectweb.medor.query.lib.BasicQueryTree
getAnnotations, getDistinct, getName, getOrderBy, getTupleStructure, setDistinct, setOrderBy
 
Methods inherited from class org.objectweb.medor.lib.BasicTupleStructure
contains, contains, getField, getField, getFieldRank, getFields, getSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
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.NestQueryNode
getNestedField, getNestingField, getNestingFields, replaceNestedField, replaceNestingField
 
Methods inherited from interface org.objectweb.medor.query.api.QueryNode
addCalculatedField, addPropagatedField, getChildren, getTupleLoader, getType, isOuter, removeField, replace, setOuter, setTupleLoader, updateCalculatedField, updatePropagatedField
 
Methods inherited from interface org.objectweb.medor.query.api.FilteredQueryTree
setQueryFilter
 
Methods inherited from interface org.objectweb.medor.api.Cloneable
clone
 

Field Detail

ds

protected DataStore ds

groupByField

protected RdbExpField groupByField

subRdbQL

protected RdbExpQueryLeaf subRdbQL

query

protected java.lang.String query
Constructor Detail

AggregateRdbQueryNode

public AggregateRdbQueryNode()

AggregateRdbQueryNode

public AggregateRdbQueryNode(QueryTreeField[] groupedFields,
                             java.lang.String groupedFieldName,
                             QueryTreeField[] groupByFields,
                             BasicRdbExpQueryLeaf subQL,
                             DataStore ds,
                             java.lang.String nodeName)
                      throws MedorException
Constructs a RDB QueryNode for an aggregation.

The SQL request (string) will be calculated.

Parameters:
ds - is the DataStore associated to the QueryLeaf to be created
Throws:
QueryLeafException - if the QualifiedTables have all the same names, and in this case also the same aliases.
MedorException
Method Detail

clone

public java.lang.Object clone(java.lang.Object clone,
                              java.util.Map obj2clone)
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class Nest
Throws:
java.lang.CloneNotSupportedException

getSqlRequest

public java.lang.String getSqlRequest(ParameterOperand[] pos,
                                      java.util.ArrayList al,
                                      boolean rangeStartAt,
                                      boolean rangeSize)
                               throws MedorException,
                                      ExpressionException
Description copied from interface: RdbQueryLeaf
Returns the associated SQL queryn giving the list of SELECT fields as an input parameter.

In the case of an RdbExpQueryLeaf, the query is computed.

Specified by:
getSqlRequest in interface RdbQueryLeaf
Parameters:
pos - is an array of ParameterOperand
al - is the input Array of fields for constructing the SELECT clause.
rangeStartAt - is true for range queries where the first row to be returned in the case of a range query is greater than 0.
rangeSize - is true for range queries where the number of rows to be returned in the case of a range query is less than Integer.MAXVALUE
Returns:
the SQL query associated to the RdbQueryLeaf, as a String.
Throws:
MedorException - in the case of RdbExpQueryLeaves if the SQL request cannot be computed from the associated Expression
ExpressionException

getSqlRequest

public java.lang.String getSqlRequest(ParameterOperand[] pos,
                                      boolean rangeStartAt,
                                      boolean rangeSize)
                               throws MedorException,
                                      ExpressionException
Builds and returns the SQL query as a String corresponding to the current RdbExpQueryLeaf.

The SQL query is computed using the aggregate fields and relies on the child RdbQueryLeaf.

Specified by:
getSqlRequest in interface RdbQueryLeaf
Parameters:
pos - is an array of ParameterOperand
rangeStartAt - is true for range queries where the first row to be returned in the case of a range query is greater than 0.
rangeSize - is true for range queries where the number of rows to be returned in the case of a range query is less than Integer.MAXVALUE
Returns:
the SQL query as a String.
Throws:
MedorException - in the case of RdbExpQueryLeaves if the SQL request cannot be computed from the associated Expression
ExpressionException

getSelectList

public java.lang.String getSelectList(java.lang.String selectList,
                                      java.util.ArrayList selectFields,
                                      boolean qualified)
                               throws MedorException
Description copied from interface: RdbQueryLeaf
Builds the SELECT clause of the query (without "SELECT ").

Specified by:
getSelectList in interface RdbQueryLeaf
Parameters:
selectList - is the start of the SELECT clause to which the list of qualified columns is appended.
selectFields - is the fields for the SELECT clause. Such fields can either be plain fields, or can be aggregate fields
qualified - indicates whether the field names should be qualified with the table name or not.
Returns:
the list of qualified columns for the SELECT clause
Throws:
MedorException

getDataStore

public DataStore getDataStore()
Specified by:
getDataStore in interface QueryLeaf

setIsSubquery

public void setIsSubquery(boolean subquery)
Description copied from interface: RdbQueryLeaf
Indicates whether the current RdbExpQueryLeaf is a subquery of another Rdb query leaf (in particular in the case of subqueries).

The default value is false.

Specified by:
setIsSubquery in interface RdbQueryLeaf
Parameters:
subquery - is true when the current RdbExpQueryLeaf is a subquery of another Rdb query leaf/node, false otherwise.

isSubquery

public boolean isSubquery()
Description copied from interface: RdbQueryLeaf
Is the current query leaf a subquery (in particular for the case of aggregates).

Specified by:
isSubquery in interface RdbQueryLeaf
Returns:
true if the current RdbExpQueryLeaf is a subquery

getQueryFilter

public Expression getQueryFilter()
Redefines getQueryFilter using the filter of the subquery.

Specified by:
getQueryFilter in interface FilteredQueryTree
Overrides:
getQueryFilter in class BasicQueryNode
Returns:
the filter of the subquery.