changeset 9636:ac41551a8e4d

Bundu/Bzws: Error message for missing channel/year, Nachtrag Pos. 20: import of two levels of infrastructure types
author mschaefer
date Mon, 11 Nov 2019 16:29:36 +0100
parents a03c54129819
children eb32f75c65c3
files artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/ChannelFinder.java backend/src/main/java/org/dive4elements/river/importer/sinfo/SInfoImporter.java backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/DepthEvolutionParser.java backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/InfrastructureParser.java backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/TkhParser.java
diffstat 5 files changed, 34 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/ChannelFinder.java	Thu Oct 31 15:24:23 2019 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/ChannelFinder.java	Mon Nov 11 16:29:36 2019 +0100
@@ -80,7 +80,7 @@
         if (channel != null)
             return new ChannelFinder(problems, channel);
 
-        problems.addProblem("channelfinder.empty");
+        problems.addProblem("bundu.channelfinder.empty");
         return null;
     }
 
--- a/backend/src/main/java/org/dive4elements/river/importer/sinfo/SInfoImporter.java	Thu Oct 31 15:24:23 2019 +0100
+++ b/backend/src/main/java/org/dive4elements/river/importer/sinfo/SInfoImporter.java	Mon Nov 11 16:29:36 2019 +0100
@@ -50,11 +50,11 @@
         INFRASTRUCTURE("Infrastrukturen_BWaStr"), //
         CHANNEL("Zu_gewaehrleistende_Fahrrinnenverhaeltnisse"), //
         COLLISION_EINZEL("Grundberuehrungen" + File.separator + "Einzeljahre"), //
-        TKH_NATUR("Transportkoerperhoehen" + File.separator + "Naturmessungen"), //
-        TKH_BERECHNUNG("Transportkoerperhoehen" + File.separator + "Berechnungsergebnisse"), //
+        TKH_NATUR("Transportkoerperhoehen" + File.separator + TkhParser.GroupDirectory.MEASUREMENT.getDirName()), //
+        TKH_BERECHNUNG("Transportkoerperhoehen" + File.separator + TkhParser.GroupDirectory.CALCULATION.getDirName()), //
         FLOW_DEPTH("Modellierte_Datensaetze" + File.separator + "Fliesstiefen"), //
-        DEPTH_EVOLUTION_AKTUELL("Fliesstiefenentwicklung" + File.separator + "Bezug_aktueller_GlW"), //
-        DEPTH_EVOLUTION_ETAPPEN("Fliesstiefenentwicklung" + File.separator + "GlW-Etappen");
+        DEPTH_EVOLUTION_AKTUELL("Fliesstiefenentwicklung" + File.separator + DepthEvolutionParser.GroupDirectory.AKTUELL.getDirName()), //
+        DEPTH_EVOLUTION_ETAPPEN("Fliesstiefenentwicklung" + File.separator + DepthEvolutionParser.GroupDirectory.ETAPPE.getDirName());
 
         private final String dirname;
 
--- a/backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/DepthEvolutionParser.java	Thu Oct 31 15:24:23 2019 +0100
+++ b/backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/DepthEvolutionParser.java	Mon Nov 11 16:29:36 2019 +0100
@@ -50,10 +50,10 @@
 
     private static final Pattern META_OLD_WSP = Pattern.compile("^#\\sHistorische Wasserspiegellage:\\s*([^;]*).*", Pattern.CASE_INSENSITIVE);
 
-    private enum GroupDirectory {
+    public enum GroupDirectory {
         NONE(DepthEvolution.Group.NONE, ""), //
-        AKTUELL(DepthEvolution.Group.AKTUELL, "Bezug_aktueller_GLW"), //
-        ETAPPE(DepthEvolution.Group.ETAPPE, "GLW-Etappen");
+        AKTUELL(DepthEvolution.Group.AKTUELL, "Bezug_aktueller_GlW"), //
+        ETAPPE(DepthEvolution.Group.ETAPPE, "GlW-Etappen");
 
         private final DepthEvolution.Group group;
         private final String dirname;
--- a/backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/InfrastructureParser.java	Thu Oct 31 15:24:23 2019 +0100
+++ b/backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/InfrastructureParser.java	Mon Nov 11 16:29:36 2019 +0100
@@ -41,7 +41,9 @@
 
     private static final Logger log = Logger.getLogger(InfrastructureParser.class);
 
-    private static final Pattern META_TYPE = Pattern.compile("^#\\sInfrastruktur:\\s*([^;]*).*", Pattern.CASE_INSENSITIVE);
+    private static final Pattern META_GROUP = Pattern.compile("^#\\sInfrastruktur:\\s*([^;]*).*", Pattern.CASE_INSENSITIVE);
+
+    private static final Pattern META_TYPE = Pattern.compile("^#\\sTyp\\/Bezeichnung:\\s*([^;]*).*", Pattern.CASE_INSENSITIVE);
 
     private static final Pattern META_PROVIDER = Pattern.compile("^#\\sDatenherkunft:\\s*([^;]*).*", Pattern.CASE_INSENSITIVE);
 
@@ -116,7 +118,9 @@
 
     @Override
     protected boolean handleMetaOther() {
-        if (handleMetaType())
+        if (handleMetaGroup())
+            return true;
+        else if (handleMetaType())
             return true;
         else if (handleMetaProvider())
             return true;
@@ -128,6 +132,25 @@
             return false;
     }
 
+    private boolean handleMetaGroup() {
+        final Matcher m = META_GROUP.matcher(this.currentLine);
+        if (m.matches()) {
+            this.metaPatternsMatched.add(META_GROUP);
+            if (this.river.getAnnotationClassifier() != null) {
+                final ImportAnnotationType group = this.river.getAnnotationClassifier().classifyDescription(m.group(1).trim(),
+                        this.river.getAnnotationClassifier().getDefaultType());
+                this.seriesHeader.setGroup(group);
+                log.info(String.format("Group name in file: '%s', will be assigned to database name '%s'", m.group(1).trim(), group.getName()));
+            }
+            else {
+                log.error("No annotation types file configured, cannot process group '" + m.group(1).trim() + "'");
+                this.headerParsingState = ParsingState.STOP;
+            }
+            return true;
+        }
+        return false;
+    }
+
     private boolean handleMetaType() {
         final Matcher m = META_TYPE.matcher(this.currentLine);
         if (m.matches()) {
--- a/backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/TkhParser.java	Thu Oct 31 15:24:23 2019 +0100
+++ b/backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/TkhParser.java	Mon Nov 11 16:29:36 2019 +0100
@@ -57,7 +57,7 @@
 
     private static final Pattern COLUMN_TITLE = Pattern.compile("Transportk((.)|(oe))rperh((.)|(oe))he\\s*\\((.+?)\\)\\s*\\[cm\\].*", Pattern.CASE_INSENSITIVE);
 
-    private enum GroupDirectory {
+    public enum GroupDirectory {
         NONE(Tkh.Group.NONE, ""), //
         CALCULATION(Tkh.Group.CALCULATION, "Berechnungsergebnisse"), //
         MEASUREMENT(Tkh.Group.MEASUREMENT, "Naturmessungen");

http://dive4elements.wald.intevation.org