Skip to content

Commit

Permalink
Add Query.setNonEmpty/isNonEmpty (bug 1994488).
Browse files Browse the repository at this point in the history
git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@123 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
julianhyde committed Nov 1, 2008
1 parent 4692256 commit dd190c9
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 10 deletions.
13 changes: 6 additions & 7 deletions src/org/olap4j/query/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2007-2007 Julian Hyde
// Copyright (C) 2007-2008 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand Down Expand Up @@ -273,12 +273,11 @@ private AxisNode toOlap4j(QueryAxis axis) {
}
}
return new AxisNode(
null,
false,
axis.getLocation(),
new ArrayList<IdentifierNode>(),
callNode);

null,
axis.isNonEmpty(),
axis.getLocation(),
new ArrayList<IdentifierNode>(),
callNode);
}

private List<ParseTreeNode> toOlap4j(QueryDimension dimension) {
Expand Down
38 changes: 37 additions & 1 deletion src/org/olap4j/query/QueryAxis.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2007-2007 Julian Hyde
// Copyright (C) 2007-2008 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand Down Expand Up @@ -31,7 +31,14 @@ public class QueryAxis {

private final Query query;
protected Axis location = null;
private boolean nonEmpty;

/**
* Creates a QueryAxis.
*
* @param query Query that the axis belongs to
* @param location Location of axis (e.g. ROWS, COLUMNS)
*/
public QueryAxis(Query query, Axis location) {
super();
this.query = query;
Expand Down Expand Up @@ -63,10 +70,39 @@ public List<QueryDimension> getDimensions() {
return dimensions;
}

/**
* Returns the name of this QueryAxis.
*
* @return the name of this axis, for example "ROWS", "COLUMNS".
*/
public String getName() {
return location.getCaption(query.getLocale());
}

/**
* Returns whether this QueryAxis filters out empty rows.
* If true, axis filters out empty rows, and the MDX to evaluate the axis
* will be generated with the "NON EMPTY" expression.
*
* @return Whether this axis should filter out empty rows
*
* @see #setNonEmpty(boolean)
*/
public boolean isNonEmpty() {
return nonEmpty;
}

/**
* Sets whether this QueryAxis filters out empty rows.
*
* @param nonEmpty Whether this axis should filter out empty rows
*
* @see #isNonEmpty()
*/
public void setNonEmpty(boolean nonEmpty) {
this.nonEmpty = nonEmpty;
}

/**
* List of QueryDimension objects. The list is active: when a dimension
* is added to the list, it is removed from its previous axis.
Expand Down
10 changes: 8 additions & 2 deletions testsrc/org/olap4j/OlapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,11 @@ public static void resultsToXml(CellSet result, Document doc, Element parent) {
}
}

public static void axisToXml(QueryAxis axis, Document doc, Element parent) {

public static void axisToXml(
QueryAxis axis,
Document doc,
Element parent)
{
try {
Element root = doc.createElement("axis");
parent.appendChild(root);
Expand All @@ -685,6 +688,9 @@ public static void axisToXml(QueryAxis axis, Document doc, Element parent) {
break;
}

addAttribute(
"nonEmpty", Boolean.toString(axis.isNonEmpty()), parent);

List<QueryDimension> dimensions = axis.getDimensions();
for (QueryDimension dimension : dimensions) {
dimensionSelectionsToXml(dimension, doc, dimensionsNode);
Expand Down

0 comments on commit dd190c9

Please sign in to comment.