changeset 3949:145b87bcb10a

Some minor bugfixes for MINFO import. flys-backend/trunk@5586 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 24 Sep 2012 09:14:48 +0000
parents 883dd49d5e74
children 82e931f88137
files flys-backend/ChangeLog flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java flys-backend/src/main/java/de/intevation/flys/importer/ImportElevationModel.java
diffstat 3 files changed, 24 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Mon Sep 24 09:13:29 2012 +0000
+++ b/flys-backend/ChangeLog	Mon Sep 24 09:14:48 2012 +0000
@@ -1,3 +1,9 @@
+2012-09-24  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java,
+	  src/main/java/de/intevation/flys/importer/ImportElevationModel.java:
+	  Some minor bugfixes for MINFO import.
+
 2012-09-24  Ingo Weinzierl <ingo@intevation.de>
 
 	* doc/schema/postgresql-spatial.sql: Adapted schema; added missing
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java	Mon Sep 24 09:13:29 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java	Mon Sep 24 09:14:48 2012 +0000
@@ -1,14 +1,12 @@
 package de.intevation.flys.importer;
 
+import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
-import java.sql.SQLException;
-
 import org.apache.log4j.Logger;
-
+import org.hibernate.Query;
 import org.hibernate.Session;
-import org.hibernate.Query;
 import org.hibernate.exception.ConstraintViolationException;
 
 import de.intevation.flys.model.BedHeightEpoch;
@@ -97,6 +95,8 @@
         ConstraintViolationException {
         log.info("Store dependencies for epoch: '" + getDescription() + "'");
 
+        BedHeightEpoch peer = getPeer(river);
+
         if (curElevationModel != null) {
             curElevationModel.storeDependencies();
         }
@@ -105,8 +105,6 @@
             oldElevationModel.storeDependencies();
         }
 
-        BedHeightEpoch peer = getPeer(river);
-
         if (peer != null) {
             log.debug("store values now...");
 
@@ -122,16 +120,21 @@
     @Override
     public BedHeightEpoch getPeer(River river) {
         if (peer == null) {
-            ElevationModel theCurModel = curElevationModel != null ? curElevationModel
-                .getPeer() : null;
+            ElevationModel theCurModel = null;
+            if (curElevationModel != null) {
+                curElevationModel.storeDependencies();
+                theCurModel = curElevationModel.getPeer();
+            }
 
             if (theCurModel == null) {
                 log.warn("BHE: Skip file - invalid current elevation model.");
                 return null;
             }
 
-            TimeInterval theTime = timeInterval != null ? timeInterval
-                .getPeer() : null;
+            TimeInterval theTime = null;
+            if (timeInterval != null) {
+                theTime = timeInterval.getPeer();
+            }
 
             if (theTime == null) {
                 log.warn("BHE: Skip file - invalid time range.");
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportElevationModel.java	Mon Sep 24 09:13:29 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportElevationModel.java	Mon Sep 24 09:14:48 2012 +0000
@@ -33,6 +33,11 @@
     }
 
     public ElevationModel getPeer() {
+        if (unit == null) {
+            log.warn("No elevation model specified.");
+            return null;
+        }
+        
         if (peer == null) {
             Session session = ImporterSession.getInstance().getDatabaseSession();
             Query query = session.createQuery(

http://dive4elements.wald.intevation.org