Skip to content

Commit

Permalink
MONDRIAN: Add the allLevelName attribute on hierarchies.
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//open/mondrian/": change = 3421]
  • Loading branch information
ebb committed Apr 1, 2005
1 parent edc7248 commit e87b3eb
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/main/mondrian/olap/HierarchyBase.java
Expand Up @@ -44,6 +44,7 @@ public abstract class HierarchyBase
protected Level[] levels;
protected final boolean hasAll;
protected String allMemberName;
protected String allLevelName;

protected HierarchyBase(Dimension dimension,
String subName,
Expand Down
9 changes: 7 additions & 2 deletions src/main/mondrian/olap/Mondrian.xml
Expand Up @@ -292,15 +292,20 @@ Revision is $Id$
<Doc>
Name of the 'all' member. If this attribute is not specified,
the all member is named 'All <i>hierarchyName</i>', for
example, 'All Store'. Note that the 'all' level is always
called '(All)'.
example, 'All Store'.
</Doc>
</Attribute>
<Attribute name="allMemberCaption" required="false">
<Doc>
A string being displayed instead as the all member's name.
</Doc>
</Attribute>
<Attribute name="allLevelName" required="false">
<Doc>
Name of the 'all' level. If this attribute is not specified,
the all member is named '(All)'.
</Doc>
</Attribute>
<Attribute name="primaryKey">
<Doc>
The name of the column which identifies members, and
Expand Down
9 changes: 7 additions & 2 deletions src/main/mondrian/rolap/RolapHierarchy.java
Expand Up @@ -72,7 +72,8 @@ class RolapHierarchy extends HierarchyBase {
setCaption(dimension.getCaption());

if (hasAll) {
Util.discard(newLevel("(All)",
this.allLevelName = "(All)";
Util.discard(newLevel(this.allLevelName,
RolapLevel.ALL | RolapLevel.UNIQUE));
this.allMemberName = "All " + name + "s";
}
Expand Down Expand Up @@ -101,9 +102,12 @@ class RolapHierarchy extends HierarchyBase {
if (xmlHierarchy.allMemberName != null) {
this.allMemberName = xmlHierarchy.allMemberName;
}
if (xmlHierarchy.allLevelName != null) {
this.allLevelName = xmlHierarchy.allLevelName;
}
this.levels = new RolapLevel[xmlHierarchy.levels.length + 1];
this.levels[0] = new RolapLevel(
this, 0, "(All)", null, null, null, null, null,
this, 0, this.allLevelName, null, null, null, null, null,
null, RolapProperty.emptyArray,
RolapLevel.ALL | RolapLevel.UNIQUE,
RolapLevel.HideMemberCondition.Never,
Expand Down Expand Up @@ -473,6 +477,7 @@ RolapDimension createClosedPeerDimension(
// Create a peer hierarchy.
RolapHierarchy peerHier = peerDimension.newHierarchy(subName, true);
peerHier.allMemberName = allMemberName;
peerHier.allLevelName = allLevelName;
peerHier.sharedHierarchy = sharedHierarchy;
peerHier.primaryKey = primaryKey;
MondrianDef.Join join = new MondrianDef.Join();
Expand Down
22 changes: 22 additions & 0 deletions testsrc/main/mondrian/test/BasicQueryTest.java
Expand Up @@ -4299,6 +4299,28 @@ public void testAllMemberCaption() {
Assert.assertEquals(caption, "Frauen und Maenner");
}

public void testAllLevelName() {
RolapConnection conn = (RolapConnection) getConnection();
Schema schema = getConnection().getSchema();
final Cube salesCube = schema.lookupCube("Sales", true);
schema.createDimension(
salesCube,
"<Dimension name=\"Gender4\" foreignKey=\"customer_id\">" + nl +
" <Hierarchy hasAll=\"true\" allMemberName=\"All Gender\"" + nl +
" allLevelName=\"GenderLevel\" primaryKey=\"customer_id\">" + nl +
" <Table name=\"customer\"/>" + nl +
" <Level name=\"Gender\" column=\"gender\" uniqueMembers=\"true\"/>" +nl +
" </Hierarchy>" + nl +
"</Dimension>");
String mdx = "select {[Gender4].[All Gender]} on columns from Sales";
Result result = TestContext.instance().executeFoodMart(mdx);
Axis axis0 = result.getAxes()[0];
Position pos0 = axis0.positions[0];
Member allGender = pos0.members[0];
String caption = allGender.getLevel().getName();
Assert.assertEquals(caption, "GenderLevel");
}

/**
* It is illegal for a query to have the same dimension on more than
* one axis.
Expand Down

0 comments on commit e87b3eb

Please sign in to comment.