Mercurial > lada > lada-server
changeset 1133:b2c3a59b40f8
Add and use helper function for identification.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Tue, 01 Nov 2016 14:19:11 +0100 |
parents | 649ce9c425b3 |
children | c1713b7fbfa0 |
files | src/main/java/de/intevation/lada/importer/laf/LafObjectListener.java src/main/java/de/intevation/lada/importer/laf/LafRawData.java |
diffstat | 2 files changed, 20 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/importer/laf/LafObjectListener.java Tue Nov 01 13:21:25 2016 +0100 +++ b/src/main/java/de/intevation/lada/importer/laf/LafObjectListener.java Tue Nov 01 14:19:11 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/LafRawData.java Tue Nov 01 13:21:25 2016 +0100 +++ b/src/main/java/de/intevation/lada/importer/laf/LafRawData.java Tue Nov 01 14:19:11 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 {