Author: ekoneil
Date: Mon Mar 28 13:22:45 2005
New Revision: 159312
URL: http://svn.apache.org/viewcvs?view=rev&rev=159312
Log:
Data grid bug fixes:
- cleanup APIs in SQLSupport
- BEEHIVE-468 When filtering a data grid using operator "isnotempty" an
IllegalFilterException is thrown.
Had left out support for this filter operation. It's supported now with a
DRT in SQLSupportTest
- BEEHIVE-458 Filterable data grids are throwing JSP expections when number of
returned rows exceed the page size limit.
Fixed a bug where a String was added to a Map expecting <String, String[]>
Add two new test cases:
- FilterURLTest -- tests URLs to ensure that they are parsed correctly
- SQLSupportTest -- tests the support for building SQL related order by / where
clauses
BB: self
DRT: NetUI pass
BVT: NetUI pass
Added:
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/FilterURLTest.java
(with props)
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/SQLSupportTest.java
(with props)
Modified:
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/config/DefaultDataGridStateCodec.java
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/config/DefaultDataGridURLBuilder.java
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/sql/SQLSupport.java
Modified:
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/config/DefaultDataGridStateCodec.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/config/DefaultDataGridStateCodec.java?view=diff&r1=159311&r2=159312
==============================================================================
---
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/config/DefaultDataGridStateCodec.java
(original)
+++
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/config/DefaultDataGridStateCodec.java
Mon Mar 28 13:22:45 2005
@@ -106,11 +106,11 @@
if(sorts == null || sorts.size() == 0)
return null;
- HashMap params = new HashMap();
String encoded = encodeSorts(sorts);
if(encoded == null)
return null;
else {
+ HashMap params = new HashMap();
params.put(PARAM_KEY_SORT, new String[] {encoded});
return params;
}
@@ -120,12 +120,12 @@
if(filters == null || filters.size() == 0)
return null;
- HashMap params = new HashMap();
String encoded = encodeFilters(filters);
if(encoded == null)
return null;
else {
- params.put(PARAM_KEY_FILTER, encoded);
+ HashMap params = new HashMap();
+ params.put(PARAM_KEY_FILTER, new String[] {encoded});
return params;
}
}
@@ -333,7 +333,7 @@
continue;
else if(terms.length == 3) {
try {
- FilterOperation fOp =
SQLSupport.mapStringToOperation(terms[1]);
+ FilterOperation fOp =
SQLSupport.mapFilterAbbreviationToOperation(terms[1]);
filter = _config.createFilter();
filter.setFilterExpression(terms[0]);
filter.setOperation(fOp);
Modified:
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/config/DefaultDataGridURLBuilder.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/config/DefaultDataGridURLBuilder.java?view=diff&r1=159311&r2=159312
==============================================================================
---
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/config/DefaultDataGridURLBuilder.java
(original)
+++
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/config/DefaultDataGridURLBuilder.java
Mon Mar 28 13:22:45 2005
@@ -225,6 +225,7 @@
Iterator iterator = merge.keySet().iterator();
while(iterator.hasNext()) {
String key = (String)iterator.next();
+ assert merge.get(key) instanceof String[];
String[] values = (String[])merge.get(key);
if(newMap.containsKey(key)) {
Object currValues = newMap.get(key);
Modified:
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/sql/SQLSupport.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/sql/SQLSupport.java?view=diff&r1=159311&r2=159312
==============================================================================
---
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/sql/SQLSupport.java
(original)
+++
incubator/beehive/trunk/netui/src/tags-databinding/org/apache/beehive/netui/databinding/datagrid/runtime/sql/SQLSupport.java
Mon Mar 28 13:22:45 2005
@@ -70,7 +70,7 @@
* @netui:jspfunction name="lookupFilterOperations"
* signature="java.util.Map lookupFilterOperations(java.lang.String)"
*/
- public static Map lookupFilterOperations(String typeHint) {
+ public static Map lookupFilterOperationLabels(String typeHint) {
LinkedHashMap ops = new LinkedHashMap<String, String>();
/* todo: i18n */
@@ -102,7 +102,7 @@
* @netui:jspfunction name="lookupDefaultFilterOperation"
* signature="java.lang.String
lookupDefaultFilterOperations(java.lang.String)"
*/
- public static String lookupDefaultFilterOperation(String typeHint) {
+ public static String lookoupDefaultFilterOperationAbbreviation(String
typeHint) {
FilterOperation fOp = OTHER_FILTER_OPERATION;
if(typeHint == null || FilterTypeHint.STRING ==
FilterTypeHint.getTypeHint(typeHint))
fOp = STRING_FILTER_OPERATION;
@@ -110,7 +110,7 @@
return fOp.getAbbreviation();
}
- public static final FilterOperation mapStringToOperation(String abbrev) {
+ public static final FilterOperation
mapFilterAbbreviationToOperation(String abbrev) {
for(FilterOperation fOp : FILTER_OPERATIONS) {
if(fOp.getAbbreviation().equals(abbrev))
return fOp;
@@ -118,6 +118,14 @@
return null;
}
+ public static final FilterOperation
mapFilterHintToOperation(FilterOperationHint hint) {
+ for(FilterOperation op : FILTER_OPERATIONS) {
+ if(op.getOperationHint().equals(hint))
+ return op;
+ }
+ return null;
+ }
+
/* non-public constructor */
private SQLSupport() {
}
@@ -216,12 +224,14 @@
sql.append(')');
break;
}
+ case IS_NOT_EMPTY:
+ {
+
sql.append("(").append(filter.getFilterExpression()).append(" IS NOT NULL)");
+ break;
+ }
case IS_EMPTY:
{
- if("0".equals(filter.getValue()))
-
sql.append("(").append(filter.getFilterExpression()).append(" IS NOT NULL)");
- else
-
sql.append("(").append(filter.getFilterExpression()).append(" IS NULL)");
+
sql.append("(").append(filter.getFilterExpression()).append(" IS NULL)");
break;
}
case EQUAL:
Added:
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/FilterURLTest.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/FilterURLTest.java?view=auto&rev=159312
==============================================================================
---
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/FilterURLTest.java
(added)
+++
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/FilterURLTest.java
Mon Mar 28 13:22:45 2005
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.test.datagrid;
+
+import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.beehive.netui.databinding.datagrid.api.DataGridConfig;
+import org.apache.beehive.netui.databinding.datagrid.api.DataGridState;
+import org.apache.beehive.netui.databinding.datagrid.api.DataGridURLBuilder;
+import org.apache.beehive.netui.databinding.datagrid.api.DataGridStateFactory;
+import org.apache.beehive.netui.test.servlet.ServletFactory;
+
+/**
+ *
+ */
+public class FilterURLTest
+ extends TestCase {
+
+ private HttpServletRequest _request = null;
+
+ public void testJIRA458() {
+ /* Failing URL:
+
http://localhost:8080/dataGridWeb/sql/filterTest/FilterTest.jpf?netui_filter=customers;customerid~contains~A,companyname~contains~e
+ */
+ String queryString =
"netui_filter=customers;customerid~contains~A,companyname~contains~e";
+ DataGridTestUtil.initQueryString(_request, queryString);
+ DataGridStateFactory factory =
DataGridStateFactory.getInstance(_request);
+ DataGridState state = factory.getDataGridState("customers");
+ DataGridURLBuilder urlBuilder =
factory.getDataGridURLBuilder("customers");
+
+ /* http://issues.apache.org/jira/browse/BEEHIVE-458
+
+ This should not throw a ClassCastException or AssertionError
+ */
+ Map map = urlBuilder.getQueryParamsForNextPage();
+ }
+
+ protected void setUp() {
+ _request = ServletFactory.getServletRequest();
+ }
+
+ protected void tearDown() {
+ _request = null;
+ }
+
+ public FilterURLTest(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ return new TestSuite(FilterURLTest.class);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+}
\ No newline at end of file
Propchange:
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/FilterURLTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/SQLSupportTest.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/SQLSupportTest.java?view=auto&rev=159312
==============================================================================
---
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/SQLSupportTest.java
(added)
+++
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/SQLSupportTest.java
Mon Mar 28 13:22:45 2005
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Header:$
+ */
+package org.apache.beehive.netui.test.datagrid;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.beehive.netui.databinding.datagrid.api.DataGridConfig;
+import org.apache.beehive.netui.databinding.datagrid.api.filter.Filter;
+import
org.apache.beehive.netui.databinding.datagrid.api.filter.FilterOperation;
+import org.apache.beehive.netui.databinding.datagrid.api.filter.FilterTypeHint;
+import
org.apache.beehive.netui.databinding.datagrid.api.filter.FilterOperationHint;
+import org.apache.beehive.netui.databinding.datagrid.api.sort.Sort;
+import org.apache.beehive.netui.databinding.datagrid.api.sort.SortDirection;
+import org.apache.beehive.netui.databinding.datagrid.runtime.sql.SQLSupport;
+
+/**
+ *
+ */
+public class SQLSupportTest
+ extends TestCase {
+
+ public void testSortEncoding() {
+ DataGridConfig config = DataGridTestUtil.getDataGridConfig();
+ Sort sort = config.createSort();
+ sort.setDirection(SortDirection.DESCENDING);
+ sort.setSortExpression("CUSTOMERS");
+ List list = new ArrayList();
+ list.add(sort);
+
+ String sortClause = SQLSupport.getInstance().createOrderByClause(list);
+ assertEquals("ORDER BY CUSTOMERS DESC", sortClause);
+ }
+
+ public void testFitlerEncoding() {
+ DataGridConfig config = DataGridTestUtil.getDataGridConfig();
+ FilterOperation fOp = null;
+ Filter filter = config.createFilter();
+ filter.setFilterExpression("CUSTOMERID");
+ filter.setValue("1234");
+ List filters = Collections.singletonList(filter);
+
+ /* isnotempty testing */
+ fOp = SQLSupport.mapFilterAbbreviationToOperation("isnotempty");
+ filter.setOperation(fOp);
+ assertEquals("WHERE (CUSTOMERID IS NOT NULL)",
SQLSupport.getInstance().createWhereClause(filters));
+ fOp =
SQLSupport.mapFilterHintToOperation(FilterOperationHint.IS_NOT_EMPTY);
+ filter.setOperation(fOp);
+ assertEquals("WHERE (CUSTOMERID IS NOT NULL)",
SQLSupport.getInstance().createWhereClause(filters));
+ fOp =
SQLSupport.mapFilterHintToOperation(FilterOperationHint.IS_NOT_EMPTY);
+ filter.setOperation(fOp);
+ filter.setTypeHint(FilterTypeHint.DATE);
+ assertEquals("WHERE (CUSTOMERID IS NOT NULL)",
SQLSupport.getInstance().createWhereClause(filters));
+
+ /* equals testing */
+ fOp = SQLSupport.mapFilterAbbreviationToOperation("eq");
+ filter.setOperation(fOp);
+ filter.setTypeHint(FilterTypeHint.STRING);
+ assertEquals("WHERE (CUSTOMERID='1234')",
SQLSupport.getInstance().createWhereClause(filters));
+ fOp = SQLSupport.mapFilterHintToOperation(FilterOperationHint.EQUAL);
+ filter.setOperation(fOp);
+ assertEquals("WHERE (CUSTOMERID='1234')",
SQLSupport.getInstance().createWhereClause(filters));
+ fOp = SQLSupport.mapFilterHintToOperation(FilterOperationHint.EQUAL);
+ filter.setTypeHint(FilterTypeHint.NUMERIC);
+ filter.setOperation(fOp);
+ assertEquals("WHERE (CUSTOMERID=1234)",
SQLSupport.getInstance().createWhereClause(filters));
+ }
+
+ protected void setUp() {
+ }
+
+ protected void tearDown() {
+ }
+
+ public SQLSupportTest(String name) {
+ super(name);
+ }
+
+ public static Test suite() {
+ return new TestSuite(SQLSupportTest.class);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(suite());
+ }
+}
\ No newline at end of file
Propchange:
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/datagrid/SQLSupportTest.java
------------------------------------------------------------------------------
svn:eol-style = native