}
private Member foo(int i) throws SQLException {
final OlapConnection connection =
getTestContext().getOlap4jConnection();
final Cube cube;
final Hierarchy measuresHierarchy;
final CellSet cellSet;
switch (i) {
case 0:
cellSet = connection.createStatement().executeOlapQuery(
"select [Measures].[Unit Sales] on 0\n"
+ "from [Sales]");
return cellSet.getAxes().get(0).getPositions().get(0)
.getMembers().get(0);
case 1:
cellSet =
connection.createStatement().executeOlapQuery(
"select [Measures].Members on 0\n"
+ "from [Sales]");
return cellSet.getAxes().get(0).getPositions().get(0)
.getMembers().get(0);
case 2:
cellSet =
connection.createStatement().executeOlapQuery(
"select [Measures].[Measures].Members on 0\n"
+ "from [Sales]");
return cellSet.getAxes().get(0).getPositions().get(0)
.getMembers().get(0);
case 3:
cube = connection.getOlapSchema().getCubes().get("Sales");
measuresHierarchy = cube.getHierarchies().get("Measures");
final NamedList<Member> rootMembers =
measuresHierarchy.getRootMembers();
return rootMembers.get(0);
case 4:
cube = connection.getOlapSchema().getCubes().get("Sales");
measuresHierarchy = cube.getHierarchies().get("Measures");
final Level measuresLevel = measuresHierarchy.getLevels().get(0);
final List<Member> levelMembers = measuresLevel.getMembers();
return levelMembers.get(0);
case 5:
cube = connection.getOlapSchema().getCubes().get("Sales");
measuresHierarchy = cube.getHierarchies().get("Measures");
return measuresHierarchy.getDefaultMember();
case 6:
cube = connection.getOlapSchema().getCubes().get("Sales");
return
cube.lookupMember(
IdentifierNode.parseIdentifier("[Measures].[Unit Sales]")
.getSegmentList());
default:
throw new IllegalArgumentException("bad index " + i);
}