details:   https://code.openbravo.com/erp/devel/pi/rev/103ab686dc05
changeset: 32735:103ab686dc05
user:      Carlos Aristu <carlos.aristu <at> openbravo.com>
date:      Wed Sep 20 19:18:25 2017 +0200
summary:   related to bug 36863: return the readable organizations in the 
current context

Be homogeneus with the OBUISEL_Selector references based on the standard 
datasource (which use the AdvanceQueryBuilder to create the client/org filters) 
and filter by the readable organizations in the case of the AD_Org table

diffstat:

 
modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/CustomQuerySelectorDatasource.java
 |  27 +---------
 1 files changed, 2 insertions(+), 25 deletions(-)

diffs (58 lines):

diff -r 03947bec5a0d -r 103ab686dc05 
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
  Wed Sep 20 18:34:55 2017 +0200
+++ 
b/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/CustomQuerySelectorDatasource.java
  Wed Sep 20 19:18:25 2017 +0200
@@ -40,7 +40,6 @@
 import org.hibernate.Hibernate;
 import org.hibernate.Query;
 import org.hibernate.criterion.Restrictions;
-import org.openbravo.base.model.AccessLevel;
 import org.openbravo.base.model.ModelProvider;
 import org.openbravo.base.model.domaintype.BigDecimalDomainType;
 import org.openbravo.base.model.domaintype.BooleanDomainType;
@@ -56,8 +55,6 @@
 import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.dal.service.OBDao;
-import org.openbravo.model.ad.datamodel.Table;
-import org.openbravo.model.ad.ui.Tab;
 import org.openbravo.service.datasource.DataSourceUtils;
 import org.openbravo.service.datasource.ReadOnlyDataSourceService;
 import org.openbravo.service.json.AdvancedQueryBuilder;
@@ -208,11 +205,8 @@
       boolean isOrgSelector = sel.getTable().getName().equals("Organization");
       String orgs;
       if (isOrgSelector) {
-        // Just retrieve the list of direct accessible organizations in the 
current context
-        orgs = 
RequestContext.get().getVariablesSecureApp().getSessionValue("#User_Org");
-        if (includeOrgZero(parameters, orgs)) {
-          orgs += "".equals(orgs) ? "'0'" : ",'0'";
-        }
+        // Just retrieve the list of readable organizations in the current 
context
+        orgs = DataSourceUtils.getOrgs(parameters.get(""));
       } else {
         orgs = 
DataSourceUtils.getOrgs(parameters.get(JsonConstants.ORG_PARAMETER));
       }
@@ -293,23 +287,6 @@
     return HQL;
   }
 
-  private boolean includeOrgZero(Map<String, String> parameters, String 
userOrgs) {
-    if (userOrgs.contains("'0'")) {
-      return false;
-    }
-    String tabId = parameters.get("tabId");
-    if (StringUtils.isEmpty(tabId)) {
-      return false;
-    }
-    Tab tab = OBDal.getInstance().get(Tab.class, tabId);
-    Table table = tab.getTable();
-    if (table == null) {
-      return false;
-    }
-    int accessLevel = Integer.parseInt(table.getDataAccessLevel());
-    return AccessLevel.ORGANIZATION.getDbValue() != accessLevel;
-  }
-
   /**
    * Returns the where clause of a selector's field based on the given value.
    * 

------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to