org.olap4j.query
Class QueryDimension

java.lang.Object
  extended by org.olap4j.query.QueryDimension

public class QueryDimension
extends Object

Usage of a dimension for an OLAP query.

It references an Dimension and allows the query creator to manage the member selections for the dimension. The state of a QueryDimension does not affect the Dimension object in any way so a single Dimension object can be referenced by many QueryDimension objects.

Since:
May 29, 2007
Version:
$Id: QueryDimension.java 482 2012-01-05 23:27:27Z jhyde $
Author:
jdixon, jhyde, Luc Boudreau

Nested Class Summary
static class QueryDimension.HierarchizeMode
          Defines in which way the hierarchize operation should be performed.
 
Constructor Summary
QueryDimension(Query query, Dimension dimension)
           
 
Method Summary
 void addQueryNodeListener(QueryNodeListener l)
          Registers a new listener for a QueryNode.
 void clearExclusions()
          Clears the current member inclusions from this query dimension.
 void clearHierarchizeMode()
          Tells the QueryDimension not to hierarchize its included selections.
 void clearInclusions()
          Clears the current member inclusions from this query dimension.
 void clearSort()
          Clears the current sorting settings.
 Selection createSelection(Level level)
          Selects level and includes all members in the query.
 Selection createSelection(List<IdentifierSegment> nameParts)
           
 Selection createSelection(Member member)
           
 Selection createSelection(Selection.Operator operator, List<IdentifierSegment> nameParts)
           
 Selection createSelection(Selection.Operator operator, Member member)
          Selects members and includes them in the query.
 void exclude(Level level)
          Selects level members and excludes them from the query.
 void exclude(List<IdentifierSegment> nameParts)
          Selects members and excludes them from the query.
 void exclude(Member member)
          Selects members and excludes them from the query.
 void exclude(Selection.Operator operator, List<IdentifierSegment> nameParts)
          Selects members and excludes them from the query.
 void exclude(Selection.Operator operator, Member member)
          Selects members and excludes them from the query.
 QueryAxis getAxis()
           
 Dimension getDimension()
          Returns the underlying dimension object onto which this query dimension is based.
 List<Selection> getExclusions()
          Returns a list of the exclusions within this dimension.
 QueryDimension.HierarchizeMode getHierarchizeMode()
          Returns the current mode of hierarchization, or null if no hierarchization is currently performed.
 List<Selection> getInclusions()
          Returns a list of the inclusions within this dimension.
 String getName()
           
 Query getQuery()
           
 SortOrder getSortOrder()
          Returns the current order in which the dimension members are sorted.
 Selection include(Level level)
          Selects a level and includes it in the query.
 Selection include(List<IdentifierSegment> nameParts)
          Selects members and includes them in the query.
 Selection include(Member member)
          Selects members and includes them in the query.
 Selection include(Selection.Operator operator, List<IdentifierSegment> nameParts)
          Selects members and includes them in the query.
 Selection include(Selection.Operator operator, Member member)
          Selects members and includes them in the query.
 boolean isHierarchyConsistent()
          Tells the QueryDimension not to keep a consistent hierarchy
 void removeQueryNodeListener(QueryNodeListener l)
          De-registers a new listener for a QueryNode.
 List<Member> resolve(Selection selection)
          Resolves a selection of members into an actual list of the root member and it's relatives selected by the Selection object.
 void setAxis(QueryAxis axis)
           
 void setDimension(Dimension dimension)
          Forces a change onto which dimension is the current base of this QueryDimension object.
 void setHierarchizeMode(QueryDimension.HierarchizeMode hierarchizeMode)
          Triggers the hierarchization of the included members within this QueryDimension.
 void setHierarchyConsistent(boolean consistent)
          Tells the QueryDimension not to keep a consistent hierarchy within the inclusions when the mdx is generated.
 void sort(SortOrder order)
          Sorts the dimension members by name in the order supplied as a parameter.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryDimension

public QueryDimension(Query query,
                      Dimension dimension)
