changeset 1136:39a12fa9421d

merged.
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 01 Nov 2016 15:01:53 +0100
parents f84b4fb82061 (current diff) c1713b7fbfa0 (diff)
children cf65bdff7843
files
diffstat 5 files changed, 49 insertions(+), 59 deletions(-) [+]
line wrap: on
line diff
--- 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() {
--- 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;
--- 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 {
--- 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 {
--- 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());
         }
 
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)