Skip to content

Commit

Permalink
Correct typos in spec; eliminate QueryAxis.xxxDimension and QueryDime…
Browse files Browse the repository at this point in the history
…nsion.xxxSelection methods; property methods now take a Property, not the property name

git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@31 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
julianhyde committed Sep 22, 2007
1 parent b07c768 commit b200add
Show file tree
Hide file tree
Showing 16 changed files with 573 additions and 317 deletions.
477 changes: 303 additions & 174 deletions doc/olap4j_fs.html

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions doc/tasks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ Javadoc
Code
----

* Write javadoc for, implement and test Level.findMember
* in QueryAxis, make dimension list mutable; remove methods QueryAxis.clearDimensions, appendDimensions, appendDimension, insertDimension, removeDimension; and add tests for the functionality of these methods; remove methods from spec.
* in QueryDimension, make selection list mutable; remove methods addSelection, addMemberSelection, addSelections, clearSelections; add tests; remove from spec.
* fix 4 TODOs in ParserTest
* document/implement Cube.lookupMember

Testing
-------
Expand Down
5 changes: 5 additions & 0 deletions src/mondrian/olap4j/MondrianOlap4jCube.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.olap4j.metadata.Dimension;
import org.olap4j.metadata.NamedSet;
import org.olap4j.metadata.Schema;
import org.olap4j.metadata.Member;

import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -85,6 +86,10 @@ public String getDescription(Locale locale) {
// todo: i81n
return cube.getDescription();
}

public Member lookupMember(String... nameParts) {
throw new UnsupportedOperationException();
}
}

// End MondrianOlap4jCube.java
4 changes: 0 additions & 4 deletions src/mondrian/olap4j/MondrianOlap4jLevel.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ public NamedList<Property> getProperties() {
throw new UnsupportedOperationException();
}

public Member findMember(String memberName) {
throw new UnsupportedOperationException();
}

public List<Member> getMembers() {
throw new UnsupportedOperationException();
}
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 @@ -112,15 +112,15 @@ public boolean isCalculatedInQuery() {
throw new UnsupportedOperationException();
}

public Object getPropertyValue(String propertyName) {
public Object getPropertyValue(Property property) {
throw new UnsupportedOperationException();
}

public String getPropertyFormattedValue(String propertyName) {
public String getPropertyFormattedValue(Property property) {
throw new UnsupportedOperationException();
}

public void setProperty(String name, Object value) throws OlapException {
public void setProperty(Property property, Object value) throws OlapException {
throw new UnsupportedOperationException();
}

Expand Down
5 changes: 5 additions & 0 deletions src/org/olap4j/Cell.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public interface Cell {
* {@link org.olap4j.CellSet#getMetaData()} followed by
* {@link CellSetMetaData#getCellProperties()}.</p>
*
* <p>Every cell has certain system properties such as "VALUE" and
* "FORMAT_STRING" (the full list is described in the
* {@link org.olap4j.metadata.Property.StandardCellProperty}
* enumeration), as well as extra properties defined by the query.</p>
*
* @param property Property whose value to retrieve
*
* @return Value of the given property for this Cell; if the property is
Expand Down
68 changes: 68 additions & 0 deletions src/org/olap4j/Position.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,74 @@
/**
* Position on one of the {@link CellSetAxis} objects in a {@link CellSet}.
*
* <p>An axis has a particular dimensionality, that is, a set of one or more
* dimensions which will appear on that axis, and every position on that axis
* will have a member of each of those dimensions. For example, in the MDX
* query</p>
*
* <blockquote>
* <code>SELECT {[Measures].[Unit Sales], [Measures].[Store Sales]} ON
* COLUMNS,<br>
* &nbsp;&nbsp;&nbsp; CrossJoin(<br>
* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {[Gender].Members},<br>
* &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {[Product].[Food],
* [Product].[Drink]}) ON ROWS<br>
* FROM [Sales]</code>
* </blockquote>
*
* <p>the <code>COLUMNS</code> axis has dimensionality
* {<code>[Measures]</code>} and the <code>ROWS</code> axis has dimensionality
* {<code>[Gender]</code>, <code>[Product]</code>}. In the result,</p>
*
* <table border="1" id="table1" cellpadding="3">
* <tr>
* <td bgcolor="#E0E0E0"><b><i>Gender</i></b></td>
* <td bgcolor="#E0E0E0"><b><i>Product</i></b></td>
* <td bgcolor="#E0E0E0"><b>Unit Sales</b></td>
* <td bgcolor="#E0E0E0"><b>Store Sales</b></td>
* </tr>
* <tr>
* <td bgcolor="#E0E0E0"><b>All Gender</b></td>
* <td bgcolor="#E0E0E0"><b>Food</b></td>
* <td align="right">191,940</td>
* <td align="right">409,035.59</td>
* </tr>
* <tr>
* <td bgcolor="#E0E0E0"><b>All Gender</b></td>
* <td bgcolor="#E0E0E0"><b>Drink</b></td>
* <td align="right">24,597</td>
* <td align="right">48,836.21</td>
* </tr>
* <tr>
* <td bgcolor="#E0E0E0"><b>F</b></td>
* <td bgcolor="#E0E0E0"><b>Food</b></td>
* <td align="right">94,814</td>
* <td align="right">203,094.17</td>
* </tr>
* <tr>
* <td bgcolor="#E0E0E0"><b>F</b></td>
* <td bgcolor="#E0E0E0"><b>Drink</b></td>
* <td align="right">12,202</td>
* <td align="right">24,457.37</td>
* </tr>
* <tr>
* <td bgcolor="#E0E0E0"><b>M</b></td>
* <td bgcolor="#E0E0E0"><b>Food</b></td>
* <td align="right">97,126</td>
* <td align="right">205,941.42</td>
* </tr>
* <tr>
* <td bgcolor="#E0E0E0"><b>M</b></td>
* <td bgcolor="#E0E0E0"><b>Drink</b></td>
* <td align="right">12,395</td>
* <td align="right">24,378.84</td>
* </tr>
* </table>
*
* <p>each of the 5 positions on the <code>ROWS</code> axis has two members,
* consistent with its dimensionality of 2. The <code>COLUMNS</code> axis has
* two positions, each with one member.</p>
*
* @author jhyde
* @version $Id$
* @since Aug 22, 2006
Expand Down
1 change: 1 addition & 0 deletions src/org/olap4j/metadata/Cube.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public interface Cube extends MetadataElement {
*/
Collection<Locale> getSupportedLocales();

Member lookupMember(String... nameParts);
}

// End Cube.java
3 changes: 0 additions & 3 deletions src/org/olap4j/metadata/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ public interface Level extends MetadataElement {
*/
NamedList<Property> getProperties();

// todo: needs specification
Member findMember(String memberName);

/**
* Returns a list of Member objects which belong to this Level.
*
Expand Down
46 changes: 36 additions & 10 deletions src/org/olap4j/metadata/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,34 +140,60 @@ private Type(int ordinal) {
boolean isCalculatedInQuery();

/**
* Returns the value of the property named <code>propertyName</code>.
* Returns the value of a given property.
*
* @see #getPropertyFormattedValue(String)
* <p>Returns null if the property is not set.</p>
*
* <p>Every member has certain system properties such as "name" and
* "caption" (the full list is described in the
* {@link org.olap4j.metadata.Property.StandardMemberProperty}
* enumeration), as well as extra properties defined for its Level
* (see {@link Level#getProperties()}).</p>
*
* @param property Property
*
* @return formatted value of the given property
*
* @see #getPropertyFormattedValue(Property)
*/
Object getPropertyValue(String propertyName);
Object getPropertyValue(Property property);

/**
* Returns the formatted value of the property named
* <code>propertyName</code>.
* Returns the formatted value of a given property.
*
* <p>Returns null if the property is not set.</p>
*
* <p>Every member has certain system properties such as "name" and
* "caption" (the full list is described in the {@link Property}
* "caption" (the full list is described in the
* {@link org.olap4j.metadata.Property.StandardMemberProperty}
* enumeration), as well as extra properties defined for its Level
* (see {@link Level#getProperties()}).</p>
*
* @see #getPropertyValue(String)
* @param property Property
*
* @return formatted value of the given property
*
* @see #getPropertyValue(Property)
*/
String getPropertyFormattedValue(String propertyName);
String getPropertyFormattedValue(Property property);

/**
* Sets a property of this member to a given value.
*
* @param name Property name
* <p>Every member has certain system properties such as "name" and
* "caption" (the full list is described in the
* {@link org.olap4j.metadata.Property.StandardMemberProperty}
* enumeration), as well as extra properties defined for its Level
* (see {@link Level#getProperties()}).</p>
*
* @param property property
*
* @param value Property value
*
* @throws OlapException if the value not valid for this property
* (for example, a String value assigned to a Boolean property)
*/
void setProperty(String name, Object value) throws OlapException;
void setProperty(Property property, Object value) throws OlapException;

/**
* Returns the definitions of the properties this member may have.
Expand Down
16 changes: 8 additions & 8 deletions src/org/olap4j/query/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Query(String name, Cube cube) throws SQLException {
for (Dimension dimension : cube.getDimensions()) {
QueryDimension queryDimension = new QueryDimension(
this, dimension);
unused.appendDimension(queryDimension);
unused.getDimensions().add(queryDimension);
dimensionMap.put(queryDimension.getName(), queryDimension);
}
across = new QueryAxis(this, Axis.COLUMNS);
Expand Down Expand Up @@ -90,10 +90,10 @@ public void swapAxes() {
QueryAxis columnsAxis = axes.get(Axis.COLUMNS);
QueryAxis rowsAxis = axes.get(Axis.ROWS);
tmp.addAll(this.across.getDimensions());
columnsAxis.clearDimensions();
columnsAxis.appendDimensions(rowsAxis.getDimensions());
rowsAxis.clearDimensions();
rowsAxis.appendDimensions(tmp);
columnsAxis.getDimensions().clear();
columnsAxis.getDimensions().addAll(rowsAxis.getDimensions());
rowsAxis.getDimensions().clear();
rowsAxis.getDimensions().addAll(tmp);
}

public Map<Axis, QueryAxis> getAxes() {
Expand All @@ -115,11 +115,11 @@ public boolean validate() {
Member member = dimension.getDefaultHierarchy().getDefaultMember();
if (queryDimension.getAxis() == null ||
queryDimension.getAxis().getLocation() == null) {
queryDimension.clearSelections();
queryDimension.addMemberSelection(member);
queryDimension.getSelections().clear();
queryDimension.getSelections().add(queryDimension.createSelection(member));
} else {
if (queryDimension.getSelections().size() == 0) {
queryDimension.addMemberSelection(member);
queryDimension.getSelections().add(queryDimension.createSelection(member));
}
}
}
Expand Down
79 changes: 44 additions & 35 deletions src/org/olap4j/query/QueryAxis.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.AbstractList;

/**
* An axis within an OLAP {@link Query}.
Expand All @@ -26,8 +27,7 @@
*/
public class QueryAxis {

protected final List<QueryDimension> dimensions =
new ArrayList<QueryDimension>();
protected final List<QueryDimension> dimensions = new DimensionList();

private final Query query;
protected Axis location = null;
Expand All @@ -39,7 +39,10 @@ public QueryAxis(Query query, Axis location) {
}

/**
* Returns the location of this axis in the query; null if unused.
* Returns the location of this <code>QueryAxis</code> in the query;
* <code>null</code> if unused.
*
* @return location of this axis in the query
*/
public Axis getLocation() {
return location;
Expand All @@ -48,54 +51,60 @@ public Axis getLocation() {
/**
* Returns a list of the dimensions placed on this QueryAxis.
*
* <p>The list is mutable; you may call <code>getDimensions().clear</code>
* or <code>getDimensions().add
* <p>The list is mutable; you may call
* <code>getDimensions().clear()</code>,
* or <code>getDimensions().add(dimension)</code>, for instance.
* When a dimension is added to an axis, it is automatically removed from
* its previous axis.</p>
*
* @return list of dimensions
*/
public List<QueryDimension> getDimensions() {
return dimensions;
}

// todo: make list mutable, and remove this method
public void clearDimensions() {
dimensions.clear();
public String getName() {
return location.getCaption(query.getLocale());
}

// todo: make list mutable, and remove this method
public void appendDimensions(List<QueryDimension> dimensionList) {
for (QueryDimension queryDimension : dimensionList) {
queryDimension.setAxis(this);
dimensions.add(queryDimension);
/**
* List of QueryDimension objects. The list is active: when a dimension
* is added to the list, it is removed from its previous axis.
*/
private class DimensionList extends AbstractList<QueryDimension> {
private final List<QueryDimension> list =
new ArrayList<QueryDimension>();

public QueryDimension get(int index) {
return list.get(index);
}
}

// todo: make list mutable, and remove this method
public void appendDimension(QueryDimension dim) {
if (dim.getAxis() != null) {
dim.getAxis().removeDimension(dim);
public int size() {
return list.size();
}
dim.setAxis(this);
dimensions.add(dim);
}

// todo: make list mutable, and remove this method
public void insertDimension(int index, QueryDimension dim) {
if (dim.getAxis() != null) {
dim.getAxis().removeDimension(dim);
public QueryDimension set(int index, QueryDimension dimension) {
if (dimension.getAxis() != null) {
dimension.getAxis().getDimensions().remove(dimension);
}
dimension.setAxis(QueryAxis.this);
return list.set(index, dimension);
}
dim.setAxis(this);
dimensions.add(index, dim);
}

// todo: make list mutable, and remove this method
public void removeDimension(QueryDimension dim) {
dim.setAxis(null);
dimensions.remove(dim);
}
public void add(int index, QueryDimension dimension) {
if (dimension.getAxis() != null) {
// careful! potential for loop
dimension.getAxis().getDimensions().remove(dimension);
}
dimension.setAxis(QueryAxis.this);
list.add(index, dimension);
}

public String getName() {
return location.getCaption(query.getLocale());
public QueryDimension remove(int index) {
QueryDimension dimension = list.remove(index);
dimension.setAxis(null);
return dimension;
}
}
}

Expand Down
Loading

0 comments on commit b200add

Please sign in to comment.