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

Julian Hyde jhyde at pentaho.com
Sat Apr 25 14:05:33 EDT 2009


I meant SchemaReader.getLevelMembers(level,boolean).


  _____  

From: mondrian-bounces at pentaho.org [mailto:mondrian-bounces at pentaho.org] On
Behalf Of Wen
Sent: Thursday, April 23, 2009 7:10 PM
To: mondrian at pentaho.org
Subject: [Mondrian] Fwd: How to get all the measures definition in amondrian
schema file


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/20090425/e4a83b59/attachment.html 


More information about the Mondrian mailing list