[Lada-commits] [PATCH 2 of 2] merged

Wald Commits scm-commit at wald.intevation.org
Tue Nov 1 15:02:02 CET 2016


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1478008913 -3600
# Node ID 39a12fa9421d1f208e5e46b90e76f0b8f30899b6
# Parent  f84b4fb82061a01b9d050647383facb2c150cd69
# Parent  c1713b7fbfa01f042ba8ce7612c7b14705b13d79
merged.

diff -r f84b4fb82061 -r 39a12fa9421d src/main/java/de/intevation/lada/importer/laf/LafErrorListener.java
--- a/src/main/java/de/intevation/lada/importer/laf/LafErrorListener.java	Tue Nov 01 15:01:03 2016 +0100
+++ b/src/main/java/de/intevation/lada/importer/laf/LafErrorListener.java	Tue Nov 01 15:01:53 2016 +0100
@@ -10,30 +10,31 @@
 import de.intevation.lada.importer.ReportItem;
 
 public class LafErrorListener extends BaseErrorListener {
+
     public static LafErrorListener INSTANCE =
         new LafErrorListener();
 
     private List<ReportItem> errors = new ArrayList<ReportItem>();
 
     @Override
-    public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol,
-                            int line, int charPositionInLine,
-                            String msg, RecognitionException e)
-    {
+    public void syntaxError(
+        Recognizer<?, ?> recognizer,
+        Object offendingSymbol,
+        int line,
+        int charPositionInLine,
+        String msg,
+        RecognitionException e
+    ) {
         String sourceName = "Parser";
         if (e != null && e.getCtx() != null) {
             sourceName = e.getCtx().getText();
         }
-        String token = "Token";
-        if (e != null && e.getOffendingToken() != null) {
-            e.getOffendingToken().getText();
-        }
+
         ReportItem err = new ReportItem();
         err.setKey(sourceName);
-        err.setValue(line + ":" + charPositionInLine + " - " + token);
+        err.setValue("line " + line + ": " + msg);
         err.setCode(670);
         this.errors.add(err);
-        System.err.println(err.getKey() + " - " +err.getValue() + " - " + err.getCode());
     }
 
     public void reset() {
diff -r f84b4fb82061 -r 39a12fa9421d src/main/java/de/intevation/lada/importer/laf/LafObjectListener.java
--- a/src/main/java/de/intevation/lada/importer/laf/LafObjectListener.java	Tue Nov 01 15:01:03 2016 +0100
+++ b/src/main/java/de/intevation/lada/importer/laf/LafObjectListener.java	Tue Nov 01 15:01:53 2016 +0100
@@ -83,18 +83,8 @@
         if (currentProbe != null) {
             data.addProbe(currentProbe);
             if (!currentErrors.isEmpty()) {
-                String identifier = currentProbe.getAttributes()
-                    .get("PROBE_ID");
-                identifier = identifier == null
-                    ? currentProbe.getAttributes().get("PROBEN_NR")
-                    : identifier;
-                identifier = identifier == null
-                    ? currentProbe.getAttributes().get("HAUPTPROBENNUMMER")
-                    : identifier;
-                identifier = identifier == null
-                    ? "not identified"
-                    : identifier;
-                errors.put(identifier, (ArrayList)currentErrors.clone());
+                errors.put(currentProbe.getIdentifier(),
+                    (ArrayList)currentErrors.clone());
             }
 
             currentErrors.clear();
@@ -127,15 +117,8 @@
     @Override public void exitProbe(LafParser.ProbeContext ctx) {
         data.addProbe(currentProbe);
         if (!currentErrors.isEmpty()) {
-            String identifier = currentProbe.getAttributes().get("PROBE_ID");
-            identifier = identifier == null
-                ? currentProbe.getAttributes().get("PROBEN_NR")
-                : identifier;
-            identifier = identifier == null
-                ? currentProbe.getAttributes().get("HAUPTPROBENNUMMER")
-                : identifier;
-            identifier = identifier == null ? "not identified" : identifier;
-            errors.put(identifier, (ArrayList)currentErrors.clone());
+            errors.put(currentProbe.getIdentifier(),
+                (ArrayList)currentErrors.clone());
         }
         currentErrors.clear();
         currentProbe = null;
diff -r f84b4fb82061 -r 39a12fa9421d src/main/java/de/intevation/lada/importer/laf/LafObjectMapper.java
--- a/src/main/java/de/intevation/lada/importer/laf/LafObjectMapper.java	Tue Nov 01 15:01:03 2016 +0100
+++ b/src/main/java/de/intevation/lada/importer/laf/LafObjectMapper.java	Tue Nov 01 15:01:53 2016 +0100
@@ -123,15 +123,14 @@
             ReportItem err = new ReportItem();
             err.setCode(699);
             err.setKey(userInfo.getName());
-            err.setValue(probe.getMstId());
+            err.setValue("Messstelle " + probe.getMstId());
             currentErrors.add(err);
-            if (currentErrors.size() > 0) {
-                List<ReportItem> copyErr = new ArrayList<ReportItem>(currentErrors);
-                errors.put(probe.getIdAlt(), copyErr);
-            }
+            errors.put(object.getIdentifier(),
+                new ArrayList<ReportItem>(currentErrors));
+
             if (currentWarnings.size() > 0) {
-                List<ReportItem> copyWarn = new ArrayList<ReportItem>(currentWarnings);
-                warnings.put(probe.getIdAlt(), copyWarn);
+                warnings.put(object.getIdentifier(),
+                    new ArrayList<ReportItem>(currentWarnings));
             }
             return;
         }
@@ -162,12 +161,12 @@
                 err.setValue("");
                 currentErrors.add(err);
                 if (currentErrors.size() > 0) {
-                    List<ReportItem> copyErr = new ArrayList<ReportItem>(currentErrors);
-                    errors.put(probe.getIdAlt(), copyErr);
+                    errors.put(object.getIdentifier(),
+                        new ArrayList<ReportItem>(currentErrors));
                 }
                 if (currentWarnings.size() > 0) {
-                    List<ReportItem> copyWarn = new ArrayList<ReportItem>(currentWarnings);
-                    warnings.put(probe.getIdAlt(), copyWarn);
+                    warnings.put(object.getIdentifier(),
+                        new ArrayList<ReportItem>(currentWarnings));
                 }
                 return;
             }
@@ -196,12 +195,12 @@
             err.setValue("No valid Probe Object");
             currentErrors.add(err);
             if (currentErrors.size() > 0) {
-                List<ReportItem> copyErr = new ArrayList<ReportItem>(currentErrors);
-                errors.put(probe.getIdAlt(), copyErr);
+                errors.put(object.getIdentifier(),
+                    new ArrayList<ReportItem>(currentErrors));
             }
             if (currentWarnings.size() > 0) {
-                List<ReportItem> copyWarn = new ArrayList<ReportItem>(currentWarnings);
-                warnings.put(probe.getIdAlt(), copyWarn);
+                warnings.put(object.getIdentifier(),
+                    new ArrayList<ReportItem>(currentWarnings));
             }
             return;
         }
@@ -237,12 +236,12 @@
         }
 
         if (currentErrors.size() > 0) {
-            List<ReportItem> copyErr = new ArrayList<ReportItem>(currentErrors);
-            errors.put(probe.getIdAlt(), copyErr);
+            errors.put(object.getIdentifier(),
+                new ArrayList<ReportItem>(currentErrors));
         }
         if (currentWarnings.size() > 0) {
-            List<ReportItem> copyWarn = new ArrayList<ReportItem>(currentWarnings);
-            warnings.put(probe.getIdAlt(), copyWarn);
+            warnings.put(object.getIdentifier(),
+                new ArrayList<ReportItem>(currentWarnings));
         }
     }
 
@@ -265,7 +264,6 @@
             return;
         }
 
-
         // Compare with messung objects in the db
         Messung newMessung = null;
         try {
diff -r f84b4fb82061 -r 39a12fa9421d src/main/java/de/intevation/lada/importer/laf/LafRawData.java
--- a/src/main/java/de/intevation/lada/importer/laf/LafRawData.java	Tue Nov 01 15:01:03 2016 +0100
+++ b/src/main/java/de/intevation/lada/importer/laf/LafRawData.java	Tue Nov 01 15:01:53 2016 +0100
@@ -67,6 +67,22 @@
         public List<Map<String, String>> getOrte() {
             return this.ort;
         }
+
+        // helper method to get identifying attribute
+        public String getIdentifier() {
+            String identifier = this.getAttributes().get("PROBE_ID");
+            identifier = identifier == null
+                ? this.getAttributes().get("PROBEN_NR")
+                : identifier;
+            identifier = identifier == null
+                ? this.getAttributes().get("HAUPTPROBENNUMMER")
+                : identifier;
+            identifier = identifier == null
+                ? "not identified"
+                : identifier;
+            return identifier;
+        }
+
     };
 
     public class Messung {
diff -r f84b4fb82061 -r 39a12fa9421d src/main/java/de/intevation/lada/rest/importer/LafImportService.java
--- a/src/main/java/de/intevation/lada/rest/importer/LafImportService.java	Tue Nov 01 15:01:03 2016 +0100
+++ b/src/main/java/de/intevation/lada/rest/importer/LafImportService.java	Tue Nov 01 15:01:53 2016 +0100
@@ -80,17 +80,9 @@
         importer.doImport(content, userInfo);
         Map<String, Object> respData = new HashMap<String,Object>();
         if (!importer.getErrors().isEmpty()) {
-            logger.debug("errs: " + importer.getErrors().size());
-            for (Entry<String, List<ReportItem>> entry : importer.getErrors().entrySet()) {
-                logger.debug(entry.getKey());
-                for (ReportItem item : entry.getValue()) {
-                    logger.debug(item.getKey() + " - " + item.getValue() + ": " + item.getCode());
-                }
-            }
             respData.put("errors", importer.getErrors());
         }
         if (!importer.getWarnings().isEmpty()) {
-            logger.debug("warns: " + importer.getWarnings().size());
             respData.put("warnings", importer.getWarnings());
         }
 


More information about the Lada-commits mailing list