details:   /erp/devel/pi/rev/c3dd7be39178
changeset: 13093:c3dd7be39178
user:      Antonio Moreno <antonio.moreno <at> openbravo.com>
date:      Mon Jul 04 10:28:33 2011 +0200
summary:   Related to issue 17789. The preference for the decimal separator 
will be correctly used if it is set.

diffstat:

 
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServlet.java
 |  21 ++++++---
 1 files changed, 14 insertions(+), 7 deletions(-)

diffs (54 lines):

diff -r 40d529162dd7 -r c3dd7be39178 
modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServlet.java
--- 
a/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServlet.java
      Mon Jul 04 10:03:18 2011 +0200
+++ 
b/modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceServlet.java
      Mon Jul 04 10:28:33 2011 +0200
@@ -234,6 +234,7 @@
     Writer writer;
     String fieldSeparator;
     String decimalSeparator;
+    String prefDecimalSeparator;
     List<String> fieldProperties;
     Map<String, String> niceFieldProperties = new HashMap<String, String>();
     boolean propertiesWritten = false;
@@ -252,14 +253,13 @@
         writer = response.getWriter();
         VariablesSecureApp vars = new VariablesSecureApp(request);
         try {
-          decimalSeparator = 
Preferences.getPreferenceValue("OBSERDS_CSVDecimalSeparator", true,
-              null, null, OBContext.getOBContext().getUser(), null, null);
+          prefDecimalSeparator = 
Preferences.getPreferenceValue("OBSERDS_CSVDecimalSeparator",
+              true, null, null, OBContext.getOBContext().getUser(), null, 
null);
         } catch (PropertyNotFoundException e) {
-          // There is no preference for the decimal separator. Getting it from 
the Format.xml
-          // configuration
-          decimalSeparator = 
vars.getSessionValue("#DecimalSeparator|generalQtyEdition").substring(
-              0, 1);
+          // There is no preference for the decimal separator.
         }
+        decimalSeparator = 
vars.getSessionValue("#DecimalSeparator|generalQtyEdition").substring(0,
+            1);
         try {
           fieldSeparator = 
Preferences.getPreferenceValue("OBSERDS_CSVFieldSeparator", true, null,
               null, OBContext.getOBContext().getUser(), null, null);
@@ -267,7 +267,8 @@
           // There is no preference for the field separator. Using the default 
one.
           fieldSeparator = ",";
         }
-        if (decimalSeparator.equals(fieldSeparator)) {
+        if ((prefDecimalSeparator != null && 
prefDecimalSeparator.equals(fieldSeparator))
+            || (prefDecimalSeparator == null && 
decimalSeparator.equals(fieldSeparator))) {
           if (!fieldSeparator.equals(";")) {
             fieldSeparator = ";";
           } else {
@@ -451,6 +452,12 @@
               keyValue = keyValue.toString().replace(".", decimalSeparator);
             } else {
               keyValue = format.format(new BigDecimal(keyValue.toString()));
+              if (prefDecimalSeparator != null) {
+                keyValue = keyValue.toString().replace(
+                    format.getDecimalFormatSymbols().getDecimalSeparator(),
+                    prefDecimalSeparator.charAt(0));
+              }
+
             }
           } else if (dateCols.contains(key) && keyValue != null
               && !keyValue.toString().equals("null")) {

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to