details:   https://code.openbravo.com/erp/devel/pi/rev/3b8a64571ce8
changeset: 34106:3b8a64571ce8
user:      Carlos Aristu <carlos.aristu <at> openbravo.com>
date:      Wed May 30 10:43:21 2018 +0200
summary:   fixes issue 38635: Wrong combo values if the org id is not received 
by the FIC

  Before the changes on issue #37980 when retrieving an empty organization in 
the FIC, the query to calculate the selected combo value was filtering by every 
organization in the client. After that changes, the query to calculate the 
combo is filtering by an empty organization list, avoiding to retrieve the 
correct value.

  This is eventually caused by a change on how the 
Utility.getReferenceableOrg() method behaves. It now returns an empty list ('') 
if no organization is provided.

  To fix the problem we are now not including the org filtering in the query 
generated by UIDefinition.getValueInComboReference() method if an empty 
organization list is provided when building the query. In this case, filtering 
by client should be enough.

diffstat:

 src/org/openbravo/erpCommon/utility/ComboTableData.java        |   5 ++-
 src/org/openbravo/erpCommon/utility/StringCollectionUtils.java |  15 ++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diffs (56 lines):

diff -r 31ee92fe5dd4 -r 3b8a64571ce8 
src/org/openbravo/erpCommon/utility/ComboTableData.java
--- a/src/org/openbravo/erpCommon/utility/ComboTableData.java   Tue May 29 
16:36:25 2018 +0200
+++ b/src/org/openbravo/erpCommon/utility/ComboTableData.java   Wed May 30 
10:43:21 2018 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2017 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2018 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -896,7 +896,8 @@
     if (aux != null) {
       StringBuilder txtAux = new StringBuilder();
       for (QueryFieldStructure auxStructure : aux) {
-        if ("ORG_LIST".equals(auxStructure.getType()) && orgList == null) {
+        if ("ORG_LIST".equals(auxStructure.getType())
+            && StringCollectionUtils.isEmptyCollection(orgList)) {
           continue;
         }
         if (!isInArray(discard, auxStructure.getType())) {
diff -r 31ee92fe5dd4 -r 3b8a64571ce8 
src/org/openbravo/erpCommon/utility/StringCollectionUtils.java
--- a/src/org/openbravo/erpCommon/utility/StringCollectionUtils.java    Tue May 
29 16:36:25 2018 +0200
+++ b/src/org/openbravo/erpCommon/utility/StringCollectionUtils.java    Wed May 
30 10:43:21 2018 +0200
@@ -23,10 +23,13 @@
 import java.util.Collection;
 import java.util.Iterator;
 
+import org.apache.commons.lang.StringUtils;
+
 /** Provides common utilities to handle {@code Collection}s as {@code 
String}s. */
 public class StringCollectionUtils {
   private static final char COMMA = ',';
   private static final char QUOUTE = '\'';
+  private static final String EMPTY_COLLECTION = "''";
 
   /**
    * Returns a {@code String} including all elements in the {@code Collection} 
received as parameter
@@ -78,4 +81,16 @@
       sb.append(COMMA);
     }
   }
+
+  /**
+   * Checks if a comma separated representation of a collection represents an 
empty collection.
+   *
+   * @param collection
+   *          A comma separated representation of a collection
+   * @return {@code true} if the provided {@code String} represents an empty 
collection. Otherwise,
+   *         return {@code false}.
+   */
+  public static boolean isEmptyCollection(String collection) {
+    return StringUtils.isBlank(collection) || 
EMPTY_COLLECTION.equals(collection);
+  }
 }

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to