details:   /erp/devel/pi/rev/4d2b8662a63f
changeset: 9364:4d2b8662a63f
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Thu Dec 23 16:09:41 2010 +0100
summary:   Throw exception when callout fails. Only get the BaseOBObject of the 
record when there is record id. Set back the request parameter after a returned 
value has been parsed from a callout response to prevent failures in the 
parsing of the next values.

details:   /erp/devel/pi/rev/67879a814f2e
changeset: 9365:67879a814f2e
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Thu Dec 23 16:10:32 2010 +0100
summary:   Removed unneeded doPost() method

details:   /erp/devel/pi/rev/4c920481c95f
changeset: 9366:4c920481c95f
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Thu Dec 23 17:50:53 2010 +0100
summary:   Fix small issue with timestamp columns

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
 |  42 +++------
 1 files changed, 15 insertions(+), 27 deletions(-)

diffs (109 lines):

diff -r 96da1e0b3a8f -r 4c920481c95f 
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 Dec 23 17:47:24 2010 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
     Thu Dec 23 17:50:53 2010 +0100
@@ -18,8 +18,6 @@
  */
 package org.openbravo.client.application.window;
 
-import java.io.IOException;
-import java.io.PrintWriter;
 import java.lang.reflect.Method;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -31,10 +29,6 @@
 import java.util.List;
 import java.util.Map;
 
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
 import org.apache.log4j.Logger;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
@@ -73,22 +67,6 @@
 
   private static final int MAX_CALLOUT_CALLS = 10;
 
-  private HttpServletResponse response;
-
-  public void doPost(HttpServletRequest localRequest, HttpServletResponse 
localResponse,
-      ServletContext localContext) throws IOException {
-    this.response = localResponse;
-    HashMap<String, Object> parameters = new HashMap<String, Object>();
-    parameters.put("MODE", "NEW");
-    parameters.put("TAB_ID", "186");
-    parameters.put("ROW_ID", "1000019");
-    JSONObject obj = execute(parameters, null);
-    PrintWriter out = response.getWriter();
-    out.print(obj.toString());
-    out.flush();
-    out.close();
-  }
-
   // @Override
   protected JSONObject execute(Map<String, Object> parameters, String content) 
{
     OBContext.setAdminMode(true);
@@ -111,7 +89,10 @@
       String changedColumn = (String) parameters.get("CHANGED_COLUMN");
       Tab tab = OBDal.getInstance().get(Tab.class, tabId);
       List<Field> fields = tab.getADFieldList();
-      BaseOBObject row = OBDal.getInstance().get(tab.getTable().getName(), 
rowId);
+      BaseOBObject row = null;
+      if (rowId != null) {
+        row = OBDal.getInstance().get(tab.getTable().getName(), rowId);
+      }
       Tab parentTab = null;
       BaseOBObject parentRecord = null;
       log.debug("TAB NAME: " + tab.getWindow().getName() + "." + tab.getName() 
+ " Tab Id:"
@@ -449,7 +430,7 @@
     Object currentValue = obj.get(prop.getName());
 
     if (currentValue != null) {
-      if (prop.isDate()) {
+      if (prop.isDate() || prop.isDatetime()) {
         currentValue = parseDateFromDAL(currentValue);
       } else if (currentValue instanceof BaseOBObject) {
         if (prop.getReferencedProperty() != null) {
@@ -469,7 +450,7 @@
         Property prop = 
object.getEntity().getPropertyByColumnName(col.getDBColumnName());
         Object value = object.get(prop.getName());
         if (value != null) {
-          if (prop.isDate()) {
+          if (prop.isDate() || prop.isDatetime()) {
             value = parseDateFromDAL(value);
           } else if (value instanceof BaseOBObject) {
             value = ((BaseOBObject) value).getId();
@@ -633,6 +614,8 @@
                         value = (String) el;
                       }
                       log.debug("Modified column: " + col.getDBColumnName() + 
"  Value: " + value);
+                      // We set the new value in the request, so that the 
JSONObject is computed
+                      // with the new value
                       rq.setRequestParameter(colId, value);
                       UIDefinition uiDef = 
UIDefinitionController.getInstance().getUIDefinition(
                           col.getId());
@@ -641,6 +624,11 @@
                       columnValues.put("inp" + 
Sqlc.TransformaNombreColumna(col.getDBColumnName()),
                           jsonobj);
                       changed = true;
+
+                      // We set the value as formatted in the JSONObject in 
the request, so that the
+                      // request now is format safe and additional 
getFieldProperties calls do not
+                      // fail
+                      rq.setRequestParameter(colId, 
jsonobj.getString("value"));
                     }
                     if (changed && col.getCallout() != null) {
                       // We need to fire this callout, as the column value was 
changed
@@ -653,9 +641,9 @@
           }
         }
       } catch (ClassNotFoundException e) {
-        log.error("Couldn't find class " + calloutClassName, e);
+        throw new OBException("Couldn't find class " + calloutClassName, e);
       } catch (Exception e) {
-        log.error("Couldn't execute callout (class " + calloutClassName + ")", 
e);
+        throw new OBException("Couldn't execute callout (class " + 
calloutClassName + ")", e);
       }
     }
     if (calledCallouts.size() == MAX_CALLOUT_CALLS) {

------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to