Skip to content

Commit

Permalink
Fixes the catalog XMLA object so that it first tries DBSCHEMA_SCHEMAT…
Browse files Browse the repository at this point in the history
…A request to find schemas and falls back to MDSCHEMA_CUBES if the server rejected the first query.

git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@425 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
lucboudreau committed Mar 22, 2011
1 parent 571c2f6 commit fd44edb
Showing 1 changed file with 36 additions and 7 deletions.
43 changes: 36 additions & 7 deletions src/org/olap4j/driver/xmla/XmlaOlap4jCatalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,52 @@ class XmlaOlap4jCatalog implements Catalog, Named {
this.olap4jDatabaseMetaData = olap4jDatabaseMetaData;
this.name = name;

// Fetching the schemas is a tricky part. There are no XMLA requests to
// obtain the available schemas for a given catalog. We therefore need
// to ask for the cubes, restricting results on the catalog, and while
// Some servers don't support MDSCHEMA_MDSCHEMATA, so we will
// override the list class so it tries it first, and falls
// back to the MDSCHEMA_CUBES trick, where ask for the cubes,
// restricting results on the catalog, and while
// iterating on the cubes, take the schema name from this recordset.
//
// Many servers (SSAS for example) won't support the schema name column
// in the returned rowset. This has to be taken into account.
// in the returned rowset. This has to be taken into account as well.
this.schemas =
new DeferredNamedListImpl<XmlaOlap4jSchema>(
XmlaOlap4jConnection.MetadataRequest.MDSCHEMA_CUBES,
XmlaOlap4jConnection.MetadataRequest.DBSCHEMA_SCHEMATA,
new XmlaOlap4jConnection.Context(
olap4jDatabaseMetaData.olap4jConnection,
olap4jDatabaseMetaData,
this,
null, null, null, null, null),
new XmlaOlap4jConnection.CatalogSchemaHandler(this.name),
null);
new XmlaOlap4jConnection.SchemaHandler(),
null)
{
@Override
protected void populateList(NamedList<XmlaOlap4jSchema> list)
throws OlapException
{
// First try DBSCHEMA_SCHEMATA
try {
super.populateList(list);
} catch (OlapException e) {
// Fallback to MDSCHEMA_CUBES trick
XmlaOlap4jConnection conn =
XmlaOlap4jCatalog.this
.olap4jDatabaseMetaData.olap4jConnection;
conn.populateList(
list,
new XmlaOlap4jConnection.Context(
conn,
conn.olap4jDatabaseMetaData,
XmlaOlap4jCatalog.this,
null, null, null, null, null),
XmlaOlap4jConnection.MetadataRequest
.MDSCHEMA_CUBES,
new XmlaOlap4jConnection.CatalogSchemaHandler(
XmlaOlap4jCatalog.this.name),
new Object[0]);
}
}
};
}

public int hashCode() {
Expand Down

0 comments on commit fd44edb

Please sign in to comment.