details:   https://code.openbravo.com/erp/devel/pi/rev/7e3fb4e2e7d4
changeset: 13790:7e3fb4e2e7d4
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Mon Sep 19 11:46:47 2011 +0200
summary:   Fixed issue 18313. Performance of the Business partner selector has 
been improved.
A big improvement has been made by removing the count which (obviously) 
included retrieving all the selected records. However, although the selector is 
now usable, performance is still not ideal. To further improve it, separating 
the selector into multiple ones (ie. not having a business partner/business 
partner location/ business partner attributes selector) should be considered, 
because the custom query (which includes a 'distinct' operator) is what is 
currently killing performance.

diffstat:

 
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ReadOnlyDataSourceService.java
             |  10 +++++++++-
 
modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/CustomQuerySelectorDatasource.java
 |   7 ++++---
 2 files changed, 13 insertions(+), 4 deletions(-)

diffs (44 lines):

diff -r 1b0163898c82 -r 7e3fb4e2e7d4 
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ReadOnlyDataSourceService.java
--- 
a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ReadOnlyDataSourceService.java
      Mon Sep 19 09:03:36 2011 +0200
+++ 
b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/ReadOnlyDataSourceService.java
      Mon Sep 19 11:46:47 2011 +0200
@@ -73,7 +73,15 @@
       jsonResponse.put(JsonConstants.RESPONSE_STARTROW, startRow);
       jsonResponse.put(JsonConstants.RESPONSE_ENDROW, jsonObjects.size() + 
startRow - 1);
       if (doCount) {
-        jsonResponse.put(JsonConstants.RESPONSE_TOTALROWS, 
getCount(parameters));
+        int num = getCount(parameters);
+        if (num == -1) {
+          int endRow = Integer.parseInt(endRowStr);
+          num = (endRow + 2);
+          if ((endRow - startRow) > jsonObjects.size()) {
+            num = startRow + jsonObjects.size();
+          }
+        }
+        jsonResponse.put(JsonConstants.RESPONSE_TOTALROWS, num);
       }
       jsonResponse.put(JsonConstants.RESPONSE_DATA, new 
JSONArray(jsonObjects));
       jsonResult.put(JsonConstants.RESPONSE_RESPONSE, jsonResponse);
diff -r 1b0163898c82 -r 7e3fb4e2e7d4 
modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/CustomQuerySelectorDatasource.java
--- 
a/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/CustomQuerySelectorDatasource.java
  Mon Sep 19 09:03:36 2011 +0200
+++ 
b/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/CustomQuerySelectorDatasource.java
  Mon Sep 19 11:46:47 2011 +0200
@@ -63,7 +63,8 @@
 
   @Override
   protected int getCount(Map<String, String> parameters) {
-    return getData(parameters, 0, -1).size();
+    // we return -1, so that the super class calculates a valid count
+    return -1;
   }
 
   @Override
@@ -293,8 +294,8 @@
    * <li>Boolean Domain Type: Returns an equals clause <i>field.clauseLeftPart 
= value</i></li>
    * <li>Foreign Key Domain Type: Returns an equals clause 
<i>field.clauseLeftPart.id = value</i></li>
    * <li>Unique Id Domain Type: Returns an equals clause 
<i>field.clauseLeftPart = value</i></li>
-   * <li>String Domain Type: Compares the clause left part with the value 
using the lower
-   * database function which to make comparison case insensitive.
+   * <li>String Domain Type: Compares the clause left part with the value 
using the lower database
+   * function which to make comparison case insensitive.
    * </ul>
    * 
    * @param value

------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
Learn about the latest advances in developing for the 
BlackBerry&reg; mobile platform with sessions, labs & more.
See new tools and technologies. Register for BlackBerry&reg; DevCon today!
http://p.sf.net/sfu/rim-devcon-copy1 
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to