diff flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java @ 2811:8926571e47fb

Finished importing MINFO bed heights (single and epoch). flys-backend/trunk@4225 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 13 Apr 2012 07:24:55 +0000
parents 04eeb45df27b
children 0d27d02b1208
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java	Thu Apr 12 12:50:49 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java	Fri Apr 13 07:24:55 2012 +0000
@@ -18,7 +18,7 @@
 import de.intevation.flys.model.TimeInterval;
 
 
-public class ImportBedHeightEpoch
+public class ImportBedHeightEpoch implements ImportBedHeight
 {
     private static Logger log = Logger.getLogger(ImportBedHeightEpoch.class);
 
@@ -46,8 +46,12 @@
     }
 
 
-    public List<ImportBedHeightEpochValue> getValues() {
-        return values;
+    public int getValueCount() {
+        return values.size();
+    }
+
+    public void setTimeInterval(ImportTimeInterval timeInterval) {
+        this.timeInterval = timeInterval;
     }
 
 
@@ -71,11 +75,29 @@
         this.oldElevationModel = oldElevationModel;
     }
 
-    public void addValue(ImportBedHeightEpochValue value) {
-        values.add(value);
+    public void setYear(int year) {
+        // do nothing
+    }
+
+    public void setSoundingWidth(int soundingWidth) {
+        // do nothing
+    }
+
+    public void setLocationSystem(ImportLocationSystem locationSystem) {
+        // do nothing
+    }
+
+    public void setType(ImportBedHeightType type) {
+        // do nothing
+    }
+
+    @Override
+    public void addValue(ImportBedHeightValue value) {
+        values.add((ImportBedHeightEpochValue) value);
     }
 
 
+    @Override
     public void storeDependencies(River river)
     throws SQLException, ConstraintViolationException
     {
@@ -96,23 +118,37 @@
         for (ImportBedHeightEpochValue value: values) {
             value.storeDependencies(peer);
         }
+
+        Session session = ImporterSession.getInstance().getDatabaseSession();
+        session.flush();
     }
 
 
+    @Override
     public BedHeightEpoch getPeer(River river) {
         if (peer == null) {
             ElevationModel theCurModel = curElevationModel != null
                 ? curElevationModel.getPeer()
                 : null;
 
+            if (theCurModel == null) {
+                log.warn("Skip file - invalid current elevation model.");
+                return null;
+            }
+
             TimeInterval theTime = timeInterval != null
                 ? timeInterval.getPeer()
                 : null;
 
+            if (theTime == null) {
+                log.warn("Skip file - invalid time range.");
+                return null;
+            }
+
             Range theRange = range != null ? range.getPeer(river) : null;
 
-            if (theCurModel == null || theRange == null || theTime == null) {
-                log.warn("Skip invalid file '" + description + "'");
+            if (theRange == null) {
+                log.warn("Skip file - invalid km range.");
                 return null;
             }
 
@@ -124,7 +160,7 @@
                 "   timeInterval=:timeInterval and " +
                 "   curElevationModel=:curElevationModel and " +
                 "   range=:range and " +
-                "   evaluationBy=: evaluationBy and " +
+                "   evaluationBy=:evaluationBy and " +
                 "   description=:description");
 
             query.setParameter("river", river);
@@ -148,6 +184,8 @@
                     evaluationBy,
                     description
                 );
+
+                session.save(peer);
             }
             else {
                 peer = bedHeights.get(0);

http://dive4elements.wald.intevation.org