details:   https://code.openbravo.com/erp/devel/pi/rev/64b9dc19a8d3
changeset: 19838:64b9dc19a8d3
user:      Augusto Mauch <augusto.mauch <at> openbravo.com>
date:      Fri Mar 01 13:37:03 2013 +0100
summary:   Fixes issue 23203: Filter works with DateTime fields

With the fix of https://issues.openbravo.com/view.php?id=22885, when a Date or 
DateTime column is filtered, plain Dates are send as criteria. This is done to 
prevent Date from being converted to its UTC format. The AdvancedQueryBuilder 
was not prepared for this change, and was expecting a full Date and Time value 
for DateTime columns. Now it first try to parse the value as a DateTime and if 
it's not possible it tries to parse the value as a Date.

diffstat:

 
modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
 |  13 +++++++--
 1 files changed, 10 insertions(+), 3 deletions(-)

diffs (44 lines):

diff -r d292f59ef8c5 -r 64b9dc19a8d3 
modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
--- 
a/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
       Fri Mar 01 13:07:52 2013 +0100
+++ 
b/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
       Fri Mar 01 13:37:03 2013 +0100
@@ -19,6 +19,7 @@
 package org.openbravo.service.json;
 
 import java.math.BigDecimal;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Calendar;
@@ -675,7 +676,13 @@
       try {
         Date date = null;
         if (property.isDatetime()) {
-          date = simpleDateTimeFormat.parse(value.toString());
+          try {
+            date = simpleDateTimeFormat.parse(value.toString());
+          } catch (ParseException e) {
+            // When a DateTime column is filtered, plan Date values are used
+            // See issue https://issues.openbravo.com/view.php?id=23203
+            date = simpleDateFormat.parse(value.toString());
+          }
         }
         if (property.isDate()) {
           date = simpleDateFormat.parse(value.toString());
@@ -726,7 +733,7 @@
         && (operator.equals(OPERATOR_GREATERTHAN) || 
operator.equals(OPERATOR_GREATEROREQUAL)
             || operator.equals(OPERATOR_IGREATERTHAN) || 
operator.equals(OPERATOR_IGREATEROREQUAL)
             || operator.equals(OPERATOR_GREATERTHANFIElD) || operator
-            .equals(OPERATOR_GREATEROREQUALFIELD));
+              .equals(OPERATOR_GREATEROREQUALFIELD));
   }
 
   private boolean isLesserOperator(String operator) {
@@ -734,7 +741,7 @@
         && (operator.equals(OPERATOR_LESSTHAN) || 
operator.equals(OPERATOR_LESSOREQUAL)
             || operator.equals(OPERATOR_ILESSTHAN) || 
operator.equals(OPERATOR_ILESSOREQUAL)
             || operator.equals(OPERATOR_LESSTHANFIELD) || operator
-            .equals(OPERATOR_LESSOREQUALFIElD));
+              .equals(OPERATOR_LESSOREQUALFIElD));
   }
 
   private String computeLeftWhereClauseForIdentifier(Property property, String 
key,

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to