[Mondrian] Fwd: How to get all the measures definition in a mondrian schema file

Wen xwcheng at gmail.com
Thu Apr 23 22:09:41 EDT 2009


Thank you reply!
I looked up mondrain API and source code, but found that there are no
"getLevelMembers"
this method of
Level.  am I using a wrong version of mondrian?

Thank you.

You want the members of the [Measures] dimension.  The [Measures] dimension
has one hierarchy, also called [Measures], and one level. All measures
(including calculated measures) belong to that level.

SchemaReader schemaReader;
Cube cube = find(schemaReader.getCubes(), "Sales");
Dimension measuresDimension = schemaReader.getCubeDimensions(cube),
"Measures");
Level measuresLevel = measuresDimension.getHierarchies()[0].getLevels()[0];
boolean includeCalc = true;
Member[] measures = measuresLevel.getLevelMembers(measuresLevel,
includeCalc);


Cube find(Cube[] cubes, String name) {
   ...
}

Dimension find(Dimension[], String name) {
  ...
}

Please use the olap4j API if possible. olap4j is the official way to
interface with mondrian these days, and things are a lot simpler.

OlapConnection connection;
NamedList<Measures> measures =
  connection.getSchema().getCubes().get("Sales").getMeasures();


olap4j is applying access-control automatically, just like SchemaReader.

Julian



---------- Forwarded message ----------
From: Wen <xwcheng at gmail.com>
Date: Thu, Apr 23, 2009 at 10:24 PM
Subject: How to get all the measures definition in a mondrian schema file
To: mondrian at pentaho.org


Hi all,
        I can get all the schema by getSchemaReader(), and then use the cube
object to get all the Dimensions definition,
measure is a special dimension, so it should be got too. but how can i get a
special measure's name
for example, in foodmart there is a "Unit Sales" measure:

 <Measure name="Unit Sales" column="unit_sales" aggregator="sum"
      formatString="Standard"/>

 the dimension.getUniqueName() method just return "[Measures]"

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20090424/f0ffd6f3/attachment.html 


More information about the Mondrian mailing list