[Lada-commits] [PATCH 4 of 5] Add and use helper function for identification
Wald Commits
scm-commit at wald.intevation.org
Tue Nov 1 14:21:13 CET 2016
# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1478006351 -3600
# Node ID b2c3a59b40f8f9f748c4bb0cb7566b6a3e48a32e
# Parent 649ce9c425b31265112e33329112285916d81b44
Add and use helper function for identification.
diff -r 649ce9c425b3 -r b2c3a59b40f8 src/main/java/de/intevation/lada/importer/laf/LafObjectListener.java
--- 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;
diff -r 649ce9c425b3 -r b2c3a59b40f8 src/main/java/de/intevation/lada/importer/laf/LafRawData.java
--- 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 {
More information about the Lada-commits
mailing list