Skip to content

Commit

Permalink
Fixes an issue with SAP BW and the XMLA driver. The XMLA driver was u…
Browse files Browse the repository at this point in the history
…sing all of the databases/catalogs/schemas to lookup cubes. This was required in the pre-1.0 code, but it is not necessary anymore because connections are now always implicitly bound to a specific schema.

I've also refactored the OlapTest class so that it fails instead of doing exception crunching/log output.

git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@477 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
lucboudreau committed Nov 7, 2011
1 parent 191b83a commit 624a2a8
Show file tree
Hide file tree
Showing 2 changed files with 1,277 additions and 1,385 deletions.
41 changes: 9 additions & 32 deletions src/org/olap4j/driver/xmla/XmlaOlap4jCellSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,6 @@ private XmlaOlap4jCellSetMetaData createMetaData(Element root)
findChild(cubeNode, MDDATASET_NS, "CubeName");
final String cubeName = gatherText(cubeNameNode);

// REVIEW: If there are multiple cubes with the same name, we should
// qualify by catalog and schema. Currently we just take the first.
XmlaOlap4jCube cube =
lookupCube(
olap4jStatement.olap4jConnection.olap4jDatabaseMetaData,
Expand All @@ -399,23 +397,6 @@ private XmlaOlap4jCellSetMetaData createMetaData(Element root)
throw getHelper().createException(
"Internal error: cube '" + cubeName + "' not found");
}
// REVIEW: We should not modify the connection. It is not safe, because
// connection might be shared between multiple statements with different
// cubes. Caller should call
//
// connection.setCatalog(
// cellSet.getMetaData().getCube().getSchema().getCatalog().getName())
//
// before doing metadata queries.
try {
this.olap4jStatement.olap4jConnection.setCatalog(
cube.getSchema().getCatalog().getName());
} catch (SQLException e) {
throw getHelper().createException(
"Internal error: setting catalog '"
+ cube.getSchema().getCatalog().getName()
+ "' caused error");
}
final Element axesInfo =
findChild(olapInfo, MDDATASET_NS, "AxesInfo");
final List<Element> axisInfos =
Expand Down Expand Up @@ -512,8 +493,8 @@ private XmlaOlap4jCellSetMetaData createMetaData(Element root)
}

/**
* Looks up a cube among all of the schemas in all of the catalogs
* in this connection.
* Looks up a cube with a given name within the current database,
* catalog and schema bound to the source connection.
*
* <p>If there are several with the same name, returns the first.
*
Expand All @@ -526,18 +507,14 @@ private XmlaOlap4jCube lookupCube(
XmlaOlap4jDatabaseMetaData databaseMetaData,
String cubeName) throws OlapException
{
for (Catalog catalog
: databaseMetaData.olap4jConnection.getOlapCatalogs())
for (Cube cube
: databaseMetaData.olap4jConnection.getOlapSchema().getCubes())
{
for (Schema schema : catalog.getSchemas()) {
for (Cube cube : schema.getCubes()) {
if (cubeName.equals(cube.getName())) {
return (XmlaOlap4jCube) cube;
}
if (cubeName.equals("[" + cube.getName() + "]")) {
return (XmlaOlap4jCube) cube;
}
}
if (cubeName.equals(cube.getName())) {
return (XmlaOlap4jCube) cube;
}
if (cubeName.equals("[" + cube.getName() + "]")) {
return (XmlaOlap4jCube) cube;
}
}
return null;
Expand Down
Loading

0 comments on commit 624a2a8

Please sign in to comment.