Skip to content

Commit

Permalink
Adds calculated members to Level.getMembers() along with a new test t…
Browse files Browse the repository at this point in the history
…o verify and updated documentation.
  • Loading branch information
lucboudreau committed Mar 1, 2013
1 parent 48a24d6 commit 5f1afbb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/org/olap4j/metadata/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.olap4j.metadata;

import org.olap4j.CellSet;
import org.olap4j.OlapException;

import java.util.List;
Expand Down Expand Up @@ -87,7 +88,9 @@ public interface Level extends MetadataElement {
/**
* Returns a list of {@link Member} objects that belong to this Level.
*
* <p>The list does not include calculated members.</p>
* <p>Since olap4j 2.0, the list includes calculated members which are
* defined server-side, if any. The list does not include any calculated
* members from an MDX query, if accessed through a {@link CellSet}.</p>
*
* <p>Some levels have a very many members. In this case, calling this
* method may be expensive in space and/or time and is not recommended.</p>
Expand Down
20 changes: 20 additions & 0 deletions testsrc/org/olap4j/ConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3665,6 +3665,26 @@ public void testParentChildAccessControl() throws Exception {
}
}

public void testLevelMembersIncludeCalculatedMembers()
throws Exception
{
connection = tester.createConnection();
final OlapConnection olapConnection =
tester.getWrapper().unwrap(connection, OlapConnection.class);
List<Measure> measures =
olapConnection.getOlapSchema()
.getCubes().get("Sales")
.getMeasures();
for (Measure m : measures) {
if (m.getUniqueName().equals("[Measures].[Profit]")
&& m.isCalculated())
{
return;
}
}
fail("Calculated measures not returned.");
}

protected void assertListsEquals(List<String> list1, List<String> list2) {
Collections.sort(list1);
Collections.sort(list2);
Expand Down

0 comments on commit 5f1afbb

Please sign in to comment.