final Dimension dimension = cube.getDimensions()[1];
assertEquals("Dimension description", dimension.getDescription());
assertEquals("Dimension caption", dimension.getCaption());
checkAnnotations(dimension.getAnnotationMap(), "a", "Dimension");
final Hierarchy hierarchy = dimension.getHierarchies()[0];
assertEquals("Hierarchy description", hierarchy.getDescription());
assertEquals("Hierarchy caption", hierarchy.getCaption());
checkAnnotations(hierarchy.getAnnotationMap(), "a", "Hierarchy");
final mondrian.olap.Level level = hierarchy.getLevels()[1];
assertEquals("Level description", level.getDescription());
assertEquals("Level caption", level.getCaption());
checkAnnotations(level.getAnnotationMap(), "a", "Level");
// Caption comes from the CAPTION member property, defaults to name.
// Description comes from the DESCRIPTION member property.
// Annotations are always empty for regular members.
final List<Member> memberList =
cube.getSchemaReader(null).withLocus()
.getLevelMembers(level, false);
final Member member = memberList.get(0);
assertEquals("Canada", member.getName());
assertEquals("Canada", member.getCaption());
assertNull(member.getDescription());
checkAnnotations(member.getAnnotationMap());
// All member. Caption defaults to name; description is null.
final Member allMember = member.getParentMember();
assertEquals("All Stores", allMember.getName());
assertEquals("All Stores", allMember.getCaption());
assertNull(allMember.getDescription());
// All level.
final mondrian.olap.Level allLevel = hierarchy.getLevels()[0];
assertEquals("(All)", allLevel.getName());
assertNull(allLevel.getDescription());
assertEquals(allLevel.getName(), allLevel.getCaption());
checkAnnotations(allLevel.getAnnotationMap());
// the first time dimension overrides the caption and description of the
// shared time dimension
final Dimension timeDimension = cube.getDimensions()[2];
assertEquals("Time1", timeDimension.getName());
assertEquals("Time usage description", timeDimension.getDescription());
assertEquals("Time usage caption", timeDimension.getCaption());
checkAnnotations(timeDimension.getAnnotationMap(), "a", "Time usage");
// Time1 is a usage of a shared dimension Time.
// Now look at the hierarchy usage within that dimension usage.
// Because the dimension usage has a name, use that as a prefix for
// name, caption and description of the hierarchy usage.
final Hierarchy timeHierarchy = timeDimension.getHierarchies()[0];
// The hierarchy in the shared dimension does not have a name, so the
// hierarchy usage inherits the name of the dimension usage, Time1.
final boolean ssasCompatibleNaming =
MondrianProperties.instance().SsasCompatibleNaming.get();
if (ssasCompatibleNaming) {
assertEquals("Time", timeHierarchy.getName());
assertEquals("Time1", timeHierarchy.getDimension().getName());
} else {
assertEquals("Time1", timeHierarchy.getName());
}
// The description is prefixed by the dimension usage name.
assertEquals(
"Time usage caption.Time shared hierarchy description",
timeHierarchy.getDescription());
// The hierarchy caption is prefixed by the caption of the dimension
// usage.
assertEquals(
"Time usage caption.Time shared hierarchy caption",
timeHierarchy.getCaption());
// No annotations.
checkAnnotations(timeHierarchy.getAnnotationMap());
// the second time dimension does not overrides caption and description
final Dimension time2Dimension = cube.getDimensions()[3];
assertEquals("Time2", time2Dimension.getName());
assertEquals(
"Time shared description", time2Dimension.getDescription());
assertEquals("Time shared caption", time2Dimension.getCaption());
checkAnnotations(time2Dimension.getAnnotationMap());
final Hierarchy time2Hierarchy = time2Dimension.getHierarchies()[0];
// The hierarchy in the shared dimension does not have a name, so the
// hierarchy usage inherits the name of the dimension usage, Time2.
if (ssasCompatibleNaming) {
assertEquals("Time", time2Hierarchy.getName());
assertEquals("Time2", time2Hierarchy.getDimension().getName());
} else {
assertEquals("Time2", time2Hierarchy.getName());
}
// The description is prefixed by the dimension usage name (because
// dimension usage has no caption).
assertEquals(
"Time2.Time shared hierarchy description",
time2Hierarchy.getDescription());
// The hierarchy caption is prefixed by the dimension usage name
// (because the dimension usage has no caption.
assertEquals(
"Time2.Time shared hierarchy caption",
time2Hierarchy.getCaption());
// No annotations.
checkAnnotations(time2Hierarchy.getAnnotationMap());
final Dimension measuresDimension = cube.getDimensions()[0];
final Hierarchy measuresHierarchy =
measuresDimension.getHierarchies()[0];
final mondrian.olap.Level measuresLevel =
measuresHierarchy.getLevels()[0];
final SchemaReader schemaReader = cube.getSchemaReader(null);
final List<Member> measures =
schemaReader.getLevelMembers(measuresLevel, true);
final Member measure = measures.get(0);
assertEquals("Unit Sales", measure.getName());
assertEquals("Measure caption", measure.getCaption());
assertEquals("Measure description", measure.getDescription());
assertEquals(
measure.getDescription(),
measure.getPropertyValue(Property.DESCRIPTION.name));
assertEquals(
measure.getCaption(),
measure.getPropertyValue(Property.CAPTION.name));
assertEquals(
measure.getCaption(),
measure.getPropertyValue(Property.MEMBER_CAPTION.name));
checkAnnotations(measure.getAnnotationMap(), "a", "Measure");
// The implicitly created [Fact Count] measure
final Member factCountMeasure = measures.get(1);
assertEquals("Fact Count", factCountMeasure.getName());
assertEquals(
false,
factCountMeasure.getPropertyValue(Property.VISIBLE.name));
final Member calcMeasure = measures.get(2);
assertEquals("Foo", calcMeasure.getName());
assertEquals("Calc member caption", calcMeasure.getCaption());
assertEquals("Calc member description", calcMeasure.getDescription());
assertEquals(
calcMeasure.getDescription(),
calcMeasure.getPropertyValue(Property.DESCRIPTION.name));
assertEquals(
calcMeasure.getCaption(),
calcMeasure.getPropertyValue(Property.CAPTION.name));
assertEquals(
calcMeasure.getCaption(),
calcMeasure.getPropertyValue(Property.MEMBER_CAPTION.name));
checkAnnotations(calcMeasure.getAnnotationMap(), "a", "Calc member");
final NamedSet namedSet = cube.getNamedSets()[0];
assertEquals("Top Periods", namedSet.getName());
assertEquals("Named set caption", namedSet.getCaption());
assertEquals("Named set description", namedSet.getDescription());
checkAnnotations(namedSet.getAnnotationMap(), "a", "Named set");
final Result result2 =
testContext.executeQuery("select from [" + virtualCubeName + "]");
final Cube cube2 = result2.getQuery().getCube();
assertEquals("Virtual cube description", cube2.getDescription());
checkAnnotations(cube2.getAnnotationMap(), "a", "Virtual cube");
final SchemaReader schemaReader2 = cube2.getSchemaReader(null);
final Dimension measuresDimension2 = cube2.getDimensions()[0];
final Hierarchy measuresHierarchy2 =
measuresDimension2.getHierarchies()[0];
final mondrian.olap.Level measuresLevel2 =
measuresHierarchy2.getLevels()[0];
final List<Member> measures2 =
schemaReader2.getLevelMembers(measuresLevel2, true);
final Member measure2 = measures2.get(0);
assertEquals("Unit Sales", measure2.getName());
assertEquals("Measure caption", measure2.getCaption());