[OBUISEL]Refactor to use new OBDao.getActiveOBObjectList() method.
authorGorka Ion Damián <gorkaion.damian@openbravo.com>
Thu, 03 Mar 2011 17:53:57 +0100
changeset 11002 3a41ea6852df
parent 11001 e136008b3bf4
child 11003 c3dea134444b
[OBUISEL]Refactor to use new OBDao.getActiveOBObjectList() method.
modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/CustomQuerySelectorDatasource.java
modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorComponent.java
--- a/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/CustomQuerySelectorDatasource.java	Thu Mar 03 17:48:49 2011 +0100
+++ b/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/CustomQuerySelectorDatasource.java	Thu Mar 03 17:53:57 2011 +0100
@@ -41,6 +41,7 @@
 import org.openbravo.client.kernel.RequestContext;
 import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.dal.service.OBDao;
 import org.openbravo.service.datasource.ReadOnlyDataSourceService;
 import org.openbravo.service.json.JsonConstants;
 import org.openbravo.service.json.JsonUtils;
@@ -75,7 +76,8 @@
     try {
 
       Selector sel = OBDal.getInstance().get(Selector.class, selectorId);
-      List<SelectorField> fields = getActiveSelectorFields(sel);
+      List<SelectorField> fields = OBDao.getActiveOBObjectList(sel,
+          Selector.PROPERTY_OBUISELSELECTORFIELDLIST);
 
       // Parse the HQL in case that optional filters are required
       String HQL = parseOptionalFilters(parameters, sel, xmlDateFormat);
@@ -171,7 +173,9 @@
 
     StringBuffer defaultExpressionsFilter = new StringBuffer();
     boolean hasFilter = false;
-    for (SelectorField field : getActiveSelectorFields(sel)) {
+    List<SelectorField> fields = OBDao.getActiveOBObjectList(sel,
+        Selector.PROPERTY_OBUISELSELECTORFIELDLIST);
+    for (SelectorField field : fields) {
       if (StringUtils.isEmpty(field.getClauseLeftPart())) {
         continue;
       }
@@ -346,7 +350,9 @@
     if (sortByClause.length() == 0) {
       String fieldName = "";
       Long sortNumber = Long.MAX_VALUE;
-      for (SelectorField selField : getActiveSelectorFields(sel)) {
+      List<SelectorField> selFields = OBDao.getActiveOBObjectList(sel,
+          Selector.PROPERTY_OBUISELSELECTORFIELDLIST);
+      for (SelectorField selField : selFields) {
         if (selField.isShowingrid() && selField.getSortno() < sortNumber) {
           sortNumber = selField.getSortno();
           fieldName = selField.getDisplayColumnAlias();
@@ -416,13 +422,4 @@
     return 0;
   }
 
-  private List<SelectorField> getActiveSelectorFields(Selector sel) {
-    OBDal.getInstance().enableActiveFilter();
-    try {
-      return sel.getOBUISELSelectorFieldList();
-    } finally {
-      OBDal.getInstance().disableActiveFilter();
-    }
-  }
-
 }
--- a/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorComponent.java	Thu Mar 03 17:48:49 2011 +0100
+++ b/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorComponent.java	Thu Mar 03 17:53:57 2011 +0100
@@ -232,12 +232,8 @@
 
   private List<SelectorField> getActiveSelectorFields() {
     if (selectorFields == null) {
-      OBDal.getInstance().enableActiveFilter();
-      try {
-        selectorFields = getSelector().getOBUISELSelectorFieldList();
-      } finally {
-        OBDal.getInstance().disableActiveFilter();
-      }
+      selectorFields = OBDao.getActiveOBObjectList(getSelector(),
+          Selector.PROPERTY_OBUISELSELECTORFIELDLIST);
     }
     return selectorFields;
   }