private void toOlap4j( UnionBuilder expression, Node current, ParseTreeNode partialExpression, int level, List<QueryHierarchy> dimensions, List<HierarchyExpander> expanders) { HierarchyExpander expander = expanders.get(level); expander.setDrills(current.drills); QueryHierarchy h = dimensions.get(level); // Creates a list of children to be processed List<Member> childrenMembers = new ArrayList<Member>(); if (current.hasChildren()) { for (Node child : current.children) { if (!h.isIncluded(child.getMember())) continue; Member p = h.getParentMember(child.getMember()); while (p != null && expander.isDrilled(p)) { p = h.getParentMember(p); } if (p == null) childrenMembers.add(child.getMember()); } } // Generates the join of this query hierarchy, appling the drills and removing // any member involved in a larger drill position. CrossJoinBuilder xJoin = new CrossJoinBuilder(); xJoin.join(partialExpression); xJoin.join(Mdx.except(h.toOlap4j(expander), UnionBuilder.fromMembers(childrenMembers))); for (int n = level + 1; n < dimensions.size(); ++n) { HierarchyExpander nextExp = expanders.get(n); nextExp.setDrills(null); QueryHierarchy nh = dimensions.get(n); xJoin.join(nh.toOlap4j(nextExp)); } expression.add(xJoin.getJoinNode()); // Recursively generates expression for larger drill positions. for (Member child : childrenMembers) { CrossJoinBuilder x = new CrossJoinBuilder(); x.join(partialExpression); x.join(Mdx.member(child)); toOlap4j( expression, current.getChild(child), x.getJoinNode(), level + 1, dimensions, expanders); } }
public ParseTreeNode toOlap4j( List<QueryHierarchy> dimensions, List<HierarchyExpander> expanders) { UnionBuilder expression = new UnionBuilder(); toOlap4j(expression, root, null, 0, dimensions, expanders); return expression.getUnionNode(); }