Package org.olap4j.query
Class Query
java.lang.Object
org.olap4j.query.Query
Base query model object.
- Since:
- May 29, 2007
- Author:
- jhyde, jdixon, Luc Boudreau
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected QueryAxis
protected final Cube
protected Map
<String, QueryDimension> protected QueryAxis
protected QueryAxis
protected final String
protected boolean
Whether or not to select the default hierarchy and default member on a dimension if no explicit selections were performed.protected QueryAxis
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
Executes the query against the current OlapConnection and returns a CellSet object representation of the data.getAxes()
Returns a map of the current query's axis.Returns the query axis for a given axis type.getCube()
Returns the underlying cube object that is used to query against.getDimension
(String name) Returns the Olap4j's Dimension object according to the name given as a parameter.Returns the current locale with which this query is expressed.getName()
Returns this query's name.Returns the MDX parse tree behind this Query.Returns the fictional axis into which all unused dimensions are stored.protected void
Subclasses should call this helper method to notify it's listeners that children were added.protected void
notifyAdd
(org.olap4j.query.QueryNode child, int index) Subclasses should call this helper method to notify its listeners that a child was added.protected void
notifyChange
(Map<Integer, org.olap4j.query.QueryNode> children) Subclasses should call this helper method to notify its listeners that children selections object has a new operator value.protected void
notifyChange
(org.olap4j.query.QueryNode child, int index) Subclasses should call this helper method to notify its listeners that a child selection object has a new operator value.protected void
notifyRemove
(Map<Integer, org.olap4j.query.QueryNode> children) Subclasses should call this helper method to notify its listeners that children were added.protected void
notifyRemove
(org.olap4j.query.QueryNode child, int index) Subclasses should call this helper method to notify its listeners that a child was removed.void
void
setSelectDefaultMembers
(boolean selectDefaultMembers) Behavior setter for a query.void
setWithList
(List<ParseTreeNode> withList) void
swapAxes()
Swaps rows and columns axes.void
tearDown()
Safely disposes of all underlying objects of this query and closes the underlyingOlapConnection
.void
tearDown
(boolean closeConnection) Safely disposes of all underlying objects of this query.void
validate()
Validates the current query structure.
-
Field Details
-
name
-
axes
-
across
-
down
-
filter
-
unused
-
cube
-
dimensionMap
-
selectDefaultMembers
protected boolean selectDefaultMembersWhether or not to select the default hierarchy and default member on a dimension if no explicit selections were performed.
-
-
Constructor Details
-
Query
Constructs a Query object.- Parameters:
name
- Any arbitrary name to give to this query.cube
- A Cube object against which to build a query.- Throws:
SQLException
- If an error occurs while accessing the cube's underlying connection.
-
-
Method Details
-
getSelect
Returns the MDX parse tree behind this Query. The returned object is generated for each call to this function. Altering the returned SelectNode object won't affect the query itself.- Returns:
- A SelectNode object representing the current query structure.
-
getCube
Returns the underlying cube object that is used to query against.- Returns:
- The Olap4j's Cube object.
-
getDimension
Returns the Olap4j's Dimension object according to the name given as a parameter. If no dimension of the given name is found, a null value will be returned.- Parameters:
name
- The name of the dimension you want the object for.- Returns:
- The dimension object, null if no dimension of that name can be found.
-
swapAxes
public void swapAxes()Swaps rows and columns axes. Only applicable if there are two axes. -
getAxis
Returns the query axis for a given axis type.If you pass axis=null, returns a special axis that is used to hold all unused hierarchies. (We may change this behavior in future.)
- Parameters:
axis
- Axis type- Returns:
- Query axis
-
getAxes
Returns a map of the current query's axis.Be aware that modifications to this list might have unpredictable consequences.
- Returns:
- A standard Map object that represents the current query's axis.
-
getUnusedAxis
Returns the fictional axis into which all unused dimensions are stored. All dimensions included in this axis will not be part of the query.- Returns:
- The QueryAxis representing dimensions that are currently not used inside the query.
-
tearDown
public void tearDown(boolean closeConnection) Safely disposes of all underlying objects of this query.- Parameters:
closeConnection
- Whether or not to call theConnection.close()
method of the underlying connection.
-
tearDown
public void tearDown()Safely disposes of all underlying objects of this query and closes the underlyingOlapConnection
.Equivalent of calling Query.tearDown(true).
-
validate
Validates the current query structure. If a dimension axis has been placed on an axis but no selections were performed on it, the default hierarchy and default member will be selected. This can be turned off by invoking thesetSelectDefaultMembers(boolean)
method.- Throws:
OlapException
- If the query is not valid, an exception will be thrown and it's message will describe exactly what to fix.
-
execute
Executes the query against the current OlapConnection and returns a CellSet object representation of the data.- Returns:
- A proper CellSet object that represents the query execution results.
- Throws:
OlapException
- If something goes sour, an OlapException will be thrown to the caller. It could be caused by many things, like a stale connection. Look at the root cause for more details.
-
getName
Returns this query's name. There is no guarantee that it is unique and is set at object instanciation.- Returns:
- This query's name.
-
getLocale
Returns the current locale with which this query is expressed.- Returns:
- A standard Locale object.
-
setSelectDefaultMembers
public void setSelectDefaultMembers(boolean selectDefaultMembers) Behavior setter for a query. By default, if a dimension is placed on an axis but no selections are made, the default hierarchy and the default member will be selected when validating the query. This behavior can be turned off by this setter.- Parameters:
selectDefaultMembers
- Enables or disables the default member and hierarchy selection upon validation.
-
getWithList
-
setWithList
-
addQueryNodeListener
-
removeQueryNodeListener
-
notifyAdd
protected void notifyAdd(org.olap4j.query.QueryNode child, int index) Subclasses should call this helper method to notify its listeners that a child was added.- Parameters:
child
- Child that was addedindex
- The index at which it was added
-
notifyAdd
Subclasses should call this helper method to notify it's listeners that children were added.- Parameters:
children
- A map of indexes and children QueryNode objects that were added
-
notifyRemove
protected void notifyRemove(org.olap4j.query.QueryNode child, int index) Subclasses should call this helper method to notify its listeners that a child was removed.- Parameters:
child
- Child that was removedindex
- Index of child
-
notifyRemove
Subclasses should call this helper method to notify its listeners that children were added.- Parameters:
children
- A map of indexes and children QueryNode objects that were removed
-
notifyChange
protected void notifyChange(org.olap4j.query.QueryNode child, int index) Subclasses should call this helper method to notify its listeners that a child selection object has a new operator value.- Parameters:
child
- Child that was updatedindex
- The index of the child among its siblings
-
notifyChange
Subclasses should call this helper method to notify its listeners that children selections object has a new operator value.- Parameters:
children
- A map of indexes and children QueryNode objects that were updated
-