diff --git a/src/org/olap4j/query/Query.java b/src/org/olap4j/query/Query.java index ab9ab5f..5e35560 100644 --- a/src/org/olap4j/query/Query.java +++ b/src/org/olap4j/query/Query.java @@ -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. */ @@ -273,12 +273,11 @@ private AxisNode toOlap4j(QueryAxis axis) { } } return new AxisNode( - null, - false, - axis.getLocation(), - new ArrayList(), - callNode); - + null, + axis.isNonEmpty(), + axis.getLocation(), + new ArrayList(), + callNode); } private List toOlap4j(QueryDimension dimension) { diff --git a/src/org/olap4j/query/QueryAxis.java b/src/org/olap4j/query/QueryAxis.java index 5f90028..f1ffde5 100644 --- a/src/org/olap4j/query/QueryAxis.java +++ b/src/org/olap4j/query/QueryAxis.java @@ -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. */ @@ -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; @@ -63,10 +70,39 @@ public List 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. diff --git a/testsrc/org/olap4j/OlapTest.java b/testsrc/org/olap4j/OlapTest.java index 2db479d..99fec24 100644 --- a/testsrc/org/olap4j/OlapTest.java +++ b/testsrc/org/olap4j/OlapTest.java @@ -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); @@ -685,6 +688,9 @@ public static void axisToXml(QueryAxis axis, Document doc, Element parent) { break; } + addAttribute( + "nonEmpty", Boolean.toString(axis.isNonEmpty()), parent); + List dimensions = axis.getDimensions(); for (QueryDimension dimension : dimensions) { dimensionSelectionsToXml(dimension, doc, dimensionsNode);