Version 6: Hierarchy Expansion, let’s drill-up

Wednesday, February 22, 2012
You can download this version of the sample, and an improved version of the component library from here.

This version includes the capability to expand/collapse a hierarchy in the cellset table. An expanded hierarchy initially shows all of its members, and the user can drill-up to hide details. A collapsed hierarchy initially shows only its root members, and the user can drill-down to show further detail.

Expanded Hierarchy: Store Type hierarchy expanded with some undrilled members

I've modified the queryCellSet composite component (and QueryCellSetBean, its associated managed bean) to include a hierarchy expansion button in the header of both cellset axes, allowing the user toggling the expand state for a hierarchy.

This functionality is supported by three methods in the QueryAxis class:

  • void expandHierarchy(QueryHierarchy h)Expands the hierarchy, invalidating any previous drill/undrill operation on every appearance of h in this axis
  • void collapseHierarchy(QueryHierarchy h)
    Collapses the hierarchy, invalidating any previous drill/undrill operation on every appearance of h in this axis
  • boolean isExpanded(QueryHierarchy h)
    Tests if the provided hierarchy is expanded in this axis.

QueryHierarchy Expression Generation

The strategy to MDX generation for an expanded hierarchy is as follows:
  • A fully expanded hierarchy generates this MDX:
    DESCENDANTS(<root members set>, 0, SELF_AND_AFTER)
  • Member undrill is implemented by an external EXCEPT:
        DESCENDANTS(<root members set>, 0, SELF_AND_AFTER),
        DESCENDANTS(<undrilled members set>, 0, AFTER)

Refactoring Axis Set Expression Generation
Previously, axis MDX expression generation was driven by the drill tree. I've refactored this logic to let the axis expression generation be driven by the QueryHierarchy inclusion/exclusion tree.
This is a simplified version of the function to generate an axis set expression for a QueryHierarchy

   * Recursively generates the set expression for a Query Hierarchy.
@param current
   *            currently visited node
@param expander
   *            helper object to execute drills/expansions
@param drillList
   *            members to drill/undrill
@param expression
   *            generated expression
private void toOlap4jQueryDidactic(VisitingInfo current,
      HierarchyExpander expander, List<Member> drillList,
      AxisExpression expression
) {
boolean isMemberIncluded =
(Operator.MEMBER) == Sign.INCLUDE;
boolean areChildrenIncluded =
(Operator.CHILDREN) == Sign.INCLUDE;
boolean areDescendantsIncluded =

// Processes current member, including or excluding it from the
    // expression as necessary.
Member currentMember = current.getMember();
if (isMemberIncluded) {
if (expander.isDrilled(currentMember, drillList)) {
// Current member is included in the hierarchy but collapsed.
        // Ends this visit as we should not include any descendant.

// Recursively calls toOlap4jQueryDidactic on overrided children
List<Member> overridedChildren = new ArrayList<Member>();
for (SelectionTree overridedChild : current.getNode()
.getOverridingChildren()) {

      VisitingInfo childVisit = current.visitChild

if (areDescendantsIncluded) {
// Expand/undrill descendants
MemberSet expansionBase;
if (areChildrenIncluded) {
expansionBase = new ChildrenMemberSet(currentMember,
} else {
expansionBase = new GrandchildrenSet(currentMember,
expander.expand(expansionBase, drillList, expression);
} else {
// Include children if necessary
if (areChildrenIncluded) {
MemberSet nonOverridingChildren
new ChildrenMemberSet(currentMember, overridedChildren);

1 comment :

  1. Participation is predicated solely on availability and management discretion. Promotional 카지노 Free Play prizes will expire on the finish of the gaming day. Insert your 24K Select card into any slot machine with Free Play enabled, enter your pin and follow the on-screen instructions. Choose among forty thrilling desk video games, with friendly dealers and an atmosphere of unparalleled consolation. Try your hand at favorites similar to Blackjack or Roulette, or take a shot at Craps, Head’s Up Hold’em, and Flop Poker. If you’re within the mood for thrilling, high-stakes action, our devoted high-limit desk video games are the place to be.