Method Detail

getQuery

public Query getQuery()

setAxis

public void setAxis(QueryAxis axis)

getAxis

public QueryAxis getAxis()

getName

public String getName()

include

public Selection include(List<IdentifierSegment> nameParts)
                  throws OlapException
Selects members and includes them in the query.

This method selects and includes a single member with the Selection.Operator.MEMBER operator.

Parameters:
nameParts - Name of the member to select and include.
Throws:
OlapException - If no member corresponding to the supplied name parts could be resolved in the cube.

createSelection

public Selection createSelection(List<IdentifierSegment> nameParts)
                          throws OlapException
Throws:
OlapException

include

public Selection include(Selection.Operator operator,
                         List<IdentifierSegment> nameParts)
                  throws OlapException
Selects members and includes them in the query.

This method selects and includes a member along with its relatives, depending on the supplied Selection.Operator operator.

Parameters:
operator - Selection operator that defines what relatives of the supplied member name to include along.
nameParts - Name of the root member to select and include.
Throws:
OlapException - If no member corresponding to the supplied name parts could be resolved in the cube.

createSelection

public Selection createSelection(Selection.Operator operator,
                                 List<IdentifierSegment> nameParts)
                          throws OlapException
Throws:
OlapException

include

public Selection include(Member member)
Selects members and includes them in the query.

This method selects and includes a single member with the Selection.Operator.MEMBER selection operator.

Parameters:
member - The member to select and include in the query.

createSelection

public Selection createSelection(Member member)

include

public Selection include(Level level)
Selects a level and includes it in the query.

This method selects and includes a all members of the given query using the Selection.Operator.MEMBERS selection operator.

Parameters:
level - The level to select and include in the query.

createSelection

public Selection createSelection(Selection.Operator operator,
                                 Member member)
Selects members and includes them in the query.

This method selects and includes a member along with it's relatives, depending on the supplied Selection.Operator operator.

Parameters:
operator - Selection operator that defines what relatives of the supplied member name to include along.
member - Root member to select and include.

createSelection

public Selection createSelection(Level level)
Selects level and includes all members in the query.

This method selects and includes all members of a given Level, using the MEMBERS operator Selection.Operator

Parameters:
level - Root level to select and include.

include

public Selection include(Selection.Operator operator,
                         Member member)
Selects members and includes them in the query.

This method selects and includes a member along with it's relatives, depending on the supplied Selection.Operator operator.

Parameters:
operator - Selection operator that defines what relatives of the supplied member name to include along.
member - Root member to select and include.

clearInclusions

public void clearInclusions()
Clears the current member inclusions from this query dimension.


exclude

public void exclude(List<IdentifierSegment> nameParts)
             throws OlapException
Selects members and excludes them from the query.

This method selects and excludes a single member with the Selection.Operator.MEMBER operator.

Parameters:
nameParts - Name of the member to select and exclude.
Throws:
OlapException - If no member corresponding to the supplied name parts could be resolved in the cube.

exclude

public void exclude(Selection.Operator operator,
                    List<IdentifierSegment> nameParts)
             throws OlapException
Selects members and excludes them from the query.

This method selects and excludes a member along with its relatives, depending on the supplied Selection.Operator operator.

Parameters:
operator - Selection operator that defines what relatives of the supplied member name to exclude along.
nameParts - Name of the root member to select and exclude.
Throws:
OlapException - If no member corresponding to the supplied name parts could be resolved in the cube.

exclude

public void exclude(Level level)
Selects level members and excludes them from the query.

This method selects and excludes members of a level with the Selection.Operator.MEMBERS selection operator.

Parameters:
level - The level to select and exclude from the query.

exclude

public void exclude(Member member)
Selects members and excludes them from the query.

This method selects and excludes a single member with the Selection.Operator.MEMBER selection operator.

Parameters:
member - The member to select and exclude from the query.

exclude

public void exclude(Selection.Operator operator,
                    Member member)
Selects members and excludes them from the query.

This method selects and excludes a member along with it's relatives, depending on the supplied Selection.Operator operator.

Parameters:
operator - Selection operator that defines what relatives of the supplied member name to exclude along.
member - Root member to select and exclude.

clearExclusions

public void clearExclusions()
Clears the current member inclusions from this query dimension.


resolve

public List<Member> resolve(Selection selection)
                     throws OlapException
Resolves a selection of members into an actual list of the root member and it's relatives selected by the Selection object.

Parameters:
selection - The selection of members to resolve.
Returns:
A list of the actual members selected by the selection object.
Throws:
OlapException - If resolving the selections triggers an exception while looking up members in the underlying cube.

getInclusions

public List<Selection> getInclusions()
Returns a list of the inclusions within this dimension.

Be aware that modifications to this list might have unpredictable consequences.

Returns:
list of inclusions

getExclusions

public List<Selection> getExclusions()
Returns a list of the exclusions within this dimension.

Be aware that modifications to this list might have unpredictable consequences.

Returns:
list of exclusions

getDimension

public Dimension getDimension()
Returns the underlying dimension object onto which this query dimension is based.

Returns a mutable object so operations on it have unpredictable consequences.

Returns:
The underlying dimension representation.

setDimension

public void setDimension(Dimension dimension)
Forces a change onto which dimension is the current base of this QueryDimension object.

Forcing a change in the duimension assignment has unpredictable consequences.

Parameters:
dimension - The new dimension to assign to this query dimension.

sort

public void sort(SortOrder order)
Sorts the dimension members by name in the order supplied as a parameter.

Parameters:
order - The SortOrder to use.

getSortOrder

public SortOrder getSortOrder()
Returns the current order in which the dimension members are sorted.

Returns:
A value of SortOrder

clearSort

public void clearSort()
Clears the current sorting settings.


getHierarchizeMode

public QueryDimension.HierarchizeMode getHierarchizeMode()
Returns the current mode of hierarchization, or null if no hierarchization is currently performed.

This capability is only available when a single dimension is selected on an axis

Returns:
Either a hierarchization mode value or null if no hierarchization is currently performed.

setHierarchizeMode

public void setHierarchizeMode(QueryDimension.HierarchizeMode hierarchizeMode)
Triggers the hierarchization of the included members within this QueryDimension.

The dimension inclusions will be wrapped in an MDX Hierarchize function call.

This capability is only available when a single dimension is selected on an axis.

Parameters:
hierarchizeMode - If parents should be included before or after their children. (Equivalent to the POST/PRE MDX literal for the Hierarchize() function) inside the Hierarchize() MDX function call.

clearHierarchizeMode

public void clearHierarchizeMode()
Tells the QueryDimension not to hierarchize its included selections.

This capability is only available when a single dimension is selected on an axis.


setHierarchyConsistent

public void setHierarchyConsistent(boolean consistent)
Tells the QueryDimension not to keep a consistent hierarchy within the inclusions when the mdx is generated. Only members whose Ancestors are included will be included.

It uses the MDX function FILTER() in combination with ANCESTOR() to produce a set like:

{[Time].[1997]},
Filter({{[Time].[Quarter].Members}}, (Ancestor([Time].CurrentMember, [Time].[Year]) IN {[Time].[1997]}))


isHierarchyConsistent

public boolean isHierarchyConsistent()
Tells the QueryDimension not to keep a consistent hierarchy


addQueryNodeListener

public void addQueryNodeListener(QueryNodeListener l)
Registers a new listener for a QueryNode.

Parameters:
l - The new listener object, implementation of QueryNodeListener
See Also:
QueryNodeListener

removeQueryNodeListener

public void removeQueryNodeListener(QueryNodeListener l)
De-registers a new listener for a QueryNode. If the listener object passed as a parameter was not registered, the method will return silently.

Parameters:
l - The listener object to de-register.
See Also:
QueryNodeListener

SourceForge.net_Logo