changeset 1310:c5721e624c0e

Insert timestamp into audit trail changed fields instead of date string.
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 08 Mar 2017 15:59:47 +0100
parents d531e8e8afa2
children b5ab25b7ac2c
files src/main/java/de/intevation/lada/rest/AuditTrailService.java
diffstat 1 files changed, 12 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/rest/AuditTrailService.java	Wed Mar 08 10:15:50 2017 +0100
+++ b/src/main/java/de/intevation/lada/rest/AuditTrailService.java	Wed Mar 08 15:59:47 2017 +0100
@@ -346,16 +346,13 @@
         return result.get(0);
     }
 
-    private String formatDate(String format, String date) {
+    private Long formatDate(String format, String date) {
         DateFormat inFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssXXX");
-        DateFormat outFormat = new SimpleDateFormat("dd.MM.yyyy hh:mm");
-        Date input;
         try {
-            input = inFormat.parse(date);
+            return inFormat.parse(date).getTime();
         } catch (ParseException e) {
-            return date;
+            return 0L;
         }
-        return outFormat.format(input);
     }
 
     /**
@@ -366,19 +363,19 @@
             String key = i.next();
             if (mappings.containsKey(key)) {
                 TableMapper m = mappings.get(key);
-                String value = "";
                 if (m.mappingTable.equals("date")) {
-                    value = formatDate(m.valueField, node.get(key).asText());
+                    Long value = formatDate(m.valueField, node.get(key).asText());
+                    node.put(key, value);
                 }
                 else {
-                    value = translateId(
-                    m.mappingTable,
-                    m.valueField,
-                    node.get(key).asText(),
-                    "id",
-                    "stamm");
+                    String value = translateId(
+                        m.mappingTable,
+                        m.valueField,
+                        node.get(key).asText(),
+                        "id",
+                        "stamm");
+                    node.put(key, value);
                 }
-                node.put(key, value);
             }
         }
         return node;
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)