details:   /erp/devel/pi/rev/3fdeec43ca7f
changeset: 10185:3fdeec43ca7f
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Fri Jan 28 12:08:27 2011 +0100
summary:   Make title of link item clickable

details:   /erp/devel/pi/rev/941165ec8006
changeset: 10186:941165ec8006
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Fri Jan 28 12:09:20 2011 +0100
summary:   Removed unnecessary call to getTabInfoRequestProperties

details:   /erp/devel/pi/rev/d3a59ff303a2
changeset: 10187:d3a59ff303a2
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Fri Jan 28 12:10:35 2011 +0100
summary:   Changed function call to inline code

details:   /erp/devel/pi/rev/e8b61ceda628
changeset: 10188:e8b61ceda628
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Fri Jan 28 12:12:00 2011 +0100
summary:   FIC changed to prevent too many conversions

details:   /erp/devel/pi/rev/248542c7ef75
changeset: 10189:248542c7ef75
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Fri Jan 28 12:13:00 2011 +0100
summary:   Added client-side conversion to classic string

details:   /erp/devel/pi/rev/7738a08484f3
changeset: 10190:7738a08484f3
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Fri Jan 28 12:13:38 2011 +0100
summary:   Added client site conversion to classic format

details:   /erp/devel/pi/rev/97a2961f92b6
changeset: 10191:97a2961f92b6
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Fri Jan 28 12:14:11 2011 +0100
summary:   Made primitive conversion method publically available

details:   /erp/devel/pi/rev/eda64ec159be
changeset: 10192:eda64ec159be
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Fri Jan 28 12:24:36 2011 +0100
summary:   Split ob-utilities in several js files

details:   /erp/devel/pi/rev/5936bc0b19b9
changeset: 10193:5936bc0b19b9
user:      Martin Taal <martin.taal <at> openbravo.com>
date:      Fri Jan 28 13:03:49 2011 +0100
summary:   Merged heads

diffstat:

 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_WINDOW.xml
                                     |    2 +
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java
       |    4 +
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl
            |    3 +-
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
 |  134 +-
 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/OBViewTab.java
                   |   38 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-action-button.js
                  |    4 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-formitem-widgets.js
               |    2 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-standard-view.js
                  |   52 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities-date.js
                 |  225 +++
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities-number.js
               |  332 +++++
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-utilities.js
                      |  577 +---------
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-form.js
                      |    2 +-
 
modules/org.openbravo.client.application/web/org.openbravo.client.application/js/ob-view-grid.js
                      |    2 -
 modules/org.openbravo.client.kernel/src-db/database/sourcedata/AD_WINDOW.xml   
                                       |    1 +
 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelConstants.java
                              |   12 +-
 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/KernelUtils.java
                                  |   14 +
 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/BinaryUIDefinition.java
                 |    9 +
 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/BooleanUIDefinition.java
                |   24 +-
 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/DateUIDefinition.java
                   |   50 +-
 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/EnumUIDefinition.java
                   |    4 +-
 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/FKComboUIDefinition.java
                |    2 +-
 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/NumberUIDefinition.java
                 |   85 +-
 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/TextUIDefinition.java
                   |    8 +
 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinition.java
                       |   37 +-
 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/YesNoUIDefinition.java
                  |   19 +-
 modules/org.openbravo.client.myob/src-db/database/sourcedata/AD_WINDOW.xml     
                                       |    2 +
 
modules/org.openbravo.service.datasource/src-db/database/sourcedata/AD_WINDOW.xml
                                     |    1 +
 
modules/org.openbravo.service.json/src/org/openbravo/service/json/JsonToDataConverter.java
                            |   86 +-
 
modules/org.openbravo.userinterface.smartclient/web/org.openbravo.userinterface.smartclient/js/ob-smartclient.js
      |    3 +
 src-db/database/build-create.xml                                               
                                       |   16 +-
 src/org/openbravo/base/secureApp/VariablesSecureApp.java                       
                                       |    4 +-
 src/org/openbravo/erpCommon/ad_reports/ReportExpense_data.xsql                 
                                       |    4 +-
 src/org/openbravo/erpCommon/ad_reports/ReportProjectProfitabilityJR.java       
                                       |   24 +-
 src/org/openbravo/erpCommon/ad_reports/ReportProjectProfitability_data.xsql    
                                       |    8 +-
 34 files changed, 939 insertions(+), 851 deletions(-)

diffs (truncated from 2556 to 300 lines):

diff -r 6eefbd8d76eb -r 5936bc0b19b9 
modules/org.openbravo.client.application/src-db/database/sourcedata/AD_WINDOW.xml
--- 
a/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_WINDOW.xml
 Thu Jan 27 19:46:33 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src-db/database/sourcedata/AD_WINDOW.xml
 Fri Jan 28 13:03:49 2011 +0100
@@ -13,6 +13,7 @@
 <!--54AE252A40C34DA285FC48DA94EB3847-->  <PROCESSING><![CDATA[N]]></PROCESSING>
 <!--54AE252A40C34DA285FC48DA94EB3847-->  <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
 <!--54AE252A40C34DA285FC48DA94EB3847-->  
<AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--54AE252A40C34DA285FC48DA94EB3847-->  
<ISTHREADSAFE><![CDATA[N]]></ISTHREADSAFE>
 <!--54AE252A40C34DA285FC48DA94EB3847--></AD_WINDOW>
 
 <!--EBA40241D46D4FA4A24E4A09C61994AA--><AD_WINDOW>
@@ -30,6 +31,7 @@
 <!--EBA40241D46D4FA4A24E4A09C61994AA-->  <PROCESSING><![CDATA[N]]></PROCESSING>
 <!--EBA40241D46D4FA4A24E4A09C61994AA-->  <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
 <!--EBA40241D46D4FA4A24E4A09C61994AA-->  
<AD_MODULE_ID><![CDATA[9BA0836A3CD74EE4AB48753A47211BCC]]></AD_MODULE_ID>
+<!--EBA40241D46D4FA4A24E4A09C61994AA-->  
<ISTHREADSAFE><![CDATA[N]]></ISTHREADSAFE>
 <!--EBA40241D46D4FA4A24E4A09C61994AA--></AD_WINDOW>
 
 </data>
diff -r 6eefbd8d76eb -r 5936bc0b19b9 
modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java
   Thu Jan 27 19:46:33 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/ApplicationComponentProvider.java
   Fri Jan 28 13:03:49 2011 +0100
@@ -82,6 +82,10 @@
     globalResources.add(createStaticResource(
         "web/org.openbravo.client.application/js/ob-utilities.js", true));
     globalResources.add(createStaticResource(
+        "web/org.openbravo.client.application/js/ob-utilities-date.js", true));
+    globalResources.add(createStaticResource(
+        "web/org.openbravo.client.application/js/ob-utilities-number.js", 
true));
+    globalResources.add(createStaticResource(
         "web/org.openbravo.client.application/js/ob-formitem-widgets.js", 
true));
     
globalResources.add(createStaticResource("web/org.openbravo.client.application/js/ob-tab.js",
         false));
diff -r 6eefbd8d76eb -r 5936bc0b19b9 
modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl
--- 
a/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl
        Thu Jan 27 19:46:33 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/templates/ob-view-tab.js.ftl
        Fri Jan 28 13:03:49 2011 +0100
@@ -47,7 +47,8 @@
           property: '${field.propertyName?js_string}',
           column: '${field.columnName?js_string}', 
           dbColumn: '${field.dbColumnName?js_string}', 
-          sessionProperty: ${field.session}
+          sessionProperty: ${field.session},
+          type: '${field.typeName?js_string}'
         }<#if field_has_next>,</#if>
       </#list>
     ],
diff -r 6eefbd8d76eb -r 5936bc0b19b9 
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 Jan 27 19:46:33 2011 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
     Fri Jan 28 13:03:49 2011 +0100
@@ -21,10 +21,7 @@
 import java.lang.reflect.Method;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -65,6 +62,7 @@
 import org.openbravo.model.ad.ui.Field;
 import org.openbravo.model.ad.ui.Tab;
 import org.openbravo.service.db.DalConnectionProvider;
+import org.openbravo.service.json.JsonToDataConverter;
 import org.openbravo.service.json.JsonUtils;
 
 /**
@@ -78,6 +76,10 @@
  * Execution of callouts
  * 
  * Insertion of all relevant data in the session
+ * 
+ * Format: in the request and session the values are always formatted in 
classic mode. The ui
+ * definition computes jsonobjects which contain a value as well as a 
classicValue, the latter is
+ * placed in the request/session for subsequent callout computations.
  */
 public class FormInitializationComponent extends BaseActionHandler {
   private static final Logger log = 
Logger.getLogger(FormInitializationComponent.class);
@@ -284,6 +286,7 @@
       Field field = columnsOfFields.get(col);
       try {
         String columnId = field.getColumn().getId();
+        final Property prop = 
KernelUtils.getInstance().getPropertyFromColumn(field.getColumn());
         UIDefinition uiDef = 
UIDefinitionController.getInstance().getUIDefinition(columnId);
         String value = null;
         if (mode.equals("NEW")) {
@@ -315,14 +318,24 @@
           // On CHANGE and SETSESSION mode, the values are read from the 
request
           JSONObject jsCol = new JSONObject();
           String colName = "inp" + Sqlc.TransformaNombreColumna(col);
+          Object jsonValue = null;
           if (jsContent.has(colName)) {
-            jsCol.put("value", jsContent.get(colName));
-            value = jsCol.toString();
+            jsonValue = jsContent.get(colName);
           } else if (jsContent.has(field.getColumn().getDBColumnName())) {
             // Special case related to the primary key column, which is sent 
with its dbcolumnname
             // instead of the "inp" name
-            jsCol.put("value", 
jsContent.get(field.getColumn().getDBColumnName()));
-            value = jsCol.toString();
+            jsonValue = jsContent.get(field.getColumn().getDBColumnName());
+          }
+
+          if (prop.isPrimitive()) {
+            final Object propValue = JsonToDataConverter
+                .convertJsonToPropertyValue(prop, jsonValue);
+            final String classicStr = uiDef.convertToClassicString(propValue);
+            jsCol.put("value", propValue);
+            jsCol.put("classicValue", classicStr);
+          } else {
+            jsCol.put("value", jsonValue);
+            jsCol.put("classicValue", jsonValue);
           }
         }
         JSONObject jsonobject = null;
@@ -343,9 +356,8 @@
           if (mode.equals("NEW") || mode.equals("EDIT") || 
mode.equals("SETSESSION")) {
             if (field.getColumn().isStoredInSession() || 
field.getColumn().isKeyColumn()) {
               setSessionValue(tab.getWindow().getId() + "|"
-                  + field.getColumn().getDBColumnName().toUpperCase(),
-                  jsonobject.has("value") ? 
uiDef.formatValueToSQL(jsonobject.get("value")
-                      .toString()) : null);
+                  + field.getColumn().getDBColumnName().toUpperCase(), 
jsonobject
+                  .has("classicValue") ? jsonobject.get("classicValue") : 
null);
             }
           }
 
@@ -364,6 +376,7 @@
       JSONObject jsonObj = new JSONObject();
       try {
         jsonObj.put("value", value);
+        jsonObj.put("classicValue", value);
       } catch (JSONException e) {
         log.error("Error while computing auxiliary input " + auxIn.getName(), 
e);
       }
@@ -406,6 +419,7 @@
     } else if (mode.equals("CHANGE") || mode.equals("SETSESSION")) {
       // In CHANGE and SETSESSION we get them from the request
       for (Field field : fields) {
+        final Property prop = 
KernelUtils.getInstance().getPropertyFromColumn(field.getColumn());
         String inpColName = "inp"
             + 
Sqlc.TransformaNombreColumna(field.getColumn().getDBColumnName());
         try {
@@ -414,8 +428,15 @@
             if (jsContent.get(inpColName) == null
                 || jsContent.get(inpColName).toString().equals("null")) {
               value = null;
+            } else if (prop.isPrimitive()) {
+              // convert to a dal value
+              final Object propValue = 
JsonToDataConverter.convertJsonToPropertyValue(prop,
+                  jsContent.get(inpColName));
+              // convert to a valid classic string
+              value = UIDefinitionController.getInstance().getUIDefinition(
+                  field.getColumn().getId()).convertToClassicString(propValue);
             } else {
-              value = jsContent.get(inpColName).toString();
+              value = (String) jsContent.get(inpColName);
             }
             RequestContext.get().setRequestParameter(inpColName, value);
           }
@@ -545,34 +566,21 @@
     }
   }
 
-  private Object parseDateFromDAL(Object value) {
-    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-    format.setLenient(true);
-    Date date;
-    try {
-      date = format.parse(value.toString());
-    } catch (ParseException e) {
-      throw new OBException("Error while parsing date: " + value, e);
-    }
-    SimpleDateFormat outFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
-    outFormat.setLenient(true);
-    return outFormat.format(date);
-  }
-
   private void setValueOfColumnInRequest(BaseOBObject obj, String columnName) {
     Entity entity = obj.getEntity();
     Property prop = entity.getPropertyByColumnName(columnName);
     Object currentValue = obj.get(prop.getName());
 
     if (currentValue != null) {
-      if (prop.isDate() || prop.isDatetime()) {
-        currentValue = parseDateFromDAL(currentValue);
-      } else if (currentValue instanceof BaseOBObject) {
+      if (currentValue instanceof BaseOBObject) {
         if (prop.getReferencedProperty() != null) {
           currentValue = ((BaseOBObject) 
currentValue).get(prop.getReferencedProperty().getName());
         } else {
           currentValue = ((BaseOBObject) currentValue).getId();
         }
+      } else {
+        currentValue = 
UIDefinitionController.getInstance().getUIDefinition(prop.getColumnId())
+            .convertToClassicString(currentValue);
       }
       RequestContext.get().setRequestParameter("inp" + 
Sqlc.TransformaNombreColumna(columnName),
           currentValue.toString());
@@ -585,15 +593,15 @@
         Property prop = 
object.getEntity().getPropertyByColumnName(col.getDBColumnName());
         Object value = object.get(prop.getName());
         if (value != null) {
-          if (prop.isDate() || prop.isDatetime()) {
-            value = parseDateFromDAL(value);
-            value = 
UIDefinitionController.getInstance().getUIDefinition(col.getId())
-                .formatValueToSQL(value.toString());
-          } else if (value instanceof BaseOBObject) {
-            value = ((BaseOBObject) value).getId();
+          if (value instanceof BaseOBObject) {
+            if (prop.getReferencedProperty() != null) {
+              value = ((BaseOBObject) 
value).get(prop.getReferencedProperty().getName());
+            } else {
+              value = ((BaseOBObject) value).getId();
+            }
           } else {
             value = 
UIDefinitionController.getInstance().getUIDefinition(col.getId())
-                .formatValueToSQL(value.toString());
+                .convertToClassicString(value);
           }
           setSessionValue(tab.getWindow().getId() + "|" + 
col.getDBColumnName(), value);
         }
@@ -625,23 +633,12 @@
     try {
       String fieldId = "inp" + 
Sqlc.TransformaNombreColumna(field.getColumn().getDBColumnName());
       RequestContext.get().setRequestParameter(fieldId,
-          jsonObj.has("value") ? jsonObj.getString("value") : null);
+          jsonObj.has("classicValue") ? jsonObj.getString("classicValue") : 
null);
     } catch (JSONException e) {
       log.error("Couldn't read JSON parameter for column " + 
field.getColumn().getDBColumnName());
     }
   }
 
-  private void setRequestContextParameters(List<Field> fields, Map<String, 
JSONObject> columnValues) {
-    for (Field field : fields) {
-      String fieldId = "inp" + 
Sqlc.TransformaNombreColumna(field.getColumn().getDBColumnName());
-      JSONObject jsonObj = columnValues.get(fieldId);
-      if (jsonObj != null) {
-        setRequestContextParameter(field, jsonObj);
-      }
-    }
-
-  }
-
   private HashMap<String, Field> buildInpField(List<Field> fields) {
     HashMap<String, Field> inpFields = new HashMap<String, Field>();
     for (Field field : fields) {
@@ -709,9 +706,9 @@
           log.error("Couldn't find method in Callout " + calloutClassName);
         } else {
           RequestContext rq = RequestContext.get();
-          // We first prepare the data so that it's usable by the callout
-          formatColumnValues(columnValues, fields);
+
           RequestContext.get().setRequestParameter("inpLastFieldChanged", 
lastFieldChanged);
+
           // We then execute the callout
           CalloutServletConfig config = new 
CalloutServletConfig(calloutClassName, RequestContext
               .getServletContext());
@@ -723,9 +720,6 @@
           method.invoke(calloutInstance, arguments);
           String calloutResponse = fakeResponse.getOutputFromWriter();
 
-          // Now we restore the request data so that it's compatible with the 
UIDefinition
-          // computation
-          setRequestContextParameters(fields, columnValues);
           // Now we parse the callout response and modify the stored values of 
the columns modified
           // by the callout
           ArrayList<NativeArray> returnedArray = new ArrayList<NativeArray>();
@@ -759,8 +753,8 @@
                               .getUIDefinition(col.getId());
                           JSONObject jsonobject = new 
JSONObject(uiDef.getFieldProperties(inpFields
                               .get(name), true));
-                          if (jsonobject.has("value")) {
-                            String newValue = jsonobject.getString("value");
+                          if (jsonobject.has("classicValue")) {
+                            String newValue = 
jsonobject.getString("classicValue");
                             if ((oldValue == null && newValue != null)
                                 || (oldValue != null && newValue == null)
                                 || (oldValue != null && newValue != null && 
!oldValue
@@ -791,8 +785,8 @@
                           col.getId());
                       JSONObject jsonobj = new 
JSONObject(uiDef.getFieldProperties(inpFields
                           .get(name), true));
-                      if (jsonobj.has("value")) {
-                        String newValue = jsonobj.getString("value");
+                      if (jsonobj.has("classicValue")) {
+                        String newValue = jsonobj.getString("classicValue");
                         log
                             .debug("Modified column: " + col.getDBColumnName() 
+ "  Value: "
                                 + value);
@@ -803,12 +797,7 @@
                               + 
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

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to