details: https://code.openbravo.com/erp/devel/pi/rev/c0f00abf9563
changeset: 13821:c0f00abf9563
user: Martin Taal <martin.taal <at> openbravo.com>
date: Fri Sep 23 06:58:04 2011 +0200
summary: Fixes issue 18079: Date filter is not working correctly
Now also handle filtering on one date correctly
diffstat:
modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
| 25 ++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diffs (42 lines):
diff -r 206013dbb86e -r c0f00abf9563
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 Sep 23 06:37:58 2011 +0200
+++
b/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
Fri Sep 23 06:58:04 2011 +0200
@@ -294,6 +294,30 @@
value = null;
}
+ // if a comparison is done on an equal date then replace
+ // with a between start time and end time on that date
+ if (operator.equals(OPERATOR_EQUALS) ||
operator.equals(OPERATOR_EQUALSFIELD)) {
+ final List<Property> properties =
JsonUtils.getPropertiesOnPath(getEntity(), fieldName);
+ if (properties.isEmpty()) {
+ return null;
+ }
+ final Property property = properties.get(properties.size() - 1);
+ if (property == null) {
+ return null;
+ }
+ // create the clauses, re-uses the code in parseSimpleClause
+ // which translates a lesserthan/greater than to the end/start
+ // time of a date
+ if (operator.equals(OPERATOR_EQUALS)) {
+ return "(" + parseSimpleClause(fieldName, OPERATOR_GREATEROREQUAL,
value) + " and "
+ + parseSimpleClause(fieldName, OPERATOR_LESSOREQUAL, value) + ")";
+
+ } else {
+ return "(" + parseSimpleClause(fieldName,
OPERATOR_GREATEROREQUALFIELD, value) + " and "
+ + parseSimpleClause(fieldName, OPERATOR_LESSOREQUALFIElD, value) +
")";
+ }
+ }
+
return parseSimpleClause(fieldName, operator, value);
}
@@ -313,6 +337,7 @@
private String parseSimpleClause(String fieldName, String operator, Object
value)
throws JSONException {
+ // note: code duplicated in parseSingleClause
final List<Property> properties =
JsonUtils.getPropertiesOnPath(getEntity(), fieldName);
if (properties.isEmpty()) {
return null;
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits