Skip to content

Commit

Permalink
Modified the access mechanism to the underlying connection object for…
Browse files Browse the repository at this point in the history
… member lookup optimization.

git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@105 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
lucboudreau committed Jul 30, 2008
1 parent 2a32251 commit 88e52dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 50 deletions.
47 changes: 3 additions & 44 deletions src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ <T extends Named> void populateList(
Element root = xxx(request);
for (Element o : childElements(root)) {
if (o.getLocalName().equals("row")) {
handler.handle(o, context, list, this);
handler.handle(o, context, list);
}
}
handler.sortList(list);
Expand Down Expand Up @@ -812,7 +812,7 @@ public void handle(Element row, Context context, List<XmlaOlap4jCatalog> list) {
static class CubeHandler extends HandlerImpl<XmlaOlap4jCube> {

public void handle(Element row, Context context,
List<XmlaOlap4jCube> list, XmlaOlap4jConnection connection)
List<XmlaOlap4jCube> list)
throws OlapException
{
/*
Expand All @@ -837,13 +837,7 @@ public void handle(Element row, Context context,
String description = stringElement(row, "DESCRIPTION");
list.add(
new XmlaOlap4jCube(
context.olap4jSchema, cubeName, description, connection));
}

public void handle(Element row, Context context,
List<XmlaOlap4jCube> list) throws OlapException {
throw new RuntimeException(
"A cube object needs a reference to the connection who created it.");
context.olap4jSchema, cubeName, description));
}
}

Expand Down Expand Up @@ -1284,28 +1278,6 @@ void handle(
Context context,
List<T> list) throws OlapException;

/**
* Converts an XML element from an XMLA result set into a metadata
* element and appends it to a list of metadata elements.
*
* @param row XMLA element
*
* @param context Context (schema, cube, dimension, etc.) that the
* request was executed in and that the element will belong to
*
* @param list List of metadata elements to append new metadata element
*
* @param connection A reference to the connection object which populated
* the object.
*
* @throws OlapException on error
*/
void handle(
Element row,
Context context,
List<T> list,
XmlaOlap4jConnection connection) throws OlapException;

/**
* Sorts a list of metadata elements.
*
Expand All @@ -1322,19 +1294,6 @@ public void sortList(List<T> list) {
// do nothing - assume XMLA returned list in correct order
}

/**
* <p>Default implementation of the handle method with a reference to the
* connection object.
*
* @see org.olap4j.driver.xmla.XmlaOlap4jConnection.Handler
* #handle(org.w3c.dom.Element,
* org.olap4j.driver.xmla.XmlaOlap4jConnection.Context,
* java.util.List, org.olap4j.driver.xmla.XmlaOlap4jConnection)
*/
public void handle(Element row, Context context, List<T> list,
XmlaOlap4jConnection connection) throws OlapException {
this.handle(row, context, list);
}
}

static class Context {
Expand Down
10 changes: 4 additions & 6 deletions src/org/olap4j/driver/xmla/XmlaOlap4jCube.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class XmlaOlap4jCube implements Cube, Named
private final NamedList<XmlaOlap4jNamedSet> namedSets =
new NamedListImpl<XmlaOlap4jNamedSet>();
private final MetadataReader metadataReader;
private XmlaOlap4jConnection connection;

/**
* Creates an XmlaOlap4jCube.
Expand All @@ -58,16 +57,14 @@ class XmlaOlap4jCube implements Cube, Named
XmlaOlap4jCube(
XmlaOlap4jSchema olap4jSchema,
String name,
String description,
XmlaOlap4jConnection connection) throws OlapException
String description) throws OlapException
{
assert olap4jSchema != null;
assert description != null;
assert name != null;
this.olap4jSchema = olap4jSchema;
this.name = name;
this.description = description;
this.connection = connection;
this.metadataReader =
new CachingMetadataReader(
new RawMetadataReader());
Expand Down Expand Up @@ -436,8 +433,9 @@ public void lookupMembersByUniqueName(
List<String> memberUniqueNames,
Map<String, XmlaOlap4jMember> memberMap) throws OlapException
{
if (connection.getDataSourceInfo()
.indexOf("Provider=Mondrian") != -1)
if (olap4jSchema.olap4jCatalog.olap4jDatabaseMetaData
.olap4jConnection.getDataSourceInfo()
.indexOf("Provider=Mondrian") != -1) //$NON-NLS-1$
{
memberMap.putAll(this.mondrianMembersLookup(memberUniqueNames));
} else {
Expand Down

0 comments on commit 88e52dd

Please sign in to comment.