details:   https://code.openbravo.com/erp/devel/pi/rev/67f3916500d9
changeset: 18592:67f3916500d9
user:      Shankar Balachandran <shankar.balachandran <at> openbravo.com>
date:      Wed Nov 21 23:27:24 2012 +0100
summary:   Fixes Issue 0022007 : Handling null values in filter by identifiers.

Modifications in replaceValueWithJoins to handle multiple joins and computed 
orderByClause before computing whereClause to handle the joins properly.

diffstat:

 
modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
 |  21 +++++++--
 1 files changed, 15 insertions(+), 6 deletions(-)

diffs (41 lines):

diff -r 0ddc1b5aa999 -r 67f3916500d9 
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
       Wed Nov 21 19:57:31 2012 +0100
+++ 
b/modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
       Wed Nov 21 23:27:24 2012 +0100
@@ -1053,8 +1053,8 @@
     }
 
     // make sure that the join clauses are computed
+    getOrderByClause();
     getWhereClause();
-    getOrderByClause();
 
     final StringBuilder sb = new StringBuilder();
     if (getMainAlias() != null) {
@@ -1229,13 +1229,22 @@
     String properties[] = value.split("\\.");
     if (properties.length > 2) {
       for (JoinDefinition join : joinDefinitions) {
-        if (compare.contains("join")) {
-          if (properties[0].equalsIgnoreCase(join.ownerAlias)) {
-            return join.joinAlias + DalUtil.DOT + properties[properties.length 
- 1];
+        if (compare.startsWith(getMainAlias())) {
+          if (compare.equalsIgnoreCase(getMainAlias() + DalUtil.DOT + 
join.property.toString())) {
+            query = join.joinAlias + DalUtil.DOT + 
properties[properties.length - 1];
           }
+
         } else {
-          if (compare.equalsIgnoreCase(getMainAlias() + DalUtil.DOT + 
join.property)) {
-            return join.joinAlias + DalUtil.DOT + properties[properties.length 
- 1];
+          String joinStatement = join.getJoinStatement();
+          String[] joinElement = joinStatement.split("as");
+          if (joinElement[0] != null) {
+            String entities[] = joinElement[0].split(" ");
+            if (entities[entities.length - 1] != null) {
+              String entityToCompare = entities[entities.length - 1];
+              if (compare.equalsIgnoreCase(entityToCompare)) {
+                query = join.joinAlias + DalUtil.DOT + 
properties[properties.length - 1];
+              }
+            }
           }
         }
       }

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to