changeset 6823:827da1952ce2 double-precision

Importer: force import of waterlevel WST-file in first run.
author Tom Gottfried <tom.gottfried@intevation.de>
date Wed, 14 Aug 2013 12:10:44 +0200
parents 1d60614c1059
children 3717d9d2f659
files backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java	Tue Aug 13 09:51:15 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java	Wed Aug 14 12:10:44 2013 +0200
@@ -1153,6 +1153,18 @@
     }
 
     public void storeDependencies() {
+        /* test whether river is already in database.
+         * Otherwise it makes no sense to skip waterlevel model WST-file
+         * because the altitude reference is taken from there. */
+        Session session = ImporterSession.getInstance().getDatabaseSession();
+        Query query = session.createQuery("from River where name=:name");
+        query.setString("name", name);
+        List<River> rivers = query.list();
+        if (rivers.isEmpty() && Config.INSTANCE.skipWst()){
+            log.error("River not yet in database. You cannot skip importing waterlevel model.");
+            return;
+        }
+
         storeWstUnit();
         storeAnnotations();
         storeHYKs();
@@ -1178,7 +1190,7 @@
 
     public void storeWstUnit() {
         if (wst == null) {
-            wstUnit = new ImportUnit("NN + m");
+            log.warn("No unit given. Waterlevel-model WST-file has to be imported already.");
         }
         else {
             wstUnit = wst.getUnit();

http://dive4elements.wald.intevation.org