use of org.olap4j.metadata.Dimension in project mondrian by pentaho.
the class MondrianOlap4jCube method getMeasures.
public List<Measure> getMeasures() {
final Dimension dimension = getDimensions().get("Measures");
if (dimension == null) {
return Collections.emptyList();
}
final MondrianOlap4jConnection olap4jConnection = olap4jSchema.olap4jCatalog.olap4jDatabaseMetaData.olap4jConnection;
try {
final mondrian.olap.SchemaReader schemaReader = olap4jConnection.getMondrianConnection().getSchemaReader().withLocus();
final MondrianOlap4jLevel measuresLevel = (MondrianOlap4jLevel) dimension.getDefaultHierarchy().getLevels().get(0);
final List<Measure> measures = new ArrayList<Measure>();
List<mondrian.olap.Member> levelMembers = schemaReader.getLevelMembers(measuresLevel.level, true);
for (mondrian.olap.Member member : levelMembers) {
// This corrects MONDRIAN-1123, a ClassCastException (see below)
// that occurs when you create a calculated member on a
// dimension other than Measures:
// java.lang.ClassCastException:
// mondrian.olap4j.MondrianOlap4jMember cannot be cast to
// org.olap4j.metadata.Measure
MondrianOlap4jMember olap4jMember = olap4jConnection.toOlap4j(member);
if (olap4jMember instanceof Measure) {
measures.add((Measure) olap4jMember);
}
}
return measures;
} catch (OlapException e) {
// Demote from checked to unchecked exception.
throw new RuntimeException(e);
}
}
Aggregations