Skip to content

Commit

Permalink
Add query model (from James Dixon), parser and parser object model.
Browse files Browse the repository at this point in the history
git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@18 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
julianhyde committed Jun 10, 2007
1 parent 5d7b66c commit 5783fb2
Show file tree
Hide file tree
Showing 62 changed files with 6,768 additions and 199 deletions.
40 changes: 37 additions & 3 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
<pathelement path="${env.CLASSPATH}"/>
<pathelement location="${ant.home}/lib/ant.jar"/>
<pathelement location="${ant.home}/lib/optional.jar"/>
<pathelement location="${ant.home}/lib/junit.jar"/>
<pathelement location="${lib.dir}/log4j-1.2.9.jar"/>
<pathelement location="${lib.dir}/javacup.jar"/>
<!-- We depend on mondrian right now. Ugh. -->
<pathelement location="${lib.dir}/mondrian-2.1.1.jar"/>
<!-- We depend on spring, but only for examples. -->
Expand All @@ -53,6 +56,7 @@
</path>

<path id="project.test.classpath">
<path refid="project.classpath"/>
</path>

<!-- verify that required dependencies are defined -->
Expand Down Expand Up @@ -91,7 +95,7 @@
<mkdir dir="${testsrc.dir}"/>
</target>

<target name="compile" depends="prepare,compile.java"/>
<target name="compile" depends="prepare,parser,compile.java"/>

<target name="compile.java">
<javac
Expand Down Expand Up @@ -119,6 +123,17 @@
<echo message="olap4j ${version}" file="VERSION.txt"/>
</target>

<target name="parser">
<taskdef name="javacup" classname="java_cup.JavaCUPTask">
<classpath refid="project.classpath"/>
</taskdef>
<javacup
srcdir="${src.dir}"
input="${src.dir}/org/olap4j/mdx/parser/impl/DefaultMdxParser.cup"
expect="61"
interface="true"/>
</target>

<target name="srczip" depends="version">
<mkdir dir="${dist.dir}" />
<delete file="${dist.src.file}"/>
Expand Down Expand Up @@ -183,7 +198,7 @@ ${doc.dir}/api/src-html/**/*"/>
includes="${dist.name}-src.zip"/>
</zip>
</target>

<target name="doczip"
depends="version,javadoc,javadoc-pdf"
description="Builds a zipfile of the documentation, which can then be
Expand Down Expand Up @@ -262,6 +277,11 @@ META-INF/**"/>

<target name="javadoc">
<mkdir dir="${javadoc.dir}" />
<!-- remove stray package.html files under classes to avoid 'multiple
sources of package comments' errors -->
<delete includeEmptyDirs="false" quiet="true">
<fileset dir="${classes.dir}" includes="**/package.html"/>
</delete>
<delete quiet="true" file="${javadoc.dir}/index.html"/>
<javadoc sourcepath="${src.dir}:${testsrc.dir}"
classpathref="project.test.classpath"
Expand All @@ -282,10 +302,16 @@ META-INF/**"/>
<tag name="testcase" description="Test-case:"
scope="constructors,methods,types"/>
<link href="http://java.sun.com/j2se/1.5.0/docs/api/"/>
<link href="http://www.junit.org/junit/javadoc/3.8/"/>
</javadoc>
</target>

<target name="javadoc-pdf">
<!-- remove stray package.html files under classes to avoid 'multiple
sources of package comments' errors -->
<delete includeEmptyDirs="false" quiet="true">
<fileset dir="${classes.dir}" includes="**/package.html"/>
</delete>
<javadoc sourcepath="${src.dir}:${testsrc.dir}"
classpathref="project.test.classpath"
packagenames="org.olap4j.*"
Expand All @@ -298,6 +324,14 @@ META-INF/**"/>
docletpath="lib/pdfdoclet-1.0.2-all.jar"
additionalparam="-pdf doc/olap4j_api.pdf -config doc/pdfdoclet.properties"
>
<tag name="pre" description="Pre-condition:"
scope="constructors,methods"/>
<tag name="post" description="Post-condition:"
scope="constructors,methods"/>
<tag name="testcase" description="Test-case:"
scope="constructors,methods,types"/>
<link href="http://java.sun.com/j2se/1.5.0/docs/api/"/>
<link href="http://www.junit.org/junit/javadoc/3.8/"/>
</javadoc>
</target>

Expand All @@ -316,7 +350,7 @@ META-INF/**"/>
<target name="retroweave">
<retroweaver srcdir="${classes.dir}" />
</target>

</project>

<!-- End build.xml -->
2 changes: 1 addition & 1 deletion doc/olap4j_fs.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ <h1>olap4j Functional Specification</h1>
Version: 0.6-dev (draft)<br>
Revision: $Id: $
(<a href="http://svn.sourceforge.net/viewvc/olap4j/trunk/doc/olap4j_fs.html?view=log">log</a>)<br>
Last modified: October 17<sup>th</sup>, 2006.</p>
Last modified: May 26<sup>th</sup>, 2007.</p>
<hr noshade="noshade">

<h2><a name="Contents">Contents</a></h2>
Expand Down
Binary file added lib/javacup.jar
Binary file not shown.
Binary file added lib/log4j-1.2.9.jar
Binary file not shown.
11 changes: 10 additions & 1 deletion src/mondrian/olap4j/MondrianOlap4jConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.olap4j.metadata.Database;
import org.olap4j.metadata.Catalog;
import org.olap4j.mdx.parser.MdxParserFactory;
import org.olap4j.mdx.parser.MdxParser;
import org.olap4j.mdx.parser.impl.DefaultMdxParserImpl;

/**
* <code>MondrianOlap4jConnection</code> ...
Expand Down Expand Up @@ -59,9 +61,12 @@ class MondrianOlap4jConnection implements OlapConnection {
*
* @param url Connect-string URL
* @param info Additional properties
* @throws SQLException if there is an error
*/
MondrianOlap4jConnection(String url, Properties info) throws SQLException {
if (!url.startsWith(CONNECT_STRING_PREFIX)) {
// This is not a URL we can handle.
// DriverManager should not have invoked us.
throw new AssertionError(
"does not start with '" + CONNECT_STRING_PREFIX + "'");
}
Expand Down Expand Up @@ -326,7 +331,11 @@ public PreparedOlapStatement prepareOlapStatement(
}

public MdxParserFactory getParserFactory() {
throw new UnsupportedOperationException();
return new MdxParserFactory() {
public MdxParser createMdxParser(OlapConnection connection) {
return new DefaultMdxParserImpl(connection);
}
};
}

public Schema getSchema() throws OlapException {
Expand Down
6 changes: 5 additions & 1 deletion src/mondrian/olap4j/MondrianOlap4jDimension.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ class MondrianOlap4jDimension implements Dimension, Named {
this.dimension = dimension;
}

public NamedList<Hierarchy> getHierarchies() throws OlapException {
public NamedList<Hierarchy> getHierarchies() {
throw new UnsupportedOperationException();
}

public Hierarchy getDefaultHierarchy() {
return getHierarchies().get(0);
}

public NamedList<Member> getRootMembers() throws OlapException {
throw new UnsupportedOperationException();
}
Expand Down
12 changes: 8 additions & 4 deletions src/mondrian/olap4j/MondrianOlap4jHierarchy.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
*/
package mondrian.olap4j;

import org.olap4j.metadata.Hierarchy;
import org.olap4j.metadata.Dimension;
import org.olap4j.metadata.Level;
import org.olap4j.metadata.NamedList;
import org.olap4j.metadata.*;

import java.util.Locale;

Expand Down Expand Up @@ -56,6 +53,13 @@ public boolean hasAll() {
throw new UnsupportedOperationException();
}

public Member getDefaultMember() {
if (false) {
return null;
}
throw new UnsupportedOperationException();
}

public String getName() {
if (false) {
return null;
Expand Down
15 changes: 15 additions & 0 deletions src/mondrian/olap4j/MondrianOlap4jLevel.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.olap4j.metadata.*;

import java.util.Locale;
import java.util.List;

/**
* <code>MondrianOlap4jLevel</code> ...
Expand Down Expand Up @@ -58,6 +59,20 @@ public NamedList<Property> getProperties() {
throw new UnsupportedOperationException();
}

public Member findMember(String memberName) {
if (false) {
return null;
}
throw new UnsupportedOperationException();
}

public List<Member> getMembers() {
if (false) {
return null;
}
throw new UnsupportedOperationException();
}

public String getName() {
if (false) {
return null;
Expand Down
6 changes: 3 additions & 3 deletions src/mondrian/olap4j/MondrianOlap4jMember.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.olap4j.metadata.Level;
import org.olap4j.metadata.Member;
import org.olap4j.OlapException;
import mondrian.olap.*;
import org.olap4j.mdx.ParseTreeNode;

import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -89,7 +89,7 @@ public int getSolveOrder() {
throw new UnsupportedOperationException();
}

public Exp getExpression() {
public ParseTreeNode getExpression() {
throw new UnsupportedOperationException();
}

Expand All @@ -113,7 +113,7 @@ public void setProperty(String name, Object value) throws OlapException {
throw new UnsupportedOperationException();
}

public List<mondrian.olap.Property> getProperties() {
public List<Property> getProperties() {
throw new UnsupportedOperationException();
}

Expand Down
3 changes: 2 additions & 1 deletion src/mondrian/olap4j/MondrianOlap4jStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.olap4j.OlapStatement;
import org.olap4j.CellSet;
import org.olap4j.OlapException;
import org.olap4j.mdx.SelectNode;

import java.sql.*;

Expand Down Expand Up @@ -254,7 +255,7 @@ public CellSet executeOlapQuery(String mdx) throws OlapException {
return openCellSet;
}

public CellSet executeOlapQuery(Query query) {
public CellSet executeOlapQuery(SelectNode selectNode) {
throw new UnsupportedOperationException();
}
}
Expand Down
35 changes: 30 additions & 5 deletions src/org/olap4j/Axis.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
*/
package org.olap4j;

import java.util.Locale;

/**
* Enumeration of axis types.
*
Expand All @@ -19,6 +21,7 @@
* @since Oct 23, 2006
*/
public enum Axis {
UNUSED,
SLICER,
COLUMNS,
ROWS,
Expand All @@ -31,18 +34,40 @@ public enum Axis {
* the {@link org.olap4j.CellSet#getAxes()}, or retrieving its
* coordinate from {@link Cell#getCoordinateList()}.
*
* <p>The axis ordinal is one less than the {@link #ordinal} value which
* every <code>enum</code> value possesses. Hence, {@link #SLICER} is -1
* (because it is not treated the same as the other axes), {@link #COLUMNS}
* is 0, {@link #ROWS} is 1, and so forth.
* <p>The axis ordinal is two less than the {@link #ordinal} value which
* every <code>enum</code> value possesses. Hence, {@link #UNUSED} is -2
* and {@link #SLICER} is -1 (because they are not treated the same as the
* other axes), {@link #COLUMNS} is 0, {@link #ROWS} is 1, and so forth.
*
* @return Axis ordinal
*/
public int axisOrdinal() {
return axisOrdinal;
}

private final int axisOrdinal = ordinal() - 1;
/**
* Returns localized name for this Axis.
*/
public String getCaption(Locale locale) {
// todo: localize
return name();
}

/**
* Returns the axis with a given {@link #axisOrdinal()}.
*/
public static Axis forOrdinal(int axisOrdinal) {
Axis axis = values()[axisOrdinal + 2];
assert axis.axisOrdinal() == axisOrdinal;
return axis;
}

private final int axisOrdinal = ordinal() - 2;

/**
* The largest legal value for {@link #forOrdinal(int)}.
*/
public static final int MAX_ORDINAL = SECTIONS.axisOrdinal();
}

// End Axis.java
16 changes: 11 additions & 5 deletions src/org/olap4j/OlapStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
*/
package org.olap4j;

import mondrian.olap.Query;

import java.sql.Statement;

import org.olap4j.mdx.SelectNode;

/**
* Object used for statically executing an MDX statement and returning an
* {@link CellSet}.
Expand All @@ -27,17 +27,23 @@ public interface OlapStatement extends Statement {

/**
* Executes an OLAP statement.
*
* @param mdx MDX <code>SELECT</code> statement
* @return Cell set
* @throws OlapException if error occurs
*/
CellSet executeOlapQuery(String mdx) throws OlapException;

/**
* Executes an OLAP statement expressed as a parse tree.
*
* <p>Validates the parse tree before executing it.
* @param query Parse tree of MDX SELECT statement
* @return Result
*
* @param selectNode Parse tree of MDX <code>SELECT</code> statement
* @return Cell set
* @throws OlapException if error occurs
*/
CellSet executeOlapQuery(Query query);
CellSet executeOlapQuery(SelectNode selectNode) throws OlapException;
}

// End OlapStatement.java
Loading

0 comments on commit 5783fb2

Please sign in to comment.