From 511578ced21791dd12e14bb0c8060ce58cfce667 Mon Sep 17 00:00:00 2001 From: Julian Hyde Date: Mon, 16 Oct 2006 05:37:08 +0000 Subject: [PATCH] Update specification and java code, especially metadata (org.olap4j.metadata) and type (org.olap4j.type) sections, and description of how to interoperate with connection pools. git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@10 c6a108a4-781c-0410-a6c6-c2d559e19af0 --- build.xml | 7 +- doc/olap4j_fs.html | 2571 ++++++++++++++++-- src/org/olap4j/Olap4j.java | 237 ++ src/org/olap4j/OlapConnection.java | 7 + src/org/olap4j/OlapDatabaseMetaData.java | 181 ++ src/org/olap4j/OlapStatement.java | 1 - src/org/olap4j/metadata/Cube.java | 3 +- src/org/olap4j/metadata/Dimension.java | 11 +- src/org/olap4j/metadata/Hierarchy.java | 2 +- src/org/olap4j/metadata/Level.java | 8 +- src/org/olap4j/metadata/Measure.java | 22 + src/org/olap4j/metadata/Member.java | 36 +- src/org/olap4j/metadata/MetadataElement.java | 51 + src/org/olap4j/metadata/Property.java | 50 +- src/org/olap4j/metadata/Schema.java | 23 + src/org/olap4j/sample/SimpleQuerySample.java | 34 +- src/org/olap4j/type/BooleanType.java | 25 + src/org/olap4j/type/CubeType.java | 51 + src/org/olap4j/type/DecimalType.java | 70 + src/org/olap4j/type/DimensionType.java | 79 + src/org/olap4j/type/HierarchyType.java | 75 + src/org/olap4j/type/LevelType.java | 103 + src/org/olap4j/type/MemberType.java | 148 + src/org/olap4j/type/NullType.java | 28 + src/org/olap4j/type/NumericType.java | 35 + src/org/olap4j/type/ScalarType.java | 45 + src/org/olap4j/type/SetType.java | 69 + src/org/olap4j/type/StringType.java | 32 + src/org/olap4j/type/SymbolType.java | 29 + src/org/olap4j/type/TupleType.java | 68 + src/org/olap4j/type/Type.java | 56 +- src/org/olap4j/type/TypeUtil.java | 161 ++ src/org/olap4j/type/package.html | 6 + 33 files changed, 4078 insertions(+), 246 deletions(-) create mode 100644 src/org/olap4j/Olap4j.java create mode 100644 src/org/olap4j/OlapDatabaseMetaData.java create mode 100644 src/org/olap4j/metadata/Measure.java create mode 100644 src/org/olap4j/metadata/MetadataElement.java create mode 100644 src/org/olap4j/metadata/Schema.java create mode 100755 src/org/olap4j/type/BooleanType.java create mode 100755 src/org/olap4j/type/CubeType.java create mode 100755 src/org/olap4j/type/DecimalType.java create mode 100755 src/org/olap4j/type/DimensionType.java create mode 100755 src/org/olap4j/type/HierarchyType.java create mode 100755 src/org/olap4j/type/LevelType.java create mode 100644 src/org/olap4j/type/MemberType.java create mode 100755 src/org/olap4j/type/NullType.java create mode 100755 src/org/olap4j/type/NumericType.java create mode 100755 src/org/olap4j/type/ScalarType.java create mode 100755 src/org/olap4j/type/SetType.java create mode 100755 src/org/olap4j/type/StringType.java create mode 100755 src/org/olap4j/type/SymbolType.java create mode 100755 src/org/olap4j/type/TupleType.java create mode 100755 src/org/olap4j/type/TypeUtil.java create mode 100755 src/org/olap4j/type/package.html diff --git a/build.xml b/build.xml index 4f597f0..5fda06e 100644 --- a/build.xml +++ b/build.xml @@ -14,7 +14,7 @@ - + @@ -183,7 +183,7 @@ ${doc.dir}/api/src-html/**/*"/> @@ -197,7 +197,8 @@ doc/api/**/*, doc/**/*.html, doc/**/*.pdf, doc/**/*.css, -doc/**/*.xml" +doc/**/*.xml, +doc/olap4j_api.pdf" excludes=" **/*~, **/_vti*/*, diff --git a/doc/olap4j_fs.html b/doc/olap4j_fs.html index e39629c..84443f8 100644 --- a/doc/olap4j_fs.html +++ b/doc/olap4j_fs.html @@ -11,6 +11,17 @@ font-weight: bold; color: maroon; } +A.javadoc { + font-family: 'courier new', monospace; + font-size: 80%; + font-weight: bold; + color: maroon; + text-decoration: none; +} +A:hover.javadoc, A:active.javadoc { + color: black; + text-decoration: underline; +} DIV.code { font-family: 'courier new', monospace; font-size: 80%; @@ -24,6 +35,15 @@ border-width: 1px; padding: 4px; } +DIV.note { + background-color: #e0e0e0; + margin-left: 20; + margin-right: 20; + border-style: solid; + border: solid #000000 1px; + border-width: 1px; + padding: 4px; +} IMG.std { border: solid #000000 1px; border-color: #000000; @@ -63,29 +83,70 @@

olap4j Functional Specification

Version: 0.6-dev (draft)
Revision: $Id: $ (log)
-Last modified: October 11th, 2006.

+Last modified: October 14th, 2006.


Contents

  1. Introduction
      -
    1. A brief history of OLAP +
    2. A brief history of OLAP standards
    3. Overview of olap4j
    4. +
    5. Relationship to other + standards
      1. olap4j and XML/A
      2. -
      3. Benefits of a +
      4. olap4j is built on + other standards
      5. +
      +
    6. +
    7. Benefits of a standard Java API for OLAP
    8. Architecture of olap4j
  2. Components of the API
    1. Driver management
    2. -
    3. Connections
    4. -
    5. Statements
    6. +
    7. Connections
        +
      1. OlapConnection
      2. +
      3. Connection pooling
      4. +
      +
    8. +
    9. Statements
        +
      1. OlapStatement
      2. +
      3. PreparedOlapStatement
      4. +
      +
    10. MDX query model
    11. MDX type model
    12. -
    13. Metadata
    14. +
    15. Metadata
      1. Access control
      2. +
      3. Metadata objects
          +
        1. Schema
        2. +
        3. Cube
        4. +
        5. Dimension
        6. +
        7. Hierarchy
        8. +
        9. Level
        10. +
        11. Measure
        12. +
        13. Member
        14. +
        15. Property
        16. +
      4. +
      5. Methods which return + schema rowsets
          +
        1. getDatasources
        2. +
        3. getDatabaseProperties
        4. +
        5. getLiterals
        6. +
        7. getCubes
        8. +
        9. getDimensions
        10. +
        11. getFunctions
        12. +
        13. getHierarchies
        14. +
        15. getLevels
        16. +
        17. getMeasures
        18. +
        19. getMembers
        20. +
        21. getProperties
        22. +
        23. getSets
        24. +
      6. +
      7. Other methods
      8. +
    16. Transform
    17. Layout
    @@ -102,11 +163,12 @@

    Contents

  3. Other data sources
-
  • Appendix A. Opportunities for +
  • Appendix A. Opportunities for specification
  • Appendix B. Feedback
  • Appendix C. Open issues
  • Appendix D. Miscellaneous
  • +
  • Appendix E. References
  • 1. Introduction

    @@ -182,14 +244,16 @@

    1.2. Overview of olap4j

    Metadata is at the heart of olap4j. You can browse the cubes, dimensions, hierarchies, members in an OLAP schema, and an MDX parse tree and query result are tied back to the same metadata objects. There is also a type -system for describing scalar expressions.

    +system for describing expressions.

    olap4j makes it possible to write an OLAP client without starting from scratch. In addition to the MDX parser, and operations on the MDX parse tree, there is a higher-level query model, which includes operations to transform queries (also called 'navigations'), and facilities to layout multidimensional results as HTML tables.

    -

    1.3. olap4j and XML/A

    +

    1.3. Relationship to other +standards

    +

    1.3.1. olap4j and XML/A

    At this point, you may be saying: what about XML/A? XML/A was here first, is an open standard, and is supported by a number of servers. Is olap4j an attempt to @@ -207,7 +271,37 @@

    1.3. olap4j and XML/A

    If a web-services based application needs these functions, it can use the XML/A provider to connect to the underlying data source, execute queries, and browse metadata, but can still use olap4j's features for MDX parsing, query -models and layout.

    +models and layout.

    +

    1.3.2. olap4j is built on other +standards

    +

    Where possible, olap4j leverages existing standards. This has several +advantages. First, an end-user familiar with the existing standards can come up +to speed with olap4j quickly. For instance, creating a connection and executing +a statement should be straightforward to anyone familiar with JDBC connections, +statements and result sets work.

    +

    If an OLAP server implementor has already implemented a driver for one +standard, then it should be less work to implement an olap4j driver. This +clearly applies to the MDX language (borrowed from XML/A and OLE DB for OLAP). +Implementation schema result sets should be straightforward if the server +already supports XML/A schema rowsets.

    +

    If olap4j is sufficiently similar to an existing standard, tools designed for +use with that standard may be applicable to olap4j also. For instance, one goal +of olap4j is that people will be able to use connection-pooling libraries such +as Jakarta Commons DBCP, +C3P0. (This presents some +challenges because olap4j extends some of the JDBC interfaces, but we hope to +solve them.)

    +

    Lastly, reusing an existing standard is less work for the authors of the new +standard!

    +

    Sometimes the standards conflict. ADOMD exposes its metadata through an +object model, whereas JDBC and XML/A expose metadata relationally, via what +XML/A calls rowsets and what we and JDBC call result sets. In this case, we +chose to do both, because of the diversity of needs of olap4j clients. Metadata +objects allow you to integrate query results with metadata using much fewer +code: positions can reference members, and you can navigate from a member to its +hierarchy, and so forth. Likewise, metadata objects can be used in building MDX +parse trees. But if a client tool wants to maintain its own metadata cache, +schema rowsets are more flexible and efficient.

    1.4. Benefits of a standard Java API for OLAP

    @@ -243,17 +337,17 @@

    1.5. Architecture of olap4j

    Classes:

    2.1.1. Driver

    Same functionality as JDBC.

    Here is an example of registering an olap4j driver:

    -
    +
    Class.forName("mondrian.olap4j.Driver");

    2.1.2. DriverManager

    Same functionality as JDBC.

    @@ -276,14 +370,14 @@

    2.2. Connections

    import org.olap4j.*;

    Class.forName("mondrian.olap4j.Driver");
    - Connection connection =
    + OlapConnection connection = (OlapConnection)
        DriverManager.createConnection(
            "jdbc:mondrian:local:Jdbc=jdbc:odbc:MondrianFoodMart;" +
            "Catalog=/WEB-INF/queries/FoodMart.xml;" +
            "Role='California manager'");
    - Statement statement = connection.createStatement();
    + OlapStatement statement = connection.createOlapStatement();

    OlapResult result =
        statement.execute(
    @@ -297,7 +391,7 @@

    2.2. Connections

    Services™ (MSAS) via XML/A. Note that besides the driver class and connect string, the code is identical.

    -
    +
    import org.olap4j.*;

    Class.forName("olap4j.impl.xmla.Driver");
    OlapConnection connection = (OlapConnection)
        DriverManager.createConnection(
            "jdbc:olap4jxmla:Server=http://localhost/xmla/msxisapi.dll;" +
            "Catalog=FoodMart");
    OlapStatement statement = connection.createOlapStatement();

    OlapResultSet result =
        statement.execute(
            "SELECT {[Measures].[Unit Sales]} ON @@ -307,128 +401,111 @@

    2.2. Connections

    In the above examples, a statement was created from a string. As we shall see, a statement can also be created from an MDX parse tree.

    -

    Package name: org.olap4j

    +

    Package name: org.olap4j

    -

    2.2.1. OlapConnection (extends -java.sql.Connection)

    -

    OlapConnection is a +

    2.2.1. OlapConnection

    +OlapConnection  (extends + +java.sql.Connection) is a connection to an OLAP data source.

    -

    2.2.2 Connection pooling

    -

    olap4j extends various JDBC interfaces:

    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    olap4j classextends JDBC classcreated by
    org.olap4j.OlapConnectionjava.sql.ConnectionConnection DriverManager.createConnection()
    - Connection DataSource.getConnection()
    org.olap4j.OlapStatementjava.sql.StatementStatement Connection.createStatement()
    org.olap4j.PreparedOlapStatementjava.sql.PreparedStatementPreparedStatement Connection.prepareStatement()
    org.olap4j.OlapResultSetjava.sql.ResultSetResultSet Statement.executeQuery(String)
    - ResultSet PreparedStatement.executeQuery()
    -

    One would expect that it would be safe to downcast the result of a factory +

    2.2.2. Connection pooling

    +

    Look again at the code samples in the previous section. One would expect that it would be safe to downcast the result of a factory method to the desired result. For example, if you invoke an OlapConnection's createStatement() method, the result should be an OlapStatement.

    -

    However, this will not be the case if you are using a connection-pooling -library, common examples of which include Jakarta Commons DBCP and C3P0. Every -connection-pooling library tracks connections by wrapping them in another class, +

    But if you you are using a connection-pooling +library (common examples of which include Jakarta Commons DBCP +and +C3P0), this is not so. Every +connection-pooling library tracks connections by wrapping them in another class, and this class will implement java.sql.Connection but not -OlapConnection. To access methods of the OlapConnection, the +OlapConnection. To access methods of the OlapConnection, the client application must first strip away the wrapper object.

    -

    The problem is not restricted to connections: some connection pools also wrap -Statement, PreparedStatement, ResultSet -and DatabaseMetaData objects. But the good news is that you don't -need to access OlapConnection, OlapStatement or -PreparedOlapStatement very often, because they do do not have many -methods

    -

     

    +

    If you are using a connection-pooling library, olap4j provides a helper class to access the object underneath a wrapped +connection, statement, prepared statement or result set. For instance,

    + +
    DataSource dataSource; // a data source using a connection + pool
    + Connection connection =
    +    DriverManager.createConnection(
    +        "jdbc:mondrian:local:Jdbc=jdbc:odbc:MondrianFoodMart;" + +
    +        "Catalog=/WEB-INF/queries/FoodMart.xml;" + +
    +        "Role='California manager'");
    + OlapConnection olapConnection = Olap4j.convert(connection);
    + OlapStatement statement = olapConnection.createOlapStatement();
    + +

    The + +Olap4j.convert(Connection) method returns an OlapConnection. It +works with common connection pools, and the resulting object is instrumented so +that any statements or prepared statements created from that connection also +work with the connection pool.

    +

    The problem does not just affect connections: some connection pools also wrap +Statement, PreparedStatement, ResultSet +and DatabaseMetaData objects, so there are convert() +methods for these too.

    +

    Hopefully this problem will only be temporary. As olap4j gains popularity, we +expect connection pools to add support for the extended interfaces, and it will +be sufficient merely to cast the objects returned from factory methods.

    2.3. Statements

    -

    2.3.1. OlapStatement

    -

    OlapStatement  (extends -java.sql.Statement) -is an object used to execute a static MDX statement and return the result it +

    2.3.1. OlapStatement

    +

    OlapStatement  (extends +java.sql.Statement) +is an object used to execute a static MDX statement and return the result it produces.

    -

    2.3.2. PreparedOlapStatement

    -

    PreparedOlapStatement +

    2.3.2. PreparedOlapStatement

    +

    PreparedOlapStatement (extends - + java.sql.PreparedStatement) represents a precompiled MDX statement.

    -

    An MDX statement is precompiled and stored in a PreparedOlapStatement -object. This object can then be used to efficiently execute this statement +

    An MDX statement is precompiled and stored in a PreparedOlapStatement +object. This object can then be used to efficiently execute this statement multiple times.

    The method - -PreparedStatement.getParameterMetaData() returns a description of the + +PreparedStatement.getParameterMetaData() returns a description of the parameters, as in JDBC. The result is an OlapParameterMetaData.

    -

    To set values of parameters, use the setType(int, type) -methods. If a parameter is a member, use the setObject(int, Object) -method; throws an exception if the object is not a member, or is a member of the +

    To set values of parameters, use the setType(int, type) +methods. If a parameter is a member, use the setObject(int, Object) +method; throws an exception if the object is not a member, or is a member of the wrong hierarchy.

    -

    Unlike JDBC, it is not necessary to assign a value to every parameter. This -is because OLAP parameters have a default value. Parameters have their default -value until they are set, and then retain their new values for each subsequent +

    Unlike JDBC, it is not necessary to assign a value to every parameter. This +is because OLAP parameters have a default value. Parameters have their default +value until they are set, and then retain their new values for each subsequent execution of this PreparedOlapStatement.

    -

    2.3.3. OlapParameterMetaData

    -

    OlapParameterMetaData +

    [How to find out what cube a prepared statement relates to?]

    +

    2.3.3. OlapParameterMetaData

    +

    OlapParameterMetaData (extends - + java.sql.ParameterMetaData) describes parameters of a PreparedOlapStatement.

    -

    2.3.4. OlapResultSet

    -

    OlapResultSet (extends - -java.sql.ResultSet) is the result of executing a 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 +

    2.3.4. OlapResultSet

    +

    OlapResultSet (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 are applicable:

    Additional methods to retrieve the axes of the multidimensional result.

    -

    2.3.5. ResultAxis

    +

    2.3.5. ResultAxis

    [tbd]

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

    -

    2.3.6. Position

    +

    2.3.6. Position

    [tbd]

    -

    2.3.7. ResultCell

    +

    2.3.7. ResultCell

    [tbd]

    2.4. MDX query model

    @@ -508,6 +585,8 @@

    2.4. MDX query model

    2.5. MDX type model

    +

    Package name: org.olap4j.mdx.type

    +

    Represents the types of nodes in an MDX query model.

    Here are some examples:

    @@ -531,7 +610,7 @@

    2.5. MDX type model

    [Store].[USA].[CA] - Member<dimension=[Store], hierarchy=[Store], level=[Store].[State], + Member<dimension=[Store], hierarchy=[Store], level=[Store].[State], member=[Store].[USA].[CA]> @@ -540,61 +619,2193 @@

    2.5. MDX type model

    -

    Since MDX is a late-binding language, some expressions will have unknown +

    Since MDX is a late-binding language, some expressions will have unknown types, or only partial type information. For example, the expression

    [Store].Levels("Sta" + "te")
    -

    will have type Level<dimension=[Store], level=unknown>. The -validator knows that the <hierarchy>.Levels(<string expr>) function -returns a level, but exactly which level is not known until the expression is +

    will have type Level<dimension=[Store], level=unknown>. The +validator knows that the <hierarchy>.Levels(<string expr>) function +returns a level, but exactly which level is not known until the expression is evaluated at runtime.

    - -

    Package name: org.olap4j.mdx.type

    - -

    Classes:

    +

    Type is the base class for all types.

    +

    Scalar types:

      -
    • BooleanType
    • -
    • CubeType
    • -
    • DecimalType
    • -
    • DimensionType
    • -
    • HierarchyType
    • -
    • LevelType
    • -
    • MemberType
    • -
    • NumericType
    • -
    • ScalarType
    • -
    • SetType
    • -
    • StringType
    • -
    • SymbolType
    • -
    • TupleType
    • -
    • Type
    • -
    • TypeUtil
    • +
    • ScalarType represents the type of an expression which has a + simple value such as a number or a string.
    • +
    • + BooleanType (extends ScalarType) represents an expression which can have values + TRUE and FALSE.
    • +
    • + NumericType represents the type of a numeric expression.
    • +
    • + DecimalType (extends NumericType) represents a fixed-point numeric expression. It + is a subclass of NumericType, and has precision and scale. An + integer expression would have scale 0.
    • +
    • StringType (extends ScalarType) represents the type of an expression which has a string + value.
    • +
    • SymbolType (extends ScalarType) represents the type of a + symbol, or flag, argument to a builtin function. For example, the ASC + keyword in the expression Order(Gender.MEMBERS, Measures.[Unit Sales], + ASC) is a symbol. Symbol types are rarely used except if you are + manipulating a parse tree.
    • +
    +

    Metadata types:

    +
      +
    • CubeType represents the type of an expression whose value + is a cube.
    • +
    • + DimensionType represents the type of an expression whose + value is a dimension.
    • +
    • + HierarchyType represents the type of an expression whose + value is a hierarchy.
    • +
    • LevelType represents the type of an expression whose value + is a level.
    • +
    • MemberType represents the type of an expression whose value + is a member.
    • +
    +

    A metadata type may be constrained to a particular part of the schema. For +example, LevelType(hierarchy=[Time]) indicates that the expression +must evaluate to one of the levels of the [Time] hierarchy, that +is, one of the values [Time].[Year], [Time].[Quarter], +or [Time].[Month].

    +

    Composite types

    +
      +
    • SetType represents the type of an expression which is a + set. It has a component type, for example, the type of the expression + {[Store].[USA].Children} is Set(Member(level=[Store].[Store + State]).
    • +
    • TupleType represents the type of an expression which + consists of an n-tuple of members. It has a set of component types, each of + which is a member type. For example, the type of the expression + CrossJoin({[Gender].[F], [Gender].[M]}, [Store].Members) is + Set(Tuple(Member(level=[Gender].[Gender]), Member(hierarchy=[Store])).
    -

    2.6. Metadata

    - -

    Package name: org.olap4j.metamodel

    - -

    The components of the OLAP model are available as read-only Java classes, and -also via schema rowsets.

    - +

    Package name: + +org.olap4j.metamodel

    +

    Metadata are the objects which describe the structure of an OLAP schema: +cubes, dimensions, members, properties and so forth.

    +

    olap4j exposes metadata in two very different ways:

    +
      +
    • A metadata object is a Java object which represents a particular +metadata class. For example, +org.olap4j.metadata.Cube.
    • +
    • A schema result set is a JDBC ResultSet which returns a record + for each instance of a particular metadata class. There is a method in + OlapDatabaseMetaData to create a schema rowset for each metadata class. Some + of these methods accept parameters to filter the rows returned. For example, + + OlapDatabaseMetaData.getCubes(<schemaName>, <cubeName>).
    • +

    2.6.1. Access control

    -

    A user's view of metadata may be subject to access control. For example, a -user may not have read access to certain hierarchies within a cube, or to -certain members within a hierarchy. The API methods must behave consistently +

    A user's view of metadata may be subject to access control. For example, a +user may not have read access to certain hierarchies within a cube, or to +certain members within a hierarchy. The API methods must behave consistently with access control.

    -

    Example: If Fred does not have access to the [Nation] +

    Example: If Fred does not have access to the [Nation] level of the [Store] hierarchy, then the Member.getParentMember() method will return null if applied to - [Store].[USA].[CA], because the 'real' parent member [Store].[USA] + [Store].[USA].[CA], because the 'real' parent member [Store].[USA] is invisible to him.

    -

    2.6.2. Schema rowsets

    +

    2.6.2. Metadata objects

    +

    [Diagram of object model, showing relationships between Schema, Cube, +Dimension, etc.]

    +
    2.6.2.1. MetadataElement
    +

    +MetadataElement is the base class for Cube, Dimension, Hierarchy, Level, Member, Property; provides +name and unique-name properties (not localized), and localized caption and +description.

    +
      +
    • String getName()
    • +
    • String getUniqueName()
    • +
    • String getCaption(Locale locale)
    • +
    • String getDescription(Locale locale)
    • +
    +
    2.6.2.2. Schema
    +

    Schema ...

    +
      +
    • String getName()
    • +
    +
    2.6.2.3. Cube
    +

    Cube ...

    +
      +
    • List<Dimension> getDimensions()
    • +
    • Schema getSchema()
    • +
    • String getName()
    • +
    +
    2.6.2.4. Dimension
    +

    Dimension +...

    +
      +
    • String getName()
    • +
    • List<Hierarchy> getHierarchies()
    • +
    • List<Member> getRootMembers()
    • +
    • Dimension.Type getDimensionType()
    • +
    +
    2.6.2.5. Hierarchy
    +

    Hierarchy +...

    +
      +
    • Dimension getDimension()
    • +
    • String getName()
    • +
    • List<Level> getLevels()
    • +
    • boolean hasAll()
    • +
    +
    2.6.2.6. Level
    +

    Level ...

    +
      +
    • int getDepth()
    • +
    • Hierarchy getHierarchy()
    • +
    • Level.Type getLevelType()
    • +
    • List<Property> getProperties()
    • +
    +
    2.6.2.6. Measure
    +

    Meaure ...

    +
      +
    • extends Member
    • +
    +
    2.6.2.7. Member
    +

    Member ...

    +
      +
    • String getName()
    • +
    • List<Member> getChildMembers()
    • +
    • Member getParentMember()
    • +
    • Level getLevel()
    • +
    • Hierarchy getHierarchy()
    • +
    • boolean isChildOrEqualTo(Member member)
    • +
    • boolean isCalculated()
    • +
    • boolean isCalculatedInQuery()
    • +
    • int solveOrder()
    • +
    • List<Member> getAncestorMembers()
    • +
    • Object getPropertyValue(String propertyName)
    • +
    • String getPropertyFormattedValue(String propertyName)
    • +
    • void setProperty(String name, Object value)
    • +
    • List<Property> getProperties()
    • +
    • int getOrdinal()
    • +
    • boolean isHidden()
    • +
    • Member getDataMember()
    • +
    +
    2.6.2.8. Property
    +

    Property +...

    +
      +
    • Datatype getType()
    • +
    • Scope getScope()
    • +
    • String getCaption()
    • +
    • boolean isInternal()
    • +
    • enum Scope { MEMBER, CELL }
    • +
    • enum Datatype { STRING, OTHER, NUMERIC, BOOLEAN }
    • +
    • enum StandardMemberProperty { CATALOG_NAME, SCHEMA_NAME, CUBE_NAME, ... + }
    • +
    • enum StandardCellProperty { BACK_COLOR, CELL_EVALUATION_LIST, ... }
    • +
    +

    2.6.3. Methods which return schema rowsets

    +

    Schema rowsets are specified as in [XML for Analysis +specification]. Here is a table of the XML/A methods and the corresponding +olap4j method.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    XML for Analysis schema rowsetOlapDatabaseMetaData method
    DISCOVER_DATASOURCES + + getDatasources
    DISCOVER_ENUMERATORSnot supported
    DISCOVER_KEYWORDS + + getMdxKeywords
    DISCOVER_LITERALS + + getLiterals
    DISCOVER_PROPERTIES + + getDatabaseProperties
    DISCOVER_SCHEMA_ROWSETSnot supported
    MDSCHEMA_ACTIONS + + getActions
    MDSCHEMA_CUBES + + getCubes
    MDSCHEMA_DIMENSIONS + + getDimensions
    MDSCHEMA_FUNCTIONS + + getFunctions
    MDSCHEMA_HIERARCHIES + + getHierarchies
    MDSCHEMA_INPUT_DATASOURCESnot supported
    MDSCHEMA_KPISnot supported
    MDSCHEMA_LEVELS + + getLevels
    MDSCHEMA_MEASURES + + getMeasures
    MDSCHEMA_MEMBERS + + getMembers
    MDSCHEMA_PROPERTIES + + getProperties
    MDSCHEMA_SETS + + getSets
    +

    The rows returned in the result set returned from the metadata +methods are structured according to the result set column layouts detailed in this +section.

    +

    All columns noted in the following result sets are required, and +they must be returned in the order shown. However, additional columns (which +should be ignored by clients not expecting thxem) can be added at the end, and +some columns can contain null data for info +xxx +

    The following sections describe the columns in each rowset. Each +section includes a table that provides the following information for each +column.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Column headingContents
    Column nameThe name of the column in the output rowset.
    TypeA description of the data type for the column.
    DescriptionA brief description of the purpose of the column.
    RestrictionIndicates whether the column can be used to restrict the + returned rowset by inclusion in the Restrictions + parameter of the Discover method. + Yes means that the column is available to + use as a Restrictions item to filter results + by this field.
    NullableIndicates whether the data must be returned or if a null + string is allowed if the column does not apply. Yes + means nulls are allowed, and the data is optional. + No means that the data is required.
    +

    [Need to clean up data types in the following tables. Types should all be +JDBC types.]

    +

    [Need to clean up column names in the following tables. Columns should be +UPPER_CASE, not CamelCase.]

    +

    [It would be useful to define enum types for the various attributes, such as +the ProviderType and AuthenticationMode attributes of getDatasources, and the +DIMENSION_TYPE attribute of getDimensions. In some cases those enums already +exist, but need to be extended.]

    + +
    2.6.3.1. getDatasources
    +

    Specified by the DISCOVER_DATASOURCES XML for Analysis method.

    +

    The returned result set contains the following columns.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Column nameTypeDescriptionNullable
    DataSourceNamestringThe name of the data source, such as + FoodMart 2000.No
    DataSourceDescriptionstringA description of the data source, as entered by the + publisher.Yes
    URLstringThe unique path that shows where to invoke the XML for + Analysis methods for that data source.Yes
    DataSourceInfostring +

    A string containing any additional information required + to connect to the data source. This can include the Initial Catalog + property or other information for the provider.

    +

    Example: "Provider=MSOLAP;Data Source=Local;"

    +
    Yes
    ProviderNamestring +

    The name of the provider behind the data source.

    +

    Example: "MSDASQL"

    +
    Yes
    ProviderTypearray +

    The types of data supported by the + provider. May include one or more of the following types. Example + follows this table.

    +
      +
    • TDP: tabular data provider.
    • +
    • MDP: multidimensional data provider.
    • +
    • DMP: data mining provider. A DMP provider + implements the OLE DB for Data Mining specification.
    • +
    +
    No
    AuthenticationModeEnumString + Specification of what type of + security mode the data source uses. Values can be one of the following: +
      +
    • Unauthenticated: no user ID or password needs to be sent.
    • +
    • Authenticated: User ID and + Password must be included in the information required for the + connection.
    • +
    • Integrated: the data source uses the + underlying security to determine authorization, such as Integrated + Security provided by Microsoft Internet Information Services (IIS).
    • +
    +
    No
    + +
    2.6.3.2. getDatabaseProperties
    + +

    Returns +information about the standard and provider-specific properties supported by an +olap4j provider. Properties that are not supported by a provider are +not listed in the return result set.

    +

    Specified by the DISCOVER_PROPERTIES XML for Analysis method.

    +

    The returned result set contains the following columns.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Column nameTypeDescriptionNullable
    PROPERTY_NAMEstringThe name of the property. No
    PROPERTY_DESCRIPTIONstringA localizable text description of the property.Yes
    PROPERTY_TYPEstringThe XML data type of the property.Yes
    PROPERTY_ACCESS_TYPEEnumStringAccess for the property. The value can be Read, Write, + or ReadWrite.No
    IS_REQUIREDbooleanTrue if a property is required, + false if it is not required.Yes
    VALUEstringThe current value of the property.Yes
    + +

    [Is VALUE a JDBC reserved word? If so, change it.]

    + +
    2.6.3.3 getLiterals
    +

    Retrieves a list of information on supported literals, including data types +and values.

    +

    Specified by the DISCOVER_LITERALS XML for Analysis method.

    +

    The returned result set contains the following columns.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Column nameTypeDescriptionRestrictionNullable
    LiteralNamestring

    The name of the literal described in the row.

    +

    Example: DBLITERAL_LIKE_PERCENT

    Yes, as an arrayNo
    LiteralValuestring +

    Contains the actual literal value.

    +

    Example, if LiteralName is + DBLITERAL_LIKE_PERCENT and the percent character (%) is used to match + zero or more characters in a LIKE clause, this column’s value would be + "%".

    +
    NoYes
    LiteralInvalidCharsstring

    The characters, in the literal, that are not valid.

    +

    For example, if table names can contain anything other + than a numeric character, this string would be "0123456789".

    NoYes
    LiteralInvalidStartingCharsstringThe characters that are not valid as the first character + of the literal. If the literal can start with any valid character, this + is null.NoYes
    LiteralMaxLengthintegerThe maximum number of characters in the literal. If + there is no maximum or the maximum is unknown, the value is –1.NoYes
    + +
    2.6.3.4. getCubes
    + +

    Describes the structure of cubes within a database.

    +

    Specified by the MDSCHEMA_CUBES XML for Analysis method.

    +

    The returned result set contains the following columns.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Column nameType indicatorDescription
    CATALOG_NAMEDBTYPE_WSTRThe name of the database.
    SCHEMA_NAMEDBTYPE_WSTRNot supported.
    CUBE_NAMEDBTYPE_WSTRThe name of the cube or dimension. Dimension + names are prefaced by a dollar sign ($) symbol.
    CUBE_TYPEDBTYPE_WSTRThe type of the cube. Valid values are:
      +
    • CUBE
    • +
    • DIMENSION
    • +
    +
    CUBE_GUIDDBTYPE_GUIDNot supported.
    CREATED_ONDBTYPE_DBTIMESTAMPNot supported.
    LAST_SCHEMA_UPDATEDBTYPE_DBTIMESTAMPThe time that the cube was last processed.
    SCHEMA_UPDATED_BYDBTYPE_WSTRNot supported.
    LAST_DATA_UPDATEDBTYPE_DBTIMESTAMPThe time that the cube was last processed.
    DATA_UPDATED_BYDBTYPE_WSTRNot supported.
    DESCRIPTIONDBTYPE_WSTRA user-friendly description of the cube.
    IS_DRILLTHROUGH_ENABLEDDBTYPE_BOOLA Boolean that always returns true.
    IS_LINKABLEDBTYPE_BOOLA Boolean that indicates whether a cube can be + used in a linked cube.
    IS_WRITE_ENABLEDDBTYPE_BOOLA Boolean that indicates whether a cube is + write-enabled.
    IS_SQL_ENABLEDDBTYPE_BOOLA Boolean that indicates whether SQL can be used + on the cube.
    CUBE_CAPTIONDBTYPE_WSTRThe caption of the cube.
    BASE_CUBE_NAMEDBTYPE_WSTRThe name of the source cube if this cube is a + perspective cube.
    ANNOTATIONSDBTYPE_WSTR(Optional) A set of notes, in XML format.
    + +

    The rowset is sorted on CATALOG_NAME, + SCHEMA_NAME, CUBE_NAME.

    + +
    2.6.3.5. getDimensions
    + +

    Retrieves a result set describing the shared and private dimensions within a database.

    +

    Specified by the MDSCHEMA_DIMENSIONS XML for Analysis method.

    +

    The returned result set contains the following columns.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Column nameType indicatorDescription
    CATALOG_NAMEDBTYPE_WSTRThe name of the database.
    SCHEMA_NAMEDBTYPE_WSTRNot supported.
    CUBE_NAMEDBTYPE_WSTRThe name of the cube.
    DIMENSION_NAMEDBTYPE_WSTRThe name of the dimension. If a dimension is + part of more than one cube or measure group, then + there is one row for each unique combination of + dimension, measure group, and cube.
    DIMENSION_UNIQUE_NAMEDBTYPE_WSTRThe unique name of the dimension.
    DIMENSION_GUIDDBTYPE_GUIDNot supported.
    DIMENSION_CAPTIONDBTYPE_WSTRThe caption of the dimension. This should be + used when displaying the name of the dimension to + the user, such as in the user interface or reports.
    DIMENSION_ORDINALDBTYPE_UI4The position of the dimension within the cube.
    DIMENSION_TYPEDBTYPE_I2The type of the dimension. Valid values include:
      +
    • MD_DIMTYPE_UNKNOWN (0)
    • +
    • MD_DIMTYPE_TIME (1)
    • +
    • MD_DIMTYPE_MEASURE (2)
    • +
    • MD_DIMTYPE_OTHER (3)
    • +
    • MD_DIMTYPE_QUANTITATIVE (5)
    • +
    • MD_DIMTYPE_ACCOUNTS (6)
    • +
    • MD_DIMTYPE_CUSTOMERS (7)
    • +
    • MD_DIMTYPE_PRODUCTS (8)
    • +
    • MD_DIMTYPE_SCENARIO (9)
    • +
    • MD_DIMTYPE_UTILIY (10)
    • +
    • MD_DIMTYPE_CURRENCY (11)
    • +
    • MD_DIMTYPE_RATES (12)
    • +
    • MD_DIMTYPE_CHANNEL (13)
    • +
    • MD_DIMTYPE_PROMOTION (14)
    • +
    • MD_DIMTYPE_ORGANIZATION (15)
    • +
    • MD_DIMTYPE_BILL_OF_MATERIALS (16)
    • +
    • MD_DIMTYPE_GEOGRAPHY (17)
    • +
    +
    DIMENSION_CARDINALITYDBTYPE_UI4The number of members in the key attribute.
    DEFAULT_HIERARCHYDBTYPE_WSTRA hierarchy from the dimension. Preserved for + backwards compatibility.
    DESCRIPTIONDBTYPE_WSTRA user-friendly description of the dimension.
    IS_VIRTUALDBTYPE_BOOLAlways FALSE.
    IS_READWRITEDBTYPE_BOOLA Boolean that indicates whether the dimension + is write-enabled.

    TRUE if the dimension is + write-enabled.

    DIMENSION_UNIQUE_SETTINGSDBTYPE_I4A bitmap that specifies which columns contain + unique values if the dimension contains only members + with unique names. The following bit value constants + are defined in Msmd.h for this bitmap: +
      +
    • MDDIMENSIONS_MEMBER_KEY_UNIQUE
    • +
    +
    DIMENSION_MASTER_UNIQUE_NAMEDBTYPE_WSTRAlways NULL.
    DIMENSION_IS_VISIBLEDBTYPE_BOOLAlways TRUE.
    + +

    The result set is sorted on CATALOG_NAME, + SCHEMA_NAME, CUBE_NAME, DIMENSION_NAME.

    + +
    2.6.3.6. getFunctions
    + +

    Retrieves a result set describing the functions available to client + applications connected to the database.

    +

    Specified by the MDSCHEMA_FUNCTIONS XML for Analysis method.

    +

    The returned result set contains the following columns.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Column nameType indicatorDescription
    FUNCTION_NAMEDBTYPE_WSTRThe name of the function.
    DESCRIPTIONDBTYPE_WSTRA description of the function.
    PARAMETER_LISTDBTYPE_WSTRA comma delimited list of parameters formatted + as in Microsoft Visual Basic. For example, a + parameter might be Name as String.
    RETURN_TYPEDBTYPE_I4The VARTYPE of the return data type of + the function.
    ORIGINDBTYPE_I4The origin of the function:
      +
    • 1 for MDX functions.
    • +
    • 2 for user-defined functions.
    • +
    +
    INTERFACE_NAMEDBTYPE_WSTRThe name of the interface for user-defined + functions

    The group name for Multidimensional + Expressions (MDX) functions.

    LIBRARY_NAMEDBTYPE_WSTRThe name of the type library for user-defined + functions. NULL for MDX functions.
    DLL_NAMEDBTYPE_WSTR(Optional) The name of the assembly that + implements the user-defined function.

    Returns + VT_NULL for MDX functions.

    HELP_FILEDBTYPE_WSTR(Optional) The name of the file that contains + the help documentation for the user-defined + function.

    Returns VT_NULL for MDX + functions.

    HELP_CONTEXTDBTYPE_I4(Optional) Returns the Help context ID for this + function.
    OBJECTDBTYPE_WSTR(Optional) The generic name of the object class + to which a property applies. For example, the rowset + corresponding to the <level_name>.Members function + returns "Level".

    Returns VT_NULL for + user-defined functions, or non-property MDX + functions.

    CAPTIONDBTYPE_WSTRThe display caption for the function.
    + +

    The rowset is sorted on ORIGIN, INTERFACE_NAME, + FUNCTION_NAME.

    + +
    2.6.3.7. getHierarchies
    +

    Retrieves a result set describing each hierarchy within a particular +dimension.

    +

    Specified by the MDSCHEMA_HIERARCHIES XML for Analysis method.

    +

    The returned result set contains the following columns.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Column nameType indicatorDescription
    CATALOG_NAMEDBTYPE_WSTRThe name of the catalog to which this hierarchy + belongs. NULL if the provider does not + support catalogs.
    SCHEMA_NAMEDBTYPE_WSTRNot supported
    CUBE_NAMEDBTYPE_WSTR(Required) The name of the cube to which this + hierarchy belongs.
    DIMENSION_UNIQUE_NAMEDBTYPE_WSTRThe unique name of the dimension to which this + hierarchy belongs. For providers that generate + unique names by qualification, each component of + this name is delimited.
    HIERARCHY_NAMEDBTYPE_WSTRThe name of the hierarchy. Blank if there is + only a single hierarchy in the dimension. This will + always have a value in Microsoft SQL Server 2005 + Analysis Services (SSAS).
    HIERARCHY_UNIQUE_NAMEDBTYPE_WSTRThe unique name of the hierarchy.
    HIERARCHY_GUIDDBTYPE_GUIDNot supported
    HIERARCHY_CAPTIONDBTYPE_WSTRA label or a caption associated with the + hierarchy. Used primarily for display purposes. If a + caption does not exist, HIERARCHY_NAME is + returned. If the dimension either does not contain a + hierarchy or has just one hierarchy, this column + will contain the name of the dimension.
    DIMENSION_TYPEDBTYPE_I2The type of the dimension. Valid values include + the following values:
      +
    • MD_DIMTYPE_UNKNOWN (0)
    • +
    • MD_DIMTYPE_TIME (1)
    • +
    • MD_DIMTYPE_MEASURE (2)
    • +
    • MD_DIMTYPE_OTHER (3)
    • +
    • MD_DIMTYPE_QUANTITATIVE (5)
    • +
    • MD_DIMTYPE_ACCOUNTS (6)
    • +
    • MD_DIMTYPE_CUSTOMERS (7)
    • +
    • MD_DIMTYPE_PRODUCTS (8)
    • +
    • MD_DIMTYPE_SCENARIO (9)
    • +
    • MD_DIMTYPE_UTILIY (10)
    • +
    • MD_DIMTYPE_CURRENCY (11)
    • +
    • MD_DIMTYPE_RATES (12)
    • +
    • MD_DIMTYPE_CHANNEL (13)
    • +
    • MD_DIMTYPE_PROMOTION (14)
    • +
    • MD_DIMTYPE_ORGANIZATION (15)
    • +
    • MD_DIMTYPE_BILL_OF_MATERIALS (16)
    • +
    • MD_DIMTYPE_GEOGRAPHY (17)
    • +
    +
    HIERARCHY_CARDINALITYDBTYPE_UI4The number of members in the hierarchy.
    DEFAULT_MEMBERDBTYPE_WSTRThe default member for this hierarchy. This is a + unique name. Every hierarchy must have a default + member.
    ALL_MEMBERDBTYPE_WSTRThe member at the highest level of the rollup.
    DESCRIPTIONDBTYPE_WSTRA human-readable description of the hierarchy. + NULL if no description exists.
    STRUCTUREDBTYPE_I2The structure of the hierarchy. Valid values + include the following values:
      +
    • MD_STRUCTURE_FULLYBALANCED (0)
    • +
    • MD_STRUCTURE_RAGGEDBALANCED (1)
    • +
    • MD_STRUCTURE_UNBALANCED (2)
    • +
    • MD_STRUCTURE_NETWORK (3)
    • +
    +
    IS_VIRTUALDBTYPE_BOOLAlways returns False.
    IS_READWRITEDBTYPE_BOOLA Boolean that indicates whether the Write Back + to dimension column is enabled.

    Returns TRUE + if the Write Back to dimension column that + represents this hierarchy is enabled.

    DIMENSION_UNIQUE_SETTINGSDBTYPE_I4Always returns MDDIMENSIONS_MEMBER_KEY_UNIQUE + (1).
    DIMENSION_MASTER_UNIQUE_NAMEDBTYPE_WSTRAlways returns NULL.
    DIMENSION_IS_VISIBLEDBTYPE_BOOLAlways returns true. If the dimension is + not visible, it will not appear in the schema + rowset.
    HIERARCHY_ORDINALDBTYPE_UI4The ordinal number of the hierarchy across all + hierarchies of the cube.
    DIMENSION_IS_SHAREDDBTYPE_BOOLAlways returns TRUE.
    HIERARCHY_IS_VISIBLEDBTYPE_BOOLA Boolean that indicates whether the hieararchy + is visible.

    Returns TRUE if the hierarchy + is visible; otherwise, FALSE.

    HIERARCHY_ORIGINDBTYPE_UI2A bit mask that determines the source of the + hierarchy:
      +
    • MD_USER_DEFINED identifies user + defined hierarchies, and has a value of + 0x0000001.
    • +
    • MD_SYSTEM_ENABLED identifies + attribute hierarchies, and has a value of + 0x0000002.
    • +
    • MD_SYSTEM_INTERNAL identifies + attributes with no attribute hierarchies, and + has a value of 0x0000004.
    • +
    +

    A parent/child attribute hierarchy is both + MD_USER_DEFINED and MD_SYSTEM_ENABLED.

    HIERARCHY_DISPLAY_FOLDERDBTYPE_WSTRThe path to be used when displaying the + hierarchy in the user interface. Folder names will + be separated by a semicolon (;). Nested folders are + indicated by a backslash (\).
    INSTANCE_SELECTIONDBTYPE_UI2A hint to the client application on how to show + the hierarchy. Valid values include the following + values:
      +
    • MD_INSTANCE_SELECTION_NONE
    • +
    • MD_INSTANCE_SELECTION_DROPDOWN
    • +
    • MD_INSTANCE_SELECTION_LIST
    • +
    • MD_INSTANCE_SELECTION_FILTEREDLIST
    • +
    • MD_INSTANCE_SELECTION_MANDATORYFILTER
    • +
    +
    + +

    The rowset is sorted on CATALOG_NAME, + SCHEMA_NAME, CUBE_NAME, DIMENSION_UNIQUE_NAME, + HIERARCHY_NAME.

    + +
    2.6.3.8. getLevels
    +

    Retrieves a result set describing each level within a particular hierarchy.

    +

    Specified by the MDSCHEMA_LEVELS XML for Analysis method.

    +

    The returned result set contains the following columns.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Column nameType indicatorDescription
    CATALOG_NAMEDBTYPE_WSTRThe name of the catalog to which this level + belongs. NULL if the provider does not + support catalogs.
    SCHEMA_NAMEDBTYPE_WSTRThe name of the schema to which this level + belongs. NULL if the provider does not + support schemas.
    CUBE_NAMEDBTYPE_WSTRThe name of the cube to which this level + belongs.
    DIMENSION_UNIQUE_NAMEDBTYPE_WSTRThe unique name of the dimension to which this + level belongs. For providers that generate unique + names by qualification, each component of this name + is delimited.
    HIERARCHY_UNIQUE_NAMEDBTYPE_WSTRThe unique name of the hierarchy. If the level + belongs to more than one hierarchy, there is one row + for each hierarchy to which it belongs. For + providers that generate unique names by + qualification, each component of this name is + delimited.
    LEVEL_NAMEDBTYPE_WSTRThe name of the level.
    LEVEL_UNIQUE_NAMEDBTYPE_WSTRThe properly escaped unique name of the level.
    LEVEL_GUIDDBTYPE_GUIDNot supported.
    LEVEL_CAPTIONDBTYPE_WSTRA label or caption associated with the + hierarchy. Used primarily for display purposes. If a + caption does not exist, LEVEL_NAME is + returned.
    LEVEL_NUMBERDBTYPE_UI4The distance of the level from the root of the + hierarchy. Root level is zero (0).
    LEVEL_CARDINALITYDBTYPE_UI4The number of members in the level.
    LEVEL_TYPEDBTYPE_I4Type of the level:
      +
    • MDLEVEL_TYPE_GEO_CONTINENT (0x2001)
    • +
    • MDLEVEL_TYPE_GEO_REGION (0x2002)
    • +
    • MDLEVEL_TYPE_GEO_COUNTRY (0x2003)
    • +
    • MDLEVEL_TYPE_GEO_STATE_OR_PROVINCE (0x2004)
    • +
    • MDLEVEL_TYPE_GEO_COUNTY (0x2005)
    • +
    • MDLEVEL_TYPE_GEO_CITY (0x2006)
    • +
    • MDLEVEL_TYPE_GEO_POSTALCODE (0x2007)
    • +
    • MDLEVEL_TYPE_GEO_POINT (0x2008)
    • +
    • MDLEVEL_TYPE_ORG_UNIT (0x1011)
    • +
    • MDLEVEL_TYPE_BOM_RESOURCE (0x1012)
    • +
    • MDLEVEL_TYPE_QUANTITATIVE (0x1013)
    • +
    • MDLEVEL_TYPE_ACCOUNT (0x1014)
    • +
    • MDLEVEL_TYPE_CUSTOMER (0x1021)
    • +
    • MDLEVEL_TYPE_CUSTOMER_GROUP (0x1022)
    • +
    • MDLEVEL_TYPE_CUSTOMER_HOUSEHOLD (0x1023)
    • +
    • MDLEVEL_TYPE_PRODUCT (0x1031)
    • +
    • MDLEVEL_TYPE_PRODUCT_GROUP (0x1032)
    • +
    • MDLEVEL_TYPE_SCENARIO (0x1015)
    • +
    • MDLEVEL_TYPE_UTILITY (0x1016)
    • +
    • MDLEVEL_TYPE_PERSON (0x1041)
    • +
    • MDLEVEL_TYPE_COMPANY (0x1042)
    • +
    • MDLEVEL_TYPE_CURRENCY_SOURCE (0x1051)
    • +
    • MDLEVEL_TYPE_CURRENCY_DESTINATION (0x1052)
    • +
    • MDLEVEL_TYPE_CHANNEL (0x1061)
    • +
    • MDLEVEL_TYPE_REPRESENTATIVE (0x1062)
    • +
    • MDLEVEL_TYPE_PROMOTION (0x1071)
    • +
    +
    DESCRIPTIONDBTYPE_WSTRA human-readable description of the level. NULL + if no description exists.
    CUSTOM_ROLLUP_SETTINGSDBTYPE_I4A bitmap that specifies the custom rollup + options:
      +
    • MDLEVELS_CUSTOM_ROLLUP_EXPRESSION (0x01) + indicates an expression exists for this level. + (Deprecated)
    • +
    • MDLEVELS_CUSTOM_ROLLUP_COLUMN (0x02) + indicates that there is a custom rollup column + for this level.
    • +
    • MDLEVELS_SKIPPED_LEVELS (0x04) + indicates that there is a skipped level + associated with members of this level.
    • +
    • MDLEVELS_CUSTOM_MEMBER_PROPERTIES (0x08) + indicates that members of the level have custom + member properties.
    • +
    • MDLEVELS_UNARY_OPERATOR (0x10) + indicates that members on the level have unary + operators.
    • +
    +
    LEVEL_UNIQUE_SETTINGSDBTYPE_I4A bitmap that specifies which columns contain + unique values, if the level only has members with + unique names or keys. The Msmd.h file defines the + following bit value constants for this bitmap: +
      +
    • MDDIMENSIONS_MEMBER_KEY_UNIQUE (1)
    • +
    • MDDIMENSIONS_MEMBER_NAME_UNIQUE (2)
    • +
    +

    The key is always unique in Microsoft SQL Server + 2005 Analysis Services (SSAS). The name will be + unique if the setting on the attribute is + UniqueInDimension or UniqueInAttribute

    LEVEL_IS_VISIBLEDBTYPE_BOOLA Boolean that indicates whether the level is + visible.

    Always returns True. If the level is not + visible, it will not be included in the schema + rowset.

    LEVEL_ORDERING_PROPERTYDBTYPE_WSTRThe ID of the attribute that the level is sorted + on.
    LEVEL_DBTYPEDBTYPE_I4The DBTYPE enumeration of the member key + column that is used for the level attribute.

    Null + if concatenated keys are used as the member key + column.

    LEVEL_MASTER_UNIQUE_NAMEDBTYPE_WSTRAlways returns NULL.
    LEVEL_NAME_SQL_COLUMN_NAMEDBTYPE_WSTRThe SQL representation of the level member + names.
    LEVEL_KEY_SQL_COLUMN_NAMEDBTYPE_WSTRThe SQL representation of the level member key + values.
    LEVEL_UNIQUE_NAME_SQL_COLUMN_NAMEDBTYPE_WSTRThe SQL representation of the member unique + names.
    LEVEL_ATTRIBUTE_HIERARCHY_NAMEDBTYPE_WSTRThe name of the attribute hierarchy providing + the source of the level.
    LEVEL_KEY_CARDINALITYDBTYPE_UI2The number of columns in the level key.
    LEVEL_ORIGINDBTYPE_UI2A bit map that defines how the level was + sourced:
      +
    • MD_ORIGIN_USER_DEFINED identifies + levels in a user defined hierarchy.
    • +
    • MD_ORIGIN_ATTRIBUTE identifies levels + in an attribute hierarchy.
    • +
    • MD_ORIGIN_KEY_ATTRIBUTE identifies + levels in a key attribute hierarchy.
    • +
    • MD_ORIGIN_INTERNAL identifies levels + in attribute hierarchies that are not enabled.
    • +
    +
    + +

    The rowset is sorted on CATALOG_NAME, + SCHEMA_NAME, CUBE_NAME, DIMENSION_UNIQUE_NAME, + HIERARCHY_UNIQUE_NAME, LEVEL_NUMBER.

    + +
    2.6.3.9. getMeasures
    +

    Retrieves a result set describing each measure within a cube.

    +

    Specified by the MDSCHEMA_MEASURES XML for Analysis method.

    +

    The returned result set contains the following columns.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Column nameType indicatorLengthDescription
    CATALOG_NAMEDBTYPE_WSTR The name of the catalog to which this measure + belongs. NULL if the provider does not + support catalogs.
    SCHEMA_NAMEDBTYPE_WSTR The name of the schema to which this measure + belongs. NULL if the provider does not + support schemas.
    CUBE_NAMEDBTYPE_WSTR The name of the cube to which this measure + belongs.
    MEASURE_NAMEDBTYPE_WSTR The name of the measure.
    MEASURE_UNIQUE_NAMEDBTYPE_WSTR The Unique name of the measure. For providers + that generate unique names by qualification, each + component of this name is delimited.
    MEASURE_CAPTIONDBTYPE_WSTR A label or caption associated with the measure. + Used primarily for display purposes. If a caption + does not exist, MEASURE_NAME is returned.
    MEASURE_GUIDDBTYPE_GUID Not supported.
    MEASURE_AGGREGATORDBTYPE_I4 An enumeration that identifies how a measure was + derived. Can be one of the following values:
      +
    • MDMEASURE_AGGR_SUM (1)
    • +
    • MDMEASURE_AGGR_COUNT (2)
    • +
    • MDMEASURE_AGGR_MIN (3)
    • +
    • MDMEASURE_AGGR_MAX (4)
    • +
    • MDMEASURE_AGGR_AVG (5)
    • +
    • MDMEASURE_AGGR_VAR (6)
    • +
    • MDMEASURE_AGGR_STD (7) + identifies that the measure was derived from an + aggregation function that was SUM, + COUNT, MIN, MAX, AVG, + VAR, or STDEV, respectively.
    • +
    • MDMEASURE_AGGR_CALCULATED (127) + identifies that the measure was derived from a + formula that was not any single function above. +
    • +
    • MDMEASURE_AGGR_UNKNOWN (0) + identifies that the measure was derived from an + unknown aggregation function or formula.
    • +
    +
    DATA_TYPEDBTYPE_UI2 The data type of the measure.
    NUMERIC_PRECISIONDBTYPE_UI2 The maximum precision of the property if the + measure object's data type is exact numeric. NULL + for all other property types.
    NUMERIC_SCALEDBTYPE_I2 The number of digits to the right of the decimal + point if the measure object's type indicator is + DBTYPE_NUMERIC or DBTYPE_DECIMAL. + Otherwise, this value is NULL.
    MEASURE_UNITSDBTYPE_WSTR Not supported
    DESCRIPTIONDBTYPE_WSTR A human-readable description of the measure. + NULL if no description exists.
    EXPRESSIONDBTYPE_WSTR An expression for the member.
    MEASURE_IS_VISIBLEDBTYPE_BOOL A Boolean that always returns True. If the + measure is not visible, it will not be included in + the schema rowset.
    LEVELS_LISTDBTYPE_WSTR A string that always returns NULL.
    MEASURE_NAME_SQL_COLUMN_NAMEDBTYPE_WSTR The name of the column in the SQL query that + corresponds to the measure's name.
    MEASURE_UNQUALIFIED_CAPTIONDBTYPE_WSTR The name of the measure, not qualified with the + measure group name.
    MEASUREGROUP_NAMEDBTYPE_WSTR The name of the measure group to which the + measure belongs.
    MEASURE_DISPLAY_FOLDERDBTYPE_WSTR The path to be used when displaying the measure + in the user interface. Folder names will be + separated by a semicolon. Nested folders are + indicated by a backslash (\).
    DEFAULT_FORMAT_STRINGDBTYPE_WSTR The default format string for the measure.
    + +

    The rowset is sorted on CATALOG_NAME, + SCHEMA_NAME, CUBE_NAME, MEASURE_NAME.

    + +
    2.6.3.10. getMembers
    +

    Retrieves a result set describing the members within a database.

    +

    Specified by the MDSCHEMA_MEMBERS XML for Analysis method.

    +

    The returned result set contains the following columns.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Column nameType indicatorLengthDescription
    CATALOG_NAMEDBTYPE_WSTR The name of the database to which this member + belongs.
    SCHEMA_NAMEDBTYPE_WSTR The name of the schema to which this member + belongs.
    CUBE_NAMEDBTYPE_WSTR The name of the cube to which this member + belongs.
    DIMENSION_UNIQUE_NAMEDBTYPE_WSTR The unique name of the dimension to which this + member belongs.
    HIERARCHY_UNIQUE_NAMEDBTYPE_WSTR The unique name of the hierarchy to which this + member belongs.
    LEVEL_UNIQUE_NAMEDBTYPE_WSTR The unique name of the level to which this + member belongs.
    LEVEL_NUMBERDBTYPE_UI4 The distance of the member from the root of the + hierarchy. The root level is zero (0).
    MEMBER_ORDINALDBTYPE_UI4 (Deprecated) Always returns 0.
    MEMBER_NAMEDBTYPE_WSTR The name of the member.
    MEMBER_UNIQUE_NAMEDBTYPE_WSTR The unique name of the member.
    MEMBER_TYPEDBTYPE_I4 The type of the member: +
      +
    • MDMEMBER_TYPE_REGULAR (1)
    • +
    • MDMEMBER_TYPE_ALL (2)
    • +
    • MDMEMBER_TYPE_MEASURE (3)
    • +
    • MDMEMBER_TYPE_FORMULA (4)
    • +
    • MDMEMBER_TYPE_UNKNOWN (0)
    • +
    • MDMEMBER_TYPE_FORMULA takes + precedence over MDMEMBER_TYPE_MEASURE. + For example, if there is a formula (calculated) + member on the Measures dimension, it is listed + as MDMEMBER_TYPE_FORMULA.
    • +
    +
    MEMBER_GUIDDBTYPE_GUID The GUID of the member. NULL if no GUID + exists.
    MEMBER_CAPTIONDBTYPE_WSTR A label or caption associated with the member. + Used primarily for display purposes. If a caption + does not exist, MEMBER_NAME is returned.
    CHILDREN_CARDINALITYDBTYPE_UI4 The number of children that the member has. This + can be an estimate, so consumers should not rely on + this to be the exact count. Providers should return + the best estimate possible.
    PARENT_LEVELDBTYPE_UI4 The distance of the member's parent from the + root level of the hierarchy. The root level is zero + (0).
    PARENT_UNIQUE_NAMEDBTYPE_WSTR The unique name of the member's parent. NULL + is returned for any members at the root level.
    PARENT_COUNTDBTYPE_UI4 The number of parents that this member has.
    DESCRIPTIONDBTYPE_WSTR Always returns NULL.
    EXPRESSIONDBTYPE_WSTR The expression for calculations, if the member + is of type MDMEMBER_TYPE_FORMULA.
    MEMBER_KEYDBTYPE_WSTR The value of the member's key column. Returns + NULL if the member has a composite key.
    IS_PLACEHOLDERMEMBERDBTYPE_BOOL A Boolean that indicates whether a member is a + placeholder member for an empty position in a + dimension hierarchy.

    It is valid only if the + MDX Compatibility property has been set to 1. +

    IS_DATAMEMBERDBTYPE_BOOL A Boolean that indicates whether the member is a + data member.

    Returns True if the member is a data + member.

    Zero or more additional columnsDBTYPE_UI2 No properties are returned if the members could + be returned from multiple levels. For example, if + the Tree operator is PARENT and SELF + for a non-parent child hierarchy, no member + properties are returned.

    This applies to ragged + hierarchies where tree operators could return + members from different levels (for example, if the + prior level contains holes and parent on members is + requested).

    + +

    The rowset is sorted on CATALOG_NAME, + SCHEMA_NAME, CUBE_NAME, DIMENSION_UNIQUE_NAME, + HIERARCHY_UNIQUE_NAME, LEVEL_UNIQUE_NAME, + LEVEL_NUMBER, MEMBER_ORDINAL.

    + +
    2.6.3.11. getProperties
    + +

    Retrieves a list of descriptions of member and cell Properties.

    +

    Specified by the MDSCHEMA_PROPERTIES XML for Analysis method.

    +

    The returned result set contains the following columns.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Column nameType indicatorDescription
    CATALOG_NAMEDBTYPE_WSTRThe name of the database.
    SCHEMA_NAMEDBTYPE_WSTRThe name of the schema to which this property + belongs. NULL if the provider does not + support schemas.
    CUBE_NAMEDBTYPE_WSTRThe name of the cube.
    DIMENSION_UNIQUE_NAMEDBTYPE_WSTRThe unique name of the dimension. For providers + that generate unique names by qualification, each + component of this name is delimited.
    HIERARCHY_UNIQUE_NAMEDBTYPE_WSTRThe unique name of the hierarchy. For providers + that generate unique names by qualification, each + component of this name is delimited.
    LEVEL_UNIQUE_NAMEDBTYPE_WSTRThe unique name of the level to which this + property belongs. If the provider does not support + named levels, it should return the + DIMENSION_UNIQUE_NAME value for this field. For + providers that generate unique names by + qualification, each component of this name is + delimited.
    MEMBER_UNIQUE_NAMEDBTYPE_WSTRThe unique name of the member to which the + property belongs. Used for data stores that do not + support named levels or have properties on a + member-by-member basis. If the property applies to + all members in a level, this column is NULL. + For providers that generate unique names by + qualification, each component of this name is + delimited.
    PROPERTY_TYPEDBTYPE_I2A bitmap that specifies the type of the + property:
      +
    • MDPROP_MEMBER (1) identifies a + property of a member. This property can be used + in the DIMENSION PROPERTIES clause of the SELECT + statement.
    • +
    • MDPROP_CELL (2) identifies a + property of a cell. This property can be used in + the CELL PROPERTIES clause that occurs at the + end of the SELECT statement.
    • +
    • MDPROP_SYSTEM (4) identifies + an internal property.
    • +
    • MDPROP_BLOB (8) identifies a + property which contains a binary large object + (blob).
    • +
    +
    PROPERTY_NAMEDBTYPE_WSTRThe name of the property. If the key for the + property is the same as the name for the property, + PROPERTY_NAME will be blank.
    PROPERTY_CAPTIONDBTYPE_WSTRA label or caption associated with the property, + used primarily for display purposes. Returns + PROPERTY_NAME if a caption does not exist.
    DATA_TYPEDBTYPE_UI2The data type of the property.
    CHARACTER_MAXIMUM_LENGTHDBTYPE_UI4The maximum possible length of the property, if + it is a character, binary, or bit type.

    Zero + indicates there is no defined maximum length.

    +

    Returns NULL for all other data types.

    CHARACTER_OCTET_LENGTHDBTYPE_UI4The maximum possible length (in bytes) of the + property, if it is a character or binary type.

    + Zero indicates there is no defined maximum length.

    +

    Returns NULL for all other data types.

    NUMERIC_PRECISIONDBTYPE_UI2The maximum precision of the property, if it is + a numeric data type.

    Returns NULL for all + other data types.

    NUMERIC_SCALEDBTYPE_I2The number of digits to the right of the decimal + point, if it is a DBTYPE_NUMERIC or + DBTYPE_DECIMAL type.

    Returns NULL for + all other data types.

    DESCRIPTIONDBTYPE_WSTRA human readable description of the property. + NULL if no description exists.
    PROPERTY_CONTENT_TYPEDBTYPE_I2The type of the property. Can be one of the + following enumerations:
      +
    • MD_PROPTYPE_REGULAR (0x00)
    • +
    • MD_PROPTYPE_ID (0x01)
    • +
    • MD_PROPTYPE_RELATION_TO_PARENT (0x02)
    • +
    • MD_PROPTYPE_ROLLUP_OPERATOR (0x03)
    • +
    • MD_PROPTYPE_ORG_TITLE (0x11)
    • +
    • MD_PROPTYPE_CAPTION (0x21)
    • +
    • MD_PROPTYPE_CAPTION_SHORT (0x22)
    • +
    • MD_PROPTYPE_CAPTION_DESCRIPTION (0x23)
    • +
    • MD_PROPTYPE_CAPTION_ABREVIATION (0x24)
    • +
    • MD_PROPTYPE_WEB_URL (0x31)
    • +
    • MD_PROPTYPE_WEB_HTML (0x32)
    • +
    • MD_PROPTYPE_WEB_XML_OR_XSL (0x33)
    • +
    • MD_PROPTYPE_WEB_MAIL_ALIAS (0x34)
    • +
    • MD_PROPTYPE_ADDRESS (0x41)
    • +
    • MD_PROPTYPE_ADDRESS_STREET (0x42)
    • +
    • MD_PROPTYPE_ADDRESS_HOUSE (0x43)
    • +
    • MD_PROPTYPE_ADDRESS_CITY (0x44)
    • +
    • MD_PROPTYPE_ADDRESS_STATE_OR_PROVINCE (0x45)
    • +
    • MD_PROPTYPE_ADDRESS_ZIP (0x46)
    • +
    • MD_PROPTYPE_ADDRESS_QUARTER (0x47)
    • +
    • MD_PROPTYPE_ADDRESS_COUNTRY (0x48)
    • +
    • MD_PROPTYPE_ADDRESS_BUILDING (0x49)
    • +
    • MD_PROPTYPE_ADDRESS_ROOM (0x4A)
    • +
    • MD_PROPTYPE_ADDRESS_FLOOR (0x4B)
    • +
    • MD_PROPTYPE_ADDRESS_FAX (0x4C)
    • +
    • MD_PROPTYPE_ADDRESS_PHONE (0x4D)
    • +
    • MD_PROPTYPE_GEO_CENTROID_X (0x61)
    • +
    • MD_PROPTYPE_GEO_CENTROID_Y (0x62)
    • +
    • MD_PROPTYPE_GEO_CENTROID_Z (0x63)
    • +
    • MD_PROPTYPE_GEO_BOUNDARY_TOP (0x64)
    • +
    • MD_PROPTYPE_GEO_BOUNDARY_LEFT (0x65)
    • +
    • MD_PROPTYPE_GEO_BOUNDARY_BOTTOM (0x66)
    • +
    • MD_PROPTYPE_GEO_BOUNDARY_RIGHT (0x67)
    • +
    • MD_PROPTYPE_GEO_BOUNDARY_FRONT (0x68)
    • +
    • MD_PROPTYPE_GEO_BOUNDARY_REAR (0x69)
    • +
    • MD_PROPTYPE_GEO_BOUNDARY_POLYGON (0x6A)
    • +
    • MD_PROPTYPE_PHYSICAL_SIZE (0x71)
    • +
    • MD_PROPTYPE_PHYSICAL_COLOR (0x72)
    • +
    • MD_PROPTYPE_PHYSICAL_WEIGHT (0x73)
    • +
    • MD_PROPTYPE_PHYSICAL_HEIGHT (0x74)
    • +
    • MD_PROPTYPE_PHYSICAL_WIDTH (0x75)
    • +
    • MD_PROPTYPE_PHYSICAL_DEPTH (0x76)
    • +
    • MD_PROPTYPE_PHYSICAL_VOLUME (0x77)
    • +
    • MD_PROPTYPE_PHYSICAL_DENSITY (0x78)
    • +
    • MD_PROPTYPE_PERSON_FULL_NAME (0x82)
    • +
    • MD_PROPTYPE_PERSON_FIRST_NAME (0x83)
    • +
    • MD_PROPTYPE_PERSON_LAST_NAME (0x84)
    • +
    • MD_PROPTYPE_PERSON_MIDDLE_NAME (0x85)
    • +
    • MD_PROPTYPE_PERSON_DEMOGRAPHIC (0x86)
    • +
    • MD_PROPTYPE_PERSON_CONTACT (0x87)
    • +
    • MD_PROPTYPE_QTY_RANGE_LOW (0x91)
    • +
    • MD_PROPTYPE_QTY_RANGE_HIGH (0x92)
    • +
    • MD_PROPTYPE_FORMATTING_COLOR (0xA1)
    • +
    • MD_PROPTYPE_FORMATTING_ORDER (0xA2)
    • +
    • MD_PROPTYPE_FORMATTING_FONT (0xA3)
    • +
    • MD_PROPTYPE_FORMATTING_FONT_EFFECTS (0xA4)
    • +
    • MD_PROPTYPE_FORMATTING_FONT_SIZE (0xA5)
    • +
    • MD_PROPTYPE_FORMATTING_SUB_TOTAL (0xA6)
    • +
    • MD_PROPTYPE_DATE (0xB1)
    • +
    • MD_PROPTYPE_DATE_START (0xB2)
    • +
    • MD_PROPTYPE_DATE_ENDED (0xB3)
    • +
    • MD_PROPTYPE_DATE_CANCELED (0xB4)
    • +
    • MD_PROPTYPE_DATE_MODIFIED (0xB5)
    • +
    • MD_PROPTYPE_DATE_DURATION (0xB6)
    • +
    • MD_PROPTYPE_VERSION (0xC1)
    • +
    +
    SQL_COLUMN_NAMEDBTYPE_WSTRThe name of the property used in SQL queries + from the cube dimension or database dDimension.
    LANGUAGEDBTYPE_UI2The translation expressed as an LCID. + Only valid for property translations.
    PROPERTY_ORIGINDBTYPE_UI2Identifies the type of hierarchy that the + property applies to:
      +
    • MD_USER_DEFINED (1) indicates + the property is on a user defined hierarchy
    • +
    • MD_SYSTEM_ENABLED (2) + indicates the property is on an attribute + hierarchy
    • +
    • MD_SYSTEM_DISABLED (4) + indicates the property is on an attribute + hierarchy that is not enabled.
    • +
    +
    PROPERTY_ATTRIBUTE_HIERARCHY_NAMEDBTYPE_WSTRThe name of the attribute hierarchy sourcing + this property.
    PROPERTY_CARDINALITYDBTYPE_WSTRThe cardinality of the property. Possible values + include the following strings:
      +
    • ONE
    • +
    • MANY
    • +
    +
    MIME_TYPEDBTYPE_WSTRThe mime type for binary large objects (BLOBs).
    PROPERTY_IS_VISIBLEDBTYPE_BOOLA Boolean that indicates whether the property is + visible.

    TRUE if the property is visible; + otherwise, FALSE.

    + +

    This schema rowset is not sorted.

    + +
    2.6.3.12. getSets
    +

    Retrieves a result set describing any sets that are currently defined in a +database, including session-scoped sets.

    +

    Specified by the MDSCHEMA_SETS XML for Analysis method.

    +

    The returned result set contains the following columns.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Column nameType indicatorDescription
    CATALOG_NAMEDBTYPE_WSTRThe name of the database.
    SCHEMA_NAMEDBTYPE_WSTRNot supported.
    CUBE_NAMEDBTYPE_WSTRThe name of the cube.
    SET_NAMEDBTYPE_WSTRThe name of the set, as specified in the + CREATE SET statement.
    SCOPEDBTYPE_I4The scope of the set:
      +
    • MDSET_SCOPE_GLOBAL (1)
    • +
    • MDSET_SCOPE_SESSION (2)
    • +
    +
    DESCRIPTIONDBTYPE_WSTRNot supported.
    EXPRESSIONDBTYPE_WSTRThe expression for the set.
    DIMENSIONSDBTYPE_WSTRA comma delimited list of hierarchies included + in the set.
    SET_CAPTIONDBTYPE_WSTRA label or caption associated with the set. The + label or caption is used primarily for display + purposes.
    SET_DISPLAY_FOLDERDBTYPE_WSTRThe path to be used by the user interface when + displaying the set. Folder names are separated by a + backslash (\), folders are separated by a + semicolon (;).
    + +

    The rowset is sorted on CATALOG_NAME, + SCHEMA_NAME, CUBE_NAME.

    + +

     

    + +

    2.6.4. Other methods

    + + + + + + + + + + +
    MethodDescription
    getMdxKeywords()Returns
    +

    OlapDatabaseMetaData extends

    Classes:

      @@ -620,13 +2831,13 @@

      2.6.1. Access control

      2.7. Transform

      -

      A transform is an operation which maps a query model to a new query model. It -is usually triggered by a gesture within the user-interface. For example, +

      A transform is an operation which maps a query model to a new query model. It +is usually triggered by a gesture within the user-interface. For example, clicking on the Unit Sales column transforms the query

      - SELECT {[Measures].[Store Sales], [Measures].[Unit Sales]} ON + SELECT {[Measures].[Store Sales], [Measures].[Unit Sales]} ON COLUMNS,
        {[Product].Members} ON ROWS
      FROM [Sales] @@ -635,7 +2846,7 @@

      2.7. Transform

      into one with sorting:

      - SELECT {[Measures].[Store Sales], [Measures].[Unit Sales]} ON + SELECT {[Measures].[Store Sales], [Measures].[Unit Sales]} ON COLUMNS,
        Order({[Product].Members}, [Measures].[Unit Sales], ASC) ON ROWS
      FROM [Sales] @@ -647,9 +2858,9 @@

      2.7. Transform

      2.8. Layout

      -

      The layout package provides data models for graphical OLAP applications. In +

      The layout package provides data models for graphical OLAP applications. In particular, the GridModel class provides, for OLAP data, what Swing's - + TableModel provides for SQL data.

      Package name: org.olap4j.layout

      @@ -658,28 +2869,28 @@

      2.8. Layout

      3. Other components

      -

      The API described above is a set of interfaces which must be implemented by -any compliant provider. The olap4j project also contains some components which +

      The API described above is a set of interfaces which must be implemented by +any compliant provider. The olap4j project also contains some components which are not part of the API.

      3.1. Test suite

      -

      The olap4j project contains a TCK (Test Compatability Kit). The TCK is a suite -of tests which can be used to verify the compliance of an implementation of the +

      The olap4j project contains a TCK (Test Compatability Kit). The TCK is a suite +of tests which can be used to verify the compliance of an implementation of the API.

      3.2. XML/A provider

      -

      The XML/A provider is an implementation of the olap4j API which talks to a +

      The XML/A provider is an implementation of the olap4j API which talks to a generic XML/A provider.

      -

      Since there are many XML/A providers, and some of them require requests in a -particular format and/or produce idiosyncratic responses, the XML/A provider +

      Since there are many XML/A providers, and some of them require requests in a +particular format and/or produce idiosyncratic responses, the XML/A provider will come in several flavors.

      4. Non-functionality

      -

      Here are some of the areas of functionality which will not be part of +

      Here are some of the areas of functionality which will not be part of the olap4j project:

      • Schema reader parses an XML file to create a schema
      • @@ -695,44 +2906,48 @@

        5. Related projects

        5.1. Mondrian provider

        -

        The Mondrian project will contain an implementation of the olap4j API based on +

        The Mondrian project will contain an implementation of the olap4j API based on the Mondrian OLAP server.

        5.2. JPivot

        -

        JPivot currently based on two data sources: the Mondrian server, and a +

        JPivot currently based on two data sources: the Mondrian server, and a generic XML/A data source.

        -

        We intend to convert JPivot to run solely on the olap4j API. Connectivity to -Mondrian and XML/A sources will be achieved by choosing the appropriate olap4j +

        We intend to convert JPivot to run solely on the olap4j API. Connectivity to +Mondrian and XML/A sources will be achieved by choosing the appropriate olap4j provider.

        5.3. Other data sources

        -

        In principle, providers could be created to other OLAP data sources. This -would be particularly straightforward for servers which already have a native +

        In principle, providers could be created to other OLAP data sources. This +would be particularly straightforward for servers which already have a native Java API.

        Appendix A. Opportunities for specification

        -

        The following are features which have been suggested for inclusion in the -olap4j specification, but which are not part of the current version. They may be +

        The following are features which have been suggested for inclusion in the +olap4j specification, but which are not part of the current version. They may be included in future revisions of the specification.

        -

        Date and Time types

        +

        A.1. Date and Time types

        -

        Include support for Date and Time values. The package org.olap4j.mdx.type +

        Include support for Date and Time values. The package org.olap4j.mdx.type could have additional classes DateType and TimeType.

        (Richard Emberson, 2006/8/14)

        -

        Schema notification

        +

        A.2. Schema notification

        -

        Add a mechanism for the client to detect that the schema has been modified -(for instance, that a cube has been added). Not necessarily to find out what +

        Add a mechanism for the client to detect that the schema has been modified +(for instance, that a cube has been added). Not necessarily to find out what those changes are.

        (Richard Emberson, 2006/8/15)

        +

        A.3. Writethrough/Writeback

        +

        Specify how clients can write cell values back to the database. Useful for +budgeting applications and 'what if?' analysis.

        +

        (PALO, 2006/10/14)

        Appendix B. Feedback

        @@ -757,7 +2972,11 @@

        JDK version

        targeting JDK 1.5, and running retroweaver for backward compatibility for JDK 1.4.

        Appendix D. Miscellaneous

        +

        D.1. To be specified

        [Discuss thread safety of connections, statements, result sets.]

        +

        Appendix E. References

        +

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


        diff --git a/src/org/olap4j/Olap4j.java b/src/org/olap4j/Olap4j.java new file mode 100644 index 0000000..312bcae --- /dev/null +++ b/src/org/olap4j/Olap4j.java @@ -0,0 +1,237 @@ +/* +// $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) 2006-2006 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j; + +import org.olap4j.mdx.parser.MdxParserFactory; + +import java.sql.*; + +/** + * Miscellaneous utility functions, in particular dealing with the wrapped + * objects created by connection pools. + * + *

        Connection pools typically work by creating wrapped versions of + * connection, statement, prepared statement, result set, and metadata objects. + * These are problematic for olap4j, because olap4j extends the JDBC interfaces, + * and the wrapped objects will not implement those interfaces. The following + * table lists the interfaces extended by olap4j:

        + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
        olap4j classextends JDBC classcreated by
        {@link OlapConnection}{@link Connection} + *
          + *
        • {@link DriverManager#getConnection(String) Connection DriverManager.getConnection(String)}
        • + *
        • {@link javax.sql.DataSource#getConnection() Connection DataSource.getConnection()}
        • + *
        + *
        {@link OlapStatement}{@link Statement} + *
          + *
        • {@link java.sql.Connection#createStatement() Statement Connection.createStatement()}
        • + *
        + *
        {@link PreparedOlapStatement}{@link PreparedStatement} + *
          + *
        • {@link Connection#prepareStatement(String) PreparedStatement Connection.prepareStatement(String)}
        • + *
        + *
        {@link OlapResultSet}{@link ResultSet} + *
          + *
        • {@link Statement#execute(String) ResultSet Statement.executeQuery(String)}
        • + *
        • {@link PreparedStatement#execute(String) ResultSet PreparedStatement.executeQuery()}
        • + *
        + *
        + * + *

        If you are using a connection pool, you cannot safely cast a + * {@link Connection} to an {@link OlapConnection}, or a {@link Statement} to + * a {@link OlapStatement}. Use the appropriate + * {@link #convert(java.sql.Connection)} method, and the resulting object will + * implement the necessary interface and also implement the behavior required + * by the connection pool in order to manage sub-objects safely. + * + *

        We plan to support common connection-pooling libraries: + *

        + * + * @author jhyde + * @version $Id: $ + * @since Oct 13, 2006 + */ +public class Olap4j { + /** + * Converts a JDBC connection ({@link java.sql.Connection}) + * to an olap4j connection ({@link OlapConnection}). + * + *

        The connection produced by an olap4j driver will already implement the + * OlapConnection interface, but certain connection pools + * add wrappers. This method removes those wrappers. + */ + public static OlapConnection convert(Connection connection) { + return adapterFor(connection).convert(connection); + } + + /** + * Converts a JDBC statement ({@link java.sql.Statement}) + * to an olap4j statement ({@link OlapStatement}). + * + *

        The statement produced by an olap4j driver will already implement the + * OlapStatement interface, but certain connection pools + * add wrappers. This method removes those wrappers. + */ + public static OlapStatement convert(Statement stmt) { + return adapterFor(stmt).convert(stmt); + } + + /** + * Converts a JDBC prepared statement ({@link java.sql.Connection}) + * to an olap4j prepared statement ({@link PreparedOlapStatement}). + * + *

        The prepared statement produced by an olap4j driver will already + * implement the PreparedOlapStatement interface, but certain + * connection pools add wrappers. This method removes those wrappers. + */ + public static PreparedOlapStatement convert(PreparedStatement pstmt) { + return adapterFor(pstmt).convert(pstmt); + } + + /** + * Converts a JDBC result set ({@link java.sql.ResultSet}) + * to an olap4j result set ({@link OlapResultSet}). + * + *

        The result set eproduced by an olap4j driver will already + * implement the OlapResultSet interface, but certain + * connection pools add wrappers. This method removes those wrappers. + */ + public static OlapResultSet convert(ResultSet resultSet) { + return adapterFor(resultSet).convert(resultSet); + } + + /** + * Converts a JDBC result set ({@link java.sql.DatabaseMetaData}) + * to an olap4j result set ({@link OlapDatabaseMetaData}). + * + *

        The DatabaseMetaData eproduced by an olap4j driver will + * already implement the OlapDatabaseMetaData interface, but + * certain connection pools add wrappers. This method removes those + * wrappers. + */ + public static OlapDatabaseMetaData convert(DatabaseMetaData metadata) { + return adapterFor(metadata).convert(metadata); + } + + /** + * Helper method to automatically create the right adapter to unpack a + * connection. + */ + private static Adapter adapterFor(Connection connection) { + return CastingAdapter.INSTANCE; + } + + /** + * Helper method to automatically create the right adapter to unpack a + * statement. + */ + private static Adapter adapterFor(Statement stmt) { + return CastingAdapter.INSTANCE; + } + + /** + * Helper method to automatically create the right adapter to unpack a + * prepared statement. + */ + private static Adapter adapterFor(PreparedStatement pstmt) { + return CastingAdapter.INSTANCE; + } + + /** + * Helper method to automatically create the right adapter to unpack a + * database metadata. + */ + private static Adapter adapterFor(DatabaseMetaData metadata) { + return CastingAdapter.INSTANCE; + } + + /** + * Helper method to automatically create the right adapter to unpack a + * result set. + */ + private static Adapter adapterFor(ResultSet resultSet) { + return CastingAdapter.INSTANCE; + } + + public static MdxParserFactory getParserFactory(Connection connection) { + return convert(connection).getParserFactory(); + } + + /** + * Specification for a helper which can remove the wrappers added by + * certain connection pools. + */ + private static interface Adapter { + OlapConnection convert(Connection connection); + OlapStatement convert(Statement stmt); + PreparedOlapStatement convert(PreparedStatement pstmt); + OlapDatabaseMetaData convert(DatabaseMetaData metadata); + OlapResultSet convert(ResultSet resultSet); + } + + + /** + * Implementation of {@link Adapter} which simply casts objects to the + * desired type. + */ + private static class CastingAdapter implements Adapter { + private static final Adapter INSTANCE = new CastingAdapter(); + + public OlapConnection convert(Connection connection) { + return (OlapConnection) connection; + } + + public OlapStatement convert(Statement stmt) { + return (OlapStatement) stmt; + } + + public PreparedOlapStatement convert(PreparedStatement pstmt) { + return (PreparedOlapStatement) pstmt; + } + + public OlapDatabaseMetaData convert(DatabaseMetaData metadata) { + return (OlapDatabaseMetaData) metadata; + } + + public OlapResultSet convert(ResultSet resultSet) { + return (OlapResultSet) resultSet; + } + } +} + +// End Olap4j.java diff --git a/src/org/olap4j/OlapConnection.java b/src/org/olap4j/OlapConnection.java index f6981c4..1a29a41 100644 --- a/src/org/olap4j/OlapConnection.java +++ b/src/org/olap4j/OlapConnection.java @@ -13,6 +13,7 @@ import java.sql.Connection; import java.sql.SQLException; +import java.sql.Statement; /** * Connection to an OLAP server. @@ -32,6 +33,12 @@ public interface OlapConnection extends Connection { * Returns the factory used to create MDX parsers in this connection. */ MdxParserFactory getParserFactory(); + + /** + * Override {@link java.sql.Connection#createStatement()} with refined + * result type. + */ + OlapStatement createStatement() throws SQLException; } // End OlapConnection.java diff --git a/src/org/olap4j/OlapDatabaseMetaData.java b/src/org/olap4j/OlapDatabaseMetaData.java new file mode 100644 index 0000000..102afa7 --- /dev/null +++ b/src/org/olap4j/OlapDatabaseMetaData.java @@ -0,0 +1,181 @@ +/* +// $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) 2006-2006 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j; + +import java.sql.DatabaseMetaData; +import java.sql.ResultSet; +import java.sql.SQLException; + +/** + * Information about an OLAP database. + * + *

        Methods are provided to query the metadata catalog of the database. + * There is a method for each metadata class, and each method takes zero or more + * parameters to qualify the instances should be returned, and returns a JDBC + * {@link java.sql.ResultSet}. + * + *

        For example, {@link #getCubes} returns the description of a cube. + * + * @author jhyde + * @version $Id: $ + * @since Oct 12, 2006 + */ +public interface OlapDatabaseMetaData extends DatabaseMetaData { + + /** + * Retrieves a list of descriptions of an Action. + * + *

        Specification as for XML/A MDSCHEMA_ACTIONS schema rowset. + * + *

        todo: document parameters and result set columns + */ + ResultSet getActions() throws SQLException; + + /** + * Retrives a list of olap4j data sources that are available on the server. + * + *

        Specification as for XML/A DISCOVER_DATASOURCES schema rowset. + * + *

        todo: document parameters and result set columns + */ + ResultSet getDatasources( + String dataSourceName) throws SQLException; + + /** + * Retrieves a list of information on supported literals, including data + * types and values. + * + *

        Specification as for XML/A DISCOVER_LITERALS schema rowset. + * + *

        todo: document parameters and result set columns + */ + ResultSet getLiterals() throws SQLException; + + /** + * Retrieves a list of the standard and provider-specific properties + * supported by an olap4j provider. Properties that are not supported by a + * provider are not listed in the return result set. + * + *

        Specification as for XML/A DISCOVER_PROPERTIES schema rowset. + * + *

        Not to be confused with {@link #getProperties()}. + * + *

        todo: document parameters and result set columns + */ + ResultSet getDatabaseProperties( + String dataSourceName) throws SQLException; + + /** + * Retrieves a list of descriptions of member and cell Properties. + * + *

        Specification as for XML/A MDSCHEMA_PROPERTIES schema rowset. + * + *

        Not to be confused with {@link #getDatabaseProperties(String)}. + * + *

        todo: document parameters and result set columns + */ + ResultSet getProperties() throws SQLException; + + /** + * Retrieves a comma-separated list of all of this database's MDX keywords. + * + * @return the list of this database's MDX keywords + * @exception java.sql.SQLException if a database access error occurs + */ + String getMdxKeywords() throws SQLException; + + /** + * Retrieves a description of a cube. + * + * @param catalog a catalog name; must match the catalog name as it + * is stored in the database; "" retrieves those without a catalog; + * null means that the catalog name should not be used to narrow + * the search + * @param schemaPattern a schema name pattern; must match the schema name + * as it is stored in the database; "" retrieves those without a schema; + * null means that the schema name should not be used to narrow + * the search + * @param cubeNamePattern a cube name pattern; must match the + * cube name as it is stored in the database + * @return ResultSet - each row is a cube description + */ + public ResultSet getCubes( + String catalog, + String schemaPattern, + String cubeNamePattern) throws SQLException; + /** + * Retrieves a result set describing the shared and private dimensions + * within a database. + * + *

        Specification as for XML/A MDSCHEMA_DIMENSIONS schema rowset. + * + *

        todo: document parameters and result set columns + */ + ResultSet getDimensions() throws SQLException; + + /** + * Retrieves a result set describing the functions available to client + * applications connected to the database. + * + *

        Specification as for XML/A MDSCHEMA_FUNCTIONS schema rowset. + * + *

        todo: document parameters and result set columns + */ + ResultSet getFunctions() throws SQLException; + + /** + * Retrieves a result set describing each hierarchy within a particular + * dimension. + * + *

        Specification as for XML/A MDSCHEMA_HIERARCHIES schema rowset. + * + *

        todo: document parameters and result set columns + */ + ResultSet getHierarchies() throws SQLException; + + /** + * Retrieves a result set describing each measure within a cube. + * + *

        Specification as for XML/A MDSCHEMA_MEASURES schema rowset. + * + *

        todo: document parameters and result set columns + */ + ResultSet getMeasures() throws SQLException; + + /** + * Retrieves a result set describing the members within a database. + * + *

        Specification as for XML/A MDSCHEMA_MEMBERS schema rowset. + * + *

        todo: document parameters and result set columns + */ + ResultSet getMembers() throws SQLException; + + /** + * Retrieves a result set describing each level within a particular + * hierarchy. + * + *

        Specification as for XML/A MDSCHEMA_LEVELS schema rowset. + * + *

        todo: document parameters and result set columns + */ + ResultSet getLevels() throws SQLException; + + /** + * Retrieves a result set describing each calculated set. + * + *

        Specification as for XML/A MDSCHEMA_SETS schema rowset. + * + *

        todo: document parameters and result set columns + */ + ResultSet getSets() throws SQLException; +} + +// End OlapDatabaseMetaData.java diff --git a/src/org/olap4j/OlapStatement.java b/src/org/olap4j/OlapStatement.java index ad2d981..a49f0f4 100644 --- a/src/org/olap4j/OlapStatement.java +++ b/src/org/olap4j/OlapStatement.java @@ -41,7 +41,6 @@ public interface OlapStatement extends Statement { * @return Result */ OlapResultSet executeOlapQuery(Query query); - } // End OlapStatement.java diff --git a/src/org/olap4j/metadata/Cube.java b/src/org/olap4j/metadata/Cube.java index 7f883ad..04a430b 100644 --- a/src/org/olap4j/metadata/Cube.java +++ b/src/org/olap4j/metadata/Cube.java @@ -16,7 +16,8 @@ * @version $Id$ * @since Aug 22, 2006 */ -public interface Cube { +public interface Cube extends MetadataElement { + Schema getSchema(); NamedList getDimensions(); } diff --git a/src/org/olap4j/metadata/Dimension.java b/src/org/olap4j/metadata/Dimension.java index 1f18c43..3d341b0 100644 --- a/src/org/olap4j/metadata/Dimension.java +++ b/src/org/olap4j/metadata/Dimension.java @@ -16,11 +16,7 @@ * @version $Id$ * @since Aug 22, 2006 */ -public interface Dimension { - /** - * Returns the name of this Dimension. - */ - String getName(); +public interface Dimension extends MetadataElement { /** * Returns the hierarchies in this Dimension. @@ -60,6 +56,11 @@ public enum Type { * Indicates that a dimension is a time dimension. */ Time, + + /** + * Indicates that a dimension is the Measures dimension. + */ + Measures, } } diff --git a/src/org/olap4j/metadata/Hierarchy.java b/src/org/olap4j/metadata/Hierarchy.java index b69d4b8..3008099 100644 --- a/src/org/olap4j/metadata/Hierarchy.java +++ b/src/org/olap4j/metadata/Hierarchy.java @@ -16,7 +16,7 @@ * @version $Id$ * @since Aug 23, 2006 */ -public interface Hierarchy { +public interface Hierarchy extends MetadataElement { /** * Returns the {@link Dimension} this Hierarchy belongs to. */ diff --git a/src/org/olap4j/metadata/Level.java b/src/org/olap4j/metadata/Level.java index 714d9ad..bf3c0e7 100644 --- a/src/org/olap4j/metadata/Level.java +++ b/src/org/olap4j/metadata/Level.java @@ -17,7 +17,7 @@ * @version $Id$ * @since Aug 23, 2006 */ -public interface Level { +public interface Level extends MetadataElement { /** * Returns the depth of this level. * @@ -34,6 +34,12 @@ public interface Level { */ Hierarchy getHierarchy(); + /** + * Returns the Dimension this Level belongs to. + * (Always equivalent to getHierarchy().getDimension().) + */ + Dimension getDimension(); + /** * Returns the type of this Level. */ diff --git a/src/org/olap4j/metadata/Measure.java b/src/org/olap4j/metadata/Measure.java new file mode 100644 index 0000000..6f5d8b4 --- /dev/null +++ b/src/org/olap4j/metadata/Measure.java @@ -0,0 +1,22 @@ +/* +// $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) 2006-2006 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j.metadata; + +/** + * Measure ... + * + * @author jhyde + * @version $Id: $ + * @since Oct 13, 2006 + */ +public interface Measure extends Member { +} + +// End Measure.java diff --git a/src/org/olap4j/metadata/Member.java b/src/org/olap4j/metadata/Member.java index 8ba2db5..f3624ee 100644 --- a/src/org/olap4j/metadata/Member.java +++ b/src/org/olap4j/metadata/Member.java @@ -13,6 +13,7 @@ import mondrian.olap.Property; import java.sql.SQLException; +import java.util.List; /** * Member is a data value in a in an OLAP Dimension. @@ -21,9 +22,7 @@ * @version $Id$ * @since Aug 22, 2006 */ -public interface Member { - String getName(); - +public interface Member extends MetadataElement { /** * Returns the children of this Member, indexed by name. * @@ -38,17 +37,32 @@ public interface Member { Member getParentMember(); /** - * Returns the level of this Member. + * Returns the Level of this Member. + * + *

        Never returns null.

        */ Level getLevel(); /** - * Returns the hierarchy of this Member. + * Returns the Hierarchy of this Member. + * + *

        Never returns null. + * Result is always the same as getLevel().getHierarchy(). */ Hierarchy getHierarchy(); + /** + * Returns the Dimension of this Member. + * + *

        Never returns null. Result is always the same as + * getLevel().getHierarchy().getDimension(). + */ + Dimension getDimension(); + /** * Returns the type of this Member. + * + *

        Never returns null.

        */ Type getMemberType(); @@ -103,7 +117,7 @@ private Type(int ordinal) { /** * Returns array of all members, which are ancestor to this. */ - Member[] getAncestorMembers(); + List getAncestorMembers(); /** * Returns whether this member is computed from a with member @@ -145,7 +159,7 @@ private Type(int ordinal) { /** * Returns the definitions of the properties this member may have. */ - Property[] getProperties(); + List getProperties(); /** * Returns the ordinal of the member. @@ -159,9 +173,11 @@ private Type(int ordinal) { boolean isHidden(); /** - * returns the depth of this member, which is not the level's depth - * in case of parent child dimensions - * @return depth + * Returns the depth of this member. + * + *

        In regular hierarchies, this is as the same as the level's depth, + * but in parent-child and ragged hierarchies the value may be + * different.

        */ int getDepth(); diff --git a/src/org/olap4j/metadata/MetadataElement.java b/src/org/olap4j/metadata/MetadataElement.java new file mode 100644 index 0000000..5011a70 --- /dev/null +++ b/src/org/olap4j/metadata/MetadataElement.java @@ -0,0 +1,51 @@ +/* +// $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) 2006-2006 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j.metadata; + +import java.util.Locale; + +/** + * Common interface for + * + * @author jhyde + * @version $Id: $ + * @since Oct 13, 2006 + */ +public interface MetadataElement { + String getName(); + + String getUniqueName(); + + /** + * Returns the caption of this element in the given locale. + * + * If locale is null or if no caption has been defined for the + * element in that locale, returns the caption in base locale. + * + * @param locale Locale + * @return Caption of this element in the given locale, or the base locale; + * never null. + */ + String getCaption(Locale locale); + + /** + * Returns the description of this element in the given locale. + * + * If locale is null or if no description has been defined for + * the element in that locale, returns the description in base locale. + * + * @param locale Locale + * @return description of this element in the given locale, or the base + * locale; never null. + */ + String getDescription(Locale locale); +} + +// End MetadataElement.java diff --git a/src/org/olap4j/metadata/Property.java b/src/org/olap4j/metadata/Property.java index b933817..ed99def 100644 --- a/src/org/olap4j/metadata/Property.java +++ b/src/org/olap4j/metadata/Property.java @@ -11,6 +11,8 @@ import mondrian.olap.PropertyFormatter; +import java.util.Locale; + /** * Definition of a property of a Member or Cell. * @@ -18,7 +20,7 @@ * @version $Id$ * @since Aug 23, 2006 */ -public interface Property { +public interface Property extends MetadataElement { /** * Returns the datatype of this Property. */ @@ -29,14 +31,6 @@ public interface Property { */ Scope getScope(); - String getDescription(); - - /** - * Returns the caption of this property. - * The default implementation returns the name of the property. - */ - String getCaption(); - boolean isInternal(); enum Scope { @@ -265,22 +259,30 @@ private StandardMemberProperty( this.description = description; } - public Datatype getType() { - return type; + public String getName() { + return name(); } - public Scope getScope() { - return Scope.MEMBER; + public String getUniqueName() { + return name(); } - public String getDescription() { + public String getDescription(Locale locale) { return description; } - public String getCaption() { + public String getCaption(Locale locale) { return name(); } + public Datatype getType() { + return type; + } + + public Scope getScope() { + return Scope.MEMBER; + } + public boolean isInternal() { return internal; } @@ -384,18 +386,26 @@ public Scope getScope() { return Scope.CELL; } - public String getDescription() { - return description; + public String getName() { + return name(); } - public PropertyFormatter getFormatter() { - return null; + public String getUniqueName() { + return name(); } - public String getCaption() { + public String getCaption(Locale locale) { return name(); } + public String getDescription(Locale locale) { + return description; + } + + public PropertyFormatter getFormatter() { + return null; + } + public boolean isInternal() { return internal; } diff --git a/src/org/olap4j/metadata/Schema.java b/src/org/olap4j/metadata/Schema.java new file mode 100644 index 0000000..af0075d --- /dev/null +++ b/src/org/olap4j/metadata/Schema.java @@ -0,0 +1,23 @@ +/* +// $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) 2006-2006 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j.metadata; + +/** + * Schema ... + * + * @author jhyde + * @version $Id: $ + * @since Oct 13, 2006 + */ +public interface Schema { + NamedList getCubes(); +} + +// End Schema.java diff --git a/src/org/olap4j/sample/SimpleQuerySample.java b/src/org/olap4j/sample/SimpleQuerySample.java index 75558a0..3e432a9 100644 --- a/src/org/olap4j/sample/SimpleQuerySample.java +++ b/src/org/olap4j/sample/SimpleQuerySample.java @@ -10,10 +10,10 @@ package org.olap4j.sample; import org.olap4j.*; +import org.olap4j.type.MemberType; import org.olap4j.mdx.parser.MdxParser; import org.olap4j.mdx.parser.MdxParserFactory; import org.olap4j.metadata.Member; -import org.olap4j.metadata.Cube; import org.olap4j.metadata.Dimension; import java.sql.*; @@ -53,10 +53,11 @@ void simpleStatement() throws SQLException, ClassNotFoundException { // Execute a statement. Statement statement = connection.createStatement(); - OlapResultSet result = statement.executeOlapQuery( + OlapResultSet result = Olap4j.convert( + statement.executeQuery( "select {[Measures].[Unit Sales]} on columns,\n" + " CrossJoin([Store].Children, [Gender].Members) on rows\n" + - "from [Sales]"); + "from [Sales]")); List resultAxes = result.getAxes(); @@ -124,17 +125,18 @@ void preparedStatement() throws SQLException, ClassNotFoundException { (OlapParameterMetaData) statement.getParameterMetaData(); // Locate the member "[Store].[USA].[WA].[Seattle]". - Cube cube = statement.getCube(); - Dimension dimension = cube.getDimensions().get("Store"); + MemberType type = (MemberType) parameterMetaData.getOlapType(1); + Dimension dimension = type.getDimension(); + assert dimension.getName().equals("Store"); Member allStores = dimension.getRootMembers().get(0); Member memberUsa = allStores.getChildMembers().get("USA"); Member memberWa = memberUsa.getChildMembers().get("WA"); Member memberSeattle = memberWa.getChildMembers().get("Seattle"); - statement.setMember(1, memberSeattle); + statement.setObject(1, memberSeattle); statement.setInt(2, 10); // Execute, and print result. - OlapResultSet result = statement.executeOlapQuery(); + OlapResultSet result = Olap4j.convert(statement.executeQuery()); printResult(result); // Close the statement and connection. @@ -150,8 +152,8 @@ void statementFromParseTree() throws ClassNotFoundException, SQLException { Class.forName("mondrian.olap4j.Driver"); // Create connection. - OlapConnection connection = (OlapConnection) - DriverManager.getConnection("jdbc:mondrian:embedded"); + OlapConnection connection = Olap4j.convert( + DriverManager.getConnection("jdbc:mondrian:embedded")); // Create a parser. MdxParserFactory parserFactory = connection.getParserFactory(); @@ -162,7 +164,7 @@ void statementFromParseTree() throws ClassNotFoundException, SQLException { query.axes[0].setNonEmpty(false); // Create statement. - Statement statement = connection.createStatement(); + OlapStatement statement = connection.createStatement(); statement.executeOlapQuery(query); } @@ -203,18 +205,6 @@ private void printResult(OlapResultSet result) { System.out.println(); } } - - void parameterMetadata() throws ClassNotFoundException, SQLException { - // Register driver. - Class.forName("mondrian.olap4j.Driver"); - - // Create connection and statement. - Connection connection = - DriverManager.getConnection("jdbc:mondrian:embedded"); - Statement statement = connection.prepareStatement(); - - - } } // End SimpleQuerySample.java diff --git a/src/org/olap4j/type/BooleanType.java b/src/org/olap4j/type/BooleanType.java new file mode 100755 index 0000000..ba32698 --- /dev/null +++ b/src/org/olap4j/type/BooleanType.java @@ -0,0 +1,25 @@ +/* +// $Id: //open/mondrian/src/main/org.olap4j.type/BooleanType.java#3 $ +// 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) 2005-2005 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j.type; + +/** + * The type of a boolean expression. + * + * @author jhyde + * @since Feb 17, 2005 + * @version $Id: //open/mondrian/src/main/org.olap4j.type/BooleanType.java#3 $ + */ +public class BooleanType extends ScalarType { + public String toString() { + return "BOOLEAN"; + } +} + +// End BooleanType.java diff --git a/src/org/olap4j/type/CubeType.java b/src/org/olap4j/type/CubeType.java new file mode 100755 index 0000000..6dec509 --- /dev/null +++ b/src/org/olap4j/type/CubeType.java @@ -0,0 +1,51 @@ +/* +// $Id: //open/mondrian/src/main/org.olap4j.type/CubeType.java#3 $ +// 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) 2005-2005 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j.type; + +import org.olap4j.metadata.Dimension; +import org.olap4j.metadata.Hierarchy; +import org.olap4j.metadata.Level; +import org.olap4j.metadata.Cube; + +/** + * The type of an expression which represents a Cube or Virtual Cube. + * + * @author jhyde + * @since Feb 17, 2005 + * @version $Id: //open/mondrian/src/main/org.olap4j.type/CubeType.java#3 $ + */ +public class CubeType implements Type { + private final Cube cube; + + /** + * Creates a type representing a cube. + */ + public CubeType(Cube cube) { + this.cube = cube; + } + + public boolean usesDimension(Dimension dimension, boolean maybe) { + return false; + } + + public Dimension getDimension() { + return null; + } + + public Hierarchy getHierarchy() { + return null; + } + + public Level getLevel() { + return null; + } +} + +// End CubeType.java diff --git a/src/org/olap4j/type/DecimalType.java b/src/org/olap4j/type/DecimalType.java new file mode 100755 index 0000000..267f967 --- /dev/null +++ b/src/org/olap4j/type/DecimalType.java @@ -0,0 +1,70 @@ +/* +// $Id: //open/mondrian/src/main/org.olap4j.type/DecimalType.java#3 $ +// 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) 2005-2005 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j.type; + +/** + * Subclass of {@link NumericType} which guarantees fixed number of decimal + * places. In particular, a decimal with zero scale is an integer. + * + * @author jhyde + * @since May 3, 2005 + * @version $Id: //open/mondrian/src/main/org.olap4j.type/DecimalType.java#3 $ + */ +public class DecimalType extends NumericType { + private final int precision; + private final int scale; + + /** + * Creates a decimal type with precision and scale. + * + *

        Examples:

          + *
        • 123.45 has precision 5, scale 2. + *
        • 12,345,000 has precision 5, scale -3. + *
        + * + *

        The largest value is 10 ^ (precision - scale). Hence the largest + * DECIMAL(5, -3) value is 10 ^ 8. + * + * @param precision Maximum number of decimal digits which a value of + * this type can have. + * Must be greater than zero. + * Use {@link Integer#MAX_VALUE} if the precision is unbounded. + * @param scale Number of digits to the right of the decimal point. + */ + public DecimalType(int precision, int scale) { + super(); + assert precision > 0 : "expected precision > 0"; + this.precision = precision; + this.scale = scale; + } + + /** + * Returns the maximum number of decimal digits which a value of + * this type can have. + */ + public int getPrecision() { + return precision; + } + + /** + * Returns the number of digits to the right of the decimal point. + */ + public int getScale() { + return scale; + } + + public String toString() { + return precision == Integer.MAX_VALUE ? + "DECIMAL(" + scale + ")" : + "DECIMAL(" + precision + ", " + scale + ")"; + } +} + +// End DecimalType.java diff --git a/src/org/olap4j/type/DimensionType.java b/src/org/olap4j/type/DimensionType.java new file mode 100755 index 0000000..8e95077 --- /dev/null +++ b/src/org/olap4j/type/DimensionType.java @@ -0,0 +1,79 @@ +/* +// $Id: //open/mondrian/src/main/org.olap4j.type/DimensionType.java#5 $ +// 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) 2005-2005 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j.type; + +import org.olap4j.metadata.Dimension; +import org.olap4j.metadata.Hierarchy; +import org.olap4j.metadata.Level; + +/** + * The type of an expression which represents a Dimension. + * + * @author jhyde + * @since Feb 17, 2005 + * @version $Id: //open/mondrian/src/main/org.olap4j.type/DimensionType.java#5 $ + */ +public class DimensionType implements Type { + private final Dimension dimension; + private final String digest; + + public static final DimensionType Unknown = new DimensionType(null); + + /** + * Creates a type representing a dimension. + * + * @param dimension Dimension that values of this type must belong to. + * Null if the dimension is unknown. + */ + public DimensionType(Dimension dimension) { + this.dimension = dimension; + StringBuffer buf = new StringBuffer("DimensionType<"); + if (dimension != null) { + buf.append("dimension=").append(dimension.getUniqueName()); + } + buf.append(">"); + this.digest = buf.toString(); + } + + public static DimensionType forDimension(Dimension dimension) { + return new DimensionType(dimension); + } + + public static DimensionType forType(Type type) { + return new DimensionType(type.getDimension()); + } + + public boolean usesDimension(Dimension dimension, boolean maybe) { + return this.dimension == dimension || + (maybe && this.dimension == null); + } + + public Hierarchy getHierarchy() { + return dimension == null ? + null : + dimension.getHierarchies().size() > 1 ? + null : + dimension.getHierarchies().get(0); + } + + public Level getLevel() { + return null; + } + + public Dimension getDimension() { + return dimension; + } + + public String toString() { + return digest; + } +} + +// End DimensionType.java diff --git a/src/org/olap4j/type/HierarchyType.java b/src/org/olap4j/type/HierarchyType.java new file mode 100755 index 0000000..6e38435 --- /dev/null +++ b/src/org/olap4j/type/HierarchyType.java @@ -0,0 +1,75 @@ +/* +// $Id: //open/mondrian/src/main/org.olap4j.type/HierarchyType.java#5 $ +// 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) 2005-2005 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j.type; + +import org.olap4j.metadata.Hierarchy; +import org.olap4j.metadata.Dimension; +import org.olap4j.metadata.Level; + +/** + * The type of an expression which represents a hierarchy. + * + * @author jhyde + * @since Feb 17, 2005 + * @version $Id: //open/mondrian/src/main/org.olap4j.type/HierarchyType.java#5 $ + */ +public class HierarchyType implements Type { + private final Dimension dimension; + private final Hierarchy hierarchy; + private final String digest; + + /** + * Creates a type representing a hierarchy. + */ + public HierarchyType(Dimension dimension, Hierarchy hierarchy) { + this.dimension = dimension; + this.hierarchy = hierarchy; + StringBuffer buf = new StringBuffer("HierarchyType<"); + if (hierarchy != null) { + buf.append("hierarchy=").append(hierarchy.getUniqueName()); + } else if (dimension != null) { + buf.append("dimension=").append(dimension.getUniqueName()); + } + buf.append(">"); + this.digest = buf.toString(); + + } + + public static HierarchyType forHierarchy(Hierarchy hierarchy) { + return new HierarchyType(hierarchy.getDimension(), hierarchy); + } + + public static HierarchyType forType(Type type) { + return new HierarchyType(type.getDimension(), type.getHierarchy()); + } + + public boolean usesDimension(Dimension dimension, boolean maybe) { + return this.dimension == dimension || + (maybe && this.dimension == null); + } + + public Dimension getDimension() { + return dimension; + } + + public Hierarchy getHierarchy() { + return hierarchy; + } + + public Level getLevel() { + return null; + } + + public String toString() { + return digest; + } +} + +// End HierarchyType.java diff --git a/src/org/olap4j/type/LevelType.java b/src/org/olap4j/type/LevelType.java new file mode 100755 index 0000000..39ddc42 --- /dev/null +++ b/src/org/olap4j/type/LevelType.java @@ -0,0 +1,103 @@ +/* +// $Id: //open/mondrian/src/main/org.olap4j.type/LevelType.java#5 $ +// 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) 2005-2005 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j.type; + +import org.olap4j.metadata.Level; +import org.olap4j.metadata.Dimension; +import org.olap4j.metadata.Hierarchy; + +/** + * The type of an expression which represents a level. + * + * @author jhyde + * @since Feb 17, 2005 + * @version $Id: //open/mondrian/src/main/org.olap4j.type/LevelType.java#5 $ + */ +public class LevelType implements Type { + private final Dimension dimension; + private final Hierarchy hierarchy; + private final Level level; + private final String digest; + + /** + * Creates a type representing a level. + * + * @param dimension + * @param hierarchy Hierarchy which values of this type must belong to, or + * null if not known + * @param level Level which values of this type must belong to, or null if + */ + public LevelType(Dimension dimension, Hierarchy hierarchy, Level level) { + this.dimension = dimension; + this.hierarchy = hierarchy; + this.level = level; + if (level != null) { + assert hierarchy != null : "hierarchy != null"; + assert level.getHierarchy() == hierarchy : + "level.getHierarchy() == hierarchy"; + } + if (hierarchy != null) { + assert dimension != null : "dimension != null"; + assert hierarchy.getDimension() == dimension : + "hierarchy.getDimension() == dimension"; + } + StringBuffer buf = new StringBuffer("LevelType<"); + if (level != null) { + buf.append("level=").append(level.getUniqueName()); + } else if (hierarchy != null) { + buf.append("hierarchy=").append(hierarchy.getUniqueName()); + } else if (dimension != null) { + buf.append("dimension=").append(dimension.getUniqueName()); + } + buf.append(">"); + this.digest = buf.toString(); + } + + public static LevelType forType(Type type) { + return new LevelType( + type.getDimension(), + type.getHierarchy(), + type.getLevel()); + + } + + public static LevelType forLevel(Level level) { + return new LevelType( + level.getDimension(), + level.getHierarchy(), + level); + } + + public boolean usesDimension(Dimension dimension, boolean maybe) { + if (this.dimension == null) { + return maybe; + } else { + return this.dimension == dimension; + } + } + + public Dimension getDimension() { + return dimension; + } + + public Hierarchy getHierarchy() { + return hierarchy; + } + + public Level getLevel() { + return level; + } + + public String toString() { + return digest; + } +} + +// End LevelType.java diff --git a/src/org/olap4j/type/MemberType.java b/src/org/olap4j/type/MemberType.java new file mode 100644 index 0000000..e1fe04c --- /dev/null +++ b/src/org/olap4j/type/MemberType.java @@ -0,0 +1,148 @@ +/* +// $Id: //open/mondrian/src/main/org.olap4j.type/MemberType.java#3 $ +// 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) 2005-2005 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j.type; + +import org.olap4j.metadata.Member; +import org.olap4j.metadata.Level; +import org.olap4j.metadata.Hierarchy; +import org.olap4j.metadata.Dimension; + +/** + * The type of an expression which represents a member. + * + * @author jhyde + * @since Feb 17, 2005 + * @version $Id: //open/mondrian/src/main/org.olap4j.type/MemberType.java#3 $ + */ +public class MemberType implements Type { + private final Hierarchy hierarchy; + private final Dimension dimension; + private final Level level; + private final Member member; + private final String digest; + + public static final MemberType Unknown = new MemberType(null, null, null, null); + + /** + * Creates a type representing a member. + * + * @param dimension + * @param hierarchy Hierarchy the member belongs to, or null if not known. + * @param level Level the member belongs to, or null if not known + * @param member The precise member, or null if not known + */ + public MemberType( + Dimension dimension, + Hierarchy hierarchy, + Level level, + Member member) { + this.dimension = dimension; + this.hierarchy = hierarchy; + this.level = level; + this.member = member; + if (member != null) { + assert level != null; + assert member.getLevel() == level; + } + if (level != null) { + assert hierarchy != null; + assert level.getHierarchy() == hierarchy; + } + if (hierarchy != null) { + assert dimension != null; + assert hierarchy.getDimension() == dimension; + } + StringBuffer buf = new StringBuffer("MemberType<"); + if (member != null) { + buf.append("member=").append(member.getUniqueName()); + } else if (level != null) { + buf.append("level=").append(level.getUniqueName()); + } else if (hierarchy != null) { + buf.append("hierarchy=").append(hierarchy.getUniqueName()); + } else if (dimension != null) { + buf.append("dimension=").append(dimension.getUniqueName()); + } + buf.append(">"); + this.digest = buf.toString(); + } + + public static MemberType forDimension(Dimension dimension) { + return new MemberType(dimension, null, null, null); + } + + public static MemberType forHierarchy(Hierarchy hierarchy) { + return new MemberType( + hierarchy.getDimension(), + hierarchy, + null, + null); + } + + public static MemberType forLevel(Level level) { + return new MemberType( + level.getDimension(), + level.getHierarchy(), + level, + null); + } + + public static MemberType forMember(Member member) { + return new MemberType( + member.getDimension(), + member.getHierarchy(), + member.getLevel(), + member); + } + + public String toString() { + return digest; + } + + public Hierarchy getHierarchy() { + return hierarchy; + } + + public Level getLevel() { + return level; + } + + public boolean usesDimension(Dimension dimension, boolean maybe) { + if (this.dimension == null) { + return maybe; + } else { + return this.dimension == dimension || + (maybe && this.dimension == null); + } + } + + public Type getValueType() { + // todo: when members have more type information (double vs. integer + // vs. string), return better type if member != null. + return new ScalarType(); + } + + public Dimension getDimension() { + return dimension; + } + + public static MemberType forType(Type type) { + if (type instanceof MemberType) { + return (MemberType) type; + } else { + return new MemberType( + type.getDimension(), + type.getHierarchy(), + type.getLevel(), + null); + } + } +} + +// End MemberType.java diff --git a/src/org/olap4j/type/NullType.java b/src/org/olap4j/type/NullType.java new file mode 100755 index 0000000..d53d88b --- /dev/null +++ b/src/org/olap4j/type/NullType.java @@ -0,0 +1,28 @@ +/* +// $Id: //open/mondrian/src/main/org.olap4j.type/NullType.java#1 $ +// 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) 2005-2005 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j.type; + +/** + * The type of a null expression. + * + * @author medstat + * @version $Id: //open/mondrian/src/main/org.olap4j.type/NullType.java#1 $ + * @since Aug 21, 2006 + */ +public class NullType extends ScalarType +{ + /** + * Creates a null type. + */ + public NullType() + { + } +} +// End NullType.java diff --git a/src/org/olap4j/type/NumericType.java b/src/org/olap4j/type/NumericType.java new file mode 100755 index 0000000..899f554 --- /dev/null +++ b/src/org/olap4j/type/NumericType.java @@ -0,0 +1,35 @@ +/* +// $Id: //open/mondrian/src/main/org.olap4j.type/NumericType.java#3 $ +// 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) 2005-2005 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j.type; + +import org.olap4j.metadata.Dimension; +import org.olap4j.metadata.Hierarchy; + +/** + * The type of a numeric expression. + * + * @author jhyde + * @since Feb 17, 2005 + * @version $Id: //open/mondrian/src/main/org.olap4j.type/NumericType.java#3 $ + */ +public class NumericType extends ScalarType { + + /** + * Creates a numeric type. + */ + public NumericType() { + } + + public String toString() { + return "NUMERIC"; + } +} + +// End NumericType.java diff --git a/src/org/olap4j/type/ScalarType.java b/src/org/olap4j/type/ScalarType.java new file mode 100755 index 0000000..8b8195b --- /dev/null +++ b/src/org/olap4j/type/ScalarType.java @@ -0,0 +1,45 @@ +/* +// $Id: //open/mondrian/src/main/org.olap4j.type/ScalarType.java#3 $ +// 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) 2005-2005 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j.type; + +import org.olap4j.metadata.Dimension; +import org.olap4j.metadata.Hierarchy; +import org.olap4j.metadata.Level; + +/** + * Base class for types which represent scalar values. + * + *

        An instance of this class means a scalar value of unknown type. + * Usually one of the derived classes {@link NumericType}, + * {@link StringType}, {@link BooleanType} is used instead. + * + * @author jhyde + * @since Feb 17, 2005 + * @version $Id: //open/mondrian/src/main/org.olap4j.type/ScalarType.java#3 $ + */ +public class ScalarType implements Type { + public boolean usesDimension(Dimension dimension, boolean maybe) { + return false; + } + + public Hierarchy getHierarchy() { + return null; + } + + public Level getLevel() { + return null; + } + + public Dimension getDimension() { + return null; + } +} + +// End ScalarType.java diff --git a/src/org/olap4j/type/SetType.java b/src/org/olap4j/type/SetType.java new file mode 100755 index 0000000..1a68213 --- /dev/null +++ b/src/org/olap4j/type/SetType.java @@ -0,0 +1,69 @@ +/* +// $Id: //open/mondrian/src/main/org.olap4j.type/SetType.java#4 $ +// 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) 2005-2005 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j.type; + +import org.olap4j.metadata.Dimension; +import org.olap4j.metadata.Hierarchy; +import org.olap4j.metadata.Level; + +/** + * Set type. + * + * @author jhyde + * @since Feb 17, 2005 + * @version $Id: //open/mondrian/src/main/org.olap4j.type/SetType.java#4 $ + */ +public class SetType implements Type { + + private final Type elementType; + + /** + * Creates a type representing a set of elements of a given type. + * + * @param elementType The type of the elements in the set, or null if not + * known + */ + public SetType(Type elementType) { + assert elementType instanceof MemberType || + elementType instanceof TupleType; + this.elementType = elementType; + } + + /** + * Returns the type of the elements of this set. + */ + public Type getElementType() { + return elementType; + } + + public boolean usesDimension(Dimension dimension, boolean maybe) { + if (elementType == null) { + return maybe; + } + return elementType.usesDimension(dimension, maybe); + } + + public Dimension getDimension() { + return elementType == null ? null : + elementType.getDimension(); + } + + public Hierarchy getHierarchy() { + return elementType == null ? null : + elementType.getHierarchy(); + } + + public Level getLevel() { + return elementType == null ? null : + elementType.getLevel(); + } +} + +// End SetType.java diff --git a/src/org/olap4j/type/StringType.java b/src/org/olap4j/type/StringType.java new file mode 100755 index 0000000..fe3e76f --- /dev/null +++ b/src/org/olap4j/type/StringType.java @@ -0,0 +1,32 @@ +/* +// $Id: //open/mondrian/src/main/org.olap4j.type/StringType.java#2 $ +// 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) 2005-2005 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j.type; + +import org.olap4j.metadata.Dimension; +import org.olap4j.metadata.Hierarchy; + +/** + * The type of a string expression. + * + * @author jhyde + * @since Feb 17, 2005 + * @version $Id: //open/mondrian/src/main/org.olap4j.type/StringType.java#2 $ + */ +public class StringType extends ScalarType { + + /** + * Creates a string type. + */ + public StringType() { + } + +} + +// End StringType.java diff --git a/src/org/olap4j/type/SymbolType.java b/src/org/olap4j/type/SymbolType.java new file mode 100755 index 0000000..948a75c --- /dev/null +++ b/src/org/olap4j/type/SymbolType.java @@ -0,0 +1,29 @@ +/* +// $Id: //open/mondrian/src/main/org.olap4j.type/SymbolType.java#2 $ +// 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) 2005-2005 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j.type; + +/** + * The type of a symbolic expression. + * + * @author jhyde + * @since Feb 17, 2005 + * @version $Id: //open/mondrian/src/main/org.olap4j.type/SymbolType.java#2 $ + */ +public class SymbolType extends ScalarType { + + /** + * Creates a symbol type. + */ + public SymbolType() { + } + +} + +// End SymbolType.java diff --git a/src/org/olap4j/type/TupleType.java b/src/org/olap4j/type/TupleType.java new file mode 100755 index 0000000..5002e35 --- /dev/null +++ b/src/org/olap4j/type/TupleType.java @@ -0,0 +1,68 @@ +/* +// $Id: //open/mondrian/src/main/org.olap4j.type/TupleType.java#3 $ +// 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) 2005-2005 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j.type; + +import org.olap4j.metadata.Dimension; +import org.olap4j.metadata.Hierarchy; +import org.olap4j.metadata.Level; + +/** + * Tuple type. + * + * @author jhyde + * @since Feb 17, 2005 + * @version $Id: //open/mondrian/src/main/org.olap4j.type/TupleType.java#3 $ + */ +public class TupleType implements Type { + public final Type[] elementTypes; + + /** + * Creates a type representing a tuple whose fields are the given types. + */ + public TupleType(Type[] elementTypes) { + assert elementTypes != null; + this.elementTypes = elementTypes.clone(); + } + + public boolean usesDimension(Dimension dimension, boolean maybe) { + for (Type elementType : elementTypes) { + if (elementType.usesDimension(dimension, maybe)) { + return true; + } + } + return false; + } + + public Dimension getDimension() { + throw new UnsupportedOperationException(); + } + + public Hierarchy getHierarchy() { + throw new UnsupportedOperationException(); + } + + public Level getLevel() { + throw new UnsupportedOperationException(); + } + + public Type getValueType() { + for (Type elementType : elementTypes) { + if (elementType instanceof MemberType) { + MemberType memberType = (MemberType) elementType; + if (memberType.getDimension().getDimensionType() == Dimension.Type.Measures) { + return memberType.getValueType(); + } + } + } + return new ScalarType(); + } +} + +// End TupleType.java diff --git a/src/org/olap4j/type/Type.java b/src/org/olap4j/type/Type.java index 1407528..58fc3aa 100644 --- a/src/org/olap4j/type/Type.java +++ b/src/org/olap4j/type/Type.java @@ -1,22 +1,66 @@ /* -// $Id: $ +// $Id: //open/mondrian/src/main/org.olap4j.type/Type.java#3 $ // 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) 2006-2006 Julian Hyde +// Copyright (C) 2005-2005 Julian Hyde // All Rights Reserved. // You must accept the terms of that agreement to use this software. */ package org.olap4j.type; +import org.olap4j.metadata.Dimension; +import org.olap4j.metadata.Hierarchy; +import org.olap4j.metadata.Level; + /** - * Type ... + * Type of an MDX expression. * * @author jhyde - * @version $Id: $ - * @since Oct 12, 2006 + * @since Feb 17, 2005 + * @version $Id: //open/mondrian/src/main/org.olap4j.type/Type.java#3 $ */ -public class Type { +public interface Type { + /** + * Returns whether this type contains a given dimension.

        + * + * For example: + *

          + *
        • DimensionType([Gender]) uses only the + * [Gender] dimension.
        • + *
        • TupleType(MemberType([Gender]), MemberType([Store])) + * uses [Gender] and [Store] + * dimensions.
        • + *

        + * + * The maybe parameter comes into play when the + * dimensional information is incomplete. For example, when applied to + * TupleType(MemberType(null), MemberType([Store])), + * usesDimension([Gender], false) returns true because it + * is possible that the expression returns a member of the + * [Gender] dimension. + * + * @param dimension Dimension + * @param maybe If true, returns true only if this type definitely + * uses the dimension + */ + boolean usesDimension(Dimension dimension, boolean maybe); + + /** + * Returns the dimension of this type, or null if not known. + */ + Dimension getDimension(); + + /** + * Returns the hierarchy of this type. If not applicable, throws. + */ + Hierarchy getHierarchy(); + + /** + * Returns the level of this type, or null if not known. + */ + Level getLevel(); + } // End Type.java diff --git a/src/org/olap4j/type/TypeUtil.java b/src/org/olap4j/type/TypeUtil.java new file mode 100755 index 0000000..bc52cb4 --- /dev/null +++ b/src/org/olap4j/type/TypeUtil.java @@ -0,0 +1,161 @@ +/* +// $Id: //open/mondrian/src/main/org.olap4j.type/TypeUtil.java#5 $ +// 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) 2005-2005 Julian Hyde +// All Rights Reserved. +// You must accept the terms of that agreement to use this software. +*/ +package org.olap4j.type; + +import org.olap4j.metadata.Hierarchy; + +/** + * Utility methods relating to types. + * + * @author jhyde + * @since Feb 17, 2005 + * @version $Id: //open/mondrian/src/main/org.olap4j.type/TypeUtil.java#5 $ + */ +public class TypeUtil { + + /** + * Given a set type, returns the element type. Or its element type, if it + * is a set type. And so on. + */ + public static Type stripSetType(Type type) { + while (type instanceof SetType) { + type = ((SetType) type).getElementType(); + } + return type; + } + + /** + * Converts a type to a member or tuple type. + * If it cannot, returns null. + */ + public static Type toMemberOrTupleType(Type type) { + type = stripSetType(type); + if (type instanceof TupleType) { + return (TupleType) type; + } else { + return toMemberType(type); + } + } + + /** + * Converts a type to a member type. + * If it is a set, strips the set. + * If it is a member type, returns the type unchanged. + * If it is a dimension, hierarchy or level type, converts it to + * a member type. + * If it is a tuple, number, string, or boolean, returns null. + */ + public static MemberType toMemberType(Type type) { + type = stripSetType(type); + if (type instanceof MemberType) { + return (MemberType) type; + } else if (type instanceof DimensionType || + type instanceof HierarchyType || + type instanceof LevelType) { + return MemberType.forType(type); + } else { + return null; + } + } + + /** + * Returns whether this type is union-compatible with another. + * In general, to be union-compatible, types must have the same + * dimensionality. + */ + public static boolean isUnionCompatible(Type type1, Type type2) { + if (type1 instanceof TupleType) { + TupleType tupleType1 = (TupleType) type1; + if (type2 instanceof TupleType) { + TupleType tupleType2 = (TupleType) type2; + if (tupleType1.elementTypes.length == + tupleType2.elementTypes.length) { + for (int i = 0; i < tupleType1.elementTypes.length; i++) { + if (!isUnionCompatible( + tupleType1.elementTypes[i], + tupleType2.elementTypes[i])) { + return false; + } + } + return true; + } + } + return false; + } else { + final MemberType memberType1 = toMemberType(type1); + if (memberType1 == null) { + return false; + } + final MemberType memberType2 = toMemberType(type2); + if (memberType2 == null) { + return false; + } + final Hierarchy hierarchy1 = memberType1.getHierarchy(); + final Hierarchy hierarchy2 = memberType2.getHierarchy(); + return equal(hierarchy1, hierarchy2); + } + } + + private static boolean equal( + final Hierarchy hierarchy1, final Hierarchy hierarchy2) { + if (hierarchy1 == null || + hierarchy2 == null || + hierarchy2.getUniqueName().equals( + hierarchy1.getUniqueName())) { + // They are compatible. + return true; + } else { + return false; + } + } + + /** + * Returns whether a value of a given type can be evaluated to a scalar + * value. + * + *

        The rules are as follows:

          + *
        • Clearly boolean, numeric and string expressions can be evaluated. + *
        • Member and tuple expressions can be interpreted as a scalar value. + * The expression is evaluated to establish the context where a measure + * can be evaluated. + *
        • Hierarchy and dimension expressions are implicitly + * converted into the current member, and evaluated as above. + *
        • Level expressions cannot be evaluated + *
        • Cube and Set (even sets with a single member) cannot be evaluated. + *
        + * + * @param type Type + * @return Whether an expression of this type can be evaluated to yield a + * scalar value. + */ + public static boolean canEvaluate(Type type) { + return ! (type instanceof SetType || + type instanceof CubeType || + type instanceof LevelType); + } + + /** + * Returns whether a type is a set type. + * + * @param type Type + * @return Whether a value of this type can be evaluated to yield a set. + */ + public static boolean isSet(Type type) { + return type instanceof SetType; + } + + public static boolean couldBeMember(Type type) { + return type instanceof MemberType || + type instanceof HierarchyType || + type instanceof DimensionType; + } +} + +// End TypeUtil.java diff --git a/src/org/olap4j/type/package.html b/src/org/olap4j/type/package.html new file mode 100755 index 0000000..a008aa5 --- /dev/null +++ b/src/org/olap4j/type/package.html @@ -0,0 +1,6 @@ + + +Type system for MDX expessions. + + +