diff backend/src/main/java/org/dive4elements/river/importer/sinfo/importitem/InfrastructureSeriesImport.java @ 8971:50416a0df385

Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
author mschaefer
date Tue, 03 Apr 2018 10:18:30 +0200
parents
children 4c5eeaff554c
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backend/src/main/java/org/dive4elements/river/importer/sinfo/importitem/InfrastructureSeriesImport.java	Tue Apr 03 10:18:30 2018 +0200
@@ -0,0 +1,88 @@
+/* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
+ * Software engineering by
+ *  Björnsen Beratende Ingenieure GmbH
+ *  Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.importer.sinfo.importitem;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.dive4elements.river.importer.ImportAnnotationType;
+import org.dive4elements.river.importer.common.AbstractSeriesImport;
+import org.dive4elements.river.model.River;
+import org.dive4elements.river.model.sinfo.Infrastructure;
+import org.dive4elements.river.model.sinfo.InfrastructureValue;
+import org.hibernate.Query;
+import org.hibernate.Session;
+
+/**
+ * Imported infrastructure data series of a river and a type
+ *
+ * @author Matthias Schäfer
+ *
+ */
+public class InfrastructureSeriesImport extends AbstractSeriesImport<Infrastructure, InfrastructureValue, InfrastructureKmLineImport> {
+
+    /***** FIELDS *****/
+
+    private static Logger log = Logger.getLogger(InfrastructureSeriesImport.class);
+
+    private ImportAnnotationType type;
+
+    private String provider;
+
+    private String evaluation_by;
+
+    private int year;
+
+
+    /***** CONSTRUCTORS *****/
+
+    public InfrastructureSeriesImport(final String filename) {
+        super(filename);
+    }
+
+
+    /***** METHODS *****/
+
+    public void setType(final ImportAnnotationType type) {
+        this.type = type;
+    }
+
+    public void setProvider(final String provider) {
+        this.provider = provider;
+    }
+
+    public void setEvaluation_by(final String evaluation_by) {
+        this.evaluation_by = evaluation_by;
+    }
+
+    public void setYear(final int year) {
+        this.year = year;
+    }
+
+    @Override
+    public Logger getLog() {
+        return log;
+    }
+
+    @Override
+    public List<Infrastructure> querySeriesItem(final Session session, final River river) {
+        final Query query = session.createQuery("FROM Infrastructure WHERE river=:river AND lower(filename)=:filename");
+        query.setParameter("river", river);
+        query.setParameter("filename", this.filename.toLowerCase());
+        return query.list();
+    }
+
+
+    @Override
+    public Infrastructure createSeriesItem(final River river) {
+        return new Infrastructure(river, this.filename, this.kmrange_info, this.comment, this.type.getPeer(), this.year, this.provider, this.evaluation_by);
+    }
+}
\ No newline at end of file

http://dive4elements.wald.intevation.org