details:   /erp/devel/pi/rev/96ea551e4d00
changeset: 11417:96ea551e4d00
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Thu Mar 31 11:32:53 2011 +0200
summary:   Fixed issue 16557. DocumentNo columns will be computed at the end, 
so that the doctypes have been already set

details:   /erp/devel/pi/rev/f5c8f4c9f1de
changeset: 11418:f5c8f4c9f1de
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Thu Mar 31 12:18:08 2011 +0200
summary:   Fixed issue 16582. Two main things have been changed in the FIC:
- runCallouts will now return a list of changed columns instead of whether a 
comboreload is necessary.
- The subsequent combo reload will now only compute the columns which depend on 
the changed columns instead of all the columns. This is done for two reasons: a 
subordinated combo (fed by a callout instead of combotabledata) would not work 
if a full combo reload is done always (ex. Payment Out window), and some combos 
rely on combo reload to work correctly (ex. Open/Close period control)

details:   /erp/devel/pi/rev/704efebf5095
changeset: 11419:704efebf5095
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Thu Mar 31 12:23:24 2011 +0200
summary:   Related to issue 16582. Remove unnecessary parameters.

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
 |  73 ++++++++-
 1 files changed, 62 insertions(+), 11 deletions(-)

diffs (161 lines):

diff -r 2c672b5fe425 -r 704efebf5095 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
     Thu Mar 31 12:02:33 2011 +0200
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
     Thu Mar 31 12:23:24 2011 +0200
@@ -191,13 +191,24 @@
 
       // Execution of callouts
       long t6 = System.currentTimeMillis();
-      boolean comboReloadNeeded = executeCallouts(mode, tab, columnValues, 
changedColumn,
+      List<String> changedCols = executeCallouts(mode, tab, columnValues, 
changedColumn,
           calloutsToCall, lastfieldChanged, calloutMessages, changeEventCols);
 
-      if (comboReloadNeeded) {
+      if (changedCols.size() > 0) {
+        List<String> columnsToComputeAgain = new ArrayList<String>();
+        for (String changedCol : changedCols) {
+          for (String colWithVal : columnsInValidation.keySet()) {
+            for (String colInVal : columnsInValidation.get(colWithVal)) {
+              if (colInVal.equalsIgnoreCase(changedCol)) {
+                if (!columnsToComputeAgain.contains(colInVal)) {
+                  columnsToComputeAgain.add(colWithVal);
+                }
+              }
+            }
+          }
+        }
         RequestContext.get().setRequestParameter("donotaddcurrentelement", 
"true");
-        computeColumnValues("CHANGE", tab, allColumns, columnValues, 
parentRecord, parentId, null,
-            jsContent, changeEventCols, calloutsToCall, lastfieldChanged);
+        subsequentComboReload(tab, columnsToComputeAgain, columnValues);
       }
 
       if (mode.equals("NEW")) {
@@ -459,6 +470,37 @@
     }
   }
 
+  private void subsequentComboReload(Tab tab, List<String> allColumns,
+      Map<String, JSONObject> columnValues) {
+    HashMap<String, Field> columnsOfFields = new HashMap<String, Field>();
+    for (Field field : tab.getADFieldList()) {
+      for (String col : allColumns) {
+        if (col.equalsIgnoreCase(field.getColumn().getDBColumnName())) {
+          columnsOfFields.put(col, field);
+        }
+      }
+    }
+    for (String col : allColumns) {
+      Field field = columnsOfFields.get(col);
+      try {
+        String columnId = field.getColumn().getId();
+        UIDefinition uiDef = 
UIDefinitionController.getInstance().getUIDefinition(columnId);
+        String value = uiDef.getFieldProperties(field, true);
+        JSONObject jsonobject = null;
+        if (value != null) {
+          jsonobject = new JSONObject(value);
+          columnValues.put("inp"
+              + 
Sqlc.TransformaNombreColumna(field.getColumn().getDBColumnName()), jsonobject);
+          setRequestContextParameter(field, jsonobject);
+        }
+      } catch (Exception e) {
+        throw new OBException(
+            "Couldn't get data for column " + 
field.getColumn().getDBColumnName(), e);
+      }
+    }
+
+  }
+
   private void computeAuxiliaryInputs(String mode, Tab tab, Map<String, 
JSONObject> columnValues) {
     for (AuxiliaryInput auxIn : tab.getADAuxiliaryInputList()) {
       Object value = computeAuxiliaryInput(auxIn, tab.getWindow().getId());
@@ -621,7 +663,7 @@
     for (Field field : fields) {
       String colName = field.getColumn().getDBColumnName();
       if (!columnsWithValidation.contains(field.getColumn().getDBColumnName())
-          && !sortedColumns.contains(colName)) {
+          && !sortedColumns.contains(colName) && 
!colName.equalsIgnoreCase("documentno")) {
         sortedColumns.add(colName);
       }
     }
@@ -633,6 +675,12 @@
           columnsInValidation);
     }
 
+    for (Field field : fields) {
+      String colName = field.getColumn().getDBColumnName();
+      if (colName.equalsIgnoreCase("documentno")) {
+        sortedColumns.add(colName);
+      }
+    }
     String cycleCols = "";
     for (String col : columnsWithValidation) {
       if (!sortedColumns.contains(col)) {
@@ -754,7 +802,7 @@
     return inpFields;
   }
 
-  private boolean executeCallouts(String mode, Tab tab, Map<String, 
JSONObject> columnValues,
+  private List<String> executeCallouts(String mode, Tab tab, Map<String, 
JSONObject> columnValues,
       String changedColumn, List<String> calloutsToCall, List<String> 
lastfieldChanged,
       List<String> messages, List<String> dynamicCols) {
 
@@ -775,20 +823,21 @@
 
     ArrayList<String> calledCallouts = new ArrayList<String>();
     if (calloutsToCall.isEmpty()) {
-      return false;
+      return new ArrayList<String>();
     }
     return runCallouts(columnValues, tab, calledCallouts, calloutsToCall, 
lastfieldChanged,
         messages, dynamicCols);
 
   }
 
-  private boolean runCallouts(Map<String, JSONObject> columnValues, Tab tab,
+  private List<String> runCallouts(Map<String, JSONObject> columnValues, Tab 
tab,
       List<String> calledCallouts, List<String> calloutsToCall, List<String> 
lastfieldChangedList,
       List<String> messages, List<String> dynamicCols) {
 
     // flush&commit to release lock in db which otherwise interfere with 
callouts which run in their
     // own jdbc connection (i.e. lock on AD_Sequence when using with Sales 
Invoice window)
     OBDal.getInstance().flush();
+    List<String> changedCols = new ArrayList<String>();
     try {
       OBDal.getInstance().getConnection().commit();
     } catch (SQLException e1) {
@@ -797,7 +846,6 @@
 
     List<Field> fields = tab.getADFieldList();
     HashMap<String, Field> inpFields = buildInpField(fields);
-    boolean comboReloadNeeded = false;
     String lastCalledCallout = "";
     String lastFieldOfLastCalloutCalled = "";
 
@@ -903,6 +951,9 @@
                                     .equals(newValue))) {
                               columnValues.put(colId, jsonobject);
                               changed = true;
+                              if (dynamicCols.contains(colId)) {
+                                changedCols.add(col.getDBColumnName());
+                              }
                             } else {
                               log
                                   .debug("Column value didn't change. We do 
not attempt to execute any additional callout");
@@ -937,7 +988,7 @@
                               + 
Sqlc.TransformaNombreColumna(col.getDBColumnName()), jsonobj);
                           changed = true;
                           if (dynamicCols.contains(colId)) {
-                            comboReloadNeeded = true;
+                            changedCols.add(col.getDBColumnName());
                           }
                           rq.setRequestParameter(colId, 
jsonobj.getString("classicValue"));
                         }
@@ -967,7 +1018,7 @@
     if (calledCallouts.size() == MAX_CALLOUT_CALLS) {
       log.warn("Warning: maximum number of callout calls reached");
     }
-    return comboReloadNeeded;
+    return changedCols;
 
   }
 

------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to