details:   https://code.openbravo.com/erp/devel/pi/rev/0edfa4a62710
changeset: 32076:0edfa4a62710
user:      Asier Lostalé <asier.lostale <at> openbravo.com>
date:      Fri May 05 11:34:45 2017 +0200
summary:   fixed issue 35909: accessible organizations is calculated per column 
in FIC

  Whenver FIC was exectued, accessible organization list was computed for each
  drop down column. The only parameter for this list is the organization of the
  current record, so the result will be the same for all columns. Being this a
  potentially heavy operation, it can result in slow FIC requests.

  Now the list is cached in OrgTree which is cached in session, so the list of
  referenceable organizations is only computed the first time it gets used per
  organization within the whole session.

diffstat:

 src/org/openbravo/base/secureApp/OrgTree.java    |  23 +++++++++++++++++++++++
 src/org/openbravo/erpCommon/utility/Utility.java |   2 +-
 2 files changed, 24 insertions(+), 1 deletions(-)

diffs (59 lines):

diff -r d9e1958bb026 -r 0edfa4a62710 
src/org/openbravo/base/secureApp/OrgTree.java
--- a/src/org/openbravo/base/secureApp/OrgTree.java     Tue May 09 18:36:12 
2017 +0200
+++ b/src/org/openbravo/base/secureApp/OrgTree.java     Fri May 05 11:34:45 
2017 +0200
@@ -15,6 +15,8 @@
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
 import org.openbravo.database.ConnectionProvider;
 import org.openbravo.erpCommon.utility.WindowTreeData;
@@ -26,6 +28,8 @@
   private static final char QUOUTE = '\'';
   private static final String QUOUTE_COMMA = "',";
 
+  private Map<String, String> referenceableOrganizations = new 
ConcurrentHashMap<>();
+
   /**
    * Creates a new Organization tree with all the nodes
    * 
@@ -193,6 +197,25 @@
   }
 
   /**
+   * Gets referenceable organizations from cache if available or computes and 
caches it if not yet
+   * in cache. Referenceable organizations is the comma separated list of 
organizations that can be
+   * referenced from a given organization.
+   * 
+   * @see OrgTree#getLogicPath(String)
+   */
+  public String getReferenceableOrganizations(String organizationId) {
+    String orgs = null;
+    if (organizationId != null) {
+      orgs = referenceableOrganizations.get(organizationId);
+    }
+    if (orgs == null) {
+      orgs = getLogicPath(organizationId).toString();
+      referenceableOrganizations.put(organizationId, orgs);
+    }
+    return orgs;
+  }
+
+  /**
    * Converts the tree into String. Nodes comma separated.
    */
   public String toString() {
diff -r d9e1958bb026 -r 0edfa4a62710 
src/org/openbravo/erpCommon/utility/Utility.java
--- a/src/org/openbravo/erpCommon/utility/Utility.java  Tue May 09 18:36:12 
2017 +0200
+++ b/src/org/openbravo/erpCommon/utility/Utility.java  Fri May 05 11:34:45 
2017 +0200
@@ -554,7 +554,7 @@
    */
   public static String getReferenceableOrg(VariablesSecureApp vars, String 
currentOrg) {
     final OrgTree tree = (OrgTree) vars.getSessionObject("#CompleteOrgTree");
-    return tree.getLogicPath(currentOrg).toString();
+    return tree.getReferenceableOrganizations(currentOrg);
   }
 
   /**

------------------------------------------------------------------------------
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