// In generaly, there is only one cube.
for (RolapCube cube : findCubes()) {
Dimension[] dims = cube.getDimensions();
// start dimensions at 1 (0 is measures)
for (int j = 1; j < dims.length; j++) {
Dimension dim = dims[j];
// Ok, got dimension.
// See if any of the levels exist as columns in the
// aggTable. This requires applying a map from:
// hierarchyName
// levelName
// levelColumnName
// to each "unassigned" column in the aggTable.
// Remember that the rule is if a level does appear,
// then all of the higher levels must also appear.
String dimName = dim.getName();
Hierarchy[] hierarchies = dim.getHierarchies();
for (Hierarchy hierarchy : hierarchies) {
HierarchyUsage[] hierarchyUsages =
cube.getUsages(hierarchy);
for (HierarchyUsage hierarchyUsage : hierarchyUsages) {
// Search through the notSeenForeignKeys list