iface) throws SQLException {
+ if (iface.isInstance(this)) {
+ return iface.cast(this);
+ }
+ throw olap4jConnection.helper.createException("cannot cast");
+ }
+
+ public boolean isWrapperFor(Class> iface) throws SQLException {
+ return iface.isInstance(this);
+ }
+}
+
+// End EmptyResultSet.java
diff --git a/src/org/olap4j/driver/xmla/Factory.java b/src/org/olap4j/driver/xmla/Factory.java
index 5e17517..88b8696 100644
--- a/src/org/olap4j/driver/xmla/Factory.java
+++ b/src/org/olap4j/driver/xmla/Factory.java
@@ -1,54 +1,54 @@
-/*
-// This software is subject to the terms of the Common Public License
-// Agreement, available at the following URL:
-// http://www.opensource.org/licenses/cpl.html.
-// Copyright (C) 2007-2007 Julian Hyde
-// All Rights Reserved.
-// You must accept the terms of that agreement to use this software.
-*/
-package org.olap4j.driver.xmla;
-
-import org.olap4j.OlapException;
-import org.olap4j.driver.xmla.proxy.XmlaOlap4jProxy;
-
-import java.sql.*;
-import java.util.Properties;
-import java.util.List;
-
-/**
- * Instantiates classes to implement the olap4j API against the
- * an XML for Analysis provider.
- *
- * There are implementations for JDBC 3.0 (which occurs in JDK 1.5)
- * and JDBC 4.0 (which occurs in JDK 1.6).
- *
- * @author jhyde
- * @version $Id$
- * @since Jun 14, 2007
- */
-interface Factory {
- Connection newConnection(
- XmlaOlap4jProxy proxy,
- String url,
- Properties info) throws SQLException;
-
- EmptyResultSet newEmptyResultSet(
- XmlaOlap4jConnection olap4jConnection);
-
- ResultSet newFixedResultSet(
- XmlaOlap4jConnection olap4jConnection,
- List headerList,
- List> rowList);
-
- XmlaOlap4jCellSet newCellSet(
- XmlaOlap4jStatement olap4jStatement) throws OlapException;
-
- XmlaOlap4jPreparedStatement newPreparedStatement(
- String mdx,
- XmlaOlap4jConnection olap4jConnection) throws OlapException;
-
- XmlaOlap4jDatabaseMetaData newDatabaseMetaData(
- XmlaOlap4jConnection olap4jConnection);
-}
-
-// End Factory.java
+/*
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2007-2007 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.driver.xmla;
+
+import org.olap4j.OlapException;
+import org.olap4j.driver.xmla.proxy.XmlaOlap4jProxy;
+
+import java.sql.*;
+import java.util.Properties;
+import java.util.List;
+
+/**
+ * Instantiates classes to implement the olap4j API against the
+ * an XML for Analysis provider.
+ *
+ * There are implementations for JDBC 3.0 (which occurs in JDK 1.5)
+ * and JDBC 4.0 (which occurs in JDK 1.6).
+ *
+ * @author jhyde
+ * @version $Id$
+ * @since Jun 14, 2007
+ */
+interface Factory {
+ Connection newConnection(
+ XmlaOlap4jProxy proxy,
+ String url,
+ Properties info) throws SQLException;
+
+ EmptyResultSet newEmptyResultSet(
+ XmlaOlap4jConnection olap4jConnection);
+
+ ResultSet newFixedResultSet(
+ XmlaOlap4jConnection olap4jConnection,
+ List headerList,
+ List> rowList);
+
+ XmlaOlap4jCellSet newCellSet(
+ XmlaOlap4jStatement olap4jStatement) throws OlapException;
+
+ XmlaOlap4jPreparedStatement newPreparedStatement(
+ String mdx,
+ XmlaOlap4jConnection olap4jConnection) throws OlapException;
+
+ XmlaOlap4jDatabaseMetaData newDatabaseMetaData(
+ XmlaOlap4jConnection olap4jConnection);
+}
+
+// End Factory.java
diff --git a/src/org/olap4j/driver/xmla/FactoryJdbc3Impl.java b/src/org/olap4j/driver/xmla/FactoryJdbc3Impl.java
index d478263..1753c45 100644
--- a/src/org/olap4j/driver/xmla/FactoryJdbc3Impl.java
+++ b/src/org/olap4j/driver/xmla/FactoryJdbc3Impl.java
@@ -1,129 +1,129 @@
-/*
-// This software is subject to the terms of the Common Public License
-// Agreement, available at the following URL:
-// http://www.opensource.org/licenses/cpl.html.
-// Copyright (C) 2007-2007 Julian Hyde
-// All Rights Reserved.
-// You must accept the terms of that agreement to use this software.
-*/
-package org.olap4j.driver.xmla;
-
-import org.olap4j.OlapException;
-import org.olap4j.driver.xmla.proxy.XmlaOlap4jProxy;
-
-import java.sql.*;
-import java.util.*;
-
-/**
- * Implementation of {@link Factory} for JDBC 3.0.
- *
- * @author jhyde
- * @version $Id$
- * @since Jun 14, 2007
- */
-class FactoryJdbc3Impl implements Factory {
- public Connection newConnection(
- XmlaOlap4jProxy proxy,
- String url,
- Properties info)
- throws SQLException
- {
- return new FactoryJdbc3Impl.XmlaOlap4jConnectionJdbc3(
- proxy, url, info);
- }
-
- public EmptyResultSet newEmptyResultSet(
- XmlaOlap4jConnection olap4jConnection)
- {
- List headerList = Collections.emptyList();
- List> rowList = Collections.emptyList();
- return new FactoryJdbc3Impl.EmptyResultSetJdbc3(
- olap4jConnection, headerList, rowList);
- }
-
- public ResultSet newFixedResultSet(
- XmlaOlap4jConnection olap4jConnection,
- List headerList,
- List> rowList)
- {
- return new EmptyResultSetJdbc3(olap4jConnection, headerList, rowList);
- }
-
- public XmlaOlap4jCellSet newCellSet(
- XmlaOlap4jStatement olap4jStatement) throws OlapException
- {
- return new FactoryJdbc3Impl.XmlaOlap4jCellSetJdbc3(
- olap4jStatement);
- }
-
- public XmlaOlap4jPreparedStatement newPreparedStatement(
- String mdx,
- XmlaOlap4jConnection olap4jConnection) throws OlapException
- {
- return new FactoryJdbc3Impl.XmlaOlap4jPreparedStatementJdbc3(
- olap4jConnection, mdx);
- }
-
- public XmlaOlap4jDatabaseMetaData newDatabaseMetaData(
- XmlaOlap4jConnection olap4jConnection)
- {
- return new FactoryJdbc3Impl.XmlaOlap4jDatabaseMetaDataJdbc3(
- olap4jConnection);
- }
-
- // Inner classes
-
- private static class XmlaOlap4jPreparedStatementJdbc3
- extends XmlaOlap4jPreparedStatement
- {
- public XmlaOlap4jPreparedStatementJdbc3(
- XmlaOlap4jConnection olap4jConnection,
- String mdx) throws OlapException
- {
- super(olap4jConnection, mdx);
- }
- }
-
- private static class XmlaOlap4jCellSetJdbc3
- extends XmlaOlap4jCellSet
- {
- public XmlaOlap4jCellSetJdbc3(
- XmlaOlap4jStatement olap4jStatement) throws OlapException
- {
- super(olap4jStatement);
- }
- }
-
- private static class EmptyResultSetJdbc3 extends EmptyResultSet {
- public EmptyResultSetJdbc3(
- XmlaOlap4jConnection olap4jConnection,
- List headerList,
- List> rowList)
- {
- super(olap4jConnection, headerList, rowList);
- }
- }
-
- private class XmlaOlap4jConnectionJdbc3 extends XmlaOlap4jConnection {
- public XmlaOlap4jConnectionJdbc3(
- XmlaOlap4jProxy proxy,
- String url,
- Properties info)
- throws SQLException
- {
- super(FactoryJdbc3Impl.this, proxy, url, info);
- }
- }
-
- private static class XmlaOlap4jDatabaseMetaDataJdbc3
- extends XmlaOlap4jDatabaseMetaData
- {
- public XmlaOlap4jDatabaseMetaDataJdbc3(
- XmlaOlap4jConnection olap4jConnection)
- {
- super(olap4jConnection);
- }
- }
-}
-
-// End FactoryJdbc3Impl.java
+/*
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2007-2007 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.driver.xmla;
+
+import org.olap4j.OlapException;
+import org.olap4j.driver.xmla.proxy.XmlaOlap4jProxy;
+
+import java.sql.*;
+import java.util.*;
+
+/**
+ * Implementation of {@link Factory} for JDBC 3.0.
+ *
+ * @author jhyde
+ * @version $Id$
+ * @since Jun 14, 2007
+ */
+class FactoryJdbc3Impl implements Factory {
+ public Connection newConnection(
+ XmlaOlap4jProxy proxy,
+ String url,
+ Properties info)
+ throws SQLException
+ {
+ return new FactoryJdbc3Impl.XmlaOlap4jConnectionJdbc3(
+ proxy, url, info);
+ }
+
+ public EmptyResultSet newEmptyResultSet(
+ XmlaOlap4jConnection olap4jConnection)
+ {
+ List headerList = Collections.emptyList();
+ List> rowList = Collections.emptyList();
+ return new FactoryJdbc3Impl.EmptyResultSetJdbc3(
+ olap4jConnection, headerList, rowList);
+ }
+
+ public ResultSet newFixedResultSet(
+ XmlaOlap4jConnection olap4jConnection,
+ List headerList,
+ List> rowList)
+ {
+ return new EmptyResultSetJdbc3(olap4jConnection, headerList, rowList);
+ }
+
+ public XmlaOlap4jCellSet newCellSet(
+ XmlaOlap4jStatement olap4jStatement) throws OlapException
+ {
+ return new FactoryJdbc3Impl.XmlaOlap4jCellSetJdbc3(
+ olap4jStatement);
+ }
+
+ public XmlaOlap4jPreparedStatement newPreparedStatement(
+ String mdx,
+ XmlaOlap4jConnection olap4jConnection) throws OlapException
+ {
+ return new FactoryJdbc3Impl.XmlaOlap4jPreparedStatementJdbc3(
+ olap4jConnection, mdx);
+ }
+
+ public XmlaOlap4jDatabaseMetaData newDatabaseMetaData(
+ XmlaOlap4jConnection olap4jConnection)
+ {
+ return new FactoryJdbc3Impl.XmlaOlap4jDatabaseMetaDataJdbc3(
+ olap4jConnection);
+ }
+
+ // Inner classes
+
+ private static class XmlaOlap4jPreparedStatementJdbc3
+ extends XmlaOlap4jPreparedStatement
+ {
+ public XmlaOlap4jPreparedStatementJdbc3(
+ XmlaOlap4jConnection olap4jConnection,
+ String mdx) throws OlapException
+ {
+ super(olap4jConnection, mdx);
+ }
+ }
+
+ private static class XmlaOlap4jCellSetJdbc3
+ extends XmlaOlap4jCellSet
+ {
+ public XmlaOlap4jCellSetJdbc3(
+ XmlaOlap4jStatement olap4jStatement) throws OlapException
+ {
+ super(olap4jStatement);
+ }
+ }
+
+ private static class EmptyResultSetJdbc3 extends EmptyResultSet {
+ public EmptyResultSetJdbc3(
+ XmlaOlap4jConnection olap4jConnection,
+ List headerList,
+ List> rowList)
+ {
+ super(olap4jConnection, headerList, rowList);
+ }
+ }
+
+ private class XmlaOlap4jConnectionJdbc3 extends XmlaOlap4jConnection {
+ public XmlaOlap4jConnectionJdbc3(
+ XmlaOlap4jProxy proxy,
+ String url,
+ Properties info)
+ throws SQLException
+ {
+ super(FactoryJdbc3Impl.this, proxy, url, info);
+ }
+ }
+
+ private static class XmlaOlap4jDatabaseMetaDataJdbc3
+ extends XmlaOlap4jDatabaseMetaData
+ {
+ public XmlaOlap4jDatabaseMetaDataJdbc3(
+ XmlaOlap4jConnection olap4jConnection)
+ {
+ super(olap4jConnection);
+ }
+ }
+}
+
+// End FactoryJdbc3Impl.java
diff --git a/src/org/olap4j/driver/xmla/FactoryJdbc4Impl.java b/src/org/olap4j/driver/xmla/FactoryJdbc4Impl.java
index 1e66c9d..749c615 100644
--- a/src/org/olap4j/driver/xmla/FactoryJdbc4Impl.java
+++ b/src/org/olap4j/driver/xmla/FactoryJdbc4Impl.java
@@ -1,806 +1,806 @@
-/*
-// This software is subject to the terms of the Common Public License
-// Agreement, available at the following URL:
-// http://www.opensource.org/licenses/cpl.html.
-// Copyright (C) 2007-2007 Julian Hyde
-// All Rights Reserved.
-// You must accept the terms of that agreement to use this software.
-*/
-package org.olap4j.driver.xmla;
-
-import java.sql.*;
-import java.util.*;
-import java.io.Reader;
-import java.io.InputStream;
-
-import org.olap4j.*;
-import org.olap4j.driver.xmla.proxy.XmlaOlap4jProxy;
-
-/**
- * Implementation of {@link Factory} for JDBC 4.0.
- *
- * @author jhyde
- * @version $Id$
- * @since Jun 14, 2007
- */
-class FactoryJdbc4Impl implements Factory {
- public Connection newConnection(
- XmlaOlap4jProxy proxy,
- String url,
- Properties info)
- throws SQLException
- {
- return new XmlaOlap4jConnectionJdbc4(
- this, proxy, url, info);
- }
-
- public EmptyResultSet newEmptyResultSet(
- XmlaOlap4jConnection olap4jConnection)
- {
- List headerList = Collections.emptyList();
- List> rowList = Collections.emptyList();
- return new EmptyResultSetJdbc4(olap4jConnection, headerList, rowList);
- }
-
- public ResultSet newFixedResultSet(
- XmlaOlap4jConnection olap4jConnection,
- List headerList,
- List> rowList)
- {
- return new EmptyResultSetJdbc4(
- olap4jConnection, headerList, rowList);
- }
-
- public XmlaOlap4jCellSet newCellSet(
- XmlaOlap4jStatement olap4jStatement) throws OlapException
- {
- return new XmlaOlap4jCellSetJdbc4(olap4jStatement);
- }
-
- public XmlaOlap4jPreparedStatement newPreparedStatement(
- String mdx,
- XmlaOlap4jConnection olap4jConnection) throws OlapException
- {
- return new XmlaOlap4jPreparedStatementJdbc4(olap4jConnection, mdx);
- }
-
- public XmlaOlap4jDatabaseMetaData newDatabaseMetaData(
- XmlaOlap4jConnection olap4jConnection)
- {
- return new XmlaOlap4jDatabaseMetaDataJdbc4(olap4jConnection);
- }
-
- // Inner classes
-
- private static class EmptyResultSetJdbc4 extends EmptyResultSet {
- EmptyResultSetJdbc4(
- XmlaOlap4jConnection olap4jConnection,
- List headerList,
- List> rowList)
- {
- super(olap4jConnection, headerList, rowList);
- }
-
- // implement java.sql.ResultSet methods
- // introduced in JDBC 4.0/JDK 1.6
-
- public RowId getRowId(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public RowId getRowId(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateRowId(int columnIndex, RowId x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateRowId(String columnLabel, RowId x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public int getHoldability() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean isClosed() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNString(
- int columnIndex, String nString) throws SQLException
- {
- throw new UnsupportedOperationException();
- }
-
- public void updateNString(
- String columnLabel, String nString) throws SQLException
- {
- throw new UnsupportedOperationException();
- }
-
- public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNClob(
- String columnLabel, NClob nClob) throws SQLException
- {
- throw new UnsupportedOperationException();
- }
-
- public NClob getNClob(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public NClob getNClob(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public SQLXML getSQLXML(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public SQLXML getSQLXML(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateSQLXML(
- int columnIndex, SQLXML xmlObject) throws SQLException
- {
- throw new UnsupportedOperationException();
- }
-
- public void updateSQLXML(
- String columnLabel, SQLXML xmlObject) throws SQLException
- {
- throw new UnsupportedOperationException();
- }
-
- public String getNString(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public String getNString(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Reader getNCharacterStream(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Reader getNCharacterStream(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNCharacterStream(
- int columnIndex, Reader x, long length) throws SQLException
- {
- throw new UnsupportedOperationException();
- }
-
- public void updateNCharacterStream(
- String columnLabel, Reader reader, long length) throws SQLException
- {
- throw new UnsupportedOperationException();
- }
-
- public void updateAsciiStream(
- int columnIndex, InputStream x, long length) throws SQLException
- {
- throw new UnsupportedOperationException();
- }
-
- public void updateBinaryStream(
- int columnIndex, InputStream x, long length) throws SQLException
- {
- throw new UnsupportedOperationException();
- }
-
- public void updateCharacterStream(
- int columnIndex, Reader x, long length) throws SQLException
- {
- throw new UnsupportedOperationException();
- }
-
- public void updateAsciiStream(
- String columnLabel, InputStream x, long length) throws SQLException
- {
- throw new UnsupportedOperationException();
- }
-
- public void updateBinaryStream(
- String columnLabel, InputStream x, long length) throws SQLException
- {
- throw new UnsupportedOperationException();
- }
-
- public void updateCharacterStream(
- String columnLabel, Reader reader, long length) throws SQLException
- {
- throw new UnsupportedOperationException();
- }
-
- public void updateBlob(
- int columnIndex,
- InputStream inputStream,
- long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBlob(
- String columnLabel,
- InputStream inputStream,
- long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateClob(
- int columnIndex, Reader reader, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateClob(
- String columnLabel, Reader reader, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNClob(
- int columnIndex, Reader reader, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNClob(
- String columnLabel, Reader reader, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNCharacterStream(
- int columnIndex, Reader x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNCharacterStream(
- String columnLabel, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateAsciiStream(
- int columnIndex, InputStream x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBinaryStream(
- int columnIndex, InputStream x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateCharacterStream(
- int columnIndex, Reader x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateAsciiStream(
- String columnLabel, InputStream x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBinaryStream(
- String columnLabel, InputStream x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateCharacterStream(
- String columnLabel, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBlob(
- int columnIndex, InputStream inputStream) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBlob(
- String columnLabel, InputStream inputStream) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateClob(int columnIndex, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateClob(
- String columnLabel, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNClob(
- int columnIndex, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNClob(
- String columnLabel, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
- }
-
- private static class XmlaOlap4jConnectionJdbc4
- extends XmlaOlap4jConnection
- implements OlapConnection
- {
- public XmlaOlap4jConnectionJdbc4(
- Factory factory,
- XmlaOlap4jProxy proxy,
- String url,
- Properties info) throws SQLException
- {
- super(factory, proxy, url, info);
- }
-
- public OlapStatement createStatement() {
- return super.createStatement();
- }
-
- public OlapDatabaseMetaData getMetaData() {
- return super.getMetaData();
- }
-
- // implement java.sql.Connection methods
- // introduced in JDBC 4.0/JDK 1.6
-
- public Clob createClob() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Blob createBlob() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public NClob createNClob() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public SQLXML createSQLXML() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean isValid(int timeout) throws SQLException {
- return !isClosed();
- }
-
- public void setClientInfo(
- String name, String value) throws SQLClientInfoException {
- throw new UnsupportedOperationException();
- }
-
- public void setClientInfo(Properties properties) throws SQLClientInfoException {
- throw new UnsupportedOperationException();
- }
-
- public String getClientInfo(String name) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Properties getClientInfo() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Array createArrayOf(
- String typeName, Object[] elements) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Struct createStruct(
- String typeName, Object[] attributes) throws SQLException {
- throw new UnsupportedOperationException();
- }
- }
-
- private static class XmlaOlap4jCellSetJdbc4 extends XmlaOlap4jCellSet {
- XmlaOlap4jCellSetJdbc4(
- XmlaOlap4jStatement olap4jStatement)
- throws OlapException
- {
- super(olap4jStatement);
- }
-
- public CellSetMetaData getMetaData() {
- return super.getMetaData();
- }
-
- // implement java.sql.CellSet methods
- // introduced in JDBC 4.0/JDK 1.6
-
- public RowId getRowId(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public RowId getRowId(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateRowId(int columnIndex, RowId x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateRowId(String columnLabel, RowId x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public int getHoldability() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean isClosed() throws SQLException {
- return closed;
- }
-
- public void updateNString(
- int columnIndex, String nString) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNString(
- String columnLabel, String nString) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNClob(
- String columnLabel, NClob nClob) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public NClob getNClob(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public NClob getNClob(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public SQLXML getSQLXML(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public SQLXML getSQLXML(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateSQLXML(
- int columnIndex, SQLXML xmlObject) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateSQLXML(
- String columnLabel, SQLXML xmlObject) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public String getNString(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public String getNString(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Reader getNCharacterStream(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Reader getNCharacterStream(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNCharacterStream(
- int columnIndex, Reader x, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNCharacterStream(
- String columnLabel, Reader reader, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateAsciiStream(
- int columnIndex, InputStream x, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBinaryStream(
- int columnIndex, InputStream x, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateCharacterStream(
- int columnIndex, Reader x, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateAsciiStream(
- String columnLabel, InputStream x, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBinaryStream(
- String columnLabel, InputStream x, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateCharacterStream(
- String columnLabel, Reader reader, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBlob(
- int columnIndex,
- InputStream inputStream,
- long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBlob(
- String columnLabel,
- InputStream inputStream,
- long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateClob(
- int columnIndex, Reader reader, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateClob(
- String columnLabel, Reader reader, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNClob(
- int columnIndex, Reader reader, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNClob(
- String columnLabel, Reader reader, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNCharacterStream(
- int columnIndex, Reader x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNCharacterStream(
- String columnLabel, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateAsciiStream(
- int columnIndex, InputStream x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBinaryStream(
- int columnIndex, InputStream x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateCharacterStream(
- int columnIndex, Reader x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateAsciiStream(
- String columnLabel, InputStream x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBinaryStream(
- String columnLabel, InputStream x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateCharacterStream(
- String columnLabel, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBlob(
- int columnIndex, InputStream inputStream) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBlob(
- String columnLabel, InputStream inputStream) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateClob(int columnIndex, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateClob(
- String columnLabel, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNClob(
- int columnIndex, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNClob(
- String columnLabel, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
- }
-
- private static class XmlaOlap4jPreparedStatementJdbc4
- extends XmlaOlap4jPreparedStatement
- {
- XmlaOlap4jPreparedStatementJdbc4(
- XmlaOlap4jConnection olap4jConnection,
- String mdx) throws OlapException
- {
- super(olap4jConnection, mdx);
- }
-
- public CellSetMetaData getMetaData() {
- return super.getMetaData();
- }
-
- // implement java.sql.PreparedStatement methods
- // introduced in JDBC 4.0/JDK 1.6
-
- public void setRowId(int parameterIndex, RowId x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setNString(
- int parameterIndex, String value) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setNCharacterStream(
- int parameterIndex, Reader value, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setNClob(int parameterIndex, NClob value) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setClob(
- int parameterIndex, Reader reader, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setBlob(
- int parameterIndex,
- InputStream inputStream,
- long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setNClob(
- int parameterIndex, Reader reader, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setSQLXML(
- int parameterIndex, SQLXML xmlObject) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setAsciiStream(
- int parameterIndex, InputStream x, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setBinaryStream(
- int parameterIndex, InputStream x, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setCharacterStream(
- int parameterIndex, Reader reader, long length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setAsciiStream(
- int parameterIndex, InputStream x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setBinaryStream(
- int parameterIndex, InputStream x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setCharacterStream(
- int parameterIndex, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setNCharacterStream(
- int parameterIndex, Reader value) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setClob(int parameterIndex, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setBlob(
- int parameterIndex, InputStream inputStream) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setNClob(
- int parameterIndex, Reader reader) throws SQLException {
- throw new UnsupportedOperationException();
- }
- }
-
- private static class XmlaOlap4jDatabaseMetaDataJdbc4
- extends XmlaOlap4jDatabaseMetaData
- {
- XmlaOlap4jDatabaseMetaDataJdbc4(
- XmlaOlap4jConnection olap4jConnection)
- {
- super(olap4jConnection);
- }
-
- public OlapConnection getConnection() {
- return super.getConnection();
- }
-
- // implement java.sql.DatabaseMetaData methods
- // introduced in JDBC 4.0/JDK 1.6
-
- public RowIdLifetime getRowIdLifetime() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public ResultSet getSchemas(
- String catalog, String schemaPattern) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public ResultSet getClientInfoProperties() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public ResultSet getFunctions(
- String catalog,
- String schemaPattern,
- String functionNamePattern) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public ResultSet getFunctionColumns(
- String catalog,
- String schemaPattern,
- String functionNamePattern,
- String columnNamePattern) throws SQLException {
- throw new UnsupportedOperationException();
- }
- }
-}
-
-// End FactoryJdbc4Impl.java
+/*
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2007-2007 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.driver.xmla;
+
+import java.sql.*;
+import java.util.*;
+import java.io.Reader;
+import java.io.InputStream;
+
+import org.olap4j.*;
+import org.olap4j.driver.xmla.proxy.XmlaOlap4jProxy;
+
+/**
+ * Implementation of {@link Factory} for JDBC 4.0.
+ *
+ * @author jhyde
+ * @version $Id$
+ * @since Jun 14, 2007
+ */
+class FactoryJdbc4Impl implements Factory {
+ public Connection newConnection(
+ XmlaOlap4jProxy proxy,
+ String url,
+ Properties info)
+ throws SQLException
+ {
+ return new XmlaOlap4jConnectionJdbc4(
+ this, proxy, url, info);
+ }
+
+ public EmptyResultSet newEmptyResultSet(
+ XmlaOlap4jConnection olap4jConnection)
+ {
+ List headerList = Collections.emptyList();
+ List> rowList = Collections.emptyList();
+ return new EmptyResultSetJdbc4(olap4jConnection, headerList, rowList);
+ }
+
+ public ResultSet newFixedResultSet(
+ XmlaOlap4jConnection olap4jConnection,
+ List headerList,
+ List> rowList)
+ {
+ return new EmptyResultSetJdbc4(
+ olap4jConnection, headerList, rowList);
+ }
+
+ public XmlaOlap4jCellSet newCellSet(
+ XmlaOlap4jStatement olap4jStatement) throws OlapException
+ {
+ return new XmlaOlap4jCellSetJdbc4(olap4jStatement);
+ }
+
+ public XmlaOlap4jPreparedStatement newPreparedStatement(
+ String mdx,
+ XmlaOlap4jConnection olap4jConnection) throws OlapException
+ {
+ return new XmlaOlap4jPreparedStatementJdbc4(olap4jConnection, mdx);
+ }
+
+ public XmlaOlap4jDatabaseMetaData newDatabaseMetaData(
+ XmlaOlap4jConnection olap4jConnection)
+ {
+ return new XmlaOlap4jDatabaseMetaDataJdbc4(olap4jConnection);
+ }
+
+ // Inner classes
+
+ private static class EmptyResultSetJdbc4 extends EmptyResultSet {
+ EmptyResultSetJdbc4(
+ XmlaOlap4jConnection olap4jConnection,
+ List headerList,
+ List> rowList)
+ {
+ super(olap4jConnection, headerList, rowList);
+ }
+
+ // implement java.sql.ResultSet methods
+ // introduced in JDBC 4.0/JDK 1.6
+
+ public RowId getRowId(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public RowId getRowId(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateRowId(int columnIndex, RowId x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateRowId(String columnLabel, RowId x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getHoldability() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isClosed() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNString(
+ int columnIndex, String nString) throws SQLException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNString(
+ String columnLabel, String nString) throws SQLException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNClob(
+ String columnLabel, NClob nClob) throws SQLException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public NClob getNClob(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public NClob getNClob(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public SQLXML getSQLXML(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public SQLXML getSQLXML(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateSQLXML(
+ int columnIndex, SQLXML xmlObject) throws SQLException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateSQLXML(
+ String columnLabel, SQLXML xmlObject) throws SQLException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getNString(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getNString(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Reader getNCharacterStream(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Reader getNCharacterStream(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNCharacterStream(
+ int columnIndex, Reader x, long length) throws SQLException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNCharacterStream(
+ String columnLabel, Reader reader, long length) throws SQLException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateAsciiStream(
+ int columnIndex, InputStream x, long length) throws SQLException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBinaryStream(
+ int columnIndex, InputStream x, long length) throws SQLException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateCharacterStream(
+ int columnIndex, Reader x, long length) throws SQLException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateAsciiStream(
+ String columnLabel, InputStream x, long length) throws SQLException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBinaryStream(
+ String columnLabel, InputStream x, long length) throws SQLException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateCharacterStream(
+ String columnLabel, Reader reader, long length) throws SQLException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBlob(
+ int columnIndex,
+ InputStream inputStream,
+ long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBlob(
+ String columnLabel,
+ InputStream inputStream,
+ long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateClob(
+ int columnIndex, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateClob(
+ String columnLabel, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNClob(
+ int columnIndex, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNClob(
+ String columnLabel, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNCharacterStream(
+ int columnIndex, Reader x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNCharacterStream(
+ String columnLabel, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateAsciiStream(
+ int columnIndex, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBinaryStream(
+ int columnIndex, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateCharacterStream(
+ int columnIndex, Reader x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateAsciiStream(
+ String columnLabel, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBinaryStream(
+ String columnLabel, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateCharacterStream(
+ String columnLabel, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBlob(
+ int columnIndex, InputStream inputStream) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBlob(
+ String columnLabel, InputStream inputStream) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateClob(int columnIndex, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateClob(
+ String columnLabel, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNClob(
+ int columnIndex, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNClob(
+ String columnLabel, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private static class XmlaOlap4jConnectionJdbc4
+ extends XmlaOlap4jConnection
+ implements OlapConnection
+ {
+ public XmlaOlap4jConnectionJdbc4(
+ Factory factory,
+ XmlaOlap4jProxy proxy,
+ String url,
+ Properties info) throws SQLException
+ {
+ super(factory, proxy, url, info);
+ }
+
+ public OlapStatement createStatement() {
+ return super.createStatement();
+ }
+
+ public OlapDatabaseMetaData getMetaData() {
+ return super.getMetaData();
+ }
+
+ // implement java.sql.Connection methods
+ // introduced in JDBC 4.0/JDK 1.6
+
+ public Clob createClob() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Blob createBlob() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public NClob createNClob() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public SQLXML createSQLXML() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isValid(int timeout) throws SQLException {
+ return !isClosed();
+ }
+
+ public void setClientInfo(
+ String name, String value) throws SQLClientInfoException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setClientInfo(Properties properties) throws SQLClientInfoException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getClientInfo(String name) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Properties getClientInfo() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Array createArrayOf(
+ String typeName, Object[] elements) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Struct createStruct(
+ String typeName, Object[] attributes) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private static class XmlaOlap4jCellSetJdbc4 extends XmlaOlap4jCellSet {
+ XmlaOlap4jCellSetJdbc4(
+ XmlaOlap4jStatement olap4jStatement)
+ throws OlapException
+ {
+ super(olap4jStatement);
+ }
+
+ public CellSetMetaData getMetaData() {
+ return super.getMetaData();
+ }
+
+ // implement java.sql.CellSet methods
+ // introduced in JDBC 4.0/JDK 1.6
+
+ public RowId getRowId(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public RowId getRowId(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateRowId(int columnIndex, RowId x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateRowId(String columnLabel, RowId x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getHoldability() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isClosed() throws SQLException {
+ return closed;
+ }
+
+ public void updateNString(
+ int columnIndex, String nString) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNString(
+ String columnLabel, String nString) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNClob(
+ String columnLabel, NClob nClob) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public NClob getNClob(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public NClob getNClob(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public SQLXML getSQLXML(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public SQLXML getSQLXML(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateSQLXML(
+ int columnIndex, SQLXML xmlObject) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateSQLXML(
+ String columnLabel, SQLXML xmlObject) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getNString(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getNString(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Reader getNCharacterStream(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Reader getNCharacterStream(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNCharacterStream(
+ int columnIndex, Reader x, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNCharacterStream(
+ String columnLabel, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateAsciiStream(
+ int columnIndex, InputStream x, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBinaryStream(
+ int columnIndex, InputStream x, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateCharacterStream(
+ int columnIndex, Reader x, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateAsciiStream(
+ String columnLabel, InputStream x, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBinaryStream(
+ String columnLabel, InputStream x, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateCharacterStream(
+ String columnLabel, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBlob(
+ int columnIndex,
+ InputStream inputStream,
+ long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBlob(
+ String columnLabel,
+ InputStream inputStream,
+ long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateClob(
+ int columnIndex, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateClob(
+ String columnLabel, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNClob(
+ int columnIndex, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNClob(
+ String columnLabel, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNCharacterStream(
+ int columnIndex, Reader x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNCharacterStream(
+ String columnLabel, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateAsciiStream(
+ int columnIndex, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBinaryStream(
+ int columnIndex, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateCharacterStream(
+ int columnIndex, Reader x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateAsciiStream(
+ String columnLabel, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBinaryStream(
+ String columnLabel, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateCharacterStream(
+ String columnLabel, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBlob(
+ int columnIndex, InputStream inputStream) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBlob(
+ String columnLabel, InputStream inputStream) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateClob(int columnIndex, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateClob(
+ String columnLabel, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNClob(
+ int columnIndex, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNClob(
+ String columnLabel, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private static class XmlaOlap4jPreparedStatementJdbc4
+ extends XmlaOlap4jPreparedStatement
+ {
+ XmlaOlap4jPreparedStatementJdbc4(
+ XmlaOlap4jConnection olap4jConnection,
+ String mdx) throws OlapException
+ {
+ super(olap4jConnection, mdx);
+ }
+
+ public CellSetMetaData getMetaData() {
+ return super.getMetaData();
+ }
+
+ // implement java.sql.PreparedStatement methods
+ // introduced in JDBC 4.0/JDK 1.6
+
+ public void setRowId(int parameterIndex, RowId x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setNString(
+ int parameterIndex, String value) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setNCharacterStream(
+ int parameterIndex, Reader value, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setNClob(int parameterIndex, NClob value) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setClob(
+ int parameterIndex, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setBlob(
+ int parameterIndex,
+ InputStream inputStream,
+ long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setNClob(
+ int parameterIndex, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setSQLXML(
+ int parameterIndex, SQLXML xmlObject) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setAsciiStream(
+ int parameterIndex, InputStream x, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setBinaryStream(
+ int parameterIndex, InputStream x, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setCharacterStream(
+ int parameterIndex, Reader reader, long length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setAsciiStream(
+ int parameterIndex, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setBinaryStream(
+ int parameterIndex, InputStream x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setCharacterStream(
+ int parameterIndex, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setNCharacterStream(
+ int parameterIndex, Reader value) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setClob(int parameterIndex, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setBlob(
+ int parameterIndex, InputStream inputStream) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setNClob(
+ int parameterIndex, Reader reader) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private static class XmlaOlap4jDatabaseMetaDataJdbc4
+ extends XmlaOlap4jDatabaseMetaData
+ {
+ XmlaOlap4jDatabaseMetaDataJdbc4(
+ XmlaOlap4jConnection olap4jConnection)
+ {
+ super(olap4jConnection);
+ }
+
+ public OlapConnection getConnection() {
+ return super.getConnection();
+ }
+
+ // implement java.sql.DatabaseMetaData methods
+ // introduced in JDBC 4.0/JDK 1.6
+
+ public RowIdLifetime getRowIdLifetime() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public ResultSet getSchemas(
+ String catalog, String schemaPattern) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public ResultSet getClientInfoProperties() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public ResultSet getFunctions(
+ String catalog,
+ String schemaPattern,
+ String functionNamePattern) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public ResultSet getFunctionColumns(
+ String catalog,
+ String schemaPattern,
+ String functionNamePattern,
+ String columnNamePattern) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
+
+// End FactoryJdbc4Impl.java
diff --git a/src/org/olap4j/driver/xmla/MetadataReader.java b/src/org/olap4j/driver/xmla/MetadataReader.java
index b53fee6..100d687 100644
--- a/src/org/olap4j/driver/xmla/MetadataReader.java
+++ b/src/org/olap4j/driver/xmla/MetadataReader.java
@@ -1,88 +1,88 @@
-/*
-// This software is subject to the terms of the Common Public License
-// Agreement, available at the following URL:
-// http://www.opensource.org/licenses/cpl.html.
-// Copyright (C) 2008-2008 Julian Hyde
-// All Rights Reserved.
-// You must accept the terms of that agreement to use this software.
-*/
-package org.olap4j.driver.xmla;
-
-import org.olap4j.OlapException;
-import org.olap4j.metadata.Member;
-
-import java.util.*;
-
-/**
- * Can read metadata, in particular members.
- *
- * @author jhyde
- * @version $Id: $
- * @since Jan 14, 2008
- */
-interface MetadataReader {
- /**
- * Looks up a member by its unique name.
- *
- * Not part of public olap4j API.
- *
- * @param memberUniqueName Unique name of member
- * @return Member, or null if not found
- * @throws org.olap4j.OlapException if error occurs
- */
- XmlaOlap4jMember lookupMemberByUniqueName(
- String memberUniqueName)
- throws OlapException;
-
- /**
- * Looks up a list of members by their unique name and writes the results
- * into a map.
- *
- *
Not part of public olap4j API.
- *
- * @param memberUniqueNames List of unique names of member
- *
- * @param memberMap Map to populate with members
- *
- * @throws org.olap4j.OlapException if error occurs
- */
- void lookupMembersByUniqueName(
- List memberUniqueNames,
- Map memberMap)
- throws OlapException;
-
- /**
- * Looks a member by its unique name and returns members related by
- * the specified tree-operations.
- *
- * Not part of public olap4j API.
- *
- * @param memberUniqueName Unique name of member
- *
- * @param treeOps Collection of tree operations to travel relative to
- * given member in order to create list of members
- *
- * @param list list to be populated with members related to the given
- * member, or empty set if the member is not found
- *
- * @throws org.olap4j.OlapException if error occurs
- */
- void lookupMemberRelatives(
- Set treeOps,
- String memberUniqueName,
- List list) throws OlapException;
-
- /**
- * Looks up members of a given level.
- *
- * @param level Level
- *
- * @throws org.olap4j.OlapException if error occurs
- *
- * @return list of members at in the level
- */
- List getLevelMembers(XmlaOlap4jLevel level)
- throws OlapException;
-}
-
-// End MetadataReader.java
+/*
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2008-2008 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.driver.xmla;
+
+import org.olap4j.OlapException;
+import org.olap4j.metadata.Member;
+
+import java.util.*;
+
+/**
+ * Can read metadata, in particular members.
+ *
+ * @author jhyde
+ * @version $Id: $
+ * @since Jan 14, 2008
+ */
+interface MetadataReader {
+ /**
+ * Looks up a member by its unique name.
+ *
+ * Not part of public olap4j API.
+ *
+ * @param memberUniqueName Unique name of member
+ * @return Member, or null if not found
+ * @throws org.olap4j.OlapException if error occurs
+ */
+ XmlaOlap4jMember lookupMemberByUniqueName(
+ String memberUniqueName)
+ throws OlapException;
+
+ /**
+ * Looks up a list of members by their unique name and writes the results
+ * into a map.
+ *
+ *
Not part of public olap4j API.
+ *
+ * @param memberUniqueNames List of unique names of member
+ *
+ * @param memberMap Map to populate with members
+ *
+ * @throws org.olap4j.OlapException if error occurs
+ */
+ void lookupMembersByUniqueName(
+ List memberUniqueNames,
+ Map memberMap)
+ throws OlapException;
+
+ /**
+ * Looks a member by its unique name and returns members related by
+ * the specified tree-operations.
+ *
+ * Not part of public olap4j API.
+ *
+ * @param memberUniqueName Unique name of member
+ *
+ * @param treeOps Collection of tree operations to travel relative to
+ * given member in order to create list of members
+ *
+ * @param list list to be populated with members related to the given
+ * member, or empty set if the member is not found
+ *
+ * @throws org.olap4j.OlapException if error occurs
+ */
+ void lookupMemberRelatives(
+ Set treeOps,
+ String memberUniqueName,
+ List list) throws OlapException;
+
+ /**
+ * Looks up members of a given level.
+ *
+ * @param level Level
+ *
+ * @throws org.olap4j.OlapException if error occurs
+ *
+ * @return list of members at in the level
+ */
+ List getLevelMembers(XmlaOlap4jLevel level)
+ throws OlapException;
+}
+
+// End MetadataReader.java
diff --git a/src/org/olap4j/driver/xmla/XmlaOlap4jCatalog.java b/src/org/olap4j/driver/xmla/XmlaOlap4jCatalog.java
index d0fbe6a..7d657ba 100644
--- a/src/org/olap4j/driver/xmla/XmlaOlap4jCatalog.java
+++ b/src/org/olap4j/driver/xmla/XmlaOlap4jCatalog.java
@@ -35,13 +35,13 @@ class XmlaOlap4jCatalog implements Catalog, Named {
assert name != null;
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 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.
*/
diff --git a/src/org/olap4j/driver/xmla/XmlaOlap4jCellSet.java b/src/org/olap4j/driver/xmla/XmlaOlap4jCellSet.java
index 04cc76c..84b4171 100644
--- a/src/org/olap4j/driver/xmla/XmlaOlap4jCellSet.java
+++ b/src/org/olap4j/driver/xmla/XmlaOlap4jCellSet.java
@@ -1,1364 +1,1366 @@
-/*
-// This software is subject to the terms of the Common Public License
-// Agreement, available at the following URL:
-// http://www.opensource.org/licenses/cpl.html.
-// Copyright (C) 2007-2007 Julian Hyde
-// All Rights Reserved.
-// You must accept the terms of that agreement to use this software.
-*/
-package org.olap4j.driver.xmla;
-
-import org.olap4j.*;
-import org.olap4j.mdx.ParseTreeNode;
-import org.olap4j.impl.Olap4jUtil;
-import static org.olap4j.driver.xmla.XmlaOlap4jUtil.*;
-import org.olap4j.metadata.*;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
-
-import java.io.*;
-import java.math.BigDecimal;
-import java.net.URL;
-import java.sql.*;
-import java.sql.Date;
-import java.util.*;
-
-/**
- * Implementation of {@link org.olap4j.CellSet}
- * for XML/A providers.
- *
- * This class has sub-classes which implement JDBC 3.0 and JDBC 4.0 APIs;
- * it is instantiated using {@link Factory#newCellSet}.
- *
- * @author jhyde
- * @version $Id$
- * @since May 24, 2007
- */
-abstract class XmlaOlap4jCellSet implements CellSet {
- final XmlaOlap4jStatement olap4jStatement;
- protected boolean closed;
- private XmlaOlap4jCellSetMetaData metaData;
- private final Map cellMap =
- new HashMap();
- private final List axisList =
- new ArrayList();
- private final List immutableAxisList =
- Olap4jUtil.cast(Collections.unmodifiableList(axisList));
- private XmlaOlap4jCellSetAxis filterAxis;
- private static final boolean DEBUG = false;
-
- private static final List standardProperties = Arrays.asList(
- "UName", "Caption", "LName", "LNum", "DisplayInfo");
-
- /**
- * Creates an XmlaOlap4jCellSet.
- *
- * @param olap4jStatement Statement
- */
- XmlaOlap4jCellSet(
- XmlaOlap4jStatement olap4jStatement)
- {
- assert olap4jStatement != null;
- this.olap4jStatement = olap4jStatement;
- this.closed = false;
- }
-
- /**
- * Gets response from the XMLA request and populates cell set axes and cells
- * with it.
- *
- * @throws OlapException on error
- */
- void populate() throws OlapException {
- byte[] bytes = olap4jStatement.getBytes();
-
- Document doc;
- try {
- doc = parse(bytes);
- } catch (IOException e) {
- throw olap4jStatement.olap4jConnection.helper.createException(
- "error creating CellSet", e);
- } catch (SAXException e) {
- throw olap4jStatement.olap4jConnection.helper.createException(
- "error creating CellSet", e);
- }
- //
- //
- //
- //
- //
- //
- // (see below)
- //
- //
- //
- //
- //
- final Element envelope = doc.getDocumentElement();
- if (DEBUG) System.out.println(XmlaOlap4jUtil.toString(doc,true));
- assert envelope.getLocalName().equals("Envelope");
- assert envelope.getNamespaceURI().equals(SOAP_NS);
- Element body =
- findChild(envelope, SOAP_NS, "Body");
- Element fault =
- findChild(body, SOAP_NS, "Fault");
- if (fault != null) {
- /*
- Example:
-
-
- SOAP-ENV:Client.00HSBC01
- XMLA connection datasource not found
- Mondrian
-
-
- 00HSBC01
- The Mondrian XML: Mondrian Error:Internal
- error: no catalog named 'LOCALDB'
-
-
-
- */
- // TODO: log doc to logfile
- final Element faultstring = findChild(fault, null, "faultstring");
- String message = faultstring.getTextContent();
- throw olap4jStatement.olap4jConnection.helper.createException(
- "XMLA provider gave exception: " + message);
- }
- Element executeResponse =
- findChild(body, XMLA_NS, "ExecuteResponse");
- Element returnElement =
- findChild(executeResponse, XMLA_NS, "return");
- // has children
- //
- //
- //
- //
- // FOO
- //
- //
- //
- // ...
- //
- //
- //
- //
- //
- //
- // ...
- //
- //
- // |
- // ...
- //
- final Element root =
- findChild(returnElement, MDDATASET_NS, "root");
-
- if (olap4jStatement instanceof XmlaOlap4jPreparedStatement) {
- this.metaData =
- ((XmlaOlap4jPreparedStatement) olap4jStatement)
- .cellSetMetaData;
- } else {
- this.metaData = createMetaData(root);
- }
-
- // todo: use CellInfo element to determine mapping of cell properties
- // to XML tags
- /*
-
-
-
-
-
- */
-
- final Element axesNode = findChild(root, MDDATASET_NS, "Axes");
- for (Element axisNode : findChildren(axesNode, MDDATASET_NS, "Axis")) {
- final String axisName = axisNode.getAttribute("name");
- final Axis axis = lookupAxis(axisName);
- final XmlaOlap4jCellSetAxis cellSetAxis =
- new XmlaOlap4jCellSetAxis(this, axis);
- switch (axis) {
- case FILTER:
- filterAxis = cellSetAxis;
- break;
- default:
- axisList.add(cellSetAxis);
- break;
- }
- final Element tuplesNode =
- findChild(axisNode, MDDATASET_NS, "Tuples");
- int ordinal = 0;
- final Map propertyValues =
- new HashMap();
-
- // First pass, gather up a list of member unique names to fetch
- // all at once.
- //
- // NOTE: This approach allows the driver to fetch a large number
- // of members in one round trip, which is much more efficient.
- // However, if the axis has a very large number of members, the map
- // may use too much memory. This is an unresolved issue.
- final MetadataReader metadataReader =
- metaData.cube.getMetadataReader();
- final Map memberMap =
- new HashMap();
- List uniqueNames = new ArrayList();
- for (Element tupleNode
- : findChildren(tuplesNode, MDDATASET_NS, "Tuple"))
- {
- for (Element memberNode
- : findChildren(tupleNode, MDDATASET_NS, "Member"))
- {
- final String uname = stringElement(memberNode, "UName");
- uniqueNames.add(uname);
- }
- }
- metadataReader.lookupMembersByUniqueName(uniqueNames, memberMap);
-
- // Second pass, populate the axis.
- for (Element tupleNode
- : findChildren(tuplesNode, MDDATASET_NS, "Tuple"))
- {
- final List members = new ArrayList();
- for (Element memberNode
- : findChildren(tupleNode, MDDATASET_NS, "Member"))
- {
- String hierarchyName =
- memberNode.getAttribute("Hierarchy");
- final String uname = stringElement(memberNode, "UName");
- Member member = memberMap.get(uname);
- if (member == null) {
- final String caption =
- stringElement(memberNode, "Caption");
- final int lnum = integerElement(memberNode, "LNum");
- final Hierarchy hierarchy =
- lookupHierarchy(metaData.cube, hierarchyName);
- final Level level = hierarchy.getLevels().get(lnum);
- member = new XmlaOlap4jSurpriseMember(
- level, hierarchy, lnum, caption, uname);
- }
- propertyValues.clear();
- for (Element childNode : childElements(memberNode)) {
- XmlaOlap4jCellSetMemberProperty property =
- ((XmlaOlap4jCellSetAxisMetaData)
- cellSetAxis.getAxisMetaData()).lookupProperty(
- hierarchyName,
- childNode.getLocalName());
- if (property != null) {
- String value = childNode.getTextContent();
- propertyValues.put(property, value);
- }
- }
- if (!propertyValues.isEmpty()) {
- member =
- new XmlaOlap4jPositionMember(
- member, propertyValues);
- }
- members.add(member);
- }
- cellSetAxis.positions.add(
- new XmlaOlap4jPosition(members, ordinal++));
- }
- }
-
- final Map propertyValues =
- new HashMap();
- final Element cellDataNode = findChild(root, MDDATASET_NS, "CellData");
- for (Element cell : findChildren(cellDataNode, MDDATASET_NS, "Cell")) {
- propertyValues.clear();
- final int cellOrdinal =
- Integer.valueOf(cell.getAttribute("CellOrdinal"));
- final Object value = getTypedValue(cell);
- final String formattedValue = stringElement(cell, "FmtValue");
- final String formatString = stringElement(cell, "FormatString");
- Olap4jUtil.discard(formatString);
- for (Element element : childElements(cell)) {
- String tag = element.getLocalName();
- final Property property =
- metaData.propertiesByTag.get(tag);
- if (property != null) {
- propertyValues.put(property, element.getTextContent());
- }
- }
- cellMap.put(
- cellOrdinal,
- new XmlaOlap4jCell(
- this,
- cellOrdinal,
- value,
- formattedValue,
- propertyValues));
- }
- }
-
- /**
- * Returns the value of a cell, cast to the appropriate Java object type
- * corresponding to the XML schema (XSD) type of the value.
- *
- * The value type must conform to XSD definitions of the XML element. See
- * RELAX
- * NG, Chapter 19 for a full list of possible data types.
- *
- *
This method does not currently support all types; must numeric types
- * are supported, but no dates are yet supported. Those not supported
- * fall back to Strings.
- *
- * @param cell The cell of which we want the casted object.
- * @return The object with a correct value.
- * @throws OlapException if any error is encountered while casting the cell
- * value
- */
- private Object getTypedValue(Element cell) throws OlapException {
- Element elm = findChild(cell, MDDATASET_NS, "Value");
- if (elm == null) {
- // Cell is null.
- return null;
- }
-
- // The object type is contained in xsi:type attribute.
- String type = elm.getAttribute("xsi:type");
- try {
- if (type.equals( "xsd:int")) {
- return XmlaOlap4jUtil.intElement(cell, "Value");
- } else if (type.equals( "xsd:integer")) {
- return XmlaOlap4jUtil.integerElement(cell, "Value");
- } else if (type.equals( "xsd:double")) {
- return XmlaOlap4jUtil.doubleElement(cell, "Value");
- } else if (type.equals( "xsd:float")) {
- return XmlaOlap4jUtil.floatElement(cell, "Value");
- } else if (type.equals( "xsd:long")) {
- return XmlaOlap4jUtil.longElement(cell, "Value");
- } else if (type.equals( "xsd:boolean")) {
- return XmlaOlap4jUtil.booleanElement(cell, "Value");
- } else {
- return XmlaOlap4jUtil.stringElement(cell, "Value");
- }
- } catch (Exception e) {
- throw new OlapException(
- "Error while casting a cell value to the correct java type for"
- + " its XSD type " + type,
- e);
- }
- }
-
- /**
- * Creates metadata for a cell set, given the DOM of the XMLA result.
- *
- * @param root Root node of XMLA result
- * @return Metadata describing this cell set
- * @throws OlapException on error
- */
- private XmlaOlap4jCellSetMetaData createMetaData(Element root)
- throws OlapException
- {
- final Element olapInfo =
- findChild(root, MDDATASET_NS, "OlapInfo");
- final Element cubeInfo =
- findChild(olapInfo, MDDATASET_NS, "CubeInfo");
- final Element cubeNode =
- findChild(cubeInfo, MDDATASET_NS, "Cube");
- final Element cubeNameNode =
- findChild(cubeNode, MDDATASET_NS, "CubeName");
- final String cubeName = gatherText(cubeNameNode);
- final XmlaOlap4jCube cube =
- (XmlaOlap4jCube)
- this.olap4jStatement.olap4jConnection.getSchema().getCubes().get(
- cubeName);
- if (cube == null) {
- throw olap4jStatement.olap4jConnection.helper.createException(
- "Internal error: cube '" + cubeName + "' not found");
- }
- final Element axesInfo =
- findChild(olapInfo, MDDATASET_NS, "AxesInfo");
- final List axisInfos =
- findChildren(axesInfo, MDDATASET_NS, "AxisInfo");
- final List axisMetaDataList =
- new ArrayList();
- XmlaOlap4jCellSetAxisMetaData filterAxisMetaData = null;
- for (Element axisInfo : axisInfos) {
- final String axisName = axisInfo.getAttribute("name");
- Axis axis = lookupAxis(axisName);
- final List hierarchyInfos =
- findChildren(axisInfo, MDDATASET_NS, "HierarchyInfo");
- final List hierarchyList =
- new ArrayList();
- /*
-
-
-
-
-
-
-
-
-
-
-
- ...
-
-
-
-
-
-
-
- */
- final List propertyList =
- new ArrayList();
- for (Element hierarchyInfo : hierarchyInfos) {
- final String hierarchyName = hierarchyInfo.getAttribute("name");
- Hierarchy hierarchy = lookupHierarchy(cube, hierarchyName);
- hierarchyList.add(hierarchy);
- for (Element childNode : childElements(hierarchyInfo)) {
- String tag = childNode.getLocalName();
- if (standardProperties.contains(tag)) {
- continue;
- }
- final String propertyUniqueName =
- childNode.getAttribute("name");
- final XmlaOlap4jCellSetMemberProperty property =
- new XmlaOlap4jCellSetMemberProperty(
- propertyUniqueName,
- hierarchy,
- tag);
- propertyList.add(property);
- }
- }
- final XmlaOlap4jCellSetAxisMetaData axisMetaData =
- new XmlaOlap4jCellSetAxisMetaData(
- olap4jStatement.olap4jConnection,
- axis,
- hierarchyList,
- propertyList);
- switch (axis) {
- case FILTER:
- filterAxisMetaData = axisMetaData;
- break;
- default:
- axisMetaDataList.add(axisMetaData);
- break;
- }
- }
- final Element cellInfo =
- findChild(olapInfo, MDDATASET_NS, "CellInfo");
- List cellProperties =
- new ArrayList();
- for (Element element : childElements(cellInfo)) {
- cellProperties.add(
- new XmlaOlap4jCellProperty(
- element.getLocalName(),
- element.getAttribute("name")));
- }
- return
- new XmlaOlap4jCellSetMetaData(
- olap4jStatement,
- cube,
- filterAxisMetaData,
- axisMetaDataList,
- cellProperties);
- }
-
- /**
- * Looks up a hierarchy in a cube with a given name or, failing that, a
- * given unique name. Throws if not found.
- *
- * @param cube Cube
- * @param hierarchyName Name (or unique name) of hierarchy.
- * @return Hierarchy
- * @throws OlapException
- */
- private Hierarchy lookupHierarchy(XmlaOlap4jCube cube, String hierarchyName)
- throws OlapException
- {
- Hierarchy hierarchy = cube.getHierarchies().get(hierarchyName);
- if (hierarchy == null) {
- for (Hierarchy hierarchy1 : cube.getHierarchies()) {
- if (hierarchy1.getUniqueName().equals(hierarchyName)) {
- hierarchy = hierarchy1;
- break;
- }
- }
- if (hierarchy == null) {
- throw this.olap4jStatement.olap4jConnection.helper
- .createException(
- "Internal error: hierarchy '" + hierarchyName
- + "' not found in cube '" + cube.getName()
- + "'");
- }
- }
- return hierarchy;
- }
-
- /**
- * Looks up an Axis with a given name.
- *
- * @param axisName Name of axis
- * @return Axis
- */
- private Axis lookupAxis(String axisName) {
- if (axisName.startsWith("Axis")) {
- final Integer ordinal =
- Integer.valueOf(axisName.substring("Axis".length()));
- return Axis.values()[Axis.COLUMNS.ordinal() + ordinal];
- } else {
- return Axis.FILTER;
- }
- }
-
- public CellSetMetaData getMetaData() {
- return metaData;
- }
-
- public Cell getCell(List coordinates) {
- return getCellInternal(coordinatesToOrdinal(coordinates));
- }
-
- public Cell getCell(int ordinal) {
- return getCellInternal(ordinal);
- }
-
- public Cell getCell(Position... positions) {
- if (positions.length != getAxes().size()) {
- throw new IllegalArgumentException(
- "cell coordinates should have dimension " + getAxes().size());
- }
- List coords = new ArrayList(positions.length);
- for (Position position : positions) {
- coords.add(position.getOrdinal());
- }
- return getCell(coords);
- }
-
- /**
- * Returns a cell given its ordinal.
- *
- * @param pos Ordinal
- * @return Cell
- * @throws IndexOutOfBoundsException if ordinal is not in range
- */
- private Cell getCellInternal(int pos) {
- final Cell cell = cellMap.get(pos);
- if (cell == null) {
- if (pos < 0 || pos >= maxOrdinal()) {
- throw new IndexOutOfBoundsException();
- } else {
- // Cell is within bounds, but is not held in the cache because
- // it has no value. Manufacture a cell with an empty value.
- return new XmlaOlap4jCell(
- this, pos, null, "",
- Collections.emptyMap());
- }
- }
- return cell;
- }
-
- /**
- * Returns a string describing the maximum coordinates of this cell set;
- * for example "2, 3" for a cell set with 2 columns and 3 rows.
- *
- * @return description of cell set bounds
- */
- private String getBoundsAsString() {
- StringBuilder buf = new StringBuilder();
- int k = 0;
- for (CellSetAxis axis : getAxes()) {
- if (k++ > 0) {
- buf.append(", ");
- }
- buf.append(axis.getPositionCount());
- }
- return buf.toString();
- }
-
- public List getAxes() {
- return immutableAxisList;
- }
-
- public CellSetAxis getFilterAxis() {
- return filterAxis;
- }
-
- /**
- * Returns the ordinal of the last cell in this cell set. This is the
- * product of the cardinalities of all axes.
- *
- * @return ordinal of last cell in cell set
- */
- private int maxOrdinal() {
- int modulo = 1;
- for (CellSetAxis axis : axisList) {
- modulo *= axis.getPositionCount();
- }
- return modulo;
- }
-
- public List ordinalToCoordinates(int ordinal) {
- List axes = getAxes();
- final List list = new ArrayList(axes.size());
- int modulo = 1;
- for (CellSetAxis axis : axes) {
- int prevModulo = modulo;
- modulo *= axis.getPositionCount();
- list.add((ordinal % modulo) / prevModulo);
- }
- if (ordinal < 0 || ordinal >= modulo) {
- throw new IndexOutOfBoundsException(
- "Cell ordinal " + ordinal
- + ") lies outside CellSet bounds ("
- + getBoundsAsString() + ")");
- }
- return list;
- }
-
- public int coordinatesToOrdinal(List coordinates) {
- List axes = getAxes();
- if (coordinates.size() != axes.size()) {
- throw new IllegalArgumentException(
- "Coordinates have different dimension " + coordinates.size()
- + " than axes " + axes.size());
- }
- int modulo = 1;
- int ordinal = 0;
- int k = 0;
- for (CellSetAxis axis : axes) {
- final Integer coordinate = coordinates.get(k++);
- if (coordinate < 0 || coordinate >= axis.getPositionCount()) {
- throw new IndexOutOfBoundsException(
- "Coordinate " + coordinate
- + " of axis " + k
- + " is out of range ("
- + getBoundsAsString() + ")");
- }
- ordinal += coordinate * modulo;
- modulo *= axis.getPositionCount();
- }
- return ordinal;
- }
-
- public boolean next() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void close() throws SQLException {
- this.closed = true;
- }
-
- public boolean wasNull() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public String getString(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean getBoolean(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public byte getByte(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public short getShort(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public int getInt(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public long getLong(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public float getFloat(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public double getDouble(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public BigDecimal getBigDecimal(
- int columnIndex, int scale) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public byte[] getBytes(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Date getDate(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Time getTime(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Timestamp getTimestamp(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public InputStream getAsciiStream(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public InputStream getUnicodeStream(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public InputStream getBinaryStream(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public String getString(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean getBoolean(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public byte getByte(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public short getShort(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public int getInt(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public long getLong(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public float getFloat(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public double getDouble(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public BigDecimal getBigDecimal(
- String columnLabel, int scale) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public byte[] getBytes(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Date getDate(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Time getTime(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Timestamp getTimestamp(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public InputStream getAsciiStream(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public InputStream getUnicodeStream(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public InputStream getBinaryStream(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public SQLWarning getWarnings() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void clearWarnings() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public String getCursorName() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Object getObject(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Object getObject(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public int findColumn(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Reader getCharacterStream(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Reader getCharacterStream(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean isBeforeFirst() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean isAfterLast() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean isFirst() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean isLast() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void beforeFirst() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void afterLast() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean first() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean last() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public int getRow() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean absolute(int row) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean relative(int rows) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean previous() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setFetchDirection(int direction) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public int getFetchDirection() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setFetchSize(int rows) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public int getFetchSize() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public int getType() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public int getConcurrency() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean rowUpdated() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean rowInserted() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean rowDeleted() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNull(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBoolean(int columnIndex, boolean x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateByte(int columnIndex, byte x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateShort(int columnIndex, short x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateInt(int columnIndex, int x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateLong(int columnIndex, long x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateFloat(int columnIndex, float x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateDouble(int columnIndex, double x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBigDecimal(
- int columnIndex, BigDecimal x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateString(int columnIndex, String x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBytes(int columnIndex, byte x[]) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateDate(int columnIndex, Date x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateTime(int columnIndex, Time x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateTimestamp(
- int columnIndex, Timestamp x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateAsciiStream(
- int columnIndex, InputStream x, int length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBinaryStream(
- int columnIndex, InputStream x, int length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateCharacterStream(
- int columnIndex, Reader x, int length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateObject(
- int columnIndex, Object x, int scaleOrLength) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateObject(int columnIndex, Object x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateNull(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBoolean(
- String columnLabel, boolean x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateByte(String columnLabel, byte x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateShort(String columnLabel, short x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateInt(String columnLabel, int x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateLong(String columnLabel, long x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateFloat(String columnLabel, float x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateDouble(String columnLabel, double x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBigDecimal(
- String columnLabel, BigDecimal x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateString(String columnLabel, String x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBytes(String columnLabel, byte x[]) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateDate(String columnLabel, Date x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateTime(String columnLabel, Time x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateTimestamp(
- String columnLabel, Timestamp x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateAsciiStream(
- String columnLabel, InputStream x, int length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBinaryStream(
- String columnLabel, InputStream x, int length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateCharacterStream(
- String columnLabel, Reader reader, int length) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateObject(
- String columnLabel, Object x, int scaleOrLength) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateObject(String columnLabel, Object x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void insertRow() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateRow() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void deleteRow() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void refreshRow() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void cancelRowUpdates() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void moveToInsertRow() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void moveToCurrentRow() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Statement getStatement() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Object getObject(
- int columnIndex, Map> map) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Ref getRef(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Blob getBlob(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Clob getClob(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Array getArray(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Object getObject(
- String columnLabel, Map> map) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Ref getRef(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Blob getBlob(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Clob getClob(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Array getArray(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Date getDate(int columnIndex, Calendar cal) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Date getDate(String columnLabel, Calendar cal) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Time getTime(int columnIndex, Calendar cal) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Time getTime(String columnLabel, Calendar cal) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Timestamp getTimestamp(
- int columnIndex, Calendar cal) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Timestamp getTimestamp(
- String columnLabel, Calendar cal) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public URL getURL(int columnIndex) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public URL getURL(String columnLabel) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateRef(int columnIndex, Ref x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateRef(String columnLabel, Ref x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBlob(int columnIndex, Blob x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateBlob(String columnLabel, Blob x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateClob(int columnIndex, Clob x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateClob(String columnLabel, Clob x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateArray(int columnIndex, Array x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void updateArray(String columnLabel, Array x) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- // implement Wrapper
-
- public T unwrap(Class iface) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean isWrapperFor(Class> iface) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Implementation of {@link Member} for a member which is not present
- * in the cube (probably because the member is a calculated member
- * defined in the query).
- */
- private static class XmlaOlap4jSurpriseMember implements Member {
- private final Level level;
- private final Hierarchy hierarchy;
- private final int lnum;
- private final String caption;
- private final String uname;
-
- /**
- * Creates an XmlaOlap4jSurpriseMember.
- *
- * @param level Level
- * @param hierarchy Hierarchy
- * @param lnum Level number
- * @param caption Caption
- * @param uname Member unique name
- */
- XmlaOlap4jSurpriseMember(
- Level level,
- Hierarchy hierarchy,
- int lnum,
- String caption,
- String uname)
- {
- this.level = level;
- this.hierarchy = hierarchy;
- this.lnum = lnum;
- this.caption = caption;
- this.uname = uname;
- }
-
- public NamedList extends Member> getChildMembers()
- {
- return Olap4jUtil.emptyNamedList();
- }
-
- public int getChildMemberCount() {
- return 0;
- }
-
- public Member getParentMember() {
- return null;
- }
-
- public Level getLevel() {
- return level;
- }
-
- public Hierarchy getHierarchy() {
- return hierarchy;
- }
-
- public Dimension getDimension() {
- return hierarchy.getDimension();
- }
-
- public Type getMemberType() {
- return Type.UNKNOWN;
- }
-
- public boolean isAll() {
- return false; // FIXME
- }
-
- public boolean isChildOrEqualTo(Member member) {
- return false; // FIXME
- }
-
- public boolean isCalculated() {
- return false; // FIXME
- }
-
- public int getSolveOrder() {
- return 0; // FIXME
- }
-
- public ParseTreeNode getExpression() {
- return null;
- }
-
- public List getAncestorMembers() {
- return Collections.emptyList(); // FIXME
- }
-
- public boolean isCalculatedInQuery() {
- return true; // probably
- }
-
- public Object getPropertyValue(Property property) {
- return null;
- }
-
- public String getPropertyFormattedValue(Property property) {
- return null;
- }
-
- public void setProperty(Property property, Object value)
- {
- throw new UnsupportedOperationException();
- }
-
- public NamedList getProperties() {
- return Olap4jUtil.emptyNamedList();
- }
-
- public int getOrdinal() {
- return -1; // FIXME
- }
-
- public boolean isHidden() {
- return false;
- }
-
- public int getDepth() {
- return lnum;
- }
-
- public Member getDataMember() {
- return null;
- }
-
- public String getName() {
- return caption;
- }
-
- public String getUniqueName() {
- return uname;
- }
-
- public String getCaption(Locale locale) {
- return caption;
- }
-
- public String getDescription(Locale locale) {
- return null;
- }
- }
-}
-
-// End XmlaOlap4jCellSet.java
+/*
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2007-2007 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.driver.xmla;
+
+import org.olap4j.*;
+import org.olap4j.mdx.ParseTreeNode;
+import org.olap4j.impl.Olap4jUtil;
+import static org.olap4j.driver.xmla.XmlaOlap4jUtil.*;
+import org.olap4j.metadata.*;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+import java.io.*;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.*;
+import java.sql.Date;
+import java.util.*;
+
+/**
+ * Implementation of {@link org.olap4j.CellSet}
+ * for XML/A providers.
+ *
+ * This class has sub-classes which implement JDBC 3.0 and JDBC 4.0 APIs;
+ * it is instantiated using {@link Factory#newCellSet}.
+ *
+ * @author jhyde
+ * @version $Id$
+ * @since May 24, 2007
+ */
+abstract class XmlaOlap4jCellSet implements CellSet {
+ final XmlaOlap4jStatement olap4jStatement;
+ protected boolean closed;
+ private XmlaOlap4jCellSetMetaData metaData;
+ private final Map cellMap =
+ new HashMap();
+ private final List axisList =
+ new ArrayList();
+ private final List immutableAxisList =
+ Olap4jUtil.cast(Collections.unmodifiableList(axisList));
+ private XmlaOlap4jCellSetAxis filterAxis;
+ private static final boolean DEBUG = false;
+
+ private static final List standardProperties = Arrays.asList(
+ "UName", "Caption", "LName", "LNum", "DisplayInfo");
+
+ /**
+ * Creates an XmlaOlap4jCellSet.
+ *
+ * @param olap4jStatement Statement
+ */
+ XmlaOlap4jCellSet(
+ XmlaOlap4jStatement olap4jStatement)
+ {
+ assert olap4jStatement != null;
+ this.olap4jStatement = olap4jStatement;
+ this.closed = false;
+ }
+
+ /**
+ * Gets response from the XMLA request and populates cell set axes and cells
+ * with it.
+ *
+ * @throws OlapException on error
+ */
+ void populate() throws OlapException {
+ byte[] bytes = olap4jStatement.getBytes();
+
+ Document doc;
+ try {
+ doc = parse(bytes);
+ } catch (IOException e) {
+ throw olap4jStatement.olap4jConnection.helper.createException(
+ "error creating CellSet", e);
+ } catch (SAXException e) {
+ throw olap4jStatement.olap4jConnection.helper.createException(
+ "error creating CellSet", e);
+ }
+ //
+ //
+ //
+ //
+ //
+ //
+ // (see below)
+ //
+ //
+ //
+ //
+ //
+ final Element envelope = doc.getDocumentElement();
+ if (DEBUG) {
+ System.out.println(XmlaOlap4jUtil.toString(doc, true));
+ }
+ assert envelope.getLocalName().equals("Envelope");
+ assert envelope.getNamespaceURI().equals(SOAP_NS);
+ Element body =
+ findChild(envelope, SOAP_NS, "Body");
+ Element fault =
+ findChild(body, SOAP_NS, "Fault");
+ if (fault != null) {
+ /*
+ Example:
+
+
+ SOAP-ENV:Client.00HSBC01
+ XMLA connection datasource not found
+ Mondrian
+
+
+ 00HSBC01
+ The Mondrian XML: Mondrian Error:Internal
+ error: no catalog named 'LOCALDB'
+
+
+
+ */
+ // TODO: log doc to logfile
+ final Element faultstring = findChild(fault, null, "faultstring");
+ String message = faultstring.getTextContent();
+ throw olap4jStatement.olap4jConnection.helper.createException(
+ "XMLA provider gave exception: " + message);
+ }
+ Element executeResponse =
+ findChild(body, XMLA_NS, "ExecuteResponse");
+ Element returnElement =
+ findChild(executeResponse, XMLA_NS, "return");
+ // has children
+ //
+ //
+ //
+ //
+ // FOO
+ //
+ //
+ //
+ // ...
+ //
+ //
+ //
+ //
+ //
+ //
+ // ...
+ //
+ //
+ // |
+ // ...
+ //
+ final Element root =
+ findChild(returnElement, MDDATASET_NS, "root");
+
+ if (olap4jStatement instanceof XmlaOlap4jPreparedStatement) {
+ this.metaData =
+ ((XmlaOlap4jPreparedStatement) olap4jStatement)
+ .cellSetMetaData;
+ } else {
+ this.metaData = createMetaData(root);
+ }
+
+ // todo: use CellInfo element to determine mapping of cell properties
+ // to XML tags
+ /*
+
+
+
+
+
+ */
+
+ final Element axesNode = findChild(root, MDDATASET_NS, "Axes");
+ for (Element axisNode : findChildren(axesNode, MDDATASET_NS, "Axis")) {
+ final String axisName = axisNode.getAttribute("name");
+ final Axis axis = lookupAxis(axisName);
+ final XmlaOlap4jCellSetAxis cellSetAxis =
+ new XmlaOlap4jCellSetAxis(this, axis);
+ switch (axis) {
+ case FILTER:
+ filterAxis = cellSetAxis;
+ break;
+ default:
+ axisList.add(cellSetAxis);
+ break;
+ }
+ final Element tuplesNode =
+ findChild(axisNode, MDDATASET_NS, "Tuples");
+ int ordinal = 0;
+ final Map propertyValues =
+ new HashMap();
+
+ // First pass, gather up a list of member unique names to fetch
+ // all at once.
+ //
+ // NOTE: This approach allows the driver to fetch a large number
+ // of members in one round trip, which is much more efficient.
+ // However, if the axis has a very large number of members, the map
+ // may use too much memory. This is an unresolved issue.
+ final MetadataReader metadataReader =
+ metaData.cube.getMetadataReader();
+ final Map memberMap =
+ new HashMap();
+ List uniqueNames = new ArrayList();
+ for (Element tupleNode
+ : findChildren(tuplesNode, MDDATASET_NS, "Tuple"))
+ {
+ for (Element memberNode
+ : findChildren(tupleNode, MDDATASET_NS, "Member"))
+ {
+ final String uname = stringElement(memberNode, "UName");
+ uniqueNames.add(uname);
+ }
+ }
+ metadataReader.lookupMembersByUniqueName(uniqueNames, memberMap);
+
+ // Second pass, populate the axis.
+ for (Element tupleNode
+ : findChildren(tuplesNode, MDDATASET_NS, "Tuple"))
+ {
+ final List members = new ArrayList();
+ for (Element memberNode
+ : findChildren(tupleNode, MDDATASET_NS, "Member"))
+ {
+ String hierarchyName =
+ memberNode.getAttribute("Hierarchy");
+ final String uname = stringElement(memberNode, "UName");
+ Member member = memberMap.get(uname);
+ if (member == null) {
+ final String caption =
+ stringElement(memberNode, "Caption");
+ final int lnum = integerElement(memberNode, "LNum");
+ final Hierarchy hierarchy =
+ lookupHierarchy(metaData.cube, hierarchyName);
+ final Level level = hierarchy.getLevels().get(lnum);
+ member = new XmlaOlap4jSurpriseMember(
+ level, hierarchy, lnum, caption, uname);
+ }
+ propertyValues.clear();
+ for (Element childNode : childElements(memberNode)) {
+ XmlaOlap4jCellSetMemberProperty property =
+ ((XmlaOlap4jCellSetAxisMetaData)
+ cellSetAxis.getAxisMetaData()).lookupProperty(
+ hierarchyName,
+ childNode.getLocalName());
+ if (property != null) {
+ String value = childNode.getTextContent();
+ propertyValues.put(property, value);
+ }
+ }
+ if (!propertyValues.isEmpty()) {
+ member =
+ new XmlaOlap4jPositionMember(
+ member, propertyValues);
+ }
+ members.add(member);
+ }
+ cellSetAxis.positions.add(
+ new XmlaOlap4jPosition(members, ordinal++));
+ }
+ }
+
+ final Map propertyValues =
+ new HashMap();
+ final Element cellDataNode = findChild(root, MDDATASET_NS, "CellData");
+ for (Element cell : findChildren(cellDataNode, MDDATASET_NS, "Cell")) {
+ propertyValues.clear();
+ final int cellOrdinal =
+ Integer.valueOf(cell.getAttribute("CellOrdinal"));
+ final Object value = getTypedValue(cell);
+ final String formattedValue = stringElement(cell, "FmtValue");
+ final String formatString = stringElement(cell, "FormatString");
+ Olap4jUtil.discard(formatString);
+ for (Element element : childElements(cell)) {
+ String tag = element.getLocalName();
+ final Property property =
+ metaData.propertiesByTag.get(tag);
+ if (property != null) {
+ propertyValues.put(property, element.getTextContent());
+ }
+ }
+ cellMap.put(
+ cellOrdinal,
+ new XmlaOlap4jCell(
+ this,
+ cellOrdinal,
+ value,
+ formattedValue,
+ propertyValues));
+ }
+ }
+
+ /**
+ * Returns the value of a cell, cast to the appropriate Java object type
+ * corresponding to the XML schema (XSD) type of the value.
+ *
+ * The value type must conform to XSD definitions of the XML element. See
+ * RELAX
+ * NG, Chapter 19 for a full list of possible data types.
+ *
+ *
This method does not currently support all types; must numeric types
+ * are supported, but no dates are yet supported. Those not supported
+ * fall back to Strings.
+ *
+ * @param cell The cell of which we want the casted object.
+ * @return The object with a correct value.
+ * @throws OlapException if any error is encountered while casting the cell
+ * value
+ */
+ private Object getTypedValue(Element cell) throws OlapException {
+ Element elm = findChild(cell, MDDATASET_NS, "Value");
+ if (elm == null) {
+ // Cell is null.
+ return null;
+ }
+
+ // The object type is contained in xsi:type attribute.
+ String type = elm.getAttribute("xsi:type");
+ try {
+ if (type.equals("xsd:int")) {
+ return XmlaOlap4jUtil.intElement(cell, "Value");
+ } else if (type.equals("xsd:integer")) {
+ return XmlaOlap4jUtil.integerElement(cell, "Value");
+ } else if (type.equals("xsd:double")) {
+ return XmlaOlap4jUtil.doubleElement(cell, "Value");
+ } else if (type.equals("xsd:float")) {
+ return XmlaOlap4jUtil.floatElement(cell, "Value");
+ } else if (type.equals("xsd:long")) {
+ return XmlaOlap4jUtil.longElement(cell, "Value");
+ } else if (type.equals("xsd:boolean")) {
+ return XmlaOlap4jUtil.booleanElement(cell, "Value");
+ } else {
+ return XmlaOlap4jUtil.stringElement(cell, "Value");
+ }
+ } catch (Exception e) {
+ throw new OlapException(
+ "Error while casting a cell value to the correct java type for"
+ + " its XSD type " + type,
+ e);
+ }
+ }
+
+ /**
+ * Creates metadata for a cell set, given the DOM of the XMLA result.
+ *
+ * @param root Root node of XMLA result
+ * @return Metadata describing this cell set
+ * @throws OlapException on error
+ */
+ private XmlaOlap4jCellSetMetaData createMetaData(Element root)
+ throws OlapException
+ {
+ final Element olapInfo =
+ findChild(root, MDDATASET_NS, "OlapInfo");
+ final Element cubeInfo =
+ findChild(olapInfo, MDDATASET_NS, "CubeInfo");
+ final Element cubeNode =
+ findChild(cubeInfo, MDDATASET_NS, "Cube");
+ final Element cubeNameNode =
+ findChild(cubeNode, MDDATASET_NS, "CubeName");
+ final String cubeName = gatherText(cubeNameNode);
+ final XmlaOlap4jCube cube =
+ (XmlaOlap4jCube)
+ this.olap4jStatement.olap4jConnection.getSchema().getCubes().get(
+ cubeName);
+ if (cube == null) {
+ throw olap4jStatement.olap4jConnection.helper.createException(
+ "Internal error: cube '" + cubeName + "' not found");
+ }
+ final Element axesInfo =
+ findChild(olapInfo, MDDATASET_NS, "AxesInfo");
+ final List axisInfos =
+ findChildren(axesInfo, MDDATASET_NS, "AxisInfo");
+ final List axisMetaDataList =
+ new ArrayList();
+ XmlaOlap4jCellSetAxisMetaData filterAxisMetaData = null;
+ for (Element axisInfo : axisInfos) {
+ final String axisName = axisInfo.getAttribute("name");
+ Axis axis = lookupAxis(axisName);
+ final List hierarchyInfos =
+ findChildren(axisInfo, MDDATASET_NS, "HierarchyInfo");
+ final List hierarchyList =
+ new ArrayList();
+ /*
+
+
+
+
+
+
+
+
+
+
+
+ ...
+
+
+
+
+
+
+
+ */
+ final List propertyList =
+ new ArrayList();
+ for (Element hierarchyInfo : hierarchyInfos) {
+ final String hierarchyName = hierarchyInfo.getAttribute("name");
+ Hierarchy hierarchy = lookupHierarchy(cube, hierarchyName);
+ hierarchyList.add(hierarchy);
+ for (Element childNode : childElements(hierarchyInfo)) {
+ String tag = childNode.getLocalName();
+ if (standardProperties.contains(tag)) {
+ continue;
+ }
+ final String propertyUniqueName =
+ childNode.getAttribute("name");
+ final XmlaOlap4jCellSetMemberProperty property =
+ new XmlaOlap4jCellSetMemberProperty(
+ propertyUniqueName,
+ hierarchy,
+ tag);
+ propertyList.add(property);
+ }
+ }
+ final XmlaOlap4jCellSetAxisMetaData axisMetaData =
+ new XmlaOlap4jCellSetAxisMetaData(
+ olap4jStatement.olap4jConnection,
+ axis,
+ hierarchyList,
+ propertyList);
+ switch (axis) {
+ case FILTER:
+ filterAxisMetaData = axisMetaData;
+ break;
+ default:
+ axisMetaDataList.add(axisMetaData);
+ break;
+ }
+ }
+ final Element cellInfo =
+ findChild(olapInfo, MDDATASET_NS, "CellInfo");
+ List cellProperties =
+ new ArrayList();
+ for (Element element : childElements(cellInfo)) {
+ cellProperties.add(
+ new XmlaOlap4jCellProperty(
+ element.getLocalName(),
+ element.getAttribute("name")));
+ }
+ return
+ new XmlaOlap4jCellSetMetaData(
+ olap4jStatement,
+ cube,
+ filterAxisMetaData,
+ axisMetaDataList,
+ cellProperties);
+ }
+
+ /**
+ * Looks up a hierarchy in a cube with a given name or, failing that, a
+ * given unique name. Throws if not found.
+ *
+ * @param cube Cube
+ * @param hierarchyName Name (or unique name) of hierarchy.
+ * @return Hierarchy
+ * @throws OlapException
+ */
+ private Hierarchy lookupHierarchy(XmlaOlap4jCube cube, String hierarchyName)
+ throws OlapException
+ {
+ Hierarchy hierarchy = cube.getHierarchies().get(hierarchyName);
+ if (hierarchy == null) {
+ for (Hierarchy hierarchy1 : cube.getHierarchies()) {
+ if (hierarchy1.getUniqueName().equals(hierarchyName)) {
+ hierarchy = hierarchy1;
+ break;
+ }
+ }
+ if (hierarchy == null) {
+ throw this.olap4jStatement.olap4jConnection.helper
+ .createException(
+ "Internal error: hierarchy '" + hierarchyName
+ + "' not found in cube '" + cube.getName()
+ + "'");
+ }
+ }
+ return hierarchy;
+ }
+
+ /**
+ * Looks up an Axis with a given name.
+ *
+ * @param axisName Name of axis
+ * @return Axis
+ */
+ private Axis lookupAxis(String axisName) {
+ if (axisName.startsWith("Axis")) {
+ final Integer ordinal =
+ Integer.valueOf(axisName.substring("Axis".length()));
+ return Axis.values()[Axis.COLUMNS.ordinal() + ordinal];
+ } else {
+ return Axis.FILTER;
+ }
+ }
+
+ public CellSetMetaData getMetaData() {
+ return metaData;
+ }
+
+ public Cell getCell(List coordinates) {
+ return getCellInternal(coordinatesToOrdinal(coordinates));
+ }
+
+ public Cell getCell(int ordinal) {
+ return getCellInternal(ordinal);
+ }
+
+ public Cell getCell(Position... positions) {
+ if (positions.length != getAxes().size()) {
+ throw new IllegalArgumentException(
+ "cell coordinates should have dimension " + getAxes().size());
+ }
+ List coords = new ArrayList(positions.length);
+ for (Position position : positions) {
+ coords.add(position.getOrdinal());
+ }
+ return getCell(coords);
+ }
+
+ /**
+ * Returns a cell given its ordinal.
+ *
+ * @param pos Ordinal
+ * @return Cell
+ * @throws IndexOutOfBoundsException if ordinal is not in range
+ */
+ private Cell getCellInternal(int pos) {
+ final Cell cell = cellMap.get(pos);
+ if (cell == null) {
+ if (pos < 0 || pos >= maxOrdinal()) {
+ throw new IndexOutOfBoundsException();
+ } else {
+ // Cell is within bounds, but is not held in the cache because
+ // it has no value. Manufacture a cell with an empty value.
+ return new XmlaOlap4jCell(
+ this, pos, null, "",
+ Collections.emptyMap());
+ }
+ }
+ return cell;
+ }
+
+ /**
+ * Returns a string describing the maximum coordinates of this cell set;
+ * for example "2, 3" for a cell set with 2 columns and 3 rows.
+ *
+ * @return description of cell set bounds
+ */
+ private String getBoundsAsString() {
+ StringBuilder buf = new StringBuilder();
+ int k = 0;
+ for (CellSetAxis axis : getAxes()) {
+ if (k++ > 0) {
+ buf.append(", ");
+ }
+ buf.append(axis.getPositionCount());
+ }
+ return buf.toString();
+ }
+
+ public List getAxes() {
+ return immutableAxisList;
+ }
+
+ public CellSetAxis getFilterAxis() {
+ return filterAxis;
+ }
+
+ /**
+ * Returns the ordinal of the last cell in this cell set. This is the
+ * product of the cardinalities of all axes.
+ *
+ * @return ordinal of last cell in cell set
+ */
+ private int maxOrdinal() {
+ int modulo = 1;
+ for (CellSetAxis axis : axisList) {
+ modulo *= axis.getPositionCount();
+ }
+ return modulo;
+ }
+
+ public List ordinalToCoordinates(int ordinal) {
+ List axes = getAxes();
+ final List list = new ArrayList(axes.size());
+ int modulo = 1;
+ for (CellSetAxis axis : axes) {
+ int prevModulo = modulo;
+ modulo *= axis.getPositionCount();
+ list.add((ordinal % modulo) / prevModulo);
+ }
+ if (ordinal < 0 || ordinal >= modulo) {
+ throw new IndexOutOfBoundsException(
+ "Cell ordinal " + ordinal
+ + ") lies outside CellSet bounds ("
+ + getBoundsAsString() + ")");
+ }
+ return list;
+ }
+
+ public int coordinatesToOrdinal(List coordinates) {
+ List axes = getAxes();
+ if (coordinates.size() != axes.size()) {
+ throw new IllegalArgumentException(
+ "Coordinates have different dimension " + coordinates.size()
+ + " than axes " + axes.size());
+ }
+ int modulo = 1;
+ int ordinal = 0;
+ int k = 0;
+ for (CellSetAxis axis : axes) {
+ final Integer coordinate = coordinates.get(k++);
+ if (coordinate < 0 || coordinate >= axis.getPositionCount()) {
+ throw new IndexOutOfBoundsException(
+ "Coordinate " + coordinate
+ + " of axis " + k
+ + " is out of range ("
+ + getBoundsAsString() + ")");
+ }
+ ordinal += coordinate * modulo;
+ modulo *= axis.getPositionCount();
+ }
+ return ordinal;
+ }
+
+ public boolean next() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void close() throws SQLException {
+ this.closed = true;
+ }
+
+ public boolean wasNull() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getString(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean getBoolean(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public byte getByte(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public short getShort(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getInt(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public long getLong(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public float getFloat(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public double getDouble(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public BigDecimal getBigDecimal(
+ int columnIndex, int scale) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public byte[] getBytes(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Date getDate(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Time getTime(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Timestamp getTimestamp(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public InputStream getAsciiStream(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public InputStream getUnicodeStream(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public InputStream getBinaryStream(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getString(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean getBoolean(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public byte getByte(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public short getShort(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getInt(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public long getLong(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public float getFloat(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public double getDouble(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public BigDecimal getBigDecimal(
+ String columnLabel, int scale) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public byte[] getBytes(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Date getDate(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Time getTime(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Timestamp getTimestamp(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public InputStream getAsciiStream(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public InputStream getUnicodeStream(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public InputStream getBinaryStream(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public SQLWarning getWarnings() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void clearWarnings() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getCursorName() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getObject(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getObject(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public int findColumn(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Reader getCharacterStream(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Reader getCharacterStream(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isBeforeFirst() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isAfterLast() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isFirst() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isLast() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void beforeFirst() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void afterLast() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean first() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean last() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getRow() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean absolute(int row) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean relative(int rows) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean previous() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setFetchDirection(int direction) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getFetchDirection() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void setFetchSize(int rows) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getFetchSize() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getType() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getConcurrency() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean rowUpdated() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean rowInserted() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean rowDeleted() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNull(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBoolean(int columnIndex, boolean x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateByte(int columnIndex, byte x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateShort(int columnIndex, short x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateInt(int columnIndex, int x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateLong(int columnIndex, long x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateFloat(int columnIndex, float x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateDouble(int columnIndex, double x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBigDecimal(
+ int columnIndex, BigDecimal x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateString(int columnIndex, String x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBytes(int columnIndex, byte x[]) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateDate(int columnIndex, Date x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateTime(int columnIndex, Time x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateTimestamp(
+ int columnIndex, Timestamp x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateAsciiStream(
+ int columnIndex, InputStream x, int length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBinaryStream(
+ int columnIndex, InputStream x, int length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateCharacterStream(
+ int columnIndex, Reader x, int length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateObject(
+ int columnIndex, Object x, int scaleOrLength) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateObject(int columnIndex, Object x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateNull(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBoolean(
+ String columnLabel, boolean x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateByte(String columnLabel, byte x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateShort(String columnLabel, short x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateInt(String columnLabel, int x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateLong(String columnLabel, long x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateFloat(String columnLabel, float x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateDouble(String columnLabel, double x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBigDecimal(
+ String columnLabel, BigDecimal x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateString(String columnLabel, String x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBytes(String columnLabel, byte x[]) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateDate(String columnLabel, Date x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateTime(String columnLabel, Time x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateTimestamp(
+ String columnLabel, Timestamp x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateAsciiStream(
+ String columnLabel, InputStream x, int length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBinaryStream(
+ String columnLabel, InputStream x, int length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateCharacterStream(
+ String columnLabel, Reader reader, int length) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateObject(
+ String columnLabel, Object x, int scaleOrLength) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateObject(String columnLabel, Object x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void insertRow() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateRow() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void deleteRow() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void refreshRow() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void cancelRowUpdates() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void moveToInsertRow() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void moveToCurrentRow() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Statement getStatement() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getObject(
+ int columnIndex, Map> map) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Ref getRef(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Blob getBlob(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Clob getClob(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Array getArray(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getObject(
+ String columnLabel, Map> map) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Ref getRef(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Blob getBlob(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Clob getClob(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Array getArray(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Date getDate(int columnIndex, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Date getDate(String columnLabel, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Time getTime(int columnIndex, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Time getTime(String columnLabel, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Timestamp getTimestamp(
+ int columnIndex, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public Timestamp getTimestamp(
+ String columnLabel, Calendar cal) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public URL getURL(int columnIndex) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public URL getURL(String columnLabel) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateRef(int columnIndex, Ref x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateRef(String columnLabel, Ref x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBlob(int columnIndex, Blob x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateBlob(String columnLabel, Blob x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateClob(int columnIndex, Clob x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateClob(String columnLabel, Clob x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateArray(int columnIndex, Array x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public void updateArray(String columnLabel, Array x) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ // implement Wrapper
+
+ public T unwrap(Class iface) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isWrapperFor(Class> iface) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Implementation of {@link Member} for a member which is not present
+ * in the cube (probably because the member is a calculated member
+ * defined in the query).
+ */
+ private static class XmlaOlap4jSurpriseMember implements Member {
+ private final Level level;
+ private final Hierarchy hierarchy;
+ private final int lnum;
+ private final String caption;
+ private final String uname;
+
+ /**
+ * Creates an XmlaOlap4jSurpriseMember.
+ *
+ * @param level Level
+ * @param hierarchy Hierarchy
+ * @param lnum Level number
+ * @param caption Caption
+ * @param uname Member unique name
+ */
+ XmlaOlap4jSurpriseMember(
+ Level level,
+ Hierarchy hierarchy,
+ int lnum,
+ String caption,
+ String uname)
+ {
+ this.level = level;
+ this.hierarchy = hierarchy;
+ this.lnum = lnum;
+ this.caption = caption;
+ this.uname = uname;
+ }
+
+ public NamedList extends Member> getChildMembers()
+ {
+ return Olap4jUtil.emptyNamedList();
+ }
+
+ public int getChildMemberCount() {
+ return 0;
+ }
+
+ public Member getParentMember() {
+ return null;
+ }
+
+ public Level getLevel() {
+ return level;
+ }
+
+ public Hierarchy getHierarchy() {
+ return hierarchy;
+ }
+
+ public Dimension getDimension() {
+ return hierarchy.getDimension();
+ }
+
+ public Type getMemberType() {
+ return Type.UNKNOWN;
+ }
+
+ public boolean isAll() {
+ return false; // FIXME
+ }
+
+ public boolean isChildOrEqualTo(Member member) {
+ return false; // FIXME
+ }
+
+ public boolean isCalculated() {
+ return false; // FIXME
+ }
+
+ public int getSolveOrder() {
+ return 0; // FIXME
+ }
+
+ public ParseTreeNode getExpression() {
+ return null;
+ }
+
+ public List getAncestorMembers() {
+ return Collections.emptyList(); // FIXME
+ }
+
+ public boolean isCalculatedInQuery() {
+ return true; // probably
+ }
+
+ public Object getPropertyValue(Property property) {
+ return null;
+ }
+
+ public String getPropertyFormattedValue(Property property) {
+ return null;
+ }
+
+ public void setProperty(Property property, Object value)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public NamedList getProperties() {
+ return Olap4jUtil.emptyNamedList();
+ }
+
+ public int getOrdinal() {
+ return -1; // FIXME
+ }
+
+ public boolean isHidden() {
+ return false;
+ }
+
+ public int getDepth() {
+ return lnum;
+ }
+
+ public Member getDataMember() {
+ return null;
+ }
+
+ public String getName() {
+ return caption;
+ }
+
+ public String getUniqueName() {
+ return uname;
+ }
+
+ public String getCaption(Locale locale) {
+ return caption;
+ }
+
+ public String getDescription(Locale locale) {
+ return null;
+ }
+ }
+}
+
+// End XmlaOlap4jCellSet.java
diff --git a/src/org/olap4j/driver/xmla/XmlaOlap4jCellSetAxisMetaData.java b/src/org/olap4j/driver/xmla/XmlaOlap4jCellSetAxisMetaData.java
index 2ad0c17..5859989 100755
--- a/src/org/olap4j/driver/xmla/XmlaOlap4jCellSetAxisMetaData.java
+++ b/src/org/olap4j/driver/xmla/XmlaOlap4jCellSetAxisMetaData.java
@@ -1,69 +1,69 @@
-/*
-// This software is subject to the terms of the Common Public License
-// Agreement, available at the following URL:
-// http://www.opensource.org/licenses/cpl.html.
-// Copyright (C) 2007-2007 Julian Hyde
-// All Rights Reserved.
-// You must accept the terms of that agreement to use this software.
-*/
-package org.olap4j.driver.xmla;
-
-import org.olap4j.Axis;
-import org.olap4j.CellSetAxisMetaData;
-import org.olap4j.impl.Olap4jUtil;
-import org.olap4j.metadata.Hierarchy;
-import org.olap4j.metadata.Property;
-
-import java.util.*;
-
-/**
- * Implementation of {@link org.olap4j.CellSetMetaData}
- * for XML/A providers.
- *
- * @author jhyde
- * @version $Id: MondrianOlap4jCellSetAxisMetaData.java 43 2007-11-21 01:57:47Z jhyde $
-* @since Nov 17, 2007
-*/
-class XmlaOlap4jCellSetAxisMetaData implements CellSetAxisMetaData {
- private final Axis axis;
- private final List hierarchyList;
- private final List propertyList;
-
- XmlaOlap4jCellSetAxisMetaData(
- XmlaOlap4jConnection olap4jConnection,
- Axis axis,
- List hierarchyList,
- List propertyList)
- {
- this.axis = axis;
- this.hierarchyList = hierarchyList;
- this.propertyList = propertyList;
- }
-
- public Axis getAxisOrdinal() {
- return axis;
- }
-
- public List getHierarchies() {
- return hierarchyList;
- }
-
- public List getProperties() {
- return Olap4jUtil.cast(propertyList);
- }
-
- XmlaOlap4jCellSetMemberProperty lookupProperty(
- String hierarchyName,
- String tag)
- {
- for (XmlaOlap4jCellSetMemberProperty property : propertyList) {
- if (property.hierarchy.getName().equals(hierarchyName)
- && property.tag.equals(tag)) {
- return property;
- }
- }
- return null;
- }
-}
-
-// End XmlaOlap4jCellSetAxisMetaData.java
+/*
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2007-2007 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.driver.xmla;
+
+import org.olap4j.Axis;
+import org.olap4j.CellSetAxisMetaData;
+import org.olap4j.impl.Olap4jUtil;
+import org.olap4j.metadata.Hierarchy;
+import org.olap4j.metadata.Property;
+
+import java.util.*;
+
+/**
+ * Implementation of {@link org.olap4j.CellSetMetaData}
+ * for XML/A providers.
+ *
+ * @author jhyde
+ * @version $Id: MondrianOlap4jCellSetAxisMetaData.java 43 2007-11-21 01:57:47Z jhyde $
+* @since Nov 17, 2007
+*/
+class XmlaOlap4jCellSetAxisMetaData implements CellSetAxisMetaData {
+ private final Axis axis;
+ private final List hierarchyList;
+ private final List propertyList;
+
+ XmlaOlap4jCellSetAxisMetaData(
+ XmlaOlap4jConnection olap4jConnection,
+ Axis axis,
+ List hierarchyList,
+ List propertyList)
+ {
+ this.axis = axis;
+ this.hierarchyList = hierarchyList;
+ this.propertyList = propertyList;
+ }
+
+ public Axis getAxisOrdinal() {
+ return axis;
+ }
+
+ public List getHierarchies() {
+ return hierarchyList;
+ }
+
+ public List getProperties() {
+ return Olap4jUtil.cast(propertyList);
+ }
+
+ XmlaOlap4jCellSetMemberProperty lookupProperty(
+ String hierarchyName,
+ String tag)
+ {
+ for (XmlaOlap4jCellSetMemberProperty property : propertyList) {
+ if (property.hierarchy.getName().equals(hierarchyName)
+ && property.tag.equals(tag)) {
+ return property;
+ }
+ }
+ return null;
+ }
+}
+
+// End XmlaOlap4jCellSetAxisMetaData.java
diff --git a/src/org/olap4j/driver/xmla/XmlaOlap4jCellSetMetaData.java b/src/org/olap4j/driver/xmla/XmlaOlap4jCellSetMetaData.java
index de1abf0..60f9bbf 100644
--- a/src/org/olap4j/driver/xmla/XmlaOlap4jCellSetMetaData.java
+++ b/src/org/olap4j/driver/xmla/XmlaOlap4jCellSetMetaData.java
@@ -1,218 +1,218 @@
-/*
-// This software is subject to the terms of the Common Public License
-// Agreement, available at the following URL:
-// http://www.opensource.org/licenses/cpl.html.
-// Copyright (C) 2007-2007 Julian Hyde
-// All Rights Reserved.
-// You must accept the terms of that agreement to use this software.
-*/
-package org.olap4j.driver.xmla;
-
-import org.olap4j.CellSetAxisMetaData;
-import org.olap4j.CellSetMetaData;
-import org.olap4j.impl.ArrayNamedListImpl;
-import org.olap4j.impl.Olap4jUtil;
-import org.olap4j.metadata.*;
-
-import java.sql.SQLException;
-import java.util.*;
-
-/**
- * Implementation of {@link org.olap4j.CellSetMetaData}
- * for XML/A providers.
- *
- * @author jhyde
- * @version $Id$
- * @since Jun 13, 2007
- */
-class XmlaOlap4jCellSetMetaData implements CellSetMetaData {
- final XmlaOlap4jCube cube;
- private final NamedList axisMetaDataList =
- new ArrayNamedListImpl() {
- protected String getName(CellSetAxisMetaData axisMetaData) {
- return axisMetaData.getAxisOrdinal().name();
- }
- };
- private final XmlaOlap4jCellSetAxisMetaData filterAxisMetaData;
- private final NamedList cellProperties =
- new ArrayNamedListImpl() {
- protected String getName(Property property) {
- return property.getName();
- }
- };
- final Map propertiesByTag;
-
- XmlaOlap4jCellSetMetaData(
- XmlaOlap4jStatement olap4jStatement,
- XmlaOlap4jCube cube,
- XmlaOlap4jCellSetAxisMetaData filterAxisMetaData,
- List axisMetaDataList,
- List cellProperties)
- {
- assert olap4jStatement != null;
- assert cube != null;
- assert filterAxisMetaData != null;
- this.cube = cube;
- this.filterAxisMetaData = filterAxisMetaData;
- this.axisMetaDataList.addAll(axisMetaDataList);
- this.propertiesByTag = new HashMap();
- for (XmlaOlap4jCellProperty cellProperty : cellProperties) {
- Property property;
- try {
- property = Property.StandardCellProperty.valueOf(
- cellProperty.propertyName);
- this.propertiesByTag.put(cellProperty.tag, property);
- } catch (IllegalArgumentException e) {
- property = cellProperty;
- this.propertiesByTag.put(property.getName(), property);
- }
- this.cellProperties.add(property);
- }
- }
-
- private XmlaOlap4jCellSetMetaData(
- XmlaOlap4jStatement olap4jStatement,
- XmlaOlap4jCube cube,
- XmlaOlap4jCellSetAxisMetaData filterAxisMetaData,
- List axisMetaDataList,
- Map propertiesByTag,
- List cellProperties)
- {
- assert olap4jStatement != null;
- assert cube != null;
- assert filterAxisMetaData != null;
- this.cube = cube;
- this.filterAxisMetaData = filterAxisMetaData;
- this.axisMetaDataList.addAll(axisMetaDataList);
- this.propertiesByTag = propertiesByTag;
- this.cellProperties.addAll(cellProperties);
- }
-
- XmlaOlap4jCellSetMetaData cloneFor(
- XmlaOlap4jPreparedStatement preparedStatement)
- {
- return new XmlaOlap4jCellSetMetaData(
- preparedStatement,
- cube,
- filterAxisMetaData,
- axisMetaDataList,
- propertiesByTag,
- cellProperties);
- }
-
- // implement CellSetMetaData
-
- public NamedList getCellProperties() {
- return Olap4jUtil.cast(cellProperties);
- }
-
- public Cube getCube() {
- return cube;
- }
-
- public NamedList getAxesMetaData() {
- return axisMetaDataList;
- }
-
- public CellSetAxisMetaData getFilterAxisMetaData() {
- return filterAxisMetaData;
- }
-
-// implement ResultSetMetaData
-
- public int getColumnCount() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean isAutoIncrement(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean isCaseSensitive(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean isSearchable(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean isCurrency(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public int isNullable(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean isSigned(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public int getColumnDisplaySize(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public String getColumnLabel(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public String getColumnName(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public String getSchemaName(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public int getPrecision(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public int getScale(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public String getTableName(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public String getCatalogName(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public int getColumnType(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public String getColumnTypeName(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean isReadOnly(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean isWritable(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean isDefinitelyWritable(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public String getColumnClassName(int column) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- // implement Wrapper
-
- public T unwrap(Class iface) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public boolean isWrapperFor(Class> iface) throws SQLException {
- throw new UnsupportedOperationException();
- }
-}
-
-// End XmlaOlap4jCellSetMetaData.java
+/*
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2007-2007 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.driver.xmla;
+
+import org.olap4j.CellSetAxisMetaData;
+import org.olap4j.CellSetMetaData;
+import org.olap4j.impl.ArrayNamedListImpl;
+import org.olap4j.impl.Olap4jUtil;
+import org.olap4j.metadata.*;
+
+import java.sql.SQLException;
+import java.util.*;
+
+/**
+ * Implementation of {@link org.olap4j.CellSetMetaData}
+ * for XML/A providers.
+ *
+ * @author jhyde
+ * @version $Id$
+ * @since Jun 13, 2007
+ */
+class XmlaOlap4jCellSetMetaData implements CellSetMetaData {
+ final XmlaOlap4jCube cube;
+ private final NamedList axisMetaDataList =
+ new ArrayNamedListImpl() {
+ protected String getName(CellSetAxisMetaData axisMetaData) {
+ return axisMetaData.getAxisOrdinal().name();
+ }
+ };
+ private final XmlaOlap4jCellSetAxisMetaData filterAxisMetaData;
+ private final NamedList cellProperties =
+ new ArrayNamedListImpl() {
+ protected String getName(Property property) {
+ return property.getName();
+ }
+ };
+ final Map propertiesByTag;
+
+ XmlaOlap4jCellSetMetaData(
+ XmlaOlap4jStatement olap4jStatement,
+ XmlaOlap4jCube cube,
+ XmlaOlap4jCellSetAxisMetaData filterAxisMetaData,
+ List axisMetaDataList,
+ List cellProperties)
+ {
+ assert olap4jStatement != null;
+ assert cube != null;
+ assert filterAxisMetaData != null;
+ this.cube = cube;
+ this.filterAxisMetaData = filterAxisMetaData;
+ this.axisMetaDataList.addAll(axisMetaDataList);
+ this.propertiesByTag = new HashMap();
+ for (XmlaOlap4jCellProperty cellProperty : cellProperties) {
+ Property property;
+ try {
+ property = Property.StandardCellProperty.valueOf(
+ cellProperty.propertyName);
+ this.propertiesByTag.put(cellProperty.tag, property);
+ } catch (IllegalArgumentException e) {
+ property = cellProperty;
+ this.propertiesByTag.put(property.getName(), property);
+ }
+ this.cellProperties.add(property);
+ }
+ }
+
+ private XmlaOlap4jCellSetMetaData(
+ XmlaOlap4jStatement olap4jStatement,
+ XmlaOlap4jCube cube,
+ XmlaOlap4jCellSetAxisMetaData filterAxisMetaData,
+ List axisMetaDataList,
+ Map propertiesByTag,
+ List cellProperties)
+ {
+ assert olap4jStatement != null;
+ assert cube != null;
+ assert filterAxisMetaData != null;
+ this.cube = cube;
+ this.filterAxisMetaData = filterAxisMetaData;
+ this.axisMetaDataList.addAll(axisMetaDataList);
+ this.propertiesByTag = propertiesByTag;
+ this.cellProperties.addAll(cellProperties);
+ }
+
+ XmlaOlap4jCellSetMetaData cloneFor(
+ XmlaOlap4jPreparedStatement preparedStatement)
+ {
+ return new XmlaOlap4jCellSetMetaData(
+ preparedStatement,
+ cube,
+ filterAxisMetaData,
+ axisMetaDataList,
+ propertiesByTag,
+ cellProperties);
+ }
+
+ // implement CellSetMetaData
+
+ public NamedList getCellProperties() {
+ return Olap4jUtil.cast(cellProperties);
+ }
+
+ public Cube getCube() {
+ return cube;
+ }
+
+ public NamedList getAxesMetaData() {
+ return axisMetaDataList;
+ }
+
+ public CellSetAxisMetaData getFilterAxisMetaData() {
+ return filterAxisMetaData;
+ }
+
+// implement ResultSetMetaData
+
+ public int getColumnCount() throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isAutoIncrement(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isCaseSensitive(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isSearchable(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isCurrency(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public int isNullable(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isSigned(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getColumnDisplaySize(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getColumnLabel(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getColumnName(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getSchemaName(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getPrecision(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getScale(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getTableName(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getCatalogName(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public int getColumnType(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getColumnTypeName(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isReadOnly(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isWritable(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isDefinitelyWritable(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getColumnClassName(int column) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ // implement Wrapper
+
+ public T unwrap(Class iface) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isWrapperFor(Class> iface) throws SQLException {
+ throw new UnsupportedOperationException();
+ }
+}
+
+// End XmlaOlap4jCellSetMetaData.java
diff --git a/src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java b/src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java
index 9375e7e..30fa025 100644
--- a/src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java
+++ b/src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java
@@ -1,1748 +1,1750 @@
-/*
-// This software is subject to the terms of the Common Public License
-// Agreement, available at the following URL:
-// http://www.opensource.org/licenses/cpl.html.
-// Copyright (C) 2007-2007 Julian Hyde
-// All Rights Reserved.
-// You must accept the terms of that agreement to use this software.
-*/
-package org.olap4j.driver.xmla;
-
-import org.olap4j.*;
-
-import static org.olap4j.driver.xmla.XmlaOlap4jUtil.*;
-
-import org.olap4j.driver.xmla.proxy.*;
-import org.olap4j.impl.*;
-import org.olap4j.mdx.ParseTreeWriter;
-import org.olap4j.mdx.SelectNode;
-import org.olap4j.mdx.parser.*;
-import org.olap4j.mdx.parser.impl.DefaultMdxParserImpl;
-import org.olap4j.metadata.*;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
-
-import java.io.*;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.sql.*;
-import java.util.*;
-import java.util.Map.*;
-import java.util.regex.*;
-
-/**
- * Implementation of {@link org.olap4j.OlapConnection}
- * for XML/A providers.
- *
- * This class has sub-classes which implement JDBC 3.0 and JDBC 4.0 APIs;
- * it is instantiated using {@link Factory#newConnection}.
- *
- * @author jhyde
- * @version $Id$
- * @since May 23, 2007
- */
-abstract class XmlaOlap4jConnection implements OlapConnection {
- /**
- * Handler for errors.
- */
- final Helper helper = new Helper();
-
- /**
- *
Current schema.
- */
- private XmlaOlap4jSchema olap4jSchema;
-
- private final XmlaOlap4jDatabaseMetaData olap4jDatabaseMetaData;
-
- private static final String CONNECT_STRING_PREFIX = "jdbc:xmla:";
-
- final Factory factory;
-
- final XmlaOlap4jProxy proxy;
-
- private boolean closed;
-
- /**
- *
URL of the HTTP server to which to send XML requests.
- */
- final URL serverUrl;
-
- private Locale locale;
- private String catalogName;
- private static final boolean DEBUG = false;
- private String roleName;
-
- /**
- *
Holds on to the provider name
- */
- private String providerName;
-
- /**
- *
Holds on to the datasource name.
- */
- private String datasourceName;
-
- /**
- * Holds the datasource name as specified by the server. Necessary because
- * some servers (such as mondrian) return both the provider
- * name and the datasource name in their response.
- *
- *
It's this value that we use inside queries, and not the jdbc
- * query value.
- */
- private String nativeDatasourceName;
- private boolean autoCommit;
- private boolean readOnly;
-
- /**
- * Name of the "DATA_SOURCE_NAME" column returned from
- * {@link org.olap4j.OlapDatabaseMetaData#getDatasources()}.
- */
- private static final String DATA_SOURCE_NAME = "DATA_SOURCE_NAME";
-
- /**
- * Name of the "PROVIDER_NAME" column returned from
- * {@link org.olap4j.OlapDatabaseMetaData#getDatasources()}.
- */
- private static final String PROVIDER_NAME = "PROVIDER_NAME";
-
- /**
- * Creates an Olap4j connection an XML/A provider.
- *
- *
This method is intentionally package-protected. The public API
- * uses the traditional JDBC {@link java.sql.DriverManager}.
- * See {@link org.olap4j.driver.xmla.XmlaOlap4jDriver} for more details.
- *
- *
Note that this constructor should make zero non-trivial calls, which
- * could cause deadlocks due to java.sql.DriverManager synchronization
- * issues.
- *
- * @pre acceptsURL(url)
- *
- * @param factory Factory
- * @param proxy Proxy object which receives XML requests
- * @param url Connect-string URL
- * @param info Additional properties
- * @throws java.sql.SQLException if there is an error
- */
- XmlaOlap4jConnection(
- Factory factory,
- XmlaOlap4jProxy proxy,
- String url,
- Properties info)
- throws SQLException
- {
- this.factory = factory;
- this.proxy = proxy;
- if (!acceptsURL(url)) {
- // This is not a URL we can handle.
- // DriverManager should not have invoked us.
- throw new AssertionError(
- "does not start with '" + CONNECT_STRING_PREFIX + "'");
- }
- Map map = parseConnectString(url, info);
-
- this.providerName = map.get(XmlaOlap4jDriver.Property.Provider.name());
- this.datasourceName = map.get(XmlaOlap4jDriver.Property.DataSource.name());
- this.catalogName = map.get(XmlaOlap4jDriver.Property.Catalog.name());
-
- // Set URL of HTTP server.
- String serverUrl = map.get(XmlaOlap4jDriver.Property.Server.name());
- if (serverUrl == null) {
- throw helper.createException("Connection property '"
- + XmlaOlap4jDriver.Property.Server.name()
- + "' must be specified");
- }
-
- // Basic authentication. Make sure the credentials passed as standard
- // JDBC parameters override any credentials already included in the URL
- // as part of the standard URL scheme.
- if (map.containsKey("user") && map.containsKey("password")) {
- serverUrl = serverUrl.replaceFirst(
- ":\\/\\/([^@]*@){0,1}",
- "://"
- .concat(map.get("user"))
- .concat(":")
- .concat(map.get("password")
- .concat("@")));
- }
-
- // Initialize the SOAP cache if needed
- initSoapCache(map);
-
- try {
- this.serverUrl = new URL(serverUrl);
- } catch (MalformedURLException e) {
- throw helper.createException(
- "Error while creating connection", e);
- }
-
- this.olap4jDatabaseMetaData =
- factory.newDatabaseMetaData(this);
- }
-
-
- /**
- * Initializes a cache object and configures it if cache
- * parameters were specified in the jdbc url.
- *
- * @param map The parameters from the jdbc url.
- * @throws OlapException Thrown when there is an error encountered
- * while creating the cache.
- */
- private void initSoapCache(Map map) throws OlapException {
-
- // Test if a SOAP cache class was defined
- if (map.containsKey(XmlaOlap4jDriver.Property.Cache.name()
- .toUpperCase()))
- {
- // Create a properties object to pass to the proxy
- // so it can configure it's cache
- Map props = new HashMap();
- // Iterate over map entries to find those related to
- // the cache config
- for (Entry entry : map.entrySet()) {
- // Check if the current entry relates to cache config.
- if (entry.getKey().startsWith(
- XmlaOlap4jDriver.Property.Cache.name().toUpperCase()
- + ".")) //$NON-NLS-1$
- {
- props.put(entry.getKey().substring(
- XmlaOlap4jDriver.Property.Cache.name()
- .length() + 1), entry.getValue());
- }
- }
-
- // Init the cache
- ((XmlaOlap4jCachedProxy) this.proxy).setCache(map, props);
- }
- }
-
-
-
- static Map parseConnectString(String url, Properties info) {
- String x = url.substring(CONNECT_STRING_PREFIX.length());
- Map map =
- ConnectStringParser.parseConnectString(x);
- for (Map.Entry entry : toMap(info).entrySet()) {
- map.put(entry.getKey(), entry.getValue());
- }
- return map;
- }
-
- static boolean acceptsURL(String url) {
- return url.startsWith(CONNECT_STRING_PREFIX);
- }
-
- /**
- * Returns the native datasource name, using the cached value if already
- * computed.
- *
- * Not part of public API.
- *
- * @return native datasource name
- * @throws OlapException if cannot find a datasource that matches
- */
- String getDataSourceInfo() throws OlapException {
- // If we already know it, return it.
- if (this.nativeDatasourceName != null) {
- return this.nativeDatasourceName;
- }
-
- ResultSet rSet = null;
- try {
- // We need to query for it
- rSet = this.olap4jDatabaseMetaData.getDatasources();
-
- // Check if the user requested a particular one.
- if (this.datasourceName != null || this.providerName != null) {
- // We iterate through the datasources
- while (rSet.next()) {
- // Get current values
- String currentDatasource = rSet.getString(DATA_SOURCE_NAME);
- String currentProvider = rSet.getString(PROVIDER_NAME);
-
- // If datasource and provider match, we got it.
- // If datasource matches but no provider is specified, we
- // got it.
- // If provider matches but no datasource specified, we
- // consider it good.
- if (currentDatasource.equals(this.datasourceName)
- && currentProvider.equals(this.providerName)
- || currentDatasource.equals(this.datasourceName)
- && this.providerName == null
- || currentProvider.equals(this.providerName)
- && this.datasourceName == null)
- {
- // Got it
- this.nativeDatasourceName = currentDatasource;
- break;
- }
- }
- } else {
- // Use first
- if (rSet.first()) {
- this.nativeDatasourceName = rSet.getString(DATA_SOURCE_NAME);
- }
- }
-
- // Throws exception to the client.
- //Tells that there are no datasource corresponding to the search criterias.
- if (this.nativeDatasourceName == null) {
- throw new OlapException("No datasource could be found.");
- }
-
- // If there is a provider
- return this.nativeDatasourceName;
- } catch (OlapException e) {
- throw e;
- } catch (SQLException e) {
- throw new OlapException("Datasource name not found.", e);
- } finally {
- try {
- if (rSet != null) {
- rSet.close();
- }
- } catch (SQLException e) {
- // ignore
- }
- }
- }
-
- public OlapStatement createStatement() {
- return new XmlaOlap4jStatement(this);
- }
-
- public PreparedStatement prepareStatement(String sql) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public CallableStatement prepareCall(String sql) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public String nativeSQL(String sql) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setAutoCommit(boolean autoCommit) throws SQLException {
- this.autoCommit = autoCommit;
- }
-
- public boolean getAutoCommit() throws SQLException {
- return autoCommit;
- }
-
- public void commit() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void rollback() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void close() throws SQLException {
- closed = true;
- }
-
- public boolean isClosed() throws SQLException {
- return closed;
- }
-
- public OlapDatabaseMetaData getMetaData() {
- return olap4jDatabaseMetaData;
- }
-
- public NamedList getCatalogs() {
- return olap4jDatabaseMetaData.getCatalogObjects();
- }
-
- public void setReadOnly(boolean readOnly) throws SQLException {
- this.readOnly = readOnly;
- }
-
- public boolean isReadOnly() throws SQLException {
- return readOnly;
- }
-
- public void setCatalog(String catalog) throws SQLException {
- this.catalogName = catalog;
- }
-
- public String getCatalog() {
- return catalogName;
- }
-
- public void setTransactionIsolation(int level) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public int getTransactionIsolation() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public SQLWarning getWarnings() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void clearWarnings() throws SQLException {
- // this driver does not support warnings, so nothing to do
- }
-
- public Statement createStatement(
- int resultSetType, int resultSetConcurrency) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public PreparedStatement prepareStatement(
- String sql,
- int resultSetType,
- int resultSetConcurrency) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public CallableStatement prepareCall(
- String sql,
- int resultSetType,
- int resultSetConcurrency) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Map> getTypeMap() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setTypeMap(Map> map) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void setHoldability(int holdability) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public int getHoldability() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Savepoint setSavepoint() throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Savepoint setSavepoint(String name) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void rollback(Savepoint savepoint) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public void releaseSavepoint(Savepoint savepoint) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public Statement createStatement(
- int resultSetType,
- int resultSetConcurrency,
- int resultSetHoldability) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public PreparedStatement prepareStatement(
- String sql,
- int resultSetType,
- int resultSetConcurrency,
- int resultSetHoldability) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public CallableStatement prepareCall(
- String sql,
- int resultSetType,
- int resultSetConcurrency,
- int resultSetHoldability) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public PreparedStatement prepareStatement(
- String sql, int autoGeneratedKeys) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public PreparedStatement prepareStatement(
- String sql, int columnIndexes[]) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- public PreparedStatement prepareStatement(
- String sql, String columnNames[]) throws SQLException {
- throw new UnsupportedOperationException();
- }
-
- // implement Wrapper
-
- public T unwrap(Class iface) throws SQLException {
- if (iface.isInstance(this)) {
- return iface.cast(this);
- }
- throw helper.createException("does not implement '" + iface + "'");
- }
-
- public boolean isWrapperFor(Class> iface) throws SQLException {
- return iface.isInstance(this);
- }
-
- // implement OlapConnection
-
- public PreparedOlapStatement prepareOlapStatement(
- String mdx)
- throws OlapException {
- return factory.newPreparedStatement(mdx, this);
- }
-
- public MdxParserFactory getParserFactory() {
- return new MdxParserFactory() {
- public MdxParser createMdxParser(OlapConnection connection) {
- return new DefaultMdxParserImpl(connection);
- }
-
- public MdxValidator createMdxValidator(OlapConnection connection) {
- return new XmlaOlap4jMdxValidator(connection);
- }
- };
- }
-
- public synchronized org.olap4j.metadata.Schema getSchema() throws OlapException {
- // initializes the olap4jSchema if necessary
- if (this.olap4jSchema == null) {
- final XmlaOlap4jCatalog catalog =
- (XmlaOlap4jCatalog)
- this.olap4jDatabaseMetaData.getCatalogObjects().get(
- catalogName);
- this.olap4jSchema = (XmlaOlap4jSchema) catalog.getSchemas()
- .get(0);
- }
- return olap4jSchema;
- }
-
- public static Map toMap(final Properties properties) {
- return new AbstractMap() {
- public Set> entrySet() {
- return Olap4jUtil.cast(properties.entrySet());
- }
- };
- }
-
- /**
- * Returns the URL which was used to create this connection.
- *
- * @return URL
- */
- String getURL() {
- throw Olap4jUtil.needToImplement(this);
- }
-
- public void setLocale(Locale locale) {
- if (locale == null) {
- throw new IllegalArgumentException("locale must not be null");
- }
- this.locale = locale;
- }
-
- public Locale getLocale() {
- if (locale == null) {
- return Locale.getDefault();
- }
- return locale;
- }
-
- public void setRoleName(String roleName) throws OlapException {
- this.roleName = roleName;
- }
-
- public String getRoleName() {
- return roleName;
- }
-
- void populateList(
- List list,
- Context context,
- MetadataRequest metadataRequest,
- Handler handler,
- Object[] restrictions) throws OlapException
- {
- String request =
- generateRequest(context, metadataRequest, restrictions);
- Element root = xxx(request);
- for (Element o : childElements(root)) {
- if (o.getLocalName().equals("row")) {
- handler.handle(o, context, list);
- }
- }
- handler.sortList(list);
- }
-
- Element xxx(String request) throws OlapException {
- byte[] bytes;
- try {
- bytes = proxy.get(serverUrl, request);
- } catch (IOException e) {
- throw helper.createException(null, e);
- }
- Document doc;
- try {
- doc = parse(bytes);
- } catch (IOException e) {
- throw helper.createException(
- "error discovering metadata", e);
- } catch (SAXException e) {
- throw helper.createException(
- "error discovering metadata", e);
- }
- //
- //
- //
- //
- //
- //
- // (see below)
- //
- //
- //
- //
- //
- final Element envelope = doc.getDocumentElement();
- if (DEBUG) System.out.println(XmlaOlap4jUtil.toString(doc,true));
- assert envelope.getLocalName().equals("Envelope");
- assert envelope.getNamespaceURI().equals(SOAP_NS);
- Element body =
- findChild(envelope, SOAP_NS, "Body");
- Element fault =
- findChild(body, SOAP_NS, "Fault");
- if (fault != null) {
- /*
-
- SOAP-ENV:Client.00HSBC01
- XMLA connection datasource not found
- Mondrian
-
-
- 00HSBC01
- The Mondrian XML: Mondrian Error:Internal
- error: no catalog named 'LOCALDB'
-
-
-
- */
- // TODO: log doc to logfile
- final Element faultstring = findChild(fault, null, "faultstring");
- String message = faultstring.getTextContent();
- throw helper.createException(
- "XMLA provider gave exception: " + message
- + "; request: " + request);
- }
- Element discoverResponse =
- findChild(body, XMLA_NS, "DiscoverResponse");
- Element returnElement =
- findChild(discoverResponse, XMLA_NS, "return");
- return findChild(returnElement, ROWSET_NS, "root");
- }
-
- /**
- * Generates a metadata request.
- *
- * The list of restrictions must have even length. Even elements must
- * be a string (the name of the restriction); odd elements must be either
- * a string (the value of the restriction) or a list of strings (multiple
- * values of the restriction)
- *
- * @param context Context
- * @param metadataRequest Metadata request
- * @param restrictions List of restrictions
- * @return XMLA SOAP request as a string.
- *
- * @throws OlapException when the query depends on a datasource name but
- * the one specified doesn't exist at the url, or there are no default
- * datasource (should use the first one)
- */
- public String generateRequest(
- Context context,
- MetadataRequest metadataRequest,
- Object[] restrictions) throws OlapException
- {
- final boolean datasourceDependentRequest =
- metadataRequest.requiresDatasourceName();
- final String catalog =
- context.olap4jConnection.getCatalog();
- final String content = "Data";
- final String encoding = proxy.getEncodingCharsetName();
- final StringBuilder buf = new StringBuilder(
- "\n"
- + "\n"
- + " \n"
- + " \n"
- + " ");
- buf.append(metadataRequest.name());
- buf.append("\n"
- + " \n"
- + " \n");
- if (restrictions.length > 0) {
- if (restrictions.length % 2 != 0) {
- throw new IllegalArgumentException();
- }
- for (int i = 0; i < restrictions.length; i += 2) {
- final String restriction = (String) restrictions[i];
- final Object o = restrictions[i + 1];
- if (o instanceof String) {
- buf.append("<").append(restriction).append(">");
- final String value = (String) o;
- buf.append(xmlEncode(value));
- buf.append("").append(restriction).append(">");
-
- } else {
- //noinspection unchecked
- List valueList = (List) o;
- for (String value : valueList) {
- buf.append("<").append(restriction).append(">");
- buf.append(xmlEncode(value));
- buf.append("").append(restriction).append(">");
- }
- }
- }
- }
- buf.append(" \n"
- + " \n"
- + " \n"
- + " \n");
-
- // Add the datasource node only if this request requires it.
- if (datasourceDependentRequest) {
- buf.append(" ");
- buf.append(xmlEncode(context.olap4jConnection.getDataSourceInfo()));
- buf.append("\n"
- + " ");
- buf.append(xmlEncode(catalog));
- buf.append("\n");
- }
-
- buf.append(" ");
- buf.append(xmlEncode(content));
- buf.append("\n"
- + " \n"
- + " \n"
- + " \n"
- + "\n"
- + "");
- return buf.toString();
- }
-
- /**
- * Encodes a string for use in an XML CDATA section.
- *
- * @param value to be xml encoded
- * @return an XML encode string or the value is not required.
- */
- private static String xmlEncode(String value) {
- value = Olap4jUtil.replace(value, "&", "&");
- value = Olap4jUtil.replace(value, "<", "<");
- value = Olap4jUtil.replace(value, ">", ">");
- value = Olap4jUtil.replace(value, "\"", """);
- value = Olap4jUtil.replace(value, "'", "'");
- return value;
- }
-
- // ~ inner classes --------------------------------------------------------
- @SuppressWarnings({"ThrowableInstanceNeverThrown"})
- static class Helper {
- OlapException createException(String msg) {
- return new OlapException(msg);
- }
-
- OlapException createException(String msg, Throwable cause) {
- return new OlapException(msg, cause);
- }
-
- OlapException createException(Cell context, String msg) {
- OlapException exception = new OlapException(msg);
- exception.setContext(context);
- return exception;
- }
-
- OlapException createException(
- Cell context, String msg, Throwable cause)
- {
- OlapException exception = new OlapException(msg, cause);
- exception.setContext(context);
- return exception;
- }
-
- public OlapException toOlapException(SQLException e) {
- if (e instanceof OlapException) {
- return (OlapException) e;
- } else {
- return new OlapException(null, e);
- }
- }
- }
-
- static class CatalogHandler
- extends HandlerImpl
- {
- public void handle(Element row, Context context, List list) {
- /*
- Example:
-
-
- FoodMart
- No description available
- California manager,No HR Cube
-
- */
- String catalogName = XmlaOlap4jUtil.stringElement(row, "CATALOG_NAME");
- // Unused: DESCRIPTION, ROLES
- list.add(
- new XmlaOlap4jCatalog(
- context.olap4jDatabaseMetaData, catalogName));
- }
- }
-
- static class CubeHandler extends HandlerImpl {
-
- public void handle(Element row, Context context,
- List list)
- throws OlapException
- {
- /*
- Example:
-
-
- FoodMart
- FoodMart
- HR
- CUBE
- true
- false
- false
- false
- FoodMart Schema - HR Cube
-
- */
- // Unused: CATALOG_NAME, SCHEMA_NAME, CUBE_TYPE,
- // IS_DRILLTHROUGH_ENABLED, IS_WRITE_ENABLED, IS_LINKABLE,
- // IS_SQL_ENABLED
- String cubeName = stringElement(row, "CUBE_NAME");
- String description = stringElement(row, "DESCRIPTION");
- list.add(
- new XmlaOlap4jCube(
- context.olap4jSchema, cubeName, description));
- }
- }
-
- static class DimensionHandler extends HandlerImpl {
- public void handle(Element row, Context context, List list) {
- /*
- Example:
-
-
- FoodMart
- FoodMart
- HR
- Department
- [Department]
- Department
- 6
- 3
- 13
- [Department]
- HR Cube - Department Dimension
- false
- false
- 0
- true
-
-
- */
- final String dimensionName =
- stringElement(row, "DIMENSION_NAME");
- final String dimensionUniqueName =
- stringElement(row, "DIMENSION_UNIQUE_NAME");
- final String dimensionCaption =
- stringElement(row, "DIMENSION_CAPTION");
- final String description =
- stringElement(row, "DESCRIPTION");
- final int dimensionType =
- integerElement(row, "DIMENSION_TYPE");
- final Dimension.Type type =
- Dimension.Type.values()[dimensionType];
- final String defaultHierarchyUniqueName =
- stringElement(row, "DEFAULT_HIERARCHY");
- list.add(
- new XmlaOlap4jDimension(
- context.olap4jCube, dimensionUniqueName, dimensionName,
- dimensionCaption, description, type,
- defaultHierarchyUniqueName));
- }
- }
-
- static class HierarchyHandler extends HandlerImpl {
- public void handle(
- Element row, Context context, List list)
- throws OlapException
- {
- /*
- Example:
-
-
- FoodMart
- FoodMart
- Sales
- [Customers]
- Customers
- [Customers]
- Customers
- 3
- 10407
- [Customers].[All Customers]
- [Customers].[All Customers]
- Sales Cube - Customers Hierarchy
- 0
- false
- false
- 0
- true
- 9
- true
- false
-
-
- */
- final String dimensionUniqueName =
- stringElement(row, "DIMENSION_UNIQUE_NAME");
- final XmlaOlap4jDimension dimension =
- context.olap4jCube.dimensionsByUname.get(dimensionUniqueName);
- final String hierarchyName =
- stringElement(row, "HIERARCHY_NAME");
- final String hierarchyUniqueName =
- stringElement(row, "HIERARCHY_UNIQUE_NAME");
- final String hierarchyCaption =
- stringElement(row, "HIERARCHY_CAPTION");
- final String description =
- stringElement(row, "DESCRIPTION");
- final String allMember =
- stringElement(row, "ALL_MEMBER");
- final String defaultMemberUniqueName =
- stringElement(row, "DEFAULT_MEMBER");
- list.add(
- new XmlaOlap4jHierarchy(
- context.getDimension(row), hierarchyUniqueName,
- hierarchyName, hierarchyCaption, description,
- allMember != null, defaultMemberUniqueName));
- }
- }
-
- static class LevelHandler extends HandlerImpl {
- public void handle(Element row, Context context, List list) {
- /*
- Example:
-
-
- FoodMart
- FoodMart
- Sales
- [Customers]
- [Customers]
- (All)
- [Customers].[(All)]
- (All)
- 0
- 1
- 1
- 0
- 3
- true
- Sales Cube - Customers Hierarchy(All) Level
-
-
- */
- final String levelName =
- stringElement(row, "LEVEL_NAME");
- final String levelUniqueName =
- stringElement(row, "LEVEL_UNIQUE_NAME");
- final String levelCaption =
- stringElement(row, "LEVEL_CAPTION");
- final String description =
- stringElement(row, "DESCRIPTION");
- final int levelNumber =
- integerElement(row, "LEVEL_NUMBER");
- final Level.Type levelType =
- Level.Type.forXmlaOrdinal(integerElement(row, "LEVEL_TYPE"));
- final int levelCardinality =
- integerElement(row, "LEVEL_CARDINALITY");
- list.add(
- new XmlaOlap4jLevel(
- context.getHierarchy(row), levelUniqueName, levelName,
- levelCaption, description, levelNumber, levelType,
- levelCardinality));
- }
- }
-
- static class MeasureHandler extends HandlerImpl {
- public void handle(Element row, Context context, List list)
- throws OlapException {
- /*
- Example:
-
-
- FoodMart
- FoodMart
- Sales
- Profit
- [Measures].[Profit]
- Profit
- 127
- 130
- true
- Sales Cube - Profit Member
-
-
- */
- final String measureName =
- stringElement(row, "MEASURE_NAME");
- final String measureUniqueName =
- stringElement(row, "MEASURE_UNIQUE_NAME");
- final String measureCaption =
- stringElement(row, "MEASURE_CAPTION");
- final String description =
- stringElement(row, "DESCRIPTION");
- final Measure.Aggregator measureAggregator =
- Measure.Aggregator.forXmlaOrdinal(
- integerElement(row, "MEASURE_AGGREGATOR"));
- final Datatype datatype =
- Datatype.forXmlaOrdinal(
- integerElement(row, "DATA_TYPE"));
- final boolean measureIsVisible =
- booleanElement(row, "MEASURE_IS_VISIBLE");
- // REVIEW: We're making a lot of assumptions about where Measures
- // live.
- final XmlaOlap4jLevel measuresLevel =
- (XmlaOlap4jLevel)
- context.getCube(row).getHierarchies().get("Measures")
- .getLevels().get(0);
-
- // Every measure is a member. MDSCHEMA_MEASURES does not return all
- // properties of measures, so lookup the corresponding member. In
- // particular, we need the ordinal.
- if (list.isEmpty()) {
- // First call this method, ask for all members of the measures
- // level. This should ensures that we get all members in one
- // round trip.
- final List measureMembers = measuresLevel.getMembers();
- Olap4jUtil.discard(measureMembers);
- }
- Member member =
- context.getCube(row).getMetadataReader()
- .lookupMemberByUniqueName(
- measureUniqueName);
- final int ordinal;
- if (member != null) {
- ordinal = member.getOrdinal();
- } else {
- ordinal = -1;
- }
-
- list.add(
- new XmlaOlap4jMeasure(
- measuresLevel, measureUniqueName, measureName,
- measureCaption, description, null, measureAggregator,
- datatype, measureIsVisible, ordinal));
- }
-
- public void sortList(List list) {
- Collections.sort(
- list,
- new Comparator() {
- public int compare(
- XmlaOlap4jMeasure o1,
- XmlaOlap4jMeasure o2)
- {
- return o1.getOrdinal() - o2.getOrdinal();
- }
- }
- );
- }
- }
-
- static class MemberHandler extends HandlerImpl {
- public void handle(Element row, Context context, List list) {
- /*
- Example:
-
-
- FoodMart
- FoodMart
- Sales
- [Gender]
- [Gender]
- [Gender].[Gender]
- 1
- 1
- F
- [Gender].[All Gender].[F]
- 1
- F
- 0
- 0
- [Gender].[All Gender]
- 1
- 1
-
-
- */
- int levelNumber = integerElement(row, "LEVEL_NUMBER");
- int memberOrdinal = integerElement(row, "MEMBER_ORDINAL");
- String memberUniqueName =
- stringElement(row, "MEMBER_UNIQUE_NAME");
- String memberName =
- stringElement(row, "MEMBER_NAME");
- String parentUniqueName =
- stringElement(row, "PARENT_UNIQUE_NAME");
- Member.Type memberType =
- Member.Type.values()[
- integerElement(row, "MEMBER_TYPE")];
- String memberCaption =
- stringElement(row, "MEMBER_CAPTION");
- int childrenCardinality =
- integerElement(row, "CHILDREN_CARDINALITY");
- // If this member is a measure, we want to return an object that
- // implements the Measure interface to all API calls. But we also
- // need to retrieve the properties that occur in MDSCHEMA_MEMBERS
- // that are not available in MDSCHEMA_MEASURES, so we create a
- // member for internal use.
- list.add(
- new XmlaOlap4jMember(
- context.getLevel(row), memberUniqueName, memberName,
- memberCaption, "", parentUniqueName, memberType,
- childrenCardinality, memberOrdinal));
- }
- }
-
- static class NamedSetHandler extends HandlerImpl {
- public void handle(Element row, Context context, List list) {
- /*
- Example:
-
-
- FoodMart
- FoodMart
- Warehouse
- [Top Sellers]
- 1
-
-
- */
- final String setName =
- stringElement(row, "SET_NAME");
- list.add(
- new XmlaOlap4jNamedSet(
- context.getCube(row), setName));
- }
- }
-
- static class SchemaHandler extends HandlerImpl {
- public void handle(Element row, Context context, List list) throws OlapException {
- /*
-
- LOCALDB
- FoodMart
- dbo
-
- */
- String schemaName = stringElement(row, "SCHEMA_NAME");
- list.add(
- new XmlaOlap4jSchema(
- context.getCatalog(row),
- schemaName));
- }
- }
-
- static class CatalogSchemaHandler extends HandlerImpl {
-
- private String catalogName;
-
- public CatalogSchemaHandler(String catalogName) {
- super();
- if (catalogName == null)
- throw new RuntimeException("The CatalogSchemaHandler handler requires a catalog name.");
- this.catalogName = catalogName;
- }
-
- public void handle(Element row, Context context, List list) throws OlapException
- {
- /*
-
- CatalogName
- FoodMart
- dbo
-
- */
-
- /*
- * We are looking for a schema name from the cubes query restricted on the
- * catalog name. Some servers don't support nor include the SCHEMA_NAME column
- * in it's response. If it's null, we convert it to an empty string as to not cause
- * problems later on.
- */
-
- String schemaName = stringElement(row, "SCHEMA_NAME");
- String catalogName = stringElement(row, "CATALOG_NAME");
-
- if (this.catalogName.equals(catalogName)) {
- list.add(
- new XmlaOlap4jSchema(
- context.getCatalog(row),
- (schemaName == null) ? "" : schemaName));
- }
- }
- }
-
- static class PropertyHandler extends HandlerImpl {
- public void handle(
- Element row,
- Context context, List list) throws OlapException
- {
- /*
- Example:
-
-
- FoodMart
- FoodMart
- HR
- [Store]
- [Store]
- [Store].[Store Name]
- Store Manager
- Store Manager
- 1
- 130
- 0
- HR Cube - Store Hierarchy - Store
- Name Level - Store Manager Property
-
- */
- String cubeName = stringElement(row, "CUBE_NAME");
- String description = stringElement(row, "DESCRIPTION");
- String uniqueName = stringElement(row, "DESCRIPTION");
- String caption = stringElement(row, "PROPERTY_CAPTION");
- String name = stringElement(row, "PROPERTY_NAME");
- Datatype dataType =
- Datatype.forXmlaOrdinal(
- integerElement(row, "DATA_TYPE"));
- final Integer contentTypeOrdinal =
- integerElement(row, "PROPERTY_CONTENT_TYPE");
- Property.ContentType contentType =
- contentTypeOrdinal == null
- ? null
- : Property.ContentType.forXmlaOrdinal(contentTypeOrdinal);
- int propertyType = integerElement(row, "PROPERTY_TYPE");
- Set type =
- Property.TypeFlag.forMask(propertyType);
- list.add(
- new XmlaOlap4jProperty(
- uniqueName, name, caption, description, dataType, type,
- contentType));
- }
- }
-
- /**
- * Callback for converting XMLA results into metadata elements.
- */
- interface Handler {
- /**
- * 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
- *
- * @throws OlapException on error
- */
- void handle(
- Element row,
- Context context,
- List list) throws OlapException;
-
- /**
- * Sorts a list of metadata elements.
- *
- * For most element types, the order returned by XMLA is correct, and
- * this method will no-op.
- *
- * @param list List of metadata elements
- */
- void sortList(List list);
- }
-
- static abstract class HandlerImpl implements Handler {
- public void sortList(List list) {
- // do nothing - assume XMLA returned list in correct order
- }
-
- }
-
- static class Context {
- final XmlaOlap4jConnection olap4jConnection;
- final XmlaOlap4jDatabaseMetaData olap4jDatabaseMetaData;
- final XmlaOlap4jCatalog olap4jCatalog;
- final XmlaOlap4jSchema olap4jSchema;
- final XmlaOlap4jCube olap4jCube;
- final XmlaOlap4jDimension olap4jDimension;
- final XmlaOlap4jHierarchy olap4jHierarchy;
- final XmlaOlap4jLevel olap4jLevel;
-
- /**
- * Creates a Context.
- *
- * @param olap4jConnection Connection (must not be null)
- * @param olap4jDatabaseMetaData DatabaseMetaData (may be null)
- * @param olap4jCatalog Catalog (may be null if DatabaseMetaData is null)
- * @param olap4jSchema Schema (may be null if Catalog is null)
- * @param olap4jCube Cube (may be null if Schema is null)
- * @param olap4jDimension Dimension (may be null if Cube is null)
- * @param olap4jHierarchy Hierarchy (may be null if Dimension is null)
- * @param olap4jLevel Level (may be null if Hierarchy is null)
- */
- Context(
- XmlaOlap4jConnection olap4jConnection,
- XmlaOlap4jDatabaseMetaData olap4jDatabaseMetaData,
- XmlaOlap4jCatalog olap4jCatalog,
- XmlaOlap4jSchema olap4jSchema,
- XmlaOlap4jCube olap4jCube,
- XmlaOlap4jDimension olap4jDimension,
- XmlaOlap4jHierarchy olap4jHierarchy,
- XmlaOlap4jLevel olap4jLevel)
- {
- this.olap4jConnection = olap4jConnection;
- this.olap4jDatabaseMetaData = olap4jDatabaseMetaData;
- this.olap4jCatalog = olap4jCatalog;
- this.olap4jSchema = olap4jSchema;
- this.olap4jCube = olap4jCube;
- this.olap4jDimension = olap4jDimension;
- this.olap4jHierarchy = olap4jHierarchy;
- this.olap4jLevel = olap4jLevel;
- assert (olap4jDatabaseMetaData != null || olap4jCatalog == null)
- && (olap4jCatalog != null || olap4jSchema == null)
- && (olap4jSchema != null || olap4jCube == null)
- && (olap4jCube != null || olap4jDimension == null)
- && (olap4jDimension != null || olap4jHierarchy == null)
- && (olap4jHierarchy != null || olap4jLevel == null);
- }
-
- /**
- * Shorthand way to create a Context at Cube level or finer.
- *
- * @param olap4jCube Cube (must not be null)
- * @param olap4jDimension Dimension (may be null)
- * @param olap4jHierarchy Hierarchy (may be null if Dimension is null)
- * @param olap4jLevel Level (may be null if Hierarchy is null)
- */
- Context(
- XmlaOlap4jCube olap4jCube,
- XmlaOlap4jDimension olap4jDimension,
- XmlaOlap4jHierarchy olap4jHierarchy,
- XmlaOlap4jLevel olap4jLevel)
- {
- this(
- olap4jCube.olap4jSchema.olap4jCatalog.olap4jDatabaseMetaData
- .olap4jConnection,
- olap4jCube.olap4jSchema.olap4jCatalog.olap4jDatabaseMetaData,
- olap4jCube.olap4jSchema.olap4jCatalog,
- olap4jCube.olap4jSchema,
- olap4jCube,
- olap4jDimension,
- olap4jHierarchy,
- olap4jLevel);
- }
-
- /**
- * Shorthand way to create a Context at Level level.
- *
- * @param olap4jLevel Level (must not be null)
- */
- Context(XmlaOlap4jLevel olap4jLevel)
- {
- this(
- olap4jLevel.olap4jHierarchy.olap4jDimension.olap4jCube,
- olap4jLevel.olap4jHierarchy.olap4jDimension,
- olap4jLevel.olap4jHierarchy,
- olap4jLevel);
- }
-
- XmlaOlap4jHierarchy getHierarchy(Element row) {
- if (olap4jHierarchy != null) {
- return olap4jHierarchy;
- }
- final String hierarchyUniqueName =
- stringElement(row, "HIERARCHY_UNIQUE_NAME");
- return getCube(row).hierarchiesByUname.get(hierarchyUniqueName);
- }
-
- XmlaOlap4jCube getCube(Element row) {
- if (olap4jCube != null) {
- return olap4jCube;
- }
- throw new UnsupportedOperationException(); // todo:
- }
-
- XmlaOlap4jDimension getDimension(Element row) {
- if (olap4jDimension != null) {
- return olap4jDimension;
- }
- final String dimensionUniqueName =
- stringElement(row, "DIMENSION_UNIQUE_NAME");
- return getCube(row).dimensionsByUname.get(dimensionUniqueName);
- }
-
- public XmlaOlap4jLevel getLevel(Element row) {
- if (olap4jLevel != null) {
- return olap4jLevel;
- }
- final String levelUniqueName =
- stringElement(row, "LEVEL_UNIQUE_NAME");
- return getCube(row).levelsByUname.get(levelUniqueName);
- }
-
- public XmlaOlap4jCatalog getCatalog(Element row) throws OlapException {
- if (olap4jCatalog != null) {
- return olap4jCatalog;
- }
- final String catalogName =
- stringElement(row, "CATALOG_NAME");
- return (XmlaOlap4jCatalog) olap4jConnection.getCatalogs().get(
- catalogName);
- }
- }
-
- enum MetadataRequest {
- DISCOVER_DATASOURCES(
- new MetadataColumn("DataSourceName"),
- new MetadataColumn("DataSourceDescription"),
- new MetadataColumn("URL"),
- new MetadataColumn("DataSourceInfo"),
- new MetadataColumn("ProviderName"),
- new MetadataColumn("ProviderType"),
- new MetadataColumn("AuthenticationMode")),
- DISCOVER_SCHEMA_ROWSETS(
- new MetadataColumn("SchemaName"),
- new MetadataColumn("SchemaGuid"),
- new MetadataColumn("Restrictions"),
- new MetadataColumn("Description")),
- DISCOVER_ENUMERATORS(
- new MetadataColumn("EnumName"),
- new MetadataColumn("EnumDescription"),
- new MetadataColumn("EnumType"),
- new MetadataColumn("ElementName"),
- new MetadataColumn("ElementDescription"),
- new MetadataColumn("ElementValue")),
- DISCOVER_PROPERTIES(
- new MetadataColumn("PropertyName"),
- new MetadataColumn("PropertyDescription"),
- new MetadataColumn("PropertyType"),
- new MetadataColumn("PropertyAccessType"),
- new MetadataColumn("IsRequired"),
- new MetadataColumn("Value")),
- DISCOVER_KEYWORDS(
- new MetadataColumn("Keyword")),
- DISCOVER_LITERALS(
- new MetadataColumn("LiteralName"),
- new MetadataColumn("LiteralValue"),
- new MetadataColumn("LiteralInvalidChars"),
- new MetadataColumn("LiteralInvalidStartingChars"),
- new MetadataColumn("LiteralMaxLength")),
- DBSCHEMA_CATALOGS(
- new MetadataColumn("CATALOG_NAME"),
- new MetadataColumn("DESCRIPTION"),
- new MetadataColumn("ROLES"),
- new MetadataColumn("DATE_MODIFIED")),
- DBSCHEMA_COLUMNS(
- new MetadataColumn("TABLE_CATALOG"),
- new MetadataColumn("TABLE_SCHEMA"),
- new MetadataColumn("TABLE_NAME"),
- new MetadataColumn("COLUMN_NAME"),
- new MetadataColumn("ORDINAL_POSITION"),
- new MetadataColumn("COLUMN_HAS_DEFAULT"),
- new MetadataColumn("COLUMN_FLAGS"),
- new MetadataColumn("IS_NULLABLE"),
- new MetadataColumn("DATA_TYPE"),
- new MetadataColumn("CHARACTER_MAXIMUM_LENGTH"),
- new MetadataColumn("CHARACTER_OCTET_LENGTH"),
- new MetadataColumn("NUMERIC_PRECISION"),
- new MetadataColumn("NUMERIC_SCALE")),
- DBSCHEMA_PROVIDER_TYPES(
- new MetadataColumn("TYPE_NAME"),
- new MetadataColumn("DATA_TYPE"),
- new MetadataColumn("COLUMN_SIZE"),
- new MetadataColumn("LITERAL_PREFIX"),
- new MetadataColumn("LITERAL_SUFFIX"),
- new MetadataColumn("IS_NULLABLE"),
- new MetadataColumn("CASE_SENSITIVE"),
- new MetadataColumn("SEARCHABLE"),
- new MetadataColumn("UNSIGNED_ATTRIBUTE"),
- new MetadataColumn("FIXED_PREC_SCALE"),
- new MetadataColumn("AUTO_UNIQUE_VALUE"),
- new MetadataColumn("IS_LONG"),
- new MetadataColumn("BEST_MATCH")),
- DBSCHEMA_TABLES(
- new MetadataColumn("TABLE_CATALOG"),
- new MetadataColumn("TABLE_SCHEMA"),
- new MetadataColumn("TABLE_NAME"),
- new MetadataColumn("TABLE_TYPE"),
- new MetadataColumn("TABLE_GUID"),
- new MetadataColumn("DESCRIPTION"),
- new MetadataColumn("TABLE_PROPID"),
- new MetadataColumn("DATE_CREATED"),
- new MetadataColumn("DATE_MODIFIED")),
- DBSCHEMA_TABLES_INFO(
- new MetadataColumn("TABLE_CATALOG"),
- new MetadataColumn("TABLE_SCHEMA"),
- new MetadataColumn("TABLE_NAME"),
- new MetadataColumn("TABLE_TYPE"),
- new MetadataColumn("TABLE_GUID"),
- new MetadataColumn("BOOKMARKS"),
- new MetadataColumn("BOOKMARK_TYPE"),
- new MetadataColumn("BOOKMARK_DATATYPE"),
- new MetadataColumn("BOOKMARK_MAXIMUM_LENGTH"),
- new MetadataColumn("BOOKMARK_INFORMATION"),
- new MetadataColumn("TABLE_VERSION"),
- new MetadataColumn("CARDINALITY"),
- new MetadataColumn("DESCRIPTION"),
- new MetadataColumn("TABLE_PROPID")),
- DBSCHEMA_SCHEMATA(
- new MetadataColumn("CATALOG_NAME"),
- new MetadataColumn("SCHEMA_NAME"),
- new MetadataColumn("SCHEMA_OWNER")),
- MDSCHEMA_ACTIONS(
- new MetadataColumn("SCHEMA_NAME"),
- new MetadataColumn("CUBE_NAME"),
- new MetadataColumn("ACTION_NAME"),
- new MetadataColumn("COORDINATE"),
- new MetadataColumn("COORDINATE_TYPE")),
- MDSCHEMA_CUBES(
- new MetadataColumn("CATALOG_NAME"),
- new MetadataColumn("SCHEMA_NAME"),
- new MetadataColumn("CUBE_NAME"),
- new MetadataColumn("CUBE_TYPE"),
- new MetadataColumn("CUBE_GUID"),
- new MetadataColumn("CREATED_ON"),
- new MetadataColumn("LAST_SCHEMA_UPDATE"),
- new MetadataColumn("SCHEMA_UPDATED_BY"),
- new MetadataColumn("LAST_DATA_UPDATE"),
- new MetadataColumn("DATA_UPDATED_BY"),
- new MetadataColumn("IS_DRILLTHROUGH_ENABLED"),
- new MetadataColumn("IS_WRITE_ENABLED"),
- new MetadataColumn("IS_LINKABLE"),
- new MetadataColumn("IS_SQL_ENABLED"),
- new MetadataColumn("DESCRIPTION")),
- MDSCHEMA_DIMENSIONS(
- new MetadataColumn("CATALOG_NAME"),
- new MetadataColumn("SCHEMA_NAME"),
- new MetadataColumn("CUBE_NAME"),
- new MetadataColumn("DIMENSION_NAME"),
- new MetadataColumn("DIMENSION_UNIQUE_NAME"),
- new MetadataColumn("DIMENSION_GUID"),
- new MetadataColumn("DIMENSION_CAPTION"),
- new MetadataColumn("DIMENSION_ORDINAL"),
- new MetadataColumn("DIMENSION_TYPE"),
- new MetadataColumn("DIMENSION_CARDINALITY"),
- new MetadataColumn("DEFAULT_HIERARCHY"),
- new MetadataColumn("DESCRIPTION"),
- new MetadataColumn("IS_VIRTUAL"),
- new MetadataColumn("IS_READWRITE"),
- new MetadataColumn("DIMENSION_UNIQUE_SETTINGS"),
- new MetadataColumn("DIMENSION_MASTER_UNIQUE_NAME"),
- new MetadataColumn("DIMENSION_IS_VISIBLE")),
- MDSCHEMA_FUNCTIONS(
- new MetadataColumn("FUNCTION_NAME"),
- new MetadataColumn("DESCRIPTION"),
- new MetadataColumn("PARAMETER_LIST"),
- new MetadataColumn("RETURN_TYPE"),
- new MetadataColumn("ORIGIN"),
- new MetadataColumn("INTERFACE_NAME"),
- new MetadataColumn("LIBRARY_NAME"),
- new MetadataColumn("CAPTION")),
- MDSCHEMA_HIERARCHIES(
- new MetadataColumn("CATALOG_NAME"),
- new MetadataColumn("SCHEMA_NAME"),
- new MetadataColumn("CUBE_NAME"),
- new MetadataColumn("DIMENSION_UNIQUE_NAME"),
- new MetadataColumn("HIERARCHY_NAME"),
- new MetadataColumn("HIERARCHY_UNIQUE_NAME"),
- new MetadataColumn("HIERARCHY_GUID"),
- new MetadataColumn("HIERARCHY_CAPTION"),
- new MetadataColumn("DIMENSION_TYPE"),
- new MetadataColumn("HIERARCHY_CARDINALITY"),
- new MetadataColumn("DEFAULT_MEMBER"),
- new MetadataColumn("ALL_MEMBER"),
- new MetadataColumn("DESCRIPTION"),
- new MetadataColumn("STRUCTURE"),
- new MetadataColumn("IS_VIRTUAL"),
- new MetadataColumn("IS_READWRITE"),
- new MetadataColumn("DIMENSION_UNIQUE_SETTINGS"),
- new MetadataColumn("DIMENSION_IS_VISIBLE"),
- new MetadataColumn("HIERARCHY_ORDINAL"),
- new MetadataColumn("DIMENSION_IS_SHARED"),
- new MetadataColumn("PARENT_CHILD")),
- MDSCHEMA_LEVELS(
- new MetadataColumn("CATALOG_NAME"),
- new MetadataColumn("SCHEMA_NAME"),
- new MetadataColumn("CUBE_NAME"),
- new MetadataColumn("DIMENSION_UNIQUE_NAME"),
- new MetadataColumn("HIERARCHY_UNIQUE_NAME"),
- new MetadataColumn("LEVEL_NAME"),
- new MetadataColumn("LEVEL_UNIQUE_NAME"),
- new MetadataColumn("LEVEL_GUID"),
- new MetadataColumn("LEVEL_CAPTION"),
- new MetadataColumn("LEVEL_NUMBER"),
- new MetadataColumn("LEVEL_CARDINALITY"),
- new MetadataColumn("LEVEL_TYPE"),
- new MetadataColumn("CUSTOM_ROLLUP_SETTINGS"),
- new MetadataColumn("LEVEL_UNIQUE_SETTINGS"),
- new MetadataColumn("LEVEL_IS_VISIBLE"),
- new MetadataColumn("DESCRIPTION")),
- MDSCHEMA_MEASURES(
- new MetadataColumn("CATALOG_NAME"),
- new MetadataColumn("SCHEMA_NAME"),
- new MetadataColumn("CUBE_NAME"),
- new MetadataColumn("MEASURE_NAME"),
- new MetadataColumn("MEASURE_UNIQUE_NAME"),
- new MetadataColumn("MEASURE_CAPTION"),
- new MetadataColumn("MEASURE_GUID"),
- new MetadataColumn("MEASURE_AGGREGATOR"),
- new MetadataColumn("DATA_TYPE"),
- new MetadataColumn("MEASURE_IS_VISIBLE"),
- new MetadataColumn("LEVELS_LIST"),
- new MetadataColumn("DESCRIPTION")),
- MDSCHEMA_MEMBERS(
- new MetadataColumn("CATALOG_NAME"),
- new MetadataColumn("SCHEMA_NAME"),
- new MetadataColumn("CUBE_NAME"),
- new MetadataColumn("DIMENSION_UNIQUE_NAME"),
- new MetadataColumn("HIERARCHY_UNIQUE_NAME"),
- new MetadataColumn("LEVEL_UNIQUE_NAME"),
- new MetadataColumn("LEVEL_NUMBER"),
- new MetadataColumn("MEMBER_ORDINAL"),
- new MetadataColumn("MEMBER_NAME"),
- new MetadataColumn("MEMBER_UNIQUE_NAME"),
- new MetadataColumn("MEMBER_TYPE"),
- new MetadataColumn("MEMBER_GUID"),
- new MetadataColumn("MEMBER_CAPTION"),
- new MetadataColumn("CHILDREN_CARDINALITY"),
- new MetadataColumn("PARENT_LEVEL"),
- new MetadataColumn("PARENT_UNIQUE_NAME"),
- new MetadataColumn("PARENT_COUNT"),
- new MetadataColumn("TREE_OP"),
- new MetadataColumn("DEPTH")),
- MDSCHEMA_PROPERTIES(
- new MetadataColumn("CATALOG_NAME"),
- new MetadataColumn("SCHEMA_NAME"),
- new MetadataColumn("CUBE_NAME"),
- new MetadataColumn("DIMENSION_UNIQUE_NAME"),
- new MetadataColumn("HIERARCHY_UNIQUE_NAME"),
- new MetadataColumn("LEVEL_UNIQUE_NAME"),
- new MetadataColumn("MEMBER_UNIQUE_NAME"),
- new MetadataColumn("PROPERTY_NAME"),
- new MetadataColumn("PROPERTY_CAPTION"),
- new MetadataColumn("PROPERTY_TYPE"),
- new MetadataColumn("DATA_TYPE"),
- new MetadataColumn("PROPERTY_CONTENT_TYPE"),
- new MetadataColumn("DESCRIPTION")),
- MDSCHEMA_SETS(
- new MetadataColumn("CATALOG_NAME"),
- new MetadataColumn("SCHEMA_NAME"),
- new MetadataColumn("CUBE_NAME"),
- new MetadataColumn("SET_NAME"),
- new MetadataColumn("SCOPE"));
-
- final List columns;
-
- MetadataRequest(MetadataColumn... columns) {
- if (name().equals("DBSCHEMA_CATALOGS")) {
- // DatabaseMetaData.getCatalogs() is defined by JDBC not XMLA,
- // so has just one column. Ignore the 4 columns from XMLA.
- columns = new MetadataColumn[] {
- new MetadataColumn("CATALOG_NAME", "TABLE_CAT")
- };
- } else if (name().equals("DBSCHEMA_SCHEMATA")) {
- // DatabaseMetaData.getCatalogs() is defined by JDBC not XMLA,
- // so has just one column. Ignore the 4 columns from XMLA.
- columns = new MetadataColumn[] {
- new MetadataColumn("SCHEMA_NAME", "TABLE_SCHEM"),
- new MetadataColumn("CATALOG_NAME", "TABLE_CAT")
- };
- }
- this.columns =
- Collections.unmodifiableList(
- Arrays.asList(columns));
- }
-
- /**
- * Returns whether this request requires a
- * {@code <DatasourceName>} element.
- *
- * @return whether this request requires a DatasourceName element
- */
- public boolean requiresDatasourceName() {
- return this != DISCOVER_DATASOURCES;
- }
- }
-
- private static final Pattern LOWERCASE_PATTERN = Pattern.compile(".*[a-z].*");
-
- static class MetadataColumn {
- final String name;
- final String xmlaName;
-
- MetadataColumn(String xmlaName, String name) {
- this.xmlaName = xmlaName;
- this.name = name;
- }
-
- MetadataColumn(String xmlaName) {
- this.xmlaName = xmlaName;
- String name = xmlaName;
- if (LOWERCASE_PATTERN.matcher(name).matches()) {
- name = Olap4jUtil.camelToUpper(name);
- }
- // VALUE is a SQL reserved word
- if (name.equals("VALUE")) {
- name = "PROPERTY_VALUE";
- }
- this.name = name;
- }
- }
-
- private static class XmlaOlap4jMdxValidator implements MdxValidator {
- private final OlapConnection connection;
-
- XmlaOlap4jMdxValidator(OlapConnection connection) {
- this.connection = connection;
- }
-
- public SelectNode validateSelect(SelectNode selectNode) throws OlapException {
- StringWriter sw = new StringWriter();
- selectNode.unparse(new ParseTreeWriter(new PrintWriter(sw)));
- String mdx = sw.toString();
- final XmlaOlap4jConnection olap4jConnection =
- (XmlaOlap4jConnection) connection;
- return selectNode;
- }
- }
-}
-
-// End XmlaOlap4jConnection.java
+/*
+// This software is subject to the terms of the Common Public License
+// Agreement, available at the following URL:
+// http://www.opensource.org/licenses/cpl.html.
+// Copyright (C) 2007-2007 Julian Hyde
+// All Rights Reserved.
+// You must accept the terms of that agreement to use this software.
+*/
+package org.olap4j.driver.xmla;
+
+import org.olap4j.*;
+
+import static org.olap4j.driver.xmla.XmlaOlap4jUtil.*;
+
+import org.olap4j.driver.xmla.proxy.*;
+import org.olap4j.impl.*;
+import org.olap4j.mdx.ParseTreeWriter;
+import org.olap4j.mdx.SelectNode;
+import org.olap4j.mdx.parser.*;
+import org.olap4j.mdx.parser.impl.DefaultMdxParserImpl;
+import org.olap4j.metadata.*;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+import java.io.*;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.sql.*;
+import java.util.*;
+import java.util.Map.*;
+import java.util.regex.*;
+
+/**
+ * Implementation of {@link org.olap4j.OlapConnection}
+ * for XML/A providers.
+ *
+ * This class has sub-classes which implement JDBC 3.0 and JDBC 4.0 APIs;
+ * it is instantiated using {@link Factory#newConnection}.
+ *
+ * @author jhyde
+ * @version $Id$
+ * @since May 23, 2007
+ */
+abstract class XmlaOlap4jConnection implements OlapConnection {
+ /**
+ * Handler for errors.
+ */
+ final Helper helper = new Helper();
+
+ /**
+ *
Current schema.
+ */
+ private XmlaOlap4jSchema olap4jSchema;
+
+ private final XmlaOlap4jDatabaseMetaData olap4jDatabaseMetaData;
+
+ private static final String CONNECT_STRING_PREFIX = "jdbc:xmla:";
+
+ final Factory factory;
+
+ final XmlaOlap4jProxy proxy;
+
+ private boolean closed;
+
+ /**
+ *
URL of the HTTP server to which to send XML requests.
+ */
+ final URL serverUrl;
+
+ private Locale locale;
+ private String catalogName;
+ private static final boolean DEBUG = false;
+ private String roleName;
+
+ /**
+ *
Holds on to the provider name
+ */
+ private String providerName;
+
+ /**
+ *
Holds on to the datasource name.
+ */
+ private String datasourceName;
+
+ /**
+ * Holds the datasource name as specified by the server. Necessary because
+ * some servers (such as mondrian) return both the provider
+ * name and the datasource name in their response.
+ *
+ *
It's this value that we use inside queries, and not the jdbc
+ * query value.
+ */
+ private String nativeDatasourceName;
+ private boolean autoCommit;
+ private boolean readOnly;
+
+ /**
+ * Name of the "DATA_SOURCE_NAME" column returned from
+ * {@link org.olap4j.OlapDatabaseMetaData#getDatasources()}.
+ */
+ private static final String DATA_SOURCE_NAME = "DATA_SOURCE_NAME";
+
+ /**
+ * Name of the "PROVIDER_NAME" column returned from
+ * {@link org.olap4j.OlapDatabaseMetaData#getDatasources()}.
+ */
+ private static final String PROVIDER_NAME = "PROVIDER_NAME";
+
+ /**
+ * Creates an Olap4j connection an XML/A provider.
+ *
+ *
This method is intentionally package-protected. The public API
+ * uses the traditional JDBC {@link java.sql.DriverManager}.
+ * See {@link org.olap4j.driver.xmla.XmlaOlap4jDriver} for more details.
+ *
+ *
Note that this constructor should make zero non-trivial calls, which
+ * could cause deadlocks due to java.sql.DriverManager synchronization
+ * issues.
+ *
+ * @pre acceptsURL(url)
+ *
+ * @param factory Factory
+ * @param proxy Proxy object which receives XML requests
+ * @param url Connect-string URL
+ * @param info Additional properties
+ * @throws java.sql.SQLException if there is an error
+ */
+ XmlaOlap4jConnection(
+ Factory factory,
+ XmlaOlap4jProxy proxy,
+ String url,
+ Properties info)
+ throws SQLException
+ {
+ this.factory = factory;
+ this.proxy = proxy;
+ if (!acceptsURL(url)) {
+ // This is not a URL we can handle.
+ // DriverManager should not have invoked us.
+ throw new AssertionError(
+ "does not start with '" + CONNECT_STRING_PREFIX + "'");
+ }
+ Map map = parseConnectString(url, info);
+
+ this.providerName = map.get(XmlaOlap4jDriver.Property.Provider.name());
+ this.datasourceName = map.get(XmlaOlap4jDriver.Property.DataSource.name());
+ this.catalogName = map.get(XmlaOlap4jDriver.Property.Catalog.name());
+
+ // Set URL of HTTP server.
+ String serverUrl = map.get(XmlaOlap4jDriver.Property.Server.name());
+ if (serverUrl == null) {
+ throw helper.createException("Connection property '"
+ + XmlaOlap4jDriver.Property.Server.name()
+ + "' must be specified");
+ }
+
+ // Basic authentication. Make sure the credentials passed as standard
+ // JDBC parameters override any credentials already included in the URL
+ // as part of the standard URL scheme.
+ if (map.containsKey("user") && map.containsKey("password")) {
+ serverUrl = serverUrl.replaceFirst(
+ ":\\/\\/([^@]*@){0,1}",
+ "://"
+ .concat(map.get("user"))
+ .concat(":")
+ .concat(map.get("password")
+ .concat("@")));
+ }
+
+ // Initialize the SOAP cache if needed
+ initSoapCache(map);
+
+ try {
+ this.serverUrl = new URL(serverUrl);
+ } catch (MalformedURLException e) {
+ throw helper.createException(
+ "Error while creating connection", e);
+ }
+
+ this.olap4jDatabaseMetaData =
+ factory.newDatabaseMetaData(this);
+ }
+
+
+ /**
+ * Initializes a cache object and configures it if cache
+ * parameters were specified in the jdbc url.
+ *
+ * @param map The parameters from the jdbc url.
+ * @throws OlapException Thrown when there is an error encountered
+ * while creating the cache.
+ */
+ private void initSoapCache(Map map) throws OlapException {
+
+ // Test if a SOAP cache class was defined
+ if (map.containsKey(XmlaOlap4jDriver.Property.Cache.name()
+ .toUpperCase()))
+ {
+ // Create a properties object to pass to the proxy
+ // so it can configure it's cache
+ Map props = new HashMap();
+ // Iterate over map entries to find those related to
+ // the cache config
+ for (Entry entry : map.entrySet()) {
+ // Check if the current entry relates to cache config.
+ if (entry.getKey().startsWith(
+ XmlaOlap4jDriver.Property.Cache.name().toUpperCase()
+ + ".")) //$NON-NLS-1$
+ {
+ props.put(entry.getKey().substring(
+ XmlaOlap4jDriver.Property.Cache.name()
+ .length() + 1), entry.getValue());
+ }
+ }
+
+ // Init the cache
+ ((XmlaOlap4jCachedProxy) this.proxy).setCache(map, props);
+ }
+ }
+
+
+
+ static Map