From 96d3da3816e8c32d6238612d09f84f28f8e72b81 Mon Sep 17 00:00:00 2001
From: Julian Hyde
Date: Tue, 13 Nov 2007 09:37:16 +0000
Subject: [PATCH] Lots of tests for metadata classes, and implement
corresponding functionality in mondrian driver. Review org.olap4j.type
package, and remove/hide several methods. Add API for creating validator and
validating an MDX parse tree. Test that non-unique axis names cause a
validation error.
git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@38 c6a108a4-781c-0410-a6c6-c2d559e19af0
---
build.xml | 2 +-
doc/olap4j_fs.html | 66 ++-
doc/tasks.txt | 12 +-
src/mondrian/olap4j/AbstractNamedList.java | 14 +-
src/mondrian/olap4j/ArrayNamedListImpl.java | 54 +++
.../olap4j/MondrianOlap4jCellSetAxis.java | 7 +-
.../olap4j/MondrianOlap4jCellSetMetaData.java | 38 +-
.../olap4j/MondrianOlap4jConnection.java | 264 +++++++++--
src/mondrian/olap4j/MondrianOlap4jCube.java | 139 +++++-
.../olap4j/MondrianOlap4jDimension.java | 40 +-
.../olap4j/MondrianOlap4jHierarchy.java | 62 ++-
src/mondrian/olap4j/MondrianOlap4jLevel.java | 48 +-
src/mondrian/olap4j/MondrianOlap4jMember.java | 38 +-
.../olap4j/MondrianOlap4jNamedSet.java | 67 +++
.../olap4j/MondrianOlap4jProperty.java | 61 +++
src/mondrian/olap4j/NamedListImpl.java | 28 +-
src/org/olap4j/CellSetAxisMetaData.java | 5 +-
src/org/olap4j/CellSetMetaData.java | 7 +-
.../xmla/XmlaOlap4jCellSetMetaData.java | 16 +-
.../driver/xmla/XmlaOlap4jConnection.java | 7 +-
src/org/olap4j/mdx/AxisNode.java | 3 +-
src/org/olap4j/mdx/CallNode.java | 24 +-
src/org/olap4j/mdx/CubeNode.java | 72 +++
...ator.java => DefaultMdxValidatorImpl.java} | 29 +-
src/org/olap4j/mdx/HierarchyNode.java | 4 +-
src/org/olap4j/mdx/LevelNode.java | 5 +-
src/org/olap4j/mdx/MemberNode.java | 6 +-
src/org/olap4j/mdx/ParseTreeNode.java | 2 +-
src/org/olap4j/mdx/ParseTreeVisitor.java | 7 +
src/org/olap4j/mdx/SelectNode.java | 43 +-
src/org/olap4j/mdx/parser/MdxParser.java | 1 -
.../olap4j/mdx/parser/MdxParserFactory.java | 8 +
src/org/olap4j/mdx/parser/MdxValidator.java | 57 +++
src/org/olap4j/metadata/Cube.java | 68 ++-
src/org/olap4j/metadata/Dimension.java | 15 -
src/org/olap4j/metadata/Hierarchy.java | 15 +
src/org/olap4j/metadata/Level.java | 9 +-
src/org/olap4j/metadata/Member.java | 23 +-
src/org/olap4j/metadata/NamedList.java | 12 +
src/org/olap4j/metadata/NamedSet.java | 9 +
src/org/olap4j/metadata/Property.java | 10 +-
src/org/olap4j/sample/SimpleQuerySample.java | 5 +-
src/org/olap4j/type/BooleanType.java | 6 +
src/org/olap4j/type/CubeType.java | 26 ++
src/org/olap4j/type/DimensionType.java | 14 +-
src/org/olap4j/type/HierarchyType.java | 21 +-
src/org/olap4j/type/LevelType.java | 25 +-
src/org/olap4j/type/MemberType.java | 64 ++-
src/org/olap4j/type/SetType.java | 5 +-
src/org/olap4j/type/SymbolType.java | 22 +
src/org/olap4j/type/TupleType.java | 44 +-
src/org/olap4j/type/Type.java | 12 +-
src/org/olap4j/type/TypeUtil.java | 44 +-
testsrc/org/olap4j/ConnectionTest.java | 434 +++++++++++++++++-
54 files changed, 1743 insertions(+), 376 deletions(-)
create mode 100644 src/mondrian/olap4j/ArrayNamedListImpl.java
create mode 100644 src/mondrian/olap4j/MondrianOlap4jNamedSet.java
create mode 100644 src/mondrian/olap4j/MondrianOlap4jProperty.java
create mode 100644 src/org/olap4j/mdx/CubeNode.java
rename src/org/olap4j/mdx/{MdxValidator.java => DefaultMdxValidatorImpl.java} (91%)
create mode 100644 src/org/olap4j/mdx/parser/MdxValidator.java
diff --git a/build.xml b/build.xml
index cc3f00f..7243bab 100644
--- a/build.xml
+++ b/build.xml
@@ -14,7 +14,7 @@
-
+
diff --git a/doc/olap4j_fs.html b/doc/olap4j_fs.html
index 7d58f1d..4563e96 100644
--- a/doc/olap4j_fs.html
+++ b/doc/olap4j_fs.html
@@ -78,10 +78,10 @@
olap4j Functional Specification
Authors: Julian Hyde, Barry Klawans
-Version: 0.89.2-dev (draft)
+Version: 0.89.3-dev (draft)
Revision: $Id$
(log)
-Last modified: September 21st, 2007.
+Last modified: November 12th, 2007.
// Create a query model.
SelectNode query = new SelectNode();
- query.setCubeName(
+ query.setFrom(
new IdentifierNode(
new
IdentifierNode.Segment("Sales")));
@@ -982,12 +982,36 @@
Package name: org.olap4j.mdx.parser
-
Provides an MDX parser.
+
Provides an MDX parser and validator.
+
Parser and validator are both allocated via a parser factory, which is
+obtained from a connection:
+
+
+ OlapConnection connection;
+ MdxParserFactory parserFactory =
+ connection.getParserFactory();
+ MdxParser parser =
+ parserFactory.createMdxParser(connection);
+ SelectNode select =
+ parser.parse("SELECT FROM [Sales]");
+ MdxValidator validator =
+ parserFactory.createMdxValidator(connection);
+ select = validator.validate(select);
+
+
Parser and validator are not thread-safe (they cannot be used by more than
+one thread simultaneously) but they can be re-used for multiple statements.
+
One of the chief purposes of validation is to assign a type to every
+expression within the parse tree. Before validation, any node's
+
+ParseTreeNode.getType() method may throw an exception, but after validation
+the getType()
method will return a type. Nodes which are not
+expressions do not have types, and will always return null
.
Classes:
@@ -1208,13 +1232,15 @@
formula.
- List<Dimension> getDimensions()
+ NamedList<Dimension> getDimensions()
List<Measure> getMeasures()
NamedList<NamedSet> getSets()
Schema getSchema()
String getName()
List<Locale> getSupportedLocales()
(see
Internationalization)
+ Member lookupMember(String... nameParts)
+ Member lookupMembers(Set<TreeOp> treeOps, String... nameParts)
@@ -1230,8 +1256,7 @@
String getName()
- List<Hierarchy> getHierarchies()
- List<Member> getRootMembers()
+ NamedList<Hierarchy> getHierarchies()
Dimension.Type getDimensionType()
@@ -1244,9 +1269,10 @@
Dimension getDimension()
String getName()
- List<Level> getLevels()
+ NamedList<Level> getLevels()
boolean hasAll()
Member getDefaultMember()
+ NamedList<Member> getRootMembers()
A Level
@@ -1257,7 +1283,7 @@
int getDepth()
Hierarchy getHierarchy()
Level.Type getLevelType()
-
List<Property> getProperties()
+
NamedList<Property> getProperties()
List<Member> getMembers()
@@ -1266,10 +1292,11 @@
MetadataElement) is a data value in an OLAP dimension.
String getName()
- List<Member> getChildMembers()
+ NamedList<Member> getChildMembers()
Member getParentMember()
Level getLevel()
Hierarchy getHierarchy()
+ boolean isAll()
boolean isChildOrEqualTo(Member member)
boolean isCalculated()
boolean isCalculatedInQuery()
@@ -1278,11 +1305,12 @@
Object getPropertyValue(Property property)
String getPropertyFormattedValue(Property property)
void setProperty(Property property, Object value)
- List<Property> getProperties()
+ NamedList<Property> getProperties()
int getOrdinal()
boolean isHidden()
Member getDataMember()
+
A Measure (extends
@@ -1312,7 +1340,6 @@
Datatype getType()
Scope getScope()
- boolean isInternal()
enum Scope { MEMBER, CELL }
enum Datatype { STRING, OTHER, NUMERIC, BOOLEAN }
enum StandardMemberProperty implements Property { CATALOG_NAME, SCHEMA_NAME, CUBE_NAME, ...
@@ -3451,8 +3478,9 @@
D.1. To be specified
+[Method for richer query of members, analogous to OlapDatabaseMetaData.getMembers(). Maybe extend Cube.lookupMember. Something with a treeop.]
[Discuss thread safety of connections, statements, result sets.]
-[API for cancelling statements.]
+[API for canceling statements.]
[2006/10/20#1. Specification should include compliance levels, like the SQL
specification does. In particular, we will allow providers to comply with a
limited subset of MDX.]
@@ -3476,10 +3504,12 @@ D.1. To be specified
efficiency as a design goal.]
D.2. Design notes
-JDK. We are targeting JDK 1.5, and running retroweaver for
+
JDK.
+We are targeting JDK 1.5, and running retroweaver for
backward compatibility for JDK 1.4. See forum thread:
-olap4j, JDK 1.5 and generics.
+olap4j, JDK 1.5 and generics.
+We also support JDK 1.6, and with it JDBC 4.0.
Result sets, random access, and memory usage
Should result sets return their axes as cursors or collections? Cursors
require less memory, but collections provide an easier programming model.
@@ -3520,4 +3550,4 @@
-