Skip to content

Commit 48d4687

Browse files
committed
Adds Cube.isDrillThroughEnabled, adds related tests and adds a mechanism to override values returned by an XMLA server for metadata calls.
git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@432 c6a108a4-781c-0410-a6c6-c2d559e19af0
1 parent a640c01 commit 48d4687

File tree

5 files changed

+88
-3
lines changed

5 files changed

+88
-3
lines changed

src/org/olap4j/driver/xmla/XmlaOlap4jCube.java

+5
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ public NamedList<Hierarchy> getHierarchies() {
146146
return Olap4jUtil.cast(hierarchies);
147147
}
148148

149+
public boolean isDrillThroughEnabled() {
150+
// XMLA does not implement drillthrough yet.
151+
return false;
152+
}
153+
149154
public List<Measure> getMeasures() {
150155
return Olap4jUtil.cast(measures);
151156
}

src/org/olap4j/driver/xmla/XmlaOlap4jDatabaseMetaData.java

+31-3
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,27 @@ abstract class XmlaOlap4jDatabaseMetaData implements OlapDatabaseMetaData {
4848
this.olap4jConnection = olap4jConnection;
4949
}
5050

51+
private ResultSet getMetadata(
52+
XmlaOlap4jConnection.MetadataRequest metadataRequest,
53+
Object... patternValues) throws OlapException
54+
{
55+
return getMetadata(
56+
metadataRequest,
57+
Collections.emptyMap(),
58+
patternValues);
59+
}
60+
5161
/**
5262
* Executes a metadata query and returns the result as a JDBC
5363
* {@link ResultSet}.
5464
*
5565
* @param metadataRequest Name of the metadata request. Corresponds to the
5666
* XMLA method name, e.g. "MDSCHEMA_CUBES"
5767
*
68+
* @param overrides Map of metadata columns to forced values. Used
69+
* to override the value returned by the server for a list of
70+
* columns.
71+
*
5872
* @param patternValues Array of alternating parameter name and value
5973
* pairs. If the parameter value is null, it is ignored.
6074
*
@@ -64,6 +78,7 @@ abstract class XmlaOlap4jDatabaseMetaData implements OlapDatabaseMetaData {
6478
*/
6579
private ResultSet getMetadata(
6680
XmlaOlap4jConnection.MetadataRequest metadataRequest,
81+
Map<XmlaOlap4jConnection.MetadataColumn, String> overrides,
6782
Object... patternValues) throws OlapException
6883
{
6984
assert patternValues.length % 2 == 0;
@@ -132,9 +147,13 @@ private ResultSet getMetadata(
132147
for (XmlaOlap4jConnection.MetadataColumn column
133148
: metadataRequest.columns)
134149
{
135-
final String value =
136-
XmlaOlap4jUtil.stringElement(row, column.xmlaName);
137-
valueList.add(value);
150+
if (overrides.containsKey(column)) {
151+
valueList.add(overrides.get(column));
152+
} else {
153+
final String value =
154+
XmlaOlap4jUtil.stringElement(row, column.xmlaName);
155+
valueList.add(value);
156+
}
138157
}
139158
rowList.add(valueList);
140159
}
@@ -1039,8 +1058,17 @@ public ResultSet getCubes(
10391058
String cubeNamePattern)
10401059
throws OlapException
10411060
{
1061+
// XMLA doesn't support drillthrough so override
1062+
// whatever the server returns.
1063+
final Map<XmlaOlap4jConnection.MetadataColumn, String> overrides =
1064+
new HashMap<XmlaOlap4jConnection.MetadataColumn, String>();
1065+
overrides.put(
1066+
XmlaOlap4jConnection.MetadataRequest
1067+
.MDSCHEMA_CUBES.getColumn("IS_DRILLTHROUGH_ENABLED"),
1068+
"false");
10421069
return getMetadata(
10431070
XmlaOlap4jConnection.MetadataRequest.MDSCHEMA_CUBES,
1071+
overrides,
10441072
"CATALOG_NAME", catalog,
10451073
"SCHEMA_NAME", wildcard(schemaPattern),
10461074
"CUBE_NAME", wildcard(cubeNamePattern));

src/org/olap4j/metadata/Cube.java

+7
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@ public interface Cube extends MetadataElement {
200200
List<Member> lookupMembers(
201201
Set<Member.TreeOp> treeOps,
202202
List<IdentifierSegment> nameParts) throws OlapException;
203+
204+
/**
205+
* Tells whether or not drill through operations are
206+
* possible in this cube.
207+
* @return True if drillthrough is enabled, false otherwise.
208+
*/
209+
boolean isDrillThroughEnabled();
203210
}
204211

205212
// End Cube.java

testsrc/org/olap4j/ConnectionTest.java

+27
Original file line numberDiff line numberDiff line change
@@ -2773,6 +2773,33 @@ public void testCubeDimensionsOrder() throws Exception {
27732773
sb.toString());
27742774
}
27752775

2776+
public void testCubesDrillthrough() throws Exception {
2777+
Class.forName(tester.getDriverClassName());
2778+
connection = tester.createConnection();
2779+
OlapConnection olapConnection =
2780+
tester.getWrapper().unwrap(connection, OlapConnection.class);
2781+
Cube cube =
2782+
olapConnection
2783+
.getOlapCatalogs()
2784+
.get("FoodMart")
2785+
.getSchemas()
2786+
.get("FoodMart")
2787+
.getCubes()
2788+
.get("Sales");
2789+
switch (tester.getFlavor()) {
2790+
case MONDRIAN:
2791+
assertTrue(cube.isDrillThroughEnabled());
2792+
break;
2793+
case REMOTE_XMLA :
2794+
case XMLA:
2795+
assertFalse(cube.isDrillThroughEnabled());
2796+
break;
2797+
default:
2798+
fail();
2799+
break;
2800+
}
2801+
}
2802+
27762803
/**
27772804
* Query with dimension properties.
27782805
*

testsrc/org/olap4j/MetadataTest.java

+18
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,24 @@ public void testDatabaseMetaDataGetCubes() throws SQLException {
535535
if (tester.getFlavor() == TestContext.Tester.Flavor.XMLA) {
536536
assertEquals(lineCount * 2, lineCount3);
537537
}
538+
s = checkResultSet(
539+
olapDatabaseMetaData.getCubes(
540+
"FoodMart",
541+
"FoodMart",
542+
"Sales"),
543+
CUBE_COLUMN_NAMES);
544+
switch (testContext.getTester().getFlavor()) {
545+
case MONDRIAN:
546+
assertTrue(s.contains(", IS_DRILLTHROUGH_ENABLED=true"));
547+
break;
548+
case XMLA:
549+
case REMOTE_XMLA:
550+
assertTrue(s.contains(", IS_DRILLTHROUGH_ENABLED=false"));
551+
assertFalse(s.contains(", IS_DRILLTHROUGH_ENABLED=true"));
552+
break;
553+
default:
554+
throw new RuntimeException("Unknown tester type.");
555+
}
538556

539557
// If we ask for 'Warehouse and Sales' cube we should get it, but
540558
// nothing else.

0 commit comments

Comments
 (0)