[Mondrian] How to get all the measures definition in a mondrianschema file

Julian Hyde jhyde at pentaho.com
Thu Apr 23 14:06:53 EDT 2009


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



  _____  

From: mondrian-bounces at pentaho.org [mailto:mondrian-bounces at pentaho.org] On
Behalf Of Wen
Sent: Thursday, April 23, 2009 7:24 AM
To: mondrian at pentaho.org
Subject: [Mondrian] How to get all the measures definition in a
mondrianschema file


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/20090423/d03807be/attachment.html 


More information about the Mondrian mailing list