[Lada-commits] [PATCH] Insert timestamp into audit trail changed fields instead of date string

Wald Commits scm-commit at wald.intevation.org
Wed Mar 8 15:59:58 CET 2017


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1488985187 -3600
# Node ID c5721e624c0e9d2dee899a37d7c46471938fee0d
# Parent  d531e8e8afa22a5f18cc62ebb5be2cd19a478e4b
Insert timestamp into audit trail changed fields instead of date string.

diff -r d531e8e8afa2 -r c5721e624c0e src/main/java/de/intevation/lada/rest/AuditTrailService.java
--- 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;


More information about the Lada-commits mailing list