changeset 9652:dd93bb84561d

Importer (s/u-info) extensions: cancelling bed-mobility import if wrong mobility keywords
author mschaefer
date Mon, 23 Mar 2020 15:03:11 +0100
parents eb3dfe900d8c
children 3b3c7513472e
files backend/src/main/java/org/dive4elements/river/importer/sinfo/importitem/BedMobilitySeriesImport.java backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/BedMobilityParser.java
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/importer/sinfo/importitem/BedMobilitySeriesImport.java	Mon Mar 23 15:00:04 2020 +0100
+++ b/backend/src/main/java/org/dive4elements/river/importer/sinfo/importitem/BedMobilitySeriesImport.java	Mon Mar 23 15:03:11 2020 +0100
@@ -48,7 +48,7 @@
     }
 
     @Override
-    public List<BedMobility> querySeriesItem(final Session session, final River river) {
+    public List<BedMobility> querySeriesItem(final Session session, final River river, final boolean doQueryParent) {
         final Query query = session.createQuery("FROM BedMobility WHERE river=:river");
         query.setParameter("river", river);
         return query.list();
--- a/backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/BedMobilityParser.java	Mon Mar 23 15:00:04 2020 +0100
+++ b/backend/src/main/java/org/dive4elements/river/importer/sinfo/parsers/BedMobilityParser.java	Mon Mar 23 15:03:11 2020 +0100
@@ -18,6 +18,7 @@
 import org.dive4elements.river.importer.Config;
 import org.dive4elements.river.importer.ImportRiver;
 import org.dive4elements.river.importer.common.AbstractParser;
+import org.dive4elements.river.importer.common.ParsingState;
 import org.dive4elements.river.importer.sinfo.importitem.BedMobilityKmLineImport;
 import org.dive4elements.river.importer.sinfo.importitem.BedMobilitySeriesImport;
 import org.dive4elements.river.model.sinfo.BedMobility;
@@ -37,6 +38,8 @@
 
     private static final String MOBILE_KEYWORD = "mobil";
 
+    private static final String STARR_KEYWORD = "starr";
+
     private static final String IMPORT_FILENAME = "Einteilung_der_Gewaessersohle.csv";
 
 
@@ -79,7 +82,13 @@
 
     @Override
     protected BedMobilityKmLineImport createKmLineImport(final Double km, final String[] values) {
-        return new BedMobilityKmLineImport(km, values[1].equalsIgnoreCase(MOBILE_KEYWORD));
+        if (values[1].equalsIgnoreCase(STARR_KEYWORD))
+            return new BedMobilityKmLineImport(km, false);
+        else if (values[1].equalsIgnoreCase(MOBILE_KEYWORD))
+            return new BedMobilityKmLineImport(km, values[1].equalsIgnoreCase(MOBILE_KEYWORD));
+        logLineError("Invalid Gewässersohle value");
+        this.headerParsingState = ParsingState.STOP;
+        return null;
     }
 
     @Override

http://dive4elements.wald.intevation.org