diff --git a/build.xml b/build.xml index 0fc74f1..f30ab8a 100644 --- a/build.xml +++ b/build.xml @@ -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) 2006-2007 Julian Hyde and others. + == Copyright (C) 2006-2008 Julian Hyde and others. == All Rights Reserved. == You must accept the terms of that agreement to use this software. --> @@ -314,7 +314,8 @@ must be run under JDK 1.5." /> - + + @@ -518,7 +519,7 @@ META-INF/**"/> - + diff --git a/src/org/olap4j/driver/xmla/DeferredNamedListImpl.java b/src/org/olap4j/driver/xmla/DeferredNamedListImpl.java index 3df3988..9e3a0f5 100644 --- a/src/org/olap4j/driver/xmla/DeferredNamedListImpl.java +++ b/src/org/olap4j/driver/xmla/DeferredNamedListImpl.java @@ -100,7 +100,7 @@ public int indexOfName(String name) { protected void populateList(NamedList list) throws OlapException { context.olap4jConnection.populateList( - list, context, metadataRequest, handler); + list, context, metadataRequest, handler, new Object[0]); } private enum State { diff --git a/src/org/olap4j/driver/xmla/XmlaOlap4jCellSetAxis.java b/src/org/olap4j/driver/xmla/XmlaOlap4jCellSetAxis.java index 715559a..f5c1780 100644 --- a/src/org/olap4j/driver/xmla/XmlaOlap4jCellSetAxis.java +++ b/src/org/olap4j/driver/xmla/XmlaOlap4jCellSetAxis.java @@ -63,7 +63,7 @@ public int getPositionCount() { } public ListIterator iterator() { - return (ListIterator) immutablePositions.iterator(); + return immutablePositions.listIterator(); } } diff --git a/src/org/olap4j/driver/xmla/XmlaOlap4jDatabaseMetaData.java b/src/org/olap4j/driver/xmla/XmlaOlap4jDatabaseMetaData.java index 0ee949e..e976004 100644 --- a/src/org/olap4j/driver/xmla/XmlaOlap4jDatabaseMetaData.java +++ b/src/org/olap4j/driver/xmla/XmlaOlap4jDatabaseMetaData.java @@ -952,7 +952,8 @@ public String getMdxKeywords() throws OlapException { new XmlaOlap4jConnection.Context( olap4jConnection, null, null, null, null, null, null, null); String request = - olap4jConnection.generateRequest(context, metadataRequest); + olap4jConnection.generateRequest( + context, metadataRequest, new Object[0]); final Element root = olap4jConnection.xxx(request); StringBuilder buf = new StringBuilder(); for (Element row : XmlaOlap4jUtil.childElements(root)) { diff --git a/src/org/olap4j/mdx/AxisNode.java b/src/org/olap4j/mdx/AxisNode.java index cfce0f0..515a884 100644 --- a/src/org/olap4j/mdx/AxisNode.java +++ b/src/org/olap4j/mdx/AxisNode.java @@ -37,17 +37,17 @@ public class AxisNode implements ParseTreeNode { * @param region Region of source code * @param nonEmpty Whether to filter out members of this axis whose cells * are all empty - * @param expression Expression to populate the axis * @param axisDef Which axis (ROWS, COLUMNS, etc.) * @param dimensionProperties List of dimension properties; if null, * empty list is assumed + * @param expression Expression to populate the axis */ public AxisNode( ParseRegion region, boolean nonEmpty, - ParseTreeNode expression, Axis axisDef, - List dimensionProperties) + List dimensionProperties, + ParseTreeNode expression) { this.region = region; this.nonEmpty = nonEmpty; diff --git a/src/org/olap4j/mdx/parser/impl/DefaultMdxParser.cup b/src/org/olap4j/mdx/parser/impl/DefaultMdxParser.cup index 1a4fbf6..b55a39a 100644 --- a/src/org/olap4j/mdx/parser/impl/DefaultMdxParser.cup +++ b/src/org/olap4j/mdx/parser/impl/DefaultMdxParser.cup @@ -154,8 +154,8 @@ parser code {: filter == null ? null : new AxisNode( - filter.getRegion(), false, filter, Axis.FILTER, - Collections.EMPTY_LIST); + filter.getRegion(), false, Axis.FILTER, + Collections.EMPTY_LIST, filter); // sort axes by ordinal Collections.sort(axisList, new Comparator() { public int compare(AxisNode o1, AxisNode o2) { @@ -1418,7 +1418,7 @@ axis_specification ::= Axis axis = Axis.valueOf(a.toUpperCase()); ParseRegion region = createRegion( bleft, bright, sleft, sright, dpleft, dpright, aleft, aright); - RESULT = new AxisNode(region, b, s, axis, emptyList(dp)); + RESULT = new AxisNode(region, b, axis, emptyList(dp), s); :} | non_empty_opt:b expression:s dim_props_opt:dp ON axis_number:n {: double d = n.doubleValue(); @@ -1436,7 +1436,7 @@ axis_specification ::= Axis axis = Axis.forOrdinal(index); ParseRegion region = createRegion( bleft, bright, sleft, sright, dpleft, dpright, nleft, nright); - RESULT = new AxisNode(region, b, s, axis, emptyList(dp)); + RESULT = new AxisNode(region, b, axis, emptyList(dp), s); :} ; diff --git a/src/org/olap4j/sample/SimpleQuerySample.java b/src/org/olap4j/sample/SimpleQuerySample.java index a8570f5..5051486 100644 --- a/src/org/olap4j/sample/SimpleQuerySample.java +++ b/src/org/olap4j/sample/SimpleQuerySample.java @@ -244,15 +244,15 @@ void executeSelectNode(OlapConnection connection) { new AxisNode( null, false, + Axis.ROWS, + new ArrayList(), new CallNode( null, "{}", Syntax.Braces, new IdentifierNode( new IdentifierNode.Segment("Measures"), - new IdentifierNode.Segment("Unit Sales"))), - Axis.ROWS, - new ArrayList())); + new IdentifierNode.Segment("Unit Sales"))))); // Create a statement based upon the query model. OlapStatement stmt; diff --git a/testsrc/org/olap4j/ConnectionTest.java b/testsrc/org/olap4j/ConnectionTest.java index ea49425..0fc96fb 100644 --- a/testsrc/org/olap4j/ConnectionTest.java +++ b/testsrc/org/olap4j/ConnectionTest.java @@ -1005,9 +1005,9 @@ public void testUnparsing() { new AxisNode( null, false, - null, Axis.FILTER, - new ArrayList()), + new ArrayList(), + null), new ArrayList()); select.getWithList().add( new WithMemberNode( @@ -1029,6 +1029,8 @@ public void testUnparsing() { new AxisNode( null, false, + Axis.COLUMNS, + new ArrayList(), new CallNode( null, "{}", @@ -1036,13 +1038,14 @@ public void testUnparsing() { Arrays.asList( (ParseTreeNode) new IdentifierNode( - new IdentifierNode.Segment("Gender")))), - Axis.COLUMNS, - new ArrayList())); + new IdentifierNode.Segment("Gender")))) + )); select.getAxisList().add( new AxisNode( null, false, + Axis.ROWS, + new ArrayList(), new CallNode( null, "{}", @@ -1052,10 +1055,7 @@ public void testUnparsing() { "Children", Syntax.Property, new IdentifierNode( - new IdentifierNode.Segment("Store")) - )), - Axis.ROWS, - new ArrayList())); + new IdentifierNode.Segment("Store")))))); select.getFilterAxis().setExpression( new IdentifierNode( new IdentifierNode.Segment("Time"), @@ -1073,7 +1073,7 @@ public void testCubeLookupMember() throws Exception { Connection connection = tester.createConnection(); OlapConnection olapConnection = ((OlapWrapper) connection).unwrap(OlapConnection.class); - Cube cube = olapConnection.getSchema().getCubes().get("Sales"); + Cube cube = olapConnection.getSchema().getCubes().get("Sales Ragged"); Member member = cube.lookupMember( @@ -1796,20 +1796,18 @@ private void buildQuery( query.setFrom(cubeNode); AxisNode columnAxis = new AxisNode( - null, false, + null, false, Axis.COLUMNS, null, new CallNode( null, "MEMBERS", Syntax.Property, new IdentifierNode( - IdentifierNode.parseIdentifier("[Gender]"))), - Axis.COLUMNS, null); + IdentifierNode.parseIdentifier("[Gender]")))); AxisNode rowAxis = new AxisNode( - null, false, + null, false, Axis.ROWS, null, new CallNode( null, "CHILDREN", Syntax.Property, new IdentifierNode( - IdentifierNode.parseIdentifier("[Customers].[USA]"))), - Axis.ROWS, null); + IdentifierNode.parseIdentifier("[Customers].[USA]")))); query.getAxisList().add(columnAxis); query.getAxisList().add(rowAxis); OlapStatement statement = olapConnection.createStatement(); @@ -1836,6 +1834,85 @@ private void buildQuery( "Row #2: 62,603\n"), TestContext.toString(cellSet)); } + + public void testBuildQuery2() throws ClassNotFoundException, SQLException { + Connection connection = tester.createConnection(); + OlapConnection olapConnection = + ((OlapWrapper) connection).unwrap(OlapConnection.class); + + Schema schema = olapConnection.getSchema(); + Cube cube = schema.getCubes().get("Sales"); + Measure measure = cube.getMeasures().get(0); + Dimension dimPromotionMedia = cube.getDimensions().get("Promotion Media"); + // + // IdentifierNode cubeNode = new IdentifierNode(new IdentifierNode.Segment(cube.getUniqueName())); + CubeNode cubeNode = new CubeNode(null, cube); + MemberNode measuresQuantity = new MemberNode(null, measure); + HierarchyNode promotionHierarchyNode = + new HierarchyNode(null, dimPromotionMedia.getDefaultHierarchy()); + CallNode promotionChildren = + new CallNode( + null, "children", Syntax.Property, promotionHierarchyNode); + // + List columnDimensionProperties = + new ArrayList(); + AxisNode columnAxis = + new AxisNode( + null, false, + Axis.COLUMNS, + columnDimensionProperties, + new CallNode(null, "{}", Syntax.Braces, measuresQuantity)); + List rowDimensionProperties = + new ArrayList(); + AxisNode rowAxis = + new AxisNode( + null, false, + Axis.ROWS, + rowDimensionProperties, + new CallNode(null, "{}", Syntax.Braces, promotionChildren)); + // + SelectNode query = new SelectNode(); + query.setFrom(cubeNode); + query.getAxisList().add(columnAxis); + query.getAxisList().add(rowAxis); + // + OlapStatement statement = olapConnection.createStatement(); + CellSet cellSet = statement.executeOlapQuery(query); + final StringWriter sw = new StringWriter(); + final PrintWriter pw = new PrintWriter(sw); + for (Position row : cellSet.getAxes().get(1)) { + for (Position column : cellSet.getAxes().get(0)) { + pw.print("ROW:"); + for (Member member : row.getMembers()) { + pw.print("[" + member.getName() + "]"); + } + pw.print(" COL:"); + for (Member member : column.getMembers()) { + pw.print("[" + member.getName() + "]"); + } + Cell cell = cellSet.getCell(column, row); + pw.println(" CELL:" + cell.getFormattedValue()); + } + } + pw.flush(); + TestContext.assertEqualsVerbose( + TestContext.fold( + "ROW:[Bulk Mail] COL:[Customer Count] CELL:333\n" + + "ROW:[Cash Register Handout] COL:[Customer Count] CELL:482\n" + + "ROW:[Daily Paper] COL:[Customer Count] CELL:528\n" + + "ROW:[Daily Paper, Radio] COL:[Customer Count] CELL:499\n" + + "ROW:[Daily Paper, Radio, TV] COL:[Customer Count] CELL:687\n" + + "ROW:[In-Store Coupon] COL:[Customer Count] CELL:290\n" + + "ROW:[No Media] COL:[Customer Count] CELL:5,043\n" + + "ROW:[Product Attachment] COL:[Customer Count] CELL:532\n" + + "ROW:[Radio] COL:[Customer Count] CELL:186\n" + + "ROW:[Street Handout] COL:[Customer Count] CELL:381\n" + + "ROW:[Sunday Paper] COL:[Customer Count] CELL:307\n" + + "ROW:[Sunday Paper, Radio] COL:[Customer Count] CELL:422\n" + + "ROW:[Sunday Paper, Radio, TV] COL:[Customer Count] CELL:196\n" + + "ROW:[TV] COL:[Customer Count] CELL:274\n"), + sw.toString()); + } } // End ConnectionTest.java