Skip to content

Commit

Permalink
MONDRIAN: Ati's i18n changes.
Browse files Browse the repository at this point in the history
  Added captions for dimension, cube, virtual cube, and a caption for the 'Measures' dimension.
  Levels can have a caption expression which is read, along with key, name, and member properties, when members are read from the database.

[git-p4: depot-paths = "//open/mondrian/": change = 4127]
  • Loading branch information
julianhyde committed Sep 21, 2005
1 parent 94ad5e0 commit ac967f3
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 33 deletions.
64 changes: 59 additions & 5 deletions src/main/mondrian/olap/Mondrian.xml
Expand Up @@ -36,7 +36,10 @@ Revision is $Id$
<Doc>Name of this schema</Doc>
</Attribute>
<Attribute name="measuresCaption" required="false">
<Doc>Label for the measures dimension</Doc>
<Doc>
Label for the measures dimension.
Can be localized from Properties file using #{propertyname}.
</Doc>
</Attribute>
<Attribute name="defaultRole" required="false">
<Doc>The name of the default role for connections to this schema</Doc>
Expand Down Expand Up @@ -99,6 +102,12 @@ Revision is $Id$
dimension', in MSOLAP parlance), or a 'private dimension'.
</Doc>
<Attribute name="name" required="true"/>
<Attribute name="caption" required="false">
<Doc>
A string being displayed instead of the Dimension's name.
Can be localized from Properties file using #{propertyname}.
</Doc>
</Attribute>
<Attribute name="foreignKey">
<Doc>
The name of the column in the fact table which joins
Expand Down Expand Up @@ -134,6 +143,12 @@ Revision is $Id$
Name of this cube.
</Doc>
</Attribute>
<Attribute name="caption" required="false">
<Doc>
A string being displayed instead of the cube's name.
Can be localized from Properties file using #{propertyname}.
</Doc>
</Attribute>
<Attribute name="cache" type="Boolean" default="true">
<Doc>
Should the Fact table data for this Cube be cached
Expand Down Expand Up @@ -198,6 +213,12 @@ Revision is $Id$
</Doc>
</Attribute>
<Attribute name="name"><Doc></Doc></Attribute>
<Attribute name="caption" required="false">
<Doc>
A string being displayed instead of the cube's name.
Can be localized from Properties file using #{propertyname}.
</Doc>
</Attribute>
<Array name="dimensions" type="VirtualCubeDimension"><Doc></Doc></Array>
<Array name="measures" type="VirtualCubeMeasure"><Doc></Doc></Array>
<Code><![CDATA[
Expand All @@ -218,8 +239,11 @@ Revision is $Id$
unspecified if the dimension is shared.
</Doc>
</Attribute>
<Attribute name="name"><Doc>
Name of the dimension.</Doc></Attribute>
<Attribute name="name">
<Doc>
Name of the dimension.
</Doc>
</Attribute>
<Code><![CDATA[
// implement CubeDimension
public Dimension getDimension(Schema schema) {
Expand Down Expand Up @@ -317,6 +341,7 @@ Revision is $Id$
<Attribute name="caption" required="false">
<Doc>
A string being displayed instead of the dimensions's name.
Can be localized from Properties file using #{propertyname}.
</Doc>
</Attribute>

Expand Down Expand Up @@ -369,12 +394,14 @@ Revision is $Id$
<Attribute name="allMemberCaption" required="false">
<Doc>
A string being displayed instead as the all member's name.
Can be localized from Properties file using #{propertyname}.
</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)'.
Can be localized from Properties file using #{propertyname}.
</Doc>
</Attribute>
<Attribute name="primaryKey">
Expand Down Expand Up @@ -403,6 +430,7 @@ Revision is $Id$
<Doc>
A string to be displayed in the user interface.
If not specified, the hierarchy's name is used.
Can be localized from Properties file using #{propertyname}.
</Doc>
</Attribute>

Expand All @@ -425,6 +453,7 @@ Revision is $Id$
The name of the table that the column comes from. If
this hierarchy is based upon just one table, defaults to
the name of that table; otherwise, it is required.
Can be localized from Properties file using #{propertyname}.
</Doc>
</Attribute>
<Attribute name="column">
Expand All @@ -439,6 +468,7 @@ Revision is $Id$
this level.
</Doc>
</Attribute>

<Attribute name="ordinalColumn" required="false">
<Doc>
The name of the column which holds member
Expand Down Expand Up @@ -517,9 +547,16 @@ Revision is $Id$
<Attribute name="caption" required="false">
<Doc>
A string being displayed instead of the level's name.
Can be localized from Properties file using #{propertyname}.
</Doc>
</Attribute>

<Attribute name="captionColumn" required="false">
<Doc>
The name of the column which holds the caption for
members.
</Doc>
</Attribute>

<Object name="keyExp" type="KeyExpression" required="false">
<Doc>
The SQL expression used to populate this level's key.
Expand Down Expand Up @@ -563,6 +600,13 @@ Revision is $Id$
return null;
}
}
public Expression getCaptionExp() {
if (captionColumn != null) {
return new Column(table, captionColumn);
} else {
return null;
}
}
public Expression getOrdinalExp() {
if (ordinalExp != null) {
return ordinalExp;
Expand Down Expand Up @@ -622,6 +666,7 @@ Revision is $Id$
<Attribute name="caption" required="false">
<Doc>
A string being displayed instead of the name.
Can be localized from Properties file using #{propertyname}.
</Doc>
</Attribute>
</Element>
Expand All @@ -631,7 +676,7 @@ Revision is $Id$
<Doc>Name of this measure.</Doc>
</Attribute>
<Attribute name="column" required="true">
<Doc>Column which is source of this measure's valies.</Doc>
<Doc>Column which is source of this measure's values.</Doc>
</Attribute>
<Attribute name="formatString">
<Doc>
Expand All @@ -657,6 +702,7 @@ Revision is $Id$
<Attribute name="caption" required="false">
<Doc>
A string being displayed instead of the name.
Can be localized from Properties file using #{propertyname}.
</Doc>
</Attribute>
<Attribute name="visible" type="Boolean" required="false">
Expand All @@ -683,6 +729,7 @@ Revision is $Id$
<Attribute name="caption" required="false">
<Doc>
A string being displayed instead of the name.
Can be localized from Properties file using #{propertyname}.
</Doc>
</Attribute>
<Attribute name="formula" required="false">
Expand Down Expand Up @@ -733,6 +780,12 @@ Revision is $Id$
<Doc>
Name of this member property.
</Doc>
</Attribute>
<Attribute name="caption" required="false">
<Doc>
A string being displayed instead of the Properties's name.
Can be localized from Properties file using #{propertyname}.
</Doc>
</Attribute>
<Attribute name="expression">
<Doc>
Expand Down Expand Up @@ -1334,6 +1387,7 @@ Revision is $Id$
<Element type="ParentExpression" class="ExpressionView"/>
<Element type="OrdinalExpression" class="ExpressionView"/>
<Element type="NameExpression" class="ExpressionView"/>
<Element type="CaptionExpression" class="ExpressionView"/>

<!-- Access control =================================================== -->
<Element type="Role">
Expand Down
8 changes: 5 additions & 3 deletions src/main/mondrian/rolap/RolapHierarchy.java
Expand Up @@ -110,7 +110,7 @@ class RolapHierarchy extends HierarchyBase {
}
this.levels = new RolapLevel[xmlHierarchy.levels.length + 1];
this.levels[0] = new RolapLevel(
this, 0, this.allLevelName, null, null, null, null, null,
this, 0, this.allLevelName, null, null, null, null, null, null,
null, RolapProperty.emptyArray,
RolapLevel.ALL | RolapLevel.UNIQUE,
RolapLevel.HideMemberCondition.Never,
Expand Down Expand Up @@ -212,7 +212,7 @@ void init(RolapCube cube, MondrianDef.CubeDimension xmlDimension) {

RolapLevel newLevel(String name, int flags) {
RolapLevel level = new RolapLevel(
this, this.levels.length, name, null, null, null,
this, this.levels.length, name, null, null, null, null,
null, null, null, RolapProperty.emptyArray, flags,
RolapLevel.HideMemberCondition.Never, LevelType.Regular);
this.levels = (RolapLevel[]) RolapUtil.addElement(this.levels, level);
Expand Down Expand Up @@ -526,9 +526,10 @@ RolapDimension createClosedPeerDimension(
int flags = src.getFlags() &~ RolapLevel.UNIQUE;
MondrianDef.Expression keyExp =
new MondrianDef.Column(clos.table.name, clos.parentColumn);

RolapLevel level = new RolapLevel(peerHier, index++,
"Closure",
keyExp, null, null,
keyExp, null, null, null,
null, null, // no longer a parent-child hierarchy
null, RolapProperty.emptyArray, flags,
src.getHideMemberCondition(), src.getLevelType());
Expand All @@ -550,6 +551,7 @@ RolapDimension createClosedPeerDimension(
null,
null,
null,
null,
null, // no longer a parent-child hierarchy
null,
RolapProperty.emptyArray,
Expand Down
29 changes: 23 additions & 6 deletions src/main/mondrian/rolap/RolapLevel.java
Expand Up @@ -49,6 +49,8 @@ public static RolapLevel lookupLevel(RolapLevel[] levels, String levelName) {
private final MondrianDef.Expression keyExp;
/** The column or expression which yields the level's ordinal. */
private final MondrianDef.Expression ordinalExp;
/** The column or expression which yields the level members' caption. */
private final MondrianDef.Expression captionExp;
/** For SQL generator. Whether values of "column" are unique globally
* unique (as opposed to unique only within the context of the parent
* member). **/
Expand Down Expand Up @@ -88,6 +90,7 @@ public static RolapLevel lookupLevel(RolapLevel[] levels, String levelName) {
String name,
MondrianDef.Expression keyExp,
MondrianDef.Expression nameExp,
MondrianDef.Expression captionExp,
MondrianDef.Expression ordinalExp,
MondrianDef.Expression parentExp,
String nullParentValue,
Expand All @@ -108,6 +111,7 @@ public static RolapLevel lookupLevel(RolapLevel[] levels, String levelName) {
if (keyExp instanceof MondrianDef.Column) {
checkColumn((MondrianDef.Column) keyExp);
}

this.flags = flags;
final boolean isAll = (flags & ALL) == ALL;
this.unique = (flags & UNIQUE) == UNIQUE;
Expand All @@ -118,6 +122,12 @@ public static RolapLevel lookupLevel(RolapLevel[] levels, String levelName) {
}
}
this.nameExp = nameExp;
if (captionExp != null) {
if (captionExp instanceof MondrianDef.Column) {
checkColumn((MondrianDef.Column) captionExp);
}
}
this.captionExp = captionExp;
if (ordinalExp != null) {
if (ordinalExp instanceof MondrianDef.Column) {
checkColumn((MondrianDef.Column) ordinalExp);
Expand Down Expand Up @@ -204,6 +214,12 @@ public MondrianDef.Expression getKeyExp() {
MondrianDef.Expression getOrdinalExp() {
return ordinalExp;
}
public MondrianDef.Expression getCaptionExp() {
return captionExp;
}
public boolean hasCaptionColumn(){
return captionExp != null;
}
int getFlags() {
return flags;
}
Expand Down Expand Up @@ -241,7 +257,7 @@ private Property lookupProperty(List list, String propertyName) {
RolapLevel(RolapHierarchy hierarchy, int depth, MondrianDef.Level xmlLevel) {
this(
hierarchy, depth, xmlLevel.name, xmlLevel.getKeyExp(),
xmlLevel.getNameExp(), xmlLevel.getOrdinalExp(),
xmlLevel.getNameExp(), xmlLevel.getCaptionExp(), xmlLevel.getOrdinalExp(),
xmlLevel.getParentExp(), xmlLevel.nullParentValue,
xmlLevel.closure, createProperties(xmlLevel),
(xmlLevel.type.equals("Numeric") ? NUMERIC : 0) |
Expand Down Expand Up @@ -270,18 +286,19 @@ private static RolapProperty[] createProperties(
MondrianDef.Level xmlLevel) {
List list = new ArrayList();
final MondrianDef.Expression nameExp = xmlLevel.getNameExp();

if (nameExp != null) {
list.add(
new RolapProperty(
Property.NAME.name, Property.TYPE_STRING,
nameExp, null, null));
list.add(new RolapProperty(
Property.NAME.name, Property.TYPE_STRING,
nameExp, null, null));
}
for (int i = 0; i < xmlLevel.properties.length; i++) {
MondrianDef.Property property = xmlLevel.properties[i];
list.add(new RolapProperty(
property.name,
convertPropertyTypeNameToCode(property.type),
xmlLevel.getPropertyExp(i), property.formatter, property.caption));
xmlLevel.getPropertyExp(i),
property.formatter, property.caption));
}
return (RolapProperty[]) list.toArray(RolapProperty.emptyArray);
}
Expand Down

0 comments on commit ac967f3

Please sign in to comment.