/** return the hierarchies that are on the slicer axis (all that are not visible) */ public static Set getSlicerHierarchies(OlapModel model) throws OlapException { Set visible = getVisibleDimensions(model); /* Get dimensions and hierarchies on the slicer */ Axis slicer = model.getResult().getSlicer(); Set selectedSlicerDims = new HashSet(); Set selectedSlicerHiers = new HashSet(); List positions = slicer.getPositions(); for (Iterator iter = positions.iterator(); iter.hasNext(); ) { Position pos = (Position) iter.next(); Member[] posMembers = pos.getMembers(); for (int i = 0; i < posMembers.length; i++) { Hierarchy hier = posMembers[i].getLevel().getHierarchy(); Dimension dim = hier.getDimension(); if (!selectedSlicerHiers.contains(hier)) selectedSlicerHiers.add(hier); if (!selectedSlicerDims.contains(dim)) selectedSlicerDims.add(dim); } } /* Return hierarchies that are not on the rows or columns and for the selected * members, return the selected hierarchy */ Set slicerHiers = new HashSet(); Dimension[] dims = model.getDimensions(); for (int i = 0; i < dims.length; i++) { if (!visible.contains(dims[i])) { if (!selectedSlicerDims.contains(dims[i])) { slicerHiers.add(dims[i].getHierarchies()[0]); } else { for (Iterator it = selectedSlicerHiers.iterator(); it.hasNext(); ) { Hierarchy hier = (Hierarchy) it.next(); Dimension dim = hier.getDimension(); if (dim.equals(dims[i])) { slicerHiers.add(hier); break; } } } } } return slicerHiers; }
protected Result run() { getConnection().getCacheControl(null).flushSchemaCache(); IntegerProperty monLimit = MondrianProperties.instance().ResultLimit; int oldLimit = monLimit.get(); try { monLimit.set(this.resultLimit); Result result = executeQuery(query, con); // Check the number of positions on the last axis, which is // the ROWS axis in a 2 axis query. int numAxes = result.getAxes().length; Axis a = result.getAxes()[numAxes - 1]; final int positionCount = a.getPositions().size(); assertEquals(rowCount, positionCount); return result; } finally { monLimit.set(oldLimit); } }
/** returns the number of members on each position */ public static int countHierarchies(Axis axis) { List positions = axis.getPositions(); if (positions.size() == 0) return 0; return ((Position) positions.get(0)).getMembers().length; }