details:   /erp/devel/pi/rev/7686b3400c4e
changeset: 9295:7686b3400c4e
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Wed Dec 22 10:47:57 2010 +0100
summary:   Fixed small issue with date parsing in the methods which set session 
parameters.

details:   /erp/devel/pi/rev/f6e784da4776
changeset: 9296:f6e784da4776
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Wed Dec 22 11:07:11 2010 +0100
summary:   Fixed validation dependency sorting issue which was related to 
casing in the column names inside the validation expression.

diffstat:

 
modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
 |  41 ++++++---
 1 files changed, 28 insertions(+), 13 deletions(-)

diffs (79 lines):

diff -r 5f7442b76cf0 -r f6e784da4776 
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
     Wed Dec 22 11:21:01 2010 +0100
+++ 
b/modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
     Wed Dec 22 11:07:11 2010 +0100
@@ -429,6 +429,20 @@
     }
   }
 
+  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);
@@ -436,17 +450,7 @@
 
     if (currentValue != null) {
       if (prop.isDate()) {
-        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        format.setLenient(true);
-        Date date;
-        try {
-          date = format.parse(currentValue.toString());
-        } catch (ParseException e) {
-          throw new OBException("Error while parsing date: " + currentValue, 
e);
-        }
-        SimpleDateFormat outFormat = new 
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
-        outFormat.setLenient(true);
-        currentValue = outFormat.format(date);
+        currentValue = parseDateFromDAL(currentValue);
       } else if (currentValue instanceof BaseOBObject) {
         if (prop.getReferencedProperty() != null) {
           currentValue = ((BaseOBObject) 
currentValue).get(prop.getReferencedProperty().getName());
@@ -465,7 +469,9 @@
         Property prop = 
object.getEntity().getPropertyByColumnName(col.getDBColumnName());
         Object value = object.get(prop.getName());
         if (value != null) {
-          if (value instanceof BaseOBObject) {
+          if (prop.isDate()) {
+            value = parseDateFromDAL(value);
+          } else if (value instanceof BaseOBObject) {
             value = ((BaseOBObject) value).getId();
           } else {
             value = 
UIDefinitionController.getInstance().getUIDefinition(col.getId())
@@ -730,7 +736,7 @@
       }
       boolean allColsSorted = true;
       for (String depCol : columnsInValidation.get(col)) {
-        if (!sortedColumns.contains(depCol))
+        if (!containsIgnoreCase(sortedColumns, depCol))
           allColsSorted = false;
       }
       if (allColsSorted)
@@ -740,6 +746,15 @@
     return null;
   }
 
+  private boolean containsIgnoreCase(List<String> list, String element) {
+    for (String e : list) {
+      if (e.equalsIgnoreCase(element)) {
+        return true;
+      }
+    }
+    return false;
+  }
+
   private String getValidation(Field field) {
     Column c = field.getColumn();
     String val = c.getValidation().getValidationCode();

------------------------------------------------------------------------------
Forrester recently released a report on the Return on Investment (ROI) of
Google Apps. They found a 300% ROI, 38%-56% cost savings, and break-even
within 7 months.  Over 3 million businesses have gone Google with Google Apps:
an online email calendar, and document program that's accessible from your 
browser. Read the Forrester report: http://p.sf.net/sfu/googleapps-sfnew
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to