From 5d7b66c95c87a10f25cd9d4ffeaa21735d8cbd3a Mon Sep 17 00:00:00 2001 From: Julian Hyde Date: Fri, 25 May 2007 22:34:38 +0000 Subject: [PATCH] Rename OlapResultSet to CellSet, OlapResultSetMetaData to CellSetMetaData, OlapResultAxis to CellSetAxis, ResultCell to Cell, ResultSetPosition to Position; add implementation of olap4j against mondrian, and a unit test git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@17 c6a108a4-781c-0410-a6c6-c2d559e19af0 --- doc/olap4j_fs.html | 90 +- src/mondrian/olap4j/AbstractNamedList.java | 53 + src/mondrian/olap4j/EmptyResultSet.java | 854 ++++++++++++++ .../olap4j/MondrianOlap4jCatalog.java | 55 + src/mondrian/olap4j/MondrianOlap4jCell.java | 114 ++ .../olap4j/MondrianOlap4jCellSet.java | 1004 +++++++++++++++++ .../olap4j/MondrianOlap4jCellSetAxis.java | 126 +++ .../olap4j/MondrianOlap4jConnection.java | 365 ++++++ src/mondrian/olap4j/MondrianOlap4jCube.java | 87 ++ .../olap4j/MondrianOlap4jDatabase.java | 50 + .../MondrianOlap4jDatabaseMetaData.java | 894 +++++++++++++++ .../olap4j/MondrianOlap4jDimension.java | 68 ++ src/mondrian/olap4j/MondrianOlap4jDriver.java | 128 +++ .../olap4j/MondrianOlap4jHierarchy.java | 88 ++ src/mondrian/olap4j/MondrianOlap4jLevel.java | 90 ++ src/mondrian/olap4j/MondrianOlap4jMember.java | 154 +++ src/mondrian/olap4j/MondrianOlap4jSchema.java | 81 ++ .../olap4j/MondrianOlap4jStatement.java | 262 +++++ src/mondrian/olap4j/Named.java | 30 + src/mondrian/olap4j/NamedListImpl.java | 49 + src/org/olap4j/Axis.java | 4 +- src/org/olap4j/{ResultCell.java => Cell.java} | 36 +- .../{OlapResultSet.java => CellSet.java} | 40 +- .../{ResultAxis.java => CellSetAxis.java} | 34 +- ...MetaData.java => CellSetAxisMetaData.java} | 8 +- ...tSetMetaData.java => CellSetMetaData.java} | 10 +- src/org/olap4j/Olap4j.java | 14 +- src/org/olap4j/OlapDatabaseMetaData.java | 1 + src/org/olap4j/OlapException.java | 26 +- src/org/olap4j/OlapStatement.java | 6 +- .../{ResultPosition.java => Position.java} | 20 +- src/org/olap4j/PreparedOlapStatement.java | 6 +- src/org/olap4j/metadata/Catalog.java | 9 + src/org/olap4j/metadata/Member.java | 2 +- src/org/olap4j/metadata/NamedList.java | 2 - src/org/olap4j/metadata/Property.java | 4 +- src/org/olap4j/metadata/Schema.java | 7 + src/org/olap4j/sample/SimpleQuerySample.java | 34 +- src/org/olap4j/sample/SpringSample.java | 4 +- src/org/olap4j/type/DimensionType.java | 5 +- src/org/olap4j/type/HierarchyType.java | 5 +- src/org/olap4j/type/LevelType.java | 5 +- src/org/olap4j/type/MemberType.java | 5 +- src/org/olap4j/type/SetType.java | 3 +- src/org/olap4j/type/TupleType.java | 3 +- src/org/olap4j/type/Type.java | 3 +- src/org/olap4j/type/TypeUtil.java | 7 +- testsrc/org/olap4j/ConnectionTest.java | 564 +++++++++ 48 files changed, 5352 insertions(+), 157 deletions(-) create mode 100644 src/mondrian/olap4j/AbstractNamedList.java create mode 100644 src/mondrian/olap4j/EmptyResultSet.java create mode 100644 src/mondrian/olap4j/MondrianOlap4jCatalog.java create mode 100644 src/mondrian/olap4j/MondrianOlap4jCell.java create mode 100644 src/mondrian/olap4j/MondrianOlap4jCellSet.java create mode 100644 src/mondrian/olap4j/MondrianOlap4jCellSetAxis.java create mode 100644 src/mondrian/olap4j/MondrianOlap4jConnection.java create mode 100644 src/mondrian/olap4j/MondrianOlap4jCube.java create mode 100644 src/mondrian/olap4j/MondrianOlap4jDatabase.java create mode 100644 src/mondrian/olap4j/MondrianOlap4jDatabaseMetaData.java create mode 100644 src/mondrian/olap4j/MondrianOlap4jDimension.java create mode 100644 src/mondrian/olap4j/MondrianOlap4jDriver.java create mode 100644 src/mondrian/olap4j/MondrianOlap4jHierarchy.java create mode 100644 src/mondrian/olap4j/MondrianOlap4jLevel.java create mode 100644 src/mondrian/olap4j/MondrianOlap4jMember.java create mode 100644 src/mondrian/olap4j/MondrianOlap4jSchema.java create mode 100644 src/mondrian/olap4j/MondrianOlap4jStatement.java create mode 100644 src/mondrian/olap4j/Named.java create mode 100644 src/mondrian/olap4j/NamedListImpl.java rename src/org/olap4j/{ResultCell.java => Cell.java} (73%) mode change 100644 => 100755 rename src/org/olap4j/{OlapResultSet.java => CellSet.java} (72%) mode change 100644 => 100755 rename src/org/olap4j/{ResultAxis.java => CellSetAxis.java} (65%) mode change 100644 => 100755 rename src/org/olap4j/{OlapResultSetAxisMetaData.java => CellSetAxisMetaData.java} (90%) mode change 100644 => 100755 rename src/org/olap4j/{OlapResultSetMetaData.java => CellSetMetaData.java} (74%) mode change 100644 => 100755 rename src/org/olap4j/{ResultPosition.java => Position.java} (62%) mode change 100644 => 100755 create mode 100644 testsrc/org/olap4j/ConnectionTest.java diff --git a/doc/olap4j_fs.html b/doc/olap4j_fs.html index fcf12de..d9e304f 100644 --- a/doc/olap4j_fs.html +++ b/doc/olap4j_fs.html @@ -121,10 +121,17 @@

Contents

  • The OlapStatement interface
  • The PreparedOlapStatement interface
  • The OlapParameterMetaData interface
  • -
  • The OlapResultSet interface
  • -
  • The ResultAxis interface
  • -
  • The ResultPosition interface
  • -
  • The ResultCell interface
  • +
  • The CellSet interface
  • +
  • The CellSetAxis interface
  • +
  • The Position interface
  • +
  • The Cell interface
  • +
  • The CellSetMetaData + interface
  • +
  • The + OlapDatabaseMetaData interface
  • +
  • The CellSetAxis interface
  • +
  • The CellSetAxisMetaData + interface
  • MDX query model
  • @@ -195,6 +202,7 @@

    Contents

  • Appendix C. Open issues
  • Appendix D. Miscellaneous
  • Appendix E. References
  • +
  • Appendix F. Change log
  • 1. Introduction

    @@ -422,8 +430,8 @@

    2.1.4 The OlapException class

    driver chooses, throw instead an OlapException.

    OlapException provides some additional information to help an OLAP client -identify the location of the error. The context is the ResultCell -or ResultPosition object where the error occurred. The region is an +identify the location of the error. The context is the Cell +or Position object where the error occurred. The region is an object representing the textual region in the MDX statement.

    Methods:

    -

    2.3.4. The OlapResultSet interface

    -

    OlapResultSet (extends +

    2.3.4. The CellSet interface

    +

    CellSet (extends java.sql.ResultSet) is the result of executing an OlapStatement or PreparedOlapStatement.

    It extends ResultSet, but since most of these methods are concerned with rows -and columns, few of ResultSet's methods are applicable. The following methods +and columns, only a few of the base class's methods are applicable. The following methods are applicable:

    Additional methods to retrieve the axes of the multidimensional result:

    -

    2.3.5. The ResultAxis interface

    -

    A ResultAxis is +

    An OlapStatement can have no more than one CellSet open. Closing an +OlapStatement, or preparing or executing a new query, implicitly closes any +previous CellSet.

    + +

    2.3.5. The CellSetAxis interface

    +

    A CellSetAxis is a ...

    [tbd]

    [access positions by index (i.e. a list) and by scrolling (i.e. an iterator)]

    -

    2.3.6. The ResultPosition interface

    -

    ResultPosition -is a position on a -ResultAxis.

    +

    2.3.6. The Position interface

    +

    Position +is a position on a +CellSetAxis.

    Methods:

    -

    2.3.7. The ResultCell interface

    -

    A ResultCell is -a cell returned from an -OlapResultSet.

    +

    2.3.7. The Cell interface

    +

    A Cell is +a cell returned from an +CellSet.

    Methods:

    +

    2.3.8. The CellSetMetaData interface

    + +

    Extends ResultSetMetaData

    + +

    2.3.9. The OlapDatabaseMetaData +interface

    + +

    Extends DatabaseMetaData

    + +

    2.3.10. The CellSetAxis interface

    + +

    2.3.11. The CellSetAxisMetaData +interface

    +

    2.4. MDX query model

    The MDX query model represents a parsed MDX statement.

    @@ -691,9 +718,9 @@

    2.4. MDX query model

    }

    // Execute the statement.
    - ResultSet rset;
    + CellSet cset;
    try {
    -    rset = stmt.execute();
    +    cset = stmt.execute();
    } catch (OlapException e) {
        System.out.println("Execution failed: " + e);
    } @@ -3299,7 +3326,6 @@

    D.1. To be specified

    is to support an object model (hence easy programming model) without increasing memory. No specific change to the specification, but decided to add memory efficiency as a design goal.]

    -

    [Is an OlapResultSet still accessible when its OlapStatement is closed?]

    D.2. Design notes

    JDK. We are targeting JDK 1.5, and running retroweaver for @@ -3317,11 +3343,11 @@

    Accessing cells

    It would be possible to access cells in a result set (a) by ordinal; (b) by coordinates; (c) by the 'etchasketch' model determined by the position of the iterator along each axis, as used by JOLAP. We decided to support (a) and (b) -but not (c). There are methods on ResultSet to convert from ordinal to +but not (c). There are methods on CellSet to convert from ordinal to coordinates and vice versa.

    If there is a huge number of cells, the client has limited memory, and bandwidth to the server is limited, random access to cells is costly. Michael -suggested that we add a method List<ResultCell> getCells(int startOrdinal, int +suggested that we add a method List<Cell> getCells(int startOrdinal, int endOrdinal), which matches XML/A behavior, but we declined to add it to the spec for now. John drew the analogy of a modern file system, implementing a serial access interface (streams) on top of random-access primitives. For now, we @@ -3332,6 +3358,12 @@

    Appendix E. References

    1. XMLA: XML for Analysis Specification, version 1.1.

    +

    Appendix F. Change log

    +
    diff --git a/src/mondrian/olap4j/AbstractNamedList.java b/src/mondrian/olap4j/AbstractNamedList.java new file mode 100644 index 0000000..cb90afd --- /dev/null +++ b/src/mondrian/olap4j/AbstractNamedList.java @@ -0,0 +1,53 @@ +/* +// $Id: $ +// 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 mondrian.olap4j; + +import org.olap4j.metadata.NamedList; + +import java.util.AbstractList; + +/** + * Partial implementation of {@link org.olap4j.metadata.NamedList}. + * + *

    Derived class must implement {@link #get(int)} and {@link #size()}, as + * per {@link java.util.AbstractList}. + * + * @see mondrian.olap4j.NamedListImpl + * + * @author jhyde + * @version $Id: $ + * @since May 25, 2007 + */ +abstract class AbstractNamedList + extends AbstractList + implements NamedList +{ + public T get(String name) { + for (T t : this) { + if (t.getName().equals(name)) { + return t; + } + } + return null; + } + + public int indexOfName(String name) { + for (int i = 0; i < size(); ++i) { + T t = get(i); + if (t.getName().equals(name)) { + return i; + } + } + return -1; + } + +} + +// End AbstractNamedList.java diff --git a/src/mondrian/olap4j/EmptyResultSet.java b/src/mondrian/olap4j/EmptyResultSet.java new file mode 100644 index 0000000..f848b6b --- /dev/null +++ b/src/mondrian/olap4j/EmptyResultSet.java @@ -0,0 +1,854 @@ +/* +// $Id: $ +// 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 mondrian.olap4j; + +import java.sql.*; +import java.math.BigDecimal; +import java.io.InputStream; +import java.io.Reader; +import java.util.Map; +import java.util.Calendar; +import java.net.URL; + +/** + * EmptyResultSet ... + * + * @author jhyde + * @version $Id: $ + * @since May 24, 2007 + */ +class EmptyResultSet implements ResultSet { + final MondrianOlap4jConnection olap4jConnection; + + EmptyResultSet(MondrianOlap4jConnection olap4jConnection) { + this.olap4jConnection = olap4jConnection; + } + + public boolean next() throws SQLException { + return false; + } + + public void close() throws SQLException { + } + + 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 { + if (false) { + return new byte[0]; + } + 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 { + if (false) { + return new byte[0]; + } + 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 ResultSetMetaData getMetaData() 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(); + } + + 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(); + } + + public T unwrap(Class 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/mondrian/olap4j/MondrianOlap4jCatalog.java b/src/mondrian/olap4j/MondrianOlap4jCatalog.java new file mode 100644 index 0000000..2648217 --- /dev/null +++ b/src/mondrian/olap4j/MondrianOlap4jCatalog.java @@ -0,0 +1,55 @@ +/* +// $Id: $ +// 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 mondrian.olap4j; + +import org.olap4j.metadata.Catalog; +import org.olap4j.metadata.NamedList; +import org.olap4j.metadata.Schema; +import org.olap4j.metadata.Database; +import org.olap4j.OlapException; + +/** + * MondrianOlap4jCatalog ... + * + * @author jhyde + * @version $Id: $ + * @since May 23, 2007 + */ +class MondrianOlap4jCatalog implements Catalog, Named { + final MondrianOlap4jDatabase olap4jDatabase; + + MondrianOlap4jCatalog( + MondrianOlap4jDatabase olap4jDatabase) { + this.olap4jDatabase = olap4jDatabase; + } + + public NamedList getSchemas() throws OlapException { + // A mondrian catalog contains one schema, so implicitly it contains + // one catalog + NamedList list = + new NamedListImpl(); + list.add( + new MondrianOlap4jSchema( + this, + olap4jDatabase.metaData.connection.getSchemaReader(), + olap4jDatabase.metaData.connection.getSchema())); + return (NamedList) list; + } + + public Database getDatabase() { + return olap4jDatabase; + } + + public String getName() { + return "LOCALDB"; + } +} + +// End MondrianOlap4jCatalog.java diff --git a/src/mondrian/olap4j/MondrianOlap4jCell.java b/src/mondrian/olap4j/MondrianOlap4jCell.java new file mode 100644 index 0000000..2fb9648 --- /dev/null +++ b/src/mondrian/olap4j/MondrianOlap4jCell.java @@ -0,0 +1,114 @@ +/* +// $Id: $ +// 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 mondrian.olap4j; + +import org.olap4j.Cell; +import org.olap4j.CellSet; +import org.olap4j.OlapException; +import org.olap4j.metadata.Property; + +import java.util.List; +import java.util.ArrayList; +import java.sql.ResultSet; + +/** + * MondrianOlap4jCell ... + * + * @author jhyde + * @version $Id: $ + * @since May 24, 2007 + */ +class MondrianOlap4jCell implements Cell { + private final int[] coordinates; + private final MondrianOlap4jCellSet olap4jCellSet; + private final mondrian.olap.Cell cell; + + MondrianOlap4jCell( + int[] coordinates, + MondrianOlap4jCellSet olap4jCellSet, + mondrian.olap.Cell cell) + { + assert coordinates != null; + assert olap4jCellSet != null; + assert cell != null; + this.coordinates = coordinates; + this.olap4jCellSet = olap4jCellSet; + this.cell = cell; + } + + public CellSet getCellSet() { + return olap4jCellSet; + } + + public int getOrdinal() { + return (Integer) cell.getPropertyValue( + mondrian.olap.Property.CELL_ORDINAL.name); + } + + public List getCoordinateList() { + ArrayList list = new ArrayList(coordinates.length); + for (int i = 0; i < coordinates.length; i++) { + list.add(coordinates[i]); + } + return list; + } + + public Object getPropertyValue(Property property) { + // We assume that mondrian properties have the same name as olap4j + // properties. + return cell.getPropertyValue(property.getName()); + } + + public boolean isEmpty() { + // FIXME + return cell.isNull(); + } + + public boolean isError() { + return cell.isError(); + } + + public boolean isNull() { + return cell.isNull(); + } + + public double getDoubleValue() throws OlapException { + Object o = cell.getValue(); + if (o instanceof Number) { + Number number = (Number) o; + return number.doubleValue(); + } + throw olap4jCellSet.olap4jStatement.olap4jConnection.helper + .createException(this, "not a number"); + } + + public String getErrorText() { + Object o = cell.getValue(); + if (o instanceof Throwable) { + return ((Throwable) o).getMessage(); + } else { + return null; + } + } + + public Object getValue() { + return cell.getValue(); + } + + public String getFormattedValue() { + return cell.getFormattedValue(); + } + + public ResultSet drillThrough() { + throw new UnsupportedOperationException(); + } +} + +// End MondrianOlap4jCell.java diff --git a/src/mondrian/olap4j/MondrianOlap4jCellSet.java b/src/mondrian/olap4j/MondrianOlap4jCellSet.java new file mode 100644 index 0000000..ff769df --- /dev/null +++ b/src/mondrian/olap4j/MondrianOlap4jCellSet.java @@ -0,0 +1,1004 @@ +/* +// $Id: $ +// 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 mondrian.olap4j; + +import org.olap4j.*; +import org.olap4j.Cell; +import org.olap4j.metadata.Property; +import org.olap4j.metadata.Cube; +import mondrian.olap.*; +import mondrian.olap.Axis; + +import java.util.*; +import java.sql.*; +import java.sql.Date; +import java.math.BigDecimal; +import java.io.InputStream; +import java.io.Reader; +import java.net.URL; + +/** + * MondrianOlap4jCellSet ... + * + * @author jhyde + * @version $Id: $ + * @since May 24, 2007 + */ +class MondrianOlap4jCellSet implements CellSet, CellSetMetaData { + final MondrianOlap4jStatement olap4jStatement; + private final Result result; + private boolean closed; + + public MondrianOlap4jCellSet( + MondrianOlap4jStatement olap4jStatement, + Result result) + { + assert olap4jStatement != null; + assert result != null; + this.olap4jStatement = olap4jStatement; + this.result = result; + this.closed = false; + } + + public CellSetMetaData getMetaData() throws OlapException { + return this; + } + + public List getAxes() { + mondrian.olap.Axis[] axes = result.getAxes(); + QueryAxis[] queryAxes = result.getQuery().getAxes(); + assert axes.length == queryAxes.length; + ArrayList list = new ArrayList(axes.length); + + for (int i = 0; i < axes.length; i++) { + Axis axis = axes[i]; + QueryAxis queryAxis = queryAxes[i]; + list.add(new MondrianOlap4jCellSetAxis(this, queryAxis, axis)); + } + return list; + } + + public CellSetAxis getFilterAxis() { + final Axis axis = result.getSlicerAxis(); + final QueryAxis queryAxis = result.getQuery().getSlicerAxis(); + return new MondrianOlap4jCellSetAxis(this, queryAxis, axis); + } + + public Cell getCell(List coordinates) { + int[] coords = new int[coordinates.size()]; + for (int i = 0; i < coords.length; i++) { + coords[i] = coordinates.get(i); + } + mondrian.olap.Cell cell = result.getCell(coords); + return new MondrianOlap4jCell(coords, this, cell); + } + + public Cell getCell(int ordinal) { + throw new UnsupportedOperationException(); + } + + public List ordinalToCoordinates(int ordinal) { + throw new UnsupportedOperationException(); + } + + public int coordinatesToOrdinal(List coordinates) { + throw new UnsupportedOperationException(); + } + + 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(); + } + + 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(); + } + + // implement Wrapper + + public T unwrap(Class iface) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean isWrapperFor(Class iface) throws SQLException { + throw new UnsupportedOperationException(); + } + + // implement CellSetMetaData + + + public List getCellProperties() { + throw new UnsupportedOperationException(); + } + + public Cube getCube() { + throw new UnsupportedOperationException(); + } + + public List getAxesMetaData() { + throw new UnsupportedOperationException(); + } + + 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(); + } +} + +// End MondrianOlap4jCellSet.java diff --git a/src/mondrian/olap4j/MondrianOlap4jCellSetAxis.java b/src/mondrian/olap4j/MondrianOlap4jCellSetAxis.java new file mode 100644 index 0000000..0ebc035 --- /dev/null +++ b/src/mondrian/olap4j/MondrianOlap4jCellSetAxis.java @@ -0,0 +1,126 @@ +/* +// $Id: $ +// 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 mondrian.olap4j; + +import org.olap4j.*; +import org.olap4j.Position; +import org.olap4j.metadata.Hierarchy; +import org.olap4j.metadata.Member; +import org.olap4j.metadata.Property; + +import java.util.*; + +/** + * MondrianOlap4jCellSetAxis ... + * + * @author jhyde + * @version $Id: $ + * @since May 24, 2007 + */ +class MondrianOlap4jCellSetAxis implements CellSetAxis, CellSetAxisMetaData { + private final MondrianOlap4jCellSet olap4jCellSet; + private final mondrian.olap.QueryAxis queryAxis; + private final mondrian.olap.Axis axis; + + MondrianOlap4jCellSetAxis( + MondrianOlap4jCellSet olap4jCellSet, + mondrian.olap.QueryAxis queryAxis, + mondrian.olap.Axis axis) + { + assert olap4jCellSet != null; + assert queryAxis != null; + assert axis != null; + this.olap4jCellSet = olap4jCellSet; + this.queryAxis = queryAxis; + this.axis = axis; + } + + public int getOrdinal() { + return queryAxis.getAxisOrdinal().logicalOrdinal(); + } + + public CellSet getCellSet() { + return olap4jCellSet; + } + + public CellSetAxisMetaData getAxisMetaData() { + throw new UnsupportedOperationException(); + } + + public List getPositions() { + return new AbstractList() { + public Position get(final int index) { + final mondrian.olap.Position mondrianPosition = + axis.getPositions().get(index); + return new MondrianOlap4jPosition(mondrianPosition, index); + } + + public int size() { + return axis.getPositions().size(); + } + }; + } + + public int getPositionCount() { + throw new UnsupportedOperationException(); + } + + public ListIterator iterate() { + throw new UnsupportedOperationException(); + } + + // implement CellSetAxisMetaData + + public org.olap4j.Axis getAxis() { + throw new UnsupportedOperationException(); + } + + public List getHierarchies() { + throw new UnsupportedOperationException(); + } + + public List getProperties() { + throw new UnsupportedOperationException(); + } + + private class MondrianOlap4jPosition implements Position { + private final mondrian.olap.Position mondrianPosition; + private final int index; + + public MondrianOlap4jPosition( + mondrian.olap.Position mondrianPosition, int index) { + this.mondrianPosition = mondrianPosition; + this.index = index; + } + + public List getMembers() { + return new AbstractList() { + + public Member get(int index) { + final mondrian.olap.Member mondrianMember = + mondrianPosition.get(index); + return new MondrianOlap4jMember( + olap4jCellSet.olap4jStatement.olap4jConnection.olap4jSchema, + mondrianMember); + } + + public int size() { + return mondrianPosition.size(); + } + }; + } + + public int getOrdinal() { + return index; + } + } +} + +// End MondrianOlap4jCellSetAxis.java diff --git a/src/mondrian/olap4j/MondrianOlap4jConnection.java b/src/mondrian/olap4j/MondrianOlap4jConnection.java new file mode 100644 index 0000000..5d28430 --- /dev/null +++ b/src/mondrian/olap4j/MondrianOlap4jConnection.java @@ -0,0 +1,365 @@ +/* +// $Id: $ +// 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 mondrian.olap4j; + +import mondrian.olap.Util; + +import java.sql.*; +import java.util.Properties; +import java.util.Map; + +import org.olap4j.*; +import org.olap4j.metadata.Schema; +import org.olap4j.metadata.Database; +import org.olap4j.metadata.Catalog; +import org.olap4j.mdx.parser.MdxParserFactory; + +/** + * MondrianOlap4jConnection ... + * + * @author jhyde + * @version $Id: $ + * @since May 23, 2007 + */ +class MondrianOlap4jConnection implements OlapConnection { + /** + * Handler for errors. + */ + final Helper helper = new Helper(); + + /** + * Underlying mondrian connection. Set on creation, cleared on close. + */ + mondrian.olap.Connection connection; + + /** + * Current schema. + */ + MondrianOlap4jSchema olap4jSchema; + + /** + * The name of the sole catalog. + */ + private static final String LOCALDB_CATALOG_NAME = "LOCALDB"; + private static final String CONNECT_STRING_PREFIX = "jdbc:mondrian:"; + + /** + * Creates an Olap4j connection to Mondrian. + * + *

    This method is intentionally package-protected. The public API + * uses the traditional JDBC {@link java.sql.DriverManager}. + * See {@link mondrian.olap4j.MondrianOlap4jDriver} for more details. + * + * @param url Connect-string URL + * @param info Additional properties + */ + MondrianOlap4jConnection(String url, Properties info) throws SQLException { + if (!url.startsWith(CONNECT_STRING_PREFIX)) { + throw new AssertionError( + "does not start with '" + CONNECT_STRING_PREFIX + "'"); + } + String x = url.substring(CONNECT_STRING_PREFIX.length()); + Util.PropertyList list = Util.parseConnectString(x); + for (Map.Entry entry : Util.toMap(info).entrySet()) { + list.put(entry.getKey(), entry.getValue()); + } + this.connection = + mondrian.olap.DriverManager.getConnection(list, null); + final OlapDatabaseMetaData olapDatabaseMetaData = getMetaData(); + final Database database = olapDatabaseMetaData.getDatabase(); + final Catalog catalog = database.getCatalogs().get(getCatalog()); + this.olap4jSchema = + new MondrianOlap4jSchema( + (MondrianOlap4jCatalog) catalog, + connection.getSchemaReader(), + connection.getSchema()); + } + + public OlapStatement createStatement() { + return new MondrianOlap4jStatement(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 { + throw new UnsupportedOperationException(); + } + + public boolean getAutoCommit() throws SQLException { + throw new UnsupportedOperationException(); + } + + public void commit() throws SQLException { + throw new UnsupportedOperationException(); + } + + public void rollback() throws SQLException { + throw new UnsupportedOperationException(); + } + + public void close() throws SQLException { + if (connection != null) { + mondrian.olap.Connection c = connection; + connection = null; + c.close(); + } + } + + public boolean isClosed() throws SQLException { + return connection == null; + } + + public OlapDatabaseMetaData getMetaData() { + return new MondrianOlap4jDatabaseMetaData(this, connection); + } + + public void setReadOnly(boolean readOnly) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean isReadOnly() throws SQLException { + throw new UnsupportedOperationException(); + } + + public void setCatalog(String catalog) throws SQLException { + if (!catalog.equals(LOCALDB_CATALOG_NAME)) { + throw new UnsupportedOperationException(); + } + } + + public String getCatalog() throws SQLException { + return LOCALDB_CATALOG_NAME; + } + + 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 { + throw new UnsupportedOperationException(); + } + + 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(); + } + + 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(); + } + + // implement Wrapper + + public T unwrap(Class iface) throws SQLException { + if (iface.isInstance(this)) { + return iface.cast(this); + } else if (iface.isInstance(connection)) { + return iface.cast(connection); + } + throw helper.createException("does not implement '" + iface + "'"); + } + + public boolean isWrapperFor(Class iface) throws SQLException { + return iface.isInstance(this) || + iface.isInstance(connection); + } + + // implement OlapConnection + + public PreparedOlapStatement prepareOlapStatement( + String mdx) + throws OlapException + { + throw new UnsupportedOperationException(); + } + + public MdxParserFactory getParserFactory() { + throw new UnsupportedOperationException(); + } + + public Schema getSchema() throws OlapException { + return olap4jSchema; + } + + // inner classes + + static class Helper { + SQLException createException(String msg) { + return new SQLException(msg); + } + + 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); + } + } + } +} + +// End MondrianOlap4jConnection.java diff --git a/src/mondrian/olap4j/MondrianOlap4jCube.java b/src/mondrian/olap4j/MondrianOlap4jCube.java new file mode 100644 index 0000000..e0cee13 --- /dev/null +++ b/src/mondrian/olap4j/MondrianOlap4jCube.java @@ -0,0 +1,87 @@ +/* +// $Id: $ +// 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 mondrian.olap4j; + +import org.olap4j.metadata.*; +import org.olap4j.metadata.Cube; +import org.olap4j.metadata.Dimension; +import org.olap4j.metadata.NamedSet; +import org.olap4j.metadata.Schema; + +import java.util.List; +import java.util.Locale; +import java.util.Collection; + +import mondrian.olap.*; + +/** + * MondrianOlap4jCube ... + * + * @author jhyde + * @version $Id: $ + * @since May 24, 2007 + */ +class MondrianOlap4jCube implements Cube, Named { + private final mondrian.olap.Cube cube; + private final MondrianOlap4jSchema olap4jSchema; + + MondrianOlap4jCube( + mondrian.olap.Cube cube, + MondrianOlap4jSchema olap4jSchema) + { + this.cube = cube; + this.olap4jSchema = olap4jSchema; + } + + public Schema getSchema() { + return olap4jSchema; + } + + public NamedList getDimensions() { + List list = + new NamedListImpl(); + for (mondrian.olap.Dimension dimension : cube.getDimensions()) { + list.add( + new MondrianOlap4jDimension( + olap4jSchema, dimension)); + } + return (NamedList) list; + } + + public List getMeasures() { + throw new UnsupportedOperationException(); + } + + public NamedList getSets() { + throw new UnsupportedOperationException(); + } + + public Collection getSupportedLocales() { + throw new UnsupportedOperationException(); + } + + public String getName() { + throw new UnsupportedOperationException(); + } + + public String getUniqueName() { + throw new UnsupportedOperationException(); + } + + public String getCaption(Locale locale) { + throw new UnsupportedOperationException(); + } + + public String getDescription(Locale locale) { + throw new UnsupportedOperationException(); + } +} + +// End MondrianOlap4jCube.java diff --git a/src/mondrian/olap4j/MondrianOlap4jDatabase.java b/src/mondrian/olap4j/MondrianOlap4jDatabase.java new file mode 100644 index 0000000..777cdf8 --- /dev/null +++ b/src/mondrian/olap4j/MondrianOlap4jDatabase.java @@ -0,0 +1,50 @@ +/* +// $Id: $ +// 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 mondrian.olap4j; + +import org.olap4j.metadata.Database; +import org.olap4j.metadata.Catalog; +import org.olap4j.metadata.NamedList; +import org.olap4j.OlapDatabaseMetaData; +import mondrian.olap.MondrianServer; + +/** + * MondrianOlap4jDatabase ... + * + * @author jhyde + * @version $Id: $ + * @since May 23, 2007 + */ +class MondrianOlap4jDatabase implements Database { + final MondrianServer mondrianServer; + final MondrianOlap4jDatabaseMetaData metaData; + + MondrianOlap4jDatabase( + MondrianServer mondrianServer, + MondrianOlap4jDatabaseMetaData metaData) + { + this.mondrianServer = mondrianServer; + this.metaData = metaData; + } + + public NamedList getCatalogs() { + // A mondrian instance contains only one catalog. + NamedListImpl list = + new NamedListImpl(); + list.add(new MondrianOlap4jCatalog(this)); + return (NamedList) list; + } + + public OlapDatabaseMetaData getMetaData() { + return metaData; + } +} + +// End MondrianOlap4jDatabase.java diff --git a/src/mondrian/olap4j/MondrianOlap4jDatabaseMetaData.java b/src/mondrian/olap4j/MondrianOlap4jDatabaseMetaData.java new file mode 100644 index 0000000..3854750 --- /dev/null +++ b/src/mondrian/olap4j/MondrianOlap4jDatabaseMetaData.java @@ -0,0 +1,894 @@ +/* +// $Id: $ +// 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 mondrian.olap4j; + +import mondrian.olap.Connection; +import mondrian.olap.MondrianServer; + +import org.olap4j.OlapDatabaseMetaData; +import org.olap4j.OlapException; +import org.olap4j.metadata.Database; + +import java.sql.ResultSet; +import java.sql.RowIdLifetime; +import java.sql.SQLException; + +/** + * Implementation of {@link org.olap4j.OlapDatabaseMetaData} for Mondrian. + * + * @author jhyde + * @version $Id: $ + * @since May 23, 2007 + */ +class MondrianOlap4jDatabaseMetaData implements OlapDatabaseMetaData { + private final MondrianOlap4jConnection olap4jConnection; + final Connection connection; + final MondrianServer mondrianServer; + + MondrianOlap4jDatabaseMetaData( + MondrianOlap4jConnection olap4jConnection, + Connection connection) + { + this.olap4jConnection = olap4jConnection; + this.connection = connection; + mondrianServer = MondrianServer.forConnection(connection); + } + + public boolean allProceduresAreCallable() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean allTablesAreSelectable() throws SQLException { + throw new UnsupportedOperationException(); + } + + public String getURL() throws SQLException { + return connection.getConnectString(); + } + + public String getUserName() throws SQLException { + // mondrian does not support a user name property + return null; + } + + public boolean isReadOnly() throws SQLException { + // all mondrian databases are read-only + return true; + } + + public boolean nullsAreSortedHigh() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean nullsAreSortedLow() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean nullsAreSortedAtStart() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean nullsAreSortedAtEnd() throws SQLException { + throw new UnsupportedOperationException(); + } + + public String getDatabaseProductName() throws SQLException { + return mondrianServer.getVersion().getProductName(); + } + + public String getDatabaseProductVersion() throws SQLException { + return mondrianServer.getVersion().getVersionString(); + } + + public String getDriverName() throws SQLException { + return MondrianOlap4jDriver.NAME; + } + + public String getDriverVersion() throws SQLException { + return MondrianOlap4jDriver.VERSION; + } + + public int getDriverMajorVersion() { + return MondrianOlap4jDriver.MAJOR_VERSION; + } + + public int getDriverMinorVersion() { + return MondrianOlap4jDriver.MINOR_VERSION; + } + + public boolean usesLocalFiles() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean usesLocalFilePerTable() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsMixedCaseIdentifiers() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean storesUpperCaseIdentifiers() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean storesLowerCaseIdentifiers() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean storesMixedCaseIdentifiers() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean storesUpperCaseQuotedIdentifiers() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean storesLowerCaseQuotedIdentifiers() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean storesMixedCaseQuotedIdentifiers() throws SQLException { + throw new UnsupportedOperationException(); + } + + public String getIdentifierQuoteString() throws SQLException { + throw new UnsupportedOperationException(); + } + + public String getSQLKeywords() throws SQLException { + throw new UnsupportedOperationException(); + } + + public String getNumericFunctions() throws SQLException { + throw new UnsupportedOperationException(); + } + + public String getStringFunctions() throws SQLException { + throw new UnsupportedOperationException(); + } + + public String getSystemFunctions() throws SQLException { + throw new UnsupportedOperationException(); + } + + public String getTimeDateFunctions() throws SQLException { + throw new UnsupportedOperationException(); + } + + public String getSearchStringEscape() throws SQLException { + throw new UnsupportedOperationException(); + } + + public String getExtraNameCharacters() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsAlterTableWithAddColumn() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsAlterTableWithDropColumn() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsColumnAliasing() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean nullPlusNonNullIsNull() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsConvert() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsConvert( + int fromType, int toType) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsTableCorrelationNames() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsDifferentTableCorrelationNames() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsExpressionsInOrderBy() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsOrderByUnrelated() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsGroupBy() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsGroupByUnrelated() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsGroupByBeyondSelect() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsLikeEscapeClause() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsMultipleResultSets() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsMultipleTransactions() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsNonNullableColumns() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsMinimumSQLGrammar() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsCoreSQLGrammar() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsExtendedSQLGrammar() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsANSI92EntryLevelSQL() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsANSI92IntermediateSQL() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsANSI92FullSQL() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsIntegrityEnhancementFacility() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsOuterJoins() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsFullOuterJoins() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsLimitedOuterJoins() throws SQLException { + throw new UnsupportedOperationException(); + } + + public String getSchemaTerm() throws SQLException { + throw new UnsupportedOperationException(); + } + + public String getProcedureTerm() throws SQLException { + throw new UnsupportedOperationException(); + } + + public String getCatalogTerm() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean isCatalogAtStart() throws SQLException { + throw new UnsupportedOperationException(); + } + + public String getCatalogSeparator() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsSchemasInDataManipulation() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsSchemasInProcedureCalls() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsSchemasInTableDefinitions() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsSchemasInIndexDefinitions() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsCatalogsInDataManipulation() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsCatalogsInProcedureCalls() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsCatalogsInTableDefinitions() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsCatalogsInIndexDefinitions() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsPositionedDelete() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsPositionedUpdate() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsSelectForUpdate() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsStoredProcedures() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsSubqueriesInComparisons() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsSubqueriesInExists() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsSubqueriesInIns() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsSubqueriesInQuantifieds() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsCorrelatedSubqueries() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsUnion() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsUnionAll() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsOpenCursorsAcrossCommit() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsOpenCursorsAcrossRollback() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsOpenStatementsAcrossCommit() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsOpenStatementsAcrossRollback() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxBinaryLiteralLength() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxCharLiteralLength() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxColumnNameLength() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxColumnsInGroupBy() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxColumnsInIndex() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxColumnsInOrderBy() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxColumnsInSelect() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxColumnsInTable() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxConnections() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxCursorNameLength() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxIndexLength() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxSchemaNameLength() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxProcedureNameLength() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxCatalogNameLength() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxRowSize() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean doesMaxRowSizeIncludeBlobs() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxStatementLength() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxStatements() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxTableNameLength() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxTablesInSelect() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxUserNameLength() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getDefaultTransactionIsolation() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsTransactions() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsTransactionIsolationLevel(int level) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsDataManipulationTransactionsOnly() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean dataDefinitionCausesTransactionCommit() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean dataDefinitionIgnoredInTransactions() throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getProcedures( + String catalog, + String schemaPattern, + String procedureNamePattern) throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getProcedureColumns( + String catalog, + String schemaPattern, + String procedureNamePattern, + String columnNamePattern) throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getTables( + String catalog, + String schemaPattern, + String tableNamePattern, + String types[]) throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getSchemas() throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getCatalogs() throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getTableTypes() throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getColumns( + String catalog, + String schemaPattern, + String tableNamePattern, + String columnNamePattern) throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getColumnPrivileges( + String catalog, + String schema, + String table, + String columnNamePattern) throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getTablePrivileges( + String catalog, + String schemaPattern, + String tableNamePattern) throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getBestRowIdentifier( + String catalog, + String schema, + String table, + int scope, + boolean nullable) throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getVersionColumns( + String catalog, String schema, String table) throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getPrimaryKeys( + String catalog, String schema, String table) throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getImportedKeys( + String catalog, String schema, String table) throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getExportedKeys( + String catalog, String schema, String table) throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getCrossReference( + String parentCatalog, + String parentSchema, + String parentTable, + String foreignCatalog, + String foreignSchema, + String foreignTable) throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getTypeInfo() throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getIndexInfo( + String catalog, + String schema, + String table, + boolean unique, + boolean approximate) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsResultSetType(int type) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsResultSetConcurrency( + int type, int concurrency) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean ownUpdatesAreVisible(int type) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean ownDeletesAreVisible(int type) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean ownInsertsAreVisible(int type) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean othersUpdatesAreVisible(int type) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean othersDeletesAreVisible(int type) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean othersInsertsAreVisible(int type) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean updatesAreDetected(int type) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean deletesAreDetected(int type) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean insertsAreDetected(int type) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsBatchUpdates() throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getUDTs( + String catalog, + String schemaPattern, + String typeNamePattern, + int[] types) throws SQLException { + throw new UnsupportedOperationException(); + } + + public java.sql.Connection getConnection() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsSavepoints() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsNamedParameters() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsMultipleOpenResults() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsGetGeneratedKeys() throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getSuperTypes( + String catalog, + String schemaPattern, + String typeNamePattern) throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getSuperTables( + String catalog, + String schemaPattern, + String tableNamePattern) throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getAttributes( + String catalog, + String schemaPattern, + String typeNamePattern, + String attributeNamePattern) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsResultSetHoldability(int holdability) throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getResultSetHoldability() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getDatabaseMajorVersion() throws SQLException { + return mondrianServer.getVersion().getMajorVersion(); + } + + public int getDatabaseMinorVersion() throws SQLException { + return mondrianServer.getVersion().getMajorVersion(); + } + + public int getJDBCMajorVersion() throws SQLException { + // mondrian olap4j supports jdbc 4.0 + return 4; + } + + public int getJDBCMinorVersion() throws SQLException { + // mondrian olap4j supports jdbc 4.0 + return 0; + } + + public int getSQLStateType() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean locatorsUpdateCopy() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean supportsStatementPooling() throws SQLException { + throw new UnsupportedOperationException(); + } + + 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(); + } + + // straightforward implementation of unwrap and isWrapperFor, since this + // class already implements the interface they most likely require: + // DatabaseMetaData and OlapDatabaseMetaData + + public T unwrap(Class iface) throws SQLException { + if (iface.isInstance(this)) { + return iface.cast(this); + } + throw olap4jConnection.helper.createException( + "does not implement '" + iface + "'"); + } + + public boolean isWrapperFor(Class iface) throws SQLException { + return iface.isInstance(this); + } + + // implement OlapDatabaseMetaData + + public Database getDatabase() { + return new MondrianOlap4jDatabase( + mondrianServer, this); + } + + public ResultSet getActions() throws OlapException { + return new EmptyResultSet(olap4jConnection); + } + + public ResultSet getDatasources( + String dataSourceName) throws OlapException { + return new EmptyResultSet(olap4jConnection); + } + + public ResultSet getLiterals() throws OlapException { + return new EmptyResultSet(olap4jConnection); + } + + public ResultSet getDatabaseProperties( + String dataSourceName) throws OlapException { + return new EmptyResultSet(olap4jConnection); + } + + public ResultSet getProperties() throws OlapException { + return new EmptyResultSet(olap4jConnection); + } + + public String getMdxKeywords() throws OlapException { + StringBuilder buf = new StringBuilder(); + for (String keyword : mondrianServer.getKeywords()) { + if (buf.length() > 0) { + buf.append(','); + } + buf.append(keyword); + } + return buf.toString(); + } + + public ResultSet getCubes( + String catalog, + String schemaPattern, + String cubeNamePattern) throws OlapException { + return new EmptyResultSet(olap4jConnection); + } + + public ResultSet getDimensions() throws OlapException { + return new EmptyResultSet(olap4jConnection); + } + + public ResultSet getFunctions() throws OlapException { + return new EmptyResultSet(olap4jConnection); + } + + public ResultSet getHierarchies() throws OlapException { + return new EmptyResultSet(olap4jConnection); + } + + public ResultSet getMeasures() throws OlapException { + return new EmptyResultSet(olap4jConnection); + } + + public ResultSet getMembers() throws OlapException { + return new EmptyResultSet(olap4jConnection); + } + + public ResultSet getLevels() throws OlapException { + return new EmptyResultSet(olap4jConnection); + } + + public ResultSet getSets() throws OlapException { + return new EmptyResultSet(olap4jConnection); + } +} + +// End MondrianOlap4jDatabaseMetaData.java diff --git a/src/mondrian/olap4j/MondrianOlap4jDimension.java b/src/mondrian/olap4j/MondrianOlap4jDimension.java new file mode 100644 index 0000000..be3cad7 --- /dev/null +++ b/src/mondrian/olap4j/MondrianOlap4jDimension.java @@ -0,0 +1,68 @@ +/* +// $Id: $ +// 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 mondrian.olap4j; + +import org.olap4j.metadata.Dimension; +import org.olap4j.metadata.Hierarchy; +import org.olap4j.metadata.NamedList; +import org.olap4j.metadata.Member; +import org.olap4j.OlapException; + +import java.util.Locale; + +/** + * MondrianOlap4jDimension ... + * + * @author jhyde + * @version $Id: $ + * @since May 24, 2007 + */ +class MondrianOlap4jDimension implements Dimension, Named { + private final MondrianOlap4jSchema olap4jSchema; + private final mondrian.olap.Dimension dimension; + + MondrianOlap4jDimension( + MondrianOlap4jSchema olap4jSchema, + mondrian.olap.Dimension dimension) + { + this.olap4jSchema = olap4jSchema; + this.dimension = dimension; + } + + public NamedList getHierarchies() throws OlapException { + throw new UnsupportedOperationException(); + } + + public NamedList getRootMembers() throws OlapException { + throw new UnsupportedOperationException(); + } + + public Type getDimensionType() throws OlapException { + throw new UnsupportedOperationException(); + } + + public String getName() { + throw new UnsupportedOperationException(); + } + + public String getUniqueName() { + throw new UnsupportedOperationException(); + } + + public String getCaption(Locale locale) { + throw new UnsupportedOperationException(); + } + + public String getDescription(Locale locale) { + throw new UnsupportedOperationException(); + } +} + +// End MondrianOlap4jDimension.java diff --git a/src/mondrian/olap4j/MondrianOlap4jDriver.java b/src/mondrian/olap4j/MondrianOlap4jDriver.java new file mode 100644 index 0000000..ddf741b --- /dev/null +++ b/src/mondrian/olap4j/MondrianOlap4jDriver.java @@ -0,0 +1,128 @@ +/* +// $Id: $ +// 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 mondrian.olap4j; + +import mondrian.rolap.RolapConnectionProperties; + +import java.sql.*; +import java.util.Properties; +import java.util.List; +import java.util.ArrayList; +import java.util.Map; + +/** + * Olap4j driver for Mondrian. + * + *

    Since olap4j is a superset of JDBC, you register this driver as you would + * any JDBC driver: + * + *

    + * Class.forName("mondrian.olap4j.MondrianOlap4jDriver"); + *
    + * + * Then create a connection using a URL with the prefix "jdbc:mondrian:". + * For example, + * + *
    + * import java.sql.Connection;
    + * import java.sql.DriverManager;
    + * import org.olap4j.OlapConnection;
    + *
    + * Connection connection =
    + *    DriverManager.getConnection(
    + *       "jdbc:mondrian:Jdbc=jdbc:odbc:MondrianFoodMart; Catalog=file:/mondrian/demo/FoodMart.xml; JdbcDrivers=sun.jdbc.odbc.JdbcOdbcDriver");
    + * OlapConnection olapConnection =
    + *    connection.unwrap(OlapConnection.class);
    + *
    + * + *

    Note how we use the {@link Connection#unwrap(Class)} method to down-cast + * the JDBC connection object to the extension {@link org.olap4j.OlapConnection} + * object. This method is only available in the JDBC 4.0 (JDK 1.6 onwards). + * + *

    Connection properties

    + * + *

    The driver supports the same set of properties as a traditional mondrian + * connection. See {@link mondrian.rolap.RolapConnectionProperties}. + * + *

    Catalogs and schemas

    + * + *

    Mondrian has a sole catalog, called "LOCALDB". You will get an error + * if you attempt to use {@link java.sql.Connection#setCatalog(String)} to set + * it to anything else. + * + * @author jhyde + * @version $Id: $ + * @since May 22, 2007 + */ +public class MondrianOlap4jDriver implements Driver { + public static final String NAME = "Mondrian olap4j driver"; + public static final String VERSION = "2.4"; + public static final int MAJOR_VERSION = 2; + public static final int MINOR_VERSION = 4; + + static { + try { + register(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + + private static void register() throws SQLException { + DriverManager.registerDriver(new MondrianOlap4jDriver()); + } + + public Connection connect(String url, Properties info) throws SQLException { + return new MondrianOlap4jConnection(url, info); + } + + public boolean acceptsURL(String url) throws SQLException { + return url.startsWith("jdbc:mondrian:"); + } + + public DriverPropertyInfo[] getPropertyInfo( + String url, Properties info) throws SQLException + { + List list = new ArrayList(); + + // First, add the contents of info + for (Map.Entry entry : info.entrySet()) { + list.add( + new DriverPropertyInfo( + (String) entry.getKey(), + (String) entry.getValue())); + } + // Next, add property defns not mentioned in info + for (RolapConnectionProperties p : RolapConnectionProperties.values()) { + if (info.containsKey(p.name())) { + continue; + } + list.add( + new DriverPropertyInfo( + p.name(), + null)); + } + return list.toArray(new DriverPropertyInfo[list.size()]); + } + + public int getMajorVersion() { + return 2; + } + + public int getMinorVersion() { + return 4; + } + + public boolean jdbcCompliant() { + return false; + } +} + +// End MondrianOlap4jDriver.java diff --git a/src/mondrian/olap4j/MondrianOlap4jHierarchy.java b/src/mondrian/olap4j/MondrianOlap4jHierarchy.java new file mode 100644 index 0000000..3b3a0f6 --- /dev/null +++ b/src/mondrian/olap4j/MondrianOlap4jHierarchy.java @@ -0,0 +1,88 @@ +/* +// $Id: $ +// 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 mondrian.olap4j; + +import org.olap4j.metadata.Hierarchy; +import org.olap4j.metadata.Dimension; +import org.olap4j.metadata.Level; +import org.olap4j.metadata.NamedList; + +import java.util.Locale; + +/** + * MondrianOlap4jHierarchy ... + * + * @author jhyde + * @version $Id: $ + * @since May 25, 2007 + */ +class MondrianOlap4jHierarchy implements Hierarchy { + private final MondrianOlap4jSchema olap4jSchema; + private final mondrian.olap.Hierarchy hierarchy; + + MondrianOlap4jHierarchy( + MondrianOlap4jSchema olap4jSchema, + mondrian.olap.Hierarchy hierarchy) + { + this.olap4jSchema = olap4jSchema; + this.hierarchy = hierarchy; + } + + public Dimension getDimension() { + if (false) { + return null; + } + throw new UnsupportedOperationException(); + } + + public NamedList getLevels() { + if (false) { + return null; + } + throw new UnsupportedOperationException(); + } + + public boolean hasAll() { + if (false) { + return false; + } + throw new UnsupportedOperationException(); + } + + public String getName() { + if (false) { + return null; + } + throw new UnsupportedOperationException(); + } + + public String getUniqueName() { + if (false) { + return null; + } + throw new UnsupportedOperationException(); + } + + public String getCaption(Locale locale) { + if (false) { + return null; + } + throw new UnsupportedOperationException(); + } + + public String getDescription(Locale locale) { + if (false) { + return null; + } + throw new UnsupportedOperationException(); + } +} + +// End MondrianOlap4jHierarchy.java diff --git a/src/mondrian/olap4j/MondrianOlap4jLevel.java b/src/mondrian/olap4j/MondrianOlap4jLevel.java new file mode 100644 index 0000000..05724a5 --- /dev/null +++ b/src/mondrian/olap4j/MondrianOlap4jLevel.java @@ -0,0 +1,90 @@ +/* +// $Id: $ +// 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 mondrian.olap4j; + +import org.olap4j.metadata.*; + +import java.util.Locale; + +/** + * MondrianOlap4jLevel ... + * + * @author jhyde + * @version $Id: $ + * @since May 25, 2007 + */ +class MondrianOlap4jLevel implements Level { + private final MondrianOlap4jSchema olap4jSchema; + private final mondrian.olap.Level level; + + public MondrianOlap4jLevel( + MondrianOlap4jSchema olap4jSchema, + mondrian.olap.Level level) + { + this.olap4jSchema = olap4jSchema; + this.level = level; + } + + public int getDepth() { + return level.getDepth(); + } + + public Hierarchy getHierarchy() { + return new MondrianOlap4jHierarchy(olap4jSchema, level.getHierarchy()); + } + + public Dimension getDimension() { + return new MondrianOlap4jDimension(olap4jSchema, level.getDimension()); + } + + public Type getLevelType() { + if (false) { + return null; + } + throw new UnsupportedOperationException(); + } + + public NamedList getProperties() { + if (false) { + return null; + } + throw new UnsupportedOperationException(); + } + + public String getName() { + if (false) { + return null; + } + throw new UnsupportedOperationException(); + } + + public String getUniqueName() { + if (false) { + return null; + } + throw new UnsupportedOperationException(); + } + + public String getCaption(Locale locale) { + if (false) { + return null; + } + throw new UnsupportedOperationException(); + } + + public String getDescription(Locale locale) { + if (false) { + return null; + } + throw new UnsupportedOperationException(); + } +} + +// End MondrianOlap4jLevel.java diff --git a/src/mondrian/olap4j/MondrianOlap4jMember.java b/src/mondrian/olap4j/MondrianOlap4jMember.java new file mode 100644 index 0000000..899d1bd --- /dev/null +++ b/src/mondrian/olap4j/MondrianOlap4jMember.java @@ -0,0 +1,154 @@ +/* +// $Id: $ +// 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 mondrian.olap4j; + +import org.olap4j.metadata.*; +import org.olap4j.metadata.Dimension; +import org.olap4j.metadata.Hierarchy; +import org.olap4j.metadata.Level; +import org.olap4j.metadata.Member; +import org.olap4j.OlapException; +import mondrian.olap.*; + +import java.util.List; +import java.util.Locale; + +/** + * Implementation of {@link Member} as a wrapper around a mondrian + * {@link mondrian.olap.Member}. + * + * @author jhyde + * @version $Id: $ + * @since May 25, 2007 + */ +class MondrianOlap4jMember implements Member, Named { + private final mondrian.olap.Member mondrianMember; + private final MondrianOlap4jSchema olap4jSchema; + + MondrianOlap4jMember( + MondrianOlap4jSchema olap4jSchema, + mondrian.olap.Member mondrianMember) + { + this.olap4jSchema = olap4jSchema; + this.mondrianMember = mondrianMember; + } + + public NamedList getChildMembers() { + final mondrian.olap.Member[] children = + olap4jSchema.schemaReader.getMemberChildren( + mondrianMember); + return new AbstractNamedList() { + public MondrianOlap4jMember get(int index) { + return new MondrianOlap4jMember(olap4jSchema, children[index]); + } + + public int size() { + return children.length; + } + }; + } + + public Member getParentMember() { + return new MondrianOlap4jMember(olap4jSchema, mondrianMember); + } + + public Level getLevel() { + return new MondrianOlap4jLevel(olap4jSchema, mondrianMember.getLevel()); + } + + public Hierarchy getHierarchy() { + return new MondrianOlap4jHierarchy( + olap4jSchema, mondrianMember.getHierarchy()); + } + + public Dimension getDimension() { + return new MondrianOlap4jDimension( + olap4jSchema, mondrianMember.getDimension()); + } + + public Type getMemberType() { + throw new UnsupportedOperationException(); + } + + public boolean isChildOrEqualTo(Member member) { + throw new UnsupportedOperationException(); + } + + public boolean isCalculated() { + throw new UnsupportedOperationException(); + } + + public int getSolveOrder() { + throw new UnsupportedOperationException(); + } + + public Exp getExpression() { + throw new UnsupportedOperationException(); + } + + public List getAncestorMembers() { + throw new UnsupportedOperationException(); + } + + public boolean isCalculatedInQuery() { + throw new UnsupportedOperationException(); + } + + public Object getPropertyValue(String propertyName) { + throw new UnsupportedOperationException(); + } + + public String getPropertyFormattedValue(String propertyName) { + throw new UnsupportedOperationException(); + } + + public void setProperty(String name, Object value) throws OlapException { + throw new UnsupportedOperationException(); + } + + public List getProperties() { + throw new UnsupportedOperationException(); + } + + public int getOrdinal() { + throw new UnsupportedOperationException(); + } + + public boolean isHidden() { + throw new UnsupportedOperationException(); + } + + public int getDepth() { + throw new UnsupportedOperationException(); + } + + public Member getDataMember() { + throw new UnsupportedOperationException(); + } + + public String getName() { + throw new UnsupportedOperationException(); + } + + public String getUniqueName() { + return mondrianMember.getUniqueName(); + } + + public String getCaption(Locale locale) { + throw new UnsupportedOperationException(); + } + + public String getDescription(Locale locale) { + throw new UnsupportedOperationException(); + } + +} + +// End MondrianOlap4jMember.java diff --git a/src/mondrian/olap4j/MondrianOlap4jSchema.java b/src/mondrian/olap4j/MondrianOlap4jSchema.java new file mode 100644 index 0000000..ee1fd40 --- /dev/null +++ b/src/mondrian/olap4j/MondrianOlap4jSchema.java @@ -0,0 +1,81 @@ +/* +// $Id: $ +// 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 mondrian.olap4j; + +import org.olap4j.metadata.*; +import org.olap4j.metadata.Cube; +import org.olap4j.metadata.Dimension; +import org.olap4j.metadata.Schema; +import org.olap4j.OlapException; + +import java.util.Locale; +import java.util.Collection; +import java.util.Collections; + +import mondrian.olap.*; +import mondrian.olap.Hierarchy; + +/** + * MondrianOlap4jSchema ... + * + * @author jhyde + * @version $Id: $ + * @since May 24, 2007 + */ +class MondrianOlap4jSchema implements Schema, Named { + final MondrianOlap4jCatalog olap4jCatalog; + private final mondrian.olap.Schema schema; + final SchemaReader schemaReader; + + MondrianOlap4jSchema( + MondrianOlap4jCatalog olap4jCatalog, + SchemaReader schemaReader, + mondrian.olap.Schema schema) + { + this.olap4jCatalog = olap4jCatalog; + this.schemaReader = schemaReader; + this.schema = schema; + } + + public Catalog getCatalog() { + return olap4jCatalog; + } + + public NamedList getCubes() throws OlapException { + NamedList list = + new NamedListImpl(); + for (mondrian.olap.Cube cube : schema.getCubes()) { + list.add(new MondrianOlap4jCube(cube, this)); + } + return (NamedList) list; + } + + public NamedList getSharedDimensions() throws OlapException { + NamedList list = + new NamedListImpl(); + for (Hierarchy hierarchy : schema.getSharedHierarchies()) { + list.add( + new MondrianOlap4jDimension( + this, + hierarchy.getDimension())); + } + return (NamedList) list; + } + + public Collection getSupportedLocales() throws OlapException { + return Collections.emptyList(); + } + + public String getName() { + return schema.getName(); + } +} + +// End MondrianOlap4jSchema.java diff --git a/src/mondrian/olap4j/MondrianOlap4jStatement.java b/src/mondrian/olap4j/MondrianOlap4jStatement.java new file mode 100644 index 0000000..a1580b1 --- /dev/null +++ b/src/mondrian/olap4j/MondrianOlap4jStatement.java @@ -0,0 +1,262 @@ +/* +// $Id: $ +// 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 mondrian.olap4j; + +import org.olap4j.OlapStatement; +import org.olap4j.CellSet; +import org.olap4j.OlapException; + +import java.sql.*; + +import mondrian.olap.Query; +import mondrian.olap.Result; + +/** + * MondrianOlap4jStatement ... + * + * @author jhyde + * @version $Id: $ + * @since May 24, 2007 + */ +class MondrianOlap4jStatement implements OlapStatement { + final MondrianOlap4jConnection olap4jConnection; + private boolean closed; + MondrianOlap4jCellSet openCellSet; + + MondrianOlap4jStatement( + MondrianOlap4jConnection olap4jConnection) + { + assert olap4jConnection != null; + this.olap4jConnection = olap4jConnection; + this.closed = false; + } + + // implement Statement + + public ResultSet executeQuery(String sql) throws SQLException { + throw new UnsupportedOperationException(); + } + + private void checkOpen() throws SQLException { + if (closed) { + throw olap4jConnection.helper.createException("closed"); + } + } + + public int executeUpdate(String sql) throws SQLException { + throw new UnsupportedOperationException(); + } + + public void close() throws SQLException { + if (!closed) { + closed = true; + if (openCellSet != null) { + CellSet c = openCellSet; + openCellSet = null; + c.close(); + } + } + } + + public int getMaxFieldSize() throws SQLException { + throw new UnsupportedOperationException(); + } + + public void setMaxFieldSize(int max) throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getMaxRows() throws SQLException { + throw new UnsupportedOperationException(); + } + + public void setMaxRows(int max) throws SQLException { + throw new UnsupportedOperationException(); + } + + public void setEscapeProcessing(boolean enable) throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getQueryTimeout() throws SQLException { + throw new UnsupportedOperationException(); + } + + public void setQueryTimeout(int seconds) throws SQLException { + throw new UnsupportedOperationException(); + } + + public void cancel() throws SQLException { + throw new UnsupportedOperationException(); + } + + public SQLWarning getWarnings() throws SQLException { + throw new UnsupportedOperationException(); + } + + public void clearWarnings() throws SQLException { + throw new UnsupportedOperationException(); + } + + public void setCursorName(String name) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean execute(String sql) throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getResultSet() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getUpdateCount() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean getMoreResults() 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 getResultSetConcurrency() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getResultSetType() throws SQLException { + throw new UnsupportedOperationException(); + } + + public void addBatch(String sql) throws SQLException { + throw new UnsupportedOperationException(); + } + + public void clearBatch() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int[] executeBatch() throws SQLException { + throw new UnsupportedOperationException(); + } + + public Connection getConnection() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean getMoreResults(int current) throws SQLException { + throw new UnsupportedOperationException(); + } + + public ResultSet getGeneratedKeys() throws SQLException { + throw new UnsupportedOperationException(); + } + + public int executeUpdate( + String sql, int autoGeneratedKeys) throws SQLException { + throw new UnsupportedOperationException(); + } + + public int executeUpdate( + String sql, int columnIndexes[]) throws SQLException { + throw new UnsupportedOperationException(); + } + + public int executeUpdate( + String sql, String columnNames[]) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean execute( + String sql, int autoGeneratedKeys) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean execute( + String sql, int columnIndexes[]) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean execute( + String sql, String columnNames[]) throws SQLException { + throw new UnsupportedOperationException(); + } + + public int getResultSetHoldability() throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean isClosed() throws SQLException { + return closed; + } + + public void setPoolable(boolean poolable) throws SQLException { + throw new UnsupportedOperationException(); + } + + public boolean isPoolable() throws SQLException { + throw new UnsupportedOperationException(); + } + + // implement Wrapper + + public T unwrap(Class iface) throws SQLException { + if (iface.isInstance(this)) { + return iface.cast(this); + } + throw olap4jConnection.helper.createException( + "does not implement '" + iface + "'"); + } + + public boolean isWrapperFor(Class iface) throws SQLException { + return iface.isInstance(this); + } + + // implement OlapStatement + + + public CellSet executeOlapQuery(String mdx) throws OlapException { + // Close the previous open CellSet, if there is one. + if (openCellSet != null) { + final MondrianOlap4jCellSet cs = openCellSet; + openCellSet = null; + try { + cs.close(); + } catch (SQLException e) { + throw olap4jConnection.helper.createException( + null, "Error while closing previous CellSet", e); + } + } + Query query = olap4jConnection.connection.parseQuery(mdx); + Result result = olap4jConnection.connection.execute(query); + openCellSet = new MondrianOlap4jCellSet(this, result); + return openCellSet; + } + + public CellSet executeOlapQuery(Query query) { + throw new UnsupportedOperationException(); + } +} + +// End MondrianOlap4jStatement.java diff --git a/src/mondrian/olap4j/Named.java b/src/mondrian/olap4j/Named.java new file mode 100644 index 0000000..e805dba --- /dev/null +++ b/src/mondrian/olap4j/Named.java @@ -0,0 +1,30 @@ +/* +// $Id: $ +// 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 mondrian.olap4j; + +/** + * Interface which describes an object which has a name, for the purposes of + * creating an implementation, {@link mondrian.olap4j.NamedListImpl} of + * {@link org.olap4j.metadata.NamedList} which works on such objects. + * + * @author jhyde + * @version $Id: $ + * @since May 23, 2007 + */ +interface Named { + /** + * Returns the name of this object. + * + * @return name of this object + */ + String getName(); +} + +// End Named.java diff --git a/src/mondrian/olap4j/NamedListImpl.java b/src/mondrian/olap4j/NamedListImpl.java new file mode 100644 index 0000000..c96e195 --- /dev/null +++ b/src/mondrian/olap4j/NamedListImpl.java @@ -0,0 +1,49 @@ +/* +// $Id: $ +// 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 mondrian.olap4j; + +import org.olap4j.metadata.NamedList; + +import java.util.ArrayList; + +/** + * Implementation of {@link org.olap4j.metadata.NamedList} which uses + * {@link java.util.ArrayList} for storage and assumes that elements implement + * the {@link Named} interface. + * + * @author jhyde + * @version $Id: $ + * @since May 23, 2007 + */ +class NamedListImpl + extends ArrayList + implements NamedList { + + public T get(String name) { + for (T t : this) { + if (t.getName().equals(name)) { + return t; + } + } + return null; + } + + public int indexOfName(String name) { + for (int i = 0; i < size(); ++i) { + T t = get(i); + if (t.getName().equals(name)) { + return i; + } + } + return -1; + } +} + +// End NamedListImpl.java diff --git a/src/org/olap4j/Axis.java b/src/org/olap4j/Axis.java index 95a4ebe..5e2e574 100644 --- a/src/org/olap4j/Axis.java +++ b/src/org/olap4j/Axis.java @@ -28,8 +28,8 @@ public enum Axis { /** * Returns the ordinal which is to be used for retrieving this axis from - * the {@link org.olap4j.OlapResultSet#getAxes()}, or retrieving its - * coordinate from {@link ResultCell#getCoordinateList()}. + * the {@link org.olap4j.CellSet#getAxes()}, or retrieving its + * coordinate from {@link Cell#getCoordinateList()}. * *

    The axis ordinal is one less than the {@link #ordinal} value which * every enum value possesses. Hence, {@link #SLICER} is -1 diff --git a/src/org/olap4j/ResultCell.java b/src/org/olap4j/Cell.java old mode 100644 new mode 100755 similarity index 73% rename from src/org/olap4j/ResultCell.java rename to src/org/olap4j/Cell.java index 8db8687..cb73937 --- a/src/org/olap4j/ResultCell.java +++ b/src/org/olap4j/Cell.java @@ -1,5 +1,5 @@ /* -// $Id$ +// $Id: Cell.java 15 2006-10-24 08:41:02Z jhyde $ // 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. @@ -15,26 +15,26 @@ import java.sql.ResultSet; /** - * Cell returned from a {@link OlapResultSet}. + * Cell returned from a {@link CellSet}. * * @author jhyde - * @version $Id$ + * @version $Id: Cell.java 15 2006-10-24 08:41:02Z jhyde $ * @since Aug 22, 2006 */ -public interface ResultCell { +public interface Cell { /** - * Returns the {@link OlapResultSet} that this ResultCell belongs to. + * Returns the {@link CellSet} that this Cell belongs to. * - * @return OlapResultSet, never null + * @return CellSet, never null */ - OlapResultSet getResultSet(); + CellSet getCellSet(); /** - * Returns the ordinal of this ResultCell. + * Returns the ordinal of this Cell. * *

    The formula is the sequence, zero-based, which the cell would be * visited in a raster-scan through all of the cells of this - * {@link OlapResultSet}. The ordinal of the first cell is zero, and the + * {@link CellSet}. The ordinal of the first cell is zero, and the * ordinal of the last cell is the product of the lengths of the axes, minus * 1. For example, if a result has 10 columns and 20 * rows, then: