diff backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/InfrastructureParser.java @ 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 ddebd4c2fe93
children 75bd347147ad
line wrap: on
line diff
--- 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()) {

http://dive4elements.wald.intevation.org