Skip to content

Commit

Permalink
Fixes compatibility issues with Essbase. Essbase expects the DataSour…
Browse files Browse the repository at this point in the history
…ceInfo element to be a tad different than other backends.

Contribution by Mark Semsel.

git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@525 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
lucboudreau committed Apr 2, 2012
1 parent 08f2550 commit 0646d5f
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 2 deletions.
46 changes: 45 additions & 1 deletion src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,39 @@ public Scenario getScenario() {
throw new UnsupportedOperationException();
}

/**
* Enumeration of server backends. Use
* {@link BackendFlavor#getFlavor(XmlaOlap4jConnection)}
* to get the vendor for a given connection.
*/
static enum BackendFlavor {
MONDRIAN("Mondrian"),
SSAS("Microsoft"),
PALO("Palo"),
SAP("SAP"),
ESSBASE("Essbase"),
UNKNOWN("");

private final String token;

private BackendFlavor(String token) {
this.token = token;
}

static BackendFlavor getFlavor(XmlaOlap4jConnection conn)
throws OlapException
{
final String dataSourceInfo =
conn.getOlapDatabase().getDataSourceInfo();
for (BackendFlavor flavor : BackendFlavor.values()) {
if (dataSourceInfo.contains(flavor.token)) {
return flavor;
}
}
throw new AssertionError("Can't determine the backend vendor.");
}
}

<T extends Named> void populateList(
List<T> list,
Context context,
Expand Down Expand Up @@ -1017,8 +1050,19 @@ public String generateRequest(

// Add the datasource node only if this request requires it.
if (metadataRequest.requiresDatasourceName()) {
final String dataSourceInfo;
switch (BackendFlavor.getFlavor(context.olap4jConnection)) {
case ESSBASE:
dataSourceInfo =
context.olap4jConnection.getOlapDatabase()
.getDataSourceInfo();
break;
default:
dataSourceInfo =
context.olap4jConnection.getDatabase();
}
buf.append(" <DataSourceInfo>");
xmlEncode(buf, context.olap4jConnection.getDatabase());
xmlEncode(buf, dataSourceInfo);
buf.append("</DataSourceInfo>\n");
}

Expand Down
15 changes: 14 additions & 1 deletion src/org/olap4j/driver/xmla/XmlaOlap4jStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.olap4j.driver.xmla;

import org.olap4j.*;
import org.olap4j.driver.xmla.XmlaOlap4jConnection.BackendFlavor;
import org.olap4j.mdx.*;

import java.io.StringWriter;
Expand Down Expand Up @@ -291,9 +292,21 @@ public boolean isWrapperFor(Class<?> iface) throws SQLException {

public CellSet executeOlapQuery(String mdx) throws OlapException {
final String catalog = olap4jConnection.getCatalog();
final String dataSourceInfo = olap4jConnection.getDatabase();
final String roleName = olap4jConnection.getRoleName();
final String propList = olap4jConnection.makeConnectionPropertyList();

final String dataSourceInfo;
switch (BackendFlavor.getFlavor(olap4jConnection)) {
case ESSBASE:
dataSourceInfo =
olap4jConnection.getOlapDatabase()
.getDataSourceInfo();
break;
default:
dataSourceInfo =
olap4jConnection.getDatabase();
}

StringBuilder buf = new StringBuilder(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<soapenv:Envelope\n"
Expand Down

0 comments on commit 0646d5f

Please sign in to comment.