changeset 2809:f283212966e8

Finished work on MINFO bed heights (single). flys-backend/trunk@4221 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 12 Apr 2012 10:42:46 +0000
parents b57c95094b68
children 04eeb45df27b
files flys-backend/ChangeLog flys-backend/doc/schema/oracle-drop-minfo.sql flys-backend/doc/schema/oracle-minfo.sql flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightSingle.java flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightSingleValue.java flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightType.java flys-backend/src/main/java/de/intevation/flys/importer/ImportElevationModel.java flys-backend/src/main/java/de/intevation/flys/importer/ImportLocationSystem.java flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java flys-backend/src/main/java/de/intevation/flys/importer/parsers/BedHeightSingleParser.java flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingle.java flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingleValue.java flys-backend/src/main/java/de/intevation/flys/model/BedHeightType.java flys-backend/src/main/java/de/intevation/flys/model/ElevationModel.java flys-backend/src/main/java/de/intevation/flys/model/LocationSystem.java
diffstat 16 files changed, 955 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Wed Apr 11 13:12:52 2012 +0000
+++ b/flys-backend/ChangeLog	Thu Apr 12 10:42:46 2012 +0000
@@ -1,3 +1,31 @@
+2012-04-12  Ingo Weinzierl <ingo@intevation.de>
+
+	* doc/schema/oracle-minfo.sql,
+	  doc/schema/oracle-drop-minfo.sql: Schema adaptions specific to MINFO bed
+	  heights.
+
+	* src/main/java/de/intevation/flys/model/BedHeightSingleValue.java,
+	  src/main/java/de/intevation/flys/model/BedHeightType.java,
+	  src/main/java/de/intevation/flys/model/ElevationModel.java,
+	  src/main/java/de/intevation/flys/model/LocationSystem.java,
+	  src/main/java/de/intevation/flys/model/BedHeightSingle.java: New model
+	  classes for MINFO bed heights.
+
+	* src/main/java/de/intevation/flys/importer/parsers/BedHeightSingleParser.java:
+	  Some logging adjustments and a little bugfix: add BedHeightSingle objects
+	  after they were parsed; otherwise they are not saved to database.
+
+	* src/main/java/de/intevation/flys/importer/ImportBedHeightSingleValue.java,
+	  src/main/java/de/intevation/flys/importer/ImportBedHeightSingle.java,
+	  src/main/java/de/intevation/flys/importer/ImportElevationModel.java,
+	  src/main/java/de/intevation/flys/importer/ImportLocationSystem.java,
+	  src/main/java/de/intevation/flys/importer/ImportBedHeightType.java,
+	  src/main/java/de/intevation/flys/importer/ImportRiver.java: Implemented
+	  storeDependencies() and getPeer().
+
+	* src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java:
+	  Registered model classes.
+
 2012-04-11  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/importer/parsers/BedHeightSingleParser.java:
--- a/flys-backend/doc/schema/oracle-drop-minfo.sql	Wed Apr 11 13:12:52 2012 +0000
+++ b/flys-backend/doc/schema/oracle-drop-minfo.sql	Thu Apr 12 10:42:46 2012 +0000
@@ -1,6 +1,7 @@
 SET AUTOCOMMIT ON;
 
 ALTER TABLE elevation_model DROP CONSTRAINT fk_unit;
+ALTER TABLE bed_height_single DROP CONSTRAINT fk_bed_single_river_id;
 ALTER TABLE bed_height_single DROP CONSTRAINT fk_type;
 ALTER TABLE bed_height_single DROP CONSTRAINT fk_location_system;
 ALTER TABLE bed_height_single DROP CONSTRAINT fk_cur_elevation_model;
@@ -8,10 +9,9 @@
 ALTER TABLE bed_height_single DROP CONSTRAINT fk_range;
 ALTER TABLE bed_height_single_values DROP CONSTRAINT fk_bed_single_values_parent;
 ALTER TABLE bed_height_epoch_values DROP CONSTRAINT fk_bed_epoch_values_parent;
-ALTER TABLE bed_height_epoch DROP CONSTRAINT fk_type;
-ALTER TABLE bed_height_epoch DROP CONSTRAINT fk_cur_elevation_model;
-ALTER TABLE bed_height_epoch DROP CONSTRAINT fk_old_elevation_model;
-ALTER TABLE bed_height_epoch DROP CONSTRAINT fk_range;
+ALTER TABLE bed_height_epoch DROP CONSTRAINT fk_epoch_cur_elevation_model;
+ALTER TABLE bed_height_epoch DROP CONSTRAINT fk_epoch_old_elevation_model;
+ALTER TABLE bed_height_epoch DROP CONSTRAINT fk_epoch_range;
 
 DROP TABLE bed_height_type;
 DROP TABLE location_system;
--- a/flys-backend/doc/schema/oracle-minfo.sql	Wed Apr 11 13:12:52 2012 +0000
+++ b/flys-backend/doc/schema/oracle-minfo.sql	Thu Apr 12 10:42:46 2012 +0000
@@ -35,6 +35,7 @@
 
 CREATE TABLE bed_height_single (
     id                      NUMBER(38,0) NOT NULL,
+    river_id                NUMBER(38,0) NOT NULL,
     year                    NUMBER(38,0) NOT NULL,
     sounding_width          NUMBER(38,0) NOT NULL,
     type_id                 NUMBER(38,0) NOT NULL,
@@ -45,6 +46,7 @@
     evaluation_by           VARCHAR(255),
     description             VARCHAR(255),
     PRIMARY KEY(id),
+    CONSTRAINT fk_bed_single_river_id FOREIGN KEY (river_id) REFERENCES rivers(id),
     CONSTRAINT fk_type FOREIGN KEY (type_id) REFERENCES bed_height_type(id),
     CONSTRAINT fk_location_system FOREIGN KEY (location_system_id) REFERENCES location_system(id),
     CONSTRAINT fk_cur_elevation_model FOREIGN KEY (cur_elevation_model_id) REFERENCES elevation_model(id),
--- a/flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java	Wed Apr 11 13:12:52 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java	Thu Apr 12 10:42:46 2012 +0000
@@ -24,6 +24,9 @@
 import de.intevation.flys.model.Annotation;
 import de.intevation.flys.model.AnnotationType;
 import de.intevation.flys.model.Attribute;
+import de.intevation.flys.model.BedHeightSingle;
+import de.intevation.flys.model.BedHeightSingleValue;
+import de.intevation.flys.model.BedHeightType;
 import de.intevation.flys.model.Building;
 import de.intevation.flys.model.Catchment;
 import de.intevation.flys.model.CrossSection;
@@ -34,6 +37,7 @@
 import de.intevation.flys.model.DischargeTable;
 import de.intevation.flys.model.DischargeTableValue;
 import de.intevation.flys.model.Edge;
+import de.intevation.flys.model.ElevationModel;
 import de.intevation.flys.model.Fixpoint;
 import de.intevation.flys.model.Floodmaps;
 import de.intevation.flys.model.Floodplain;
@@ -45,6 +49,7 @@
 import de.intevation.flys.model.HYKFlowZoneType;
 import de.intevation.flys.model.HYKFlowZone;
 import de.intevation.flys.model.Line;
+import de.intevation.flys.model.LocationSystem;
 import de.intevation.flys.model.MainValueType;
 import de.intevation.flys.model.NamedMainValue;
 import de.intevation.flys.model.MainValue;
@@ -213,6 +218,9 @@
         cfg.addAnnotatedClass(Annotation.class);
         cfg.addAnnotatedClass(AnnotationType.class);
         cfg.addAnnotatedClass(Attribute.class);
+        cfg.addAnnotatedClass(BedHeightSingle.class);
+        cfg.addAnnotatedClass(BedHeightSingleValue.class);
+        cfg.addAnnotatedClass(BedHeightType.class);
         cfg.addAnnotatedClass(Building.class);
         cfg.addAnnotatedClass(Catchment.class);
         cfg.addAnnotatedClass(CrossSection.class);
@@ -223,6 +231,7 @@
         cfg.addAnnotatedClass(DischargeTable.class);
         cfg.addAnnotatedClass(DischargeTableValue.class);
         cfg.addAnnotatedClass(Edge.class);
+        cfg.addAnnotatedClass(ElevationModel.class);
         cfg.addAnnotatedClass(Fixpoint.class);
         cfg.addAnnotatedClass(Floodplain.class);
         cfg.addAnnotatedClass(Floodmaps.class);
@@ -234,6 +243,7 @@
         cfg.addAnnotatedClass(HYKFlowZoneType.class);
         cfg.addAnnotatedClass(HYKFlowZone.class);
         cfg.addAnnotatedClass(Line.class);
+        cfg.addAnnotatedClass(LocationSystem.class);
         cfg.addAnnotatedClass(MainValueType.class);
         cfg.addAnnotatedClass(NamedMainValue.class);
         cfg.addAnnotatedClass(MainValue.class);
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightSingle.java	Wed Apr 11 13:12:52 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightSingle.java	Thu Apr 12 10:42:46 2012 +0000
@@ -3,8 +3,18 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import java.sql.SQLException;
+
 import org.apache.log4j.Logger;
 
+import org.hibernate.Session;
+import org.hibernate.Query;
+import org.hibernate.exception.ConstraintViolationException;
+
+import de.intevation.flys.model.BedHeightSingle;
+import de.intevation.flys.model.BedHeightType;
+import de.intevation.flys.model.ElevationModel;
+import de.intevation.flys.model.Range;
 import de.intevation.flys.model.River;
 
 
@@ -26,6 +36,8 @@
 
     protected List<ImportBedHeightSingleValue> values;
 
+    protected BedHeightSingle peer;
+
 
     public ImportBedHeightSingle(String description) {
         this.description = description;
@@ -37,6 +49,10 @@
         return description;
     }
 
+    public List<ImportBedHeightSingleValue> getValues() {
+        return values;
+    }
+
 
     public void setYear(int year) {
         this.year = year;
@@ -78,9 +94,86 @@
         values.add(value);
     }
 
-    public void storeDependencies(River river) {
+    public void storeDependencies(River river)
+    throws SQLException, ConstraintViolationException
+    {
         log.info("Store dependencies for single: '" + getDescription() + "'");
-        log.error("TODO: IMPLEMENT ME!");
+
+        if (type != null) {
+            type.storeDependencies();
+        }
+
+        if (locationSystem != null) {
+            locationSystem.storeDependencies();
+        }
+
+        if (curElevationModel != null) {
+            curElevationModel.storeDependencies();
+        }
+
+        if (oldElevationModel != null) {
+            oldElevationModel.storeDependencies();
+        }
+
+        BedHeightSingle peer = getPeer(river);
+
+        for (ImportBedHeightSingleValue value: values) {
+            value.storeDependencies(peer);
+        }
+    }
+
+    public BedHeightSingle getPeer(River river) {
+        if (peer == null) {
+            BedHeightType  theType     = type != null ? type.getPeer() : null;
+            ElevationModel theCurModel = curElevationModel.getPeer();
+            Range          theRange    = range != null ? range.getPeer(river) : null;
+
+            if (theType == null || theCurModel == null || theRange == null) {
+                log.warn("Skip invalid file '" + description + "'");
+                return null;
+            }
+
+            Session session = ImporterSession.getInstance().getDatabaseSession();
+
+            Query query = session.createQuery(
+                "from BedHeightSingle where " +
+                "river=:river and year=:year and soundingWidth=:soundingWidth " +
+                "and type=:type and locationSystem=:locationSystem and " +
+                "curElevationModel=:curElevationModel and range=:range");
+
+            query.setParameter("river", river);
+            query.setParameter("year", year);
+            query.setParameter("soundingWidth", soundingWidth);
+            query.setParameter("type", theType);
+            query.setParameter("locationSystem", locationSystem.getPeer());
+            query.setParameter("curElevationModel", theCurModel);
+            query.setParameter("range", range.getPeer(river));
+
+            List<BedHeightSingle> bedHeights = query.list();
+            if (bedHeights.isEmpty()) {
+                log.info("Create new BedHeightSingle DB instance.");
+
+                peer = new BedHeightSingle(
+                    river,
+                    year,
+                    soundingWidth,
+                    theType,
+                    locationSystem.getPeer(),
+                    theCurModel,
+                    oldElevationModel != null ? oldElevationModel.getPeer() : null,
+                    range.getPeer(river),
+                    evaluationBy,
+                    description
+                );
+
+                session.save(peer);
+            }
+            else {
+                peer = bedHeights.get(0);
+            }
+        }
+
+        return peer;
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightSingleValue.java	Wed Apr 11 13:12:52 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightSingleValue.java	Thu Apr 12 10:42:46 2012 +0000
@@ -1,10 +1,24 @@
 package de.intevation.flys.importer;
 
+import java.util.List;
+
 import java.math.BigDecimal;
 
+import org.apache.log4j.Logger;
+
+import org.hibernate.Session;
+import org.hibernate.Query;
+
+import de.intevation.flys.model.BedHeightSingle;
+import de.intevation.flys.model.BedHeightSingleValue;
+
 
 public class ImportBedHeightSingleValue {
 
+    private static final Logger log =
+        Logger.getLogger(ImportBedHeightSingleValue.class);
+
+
     protected ImportBedHeightSingle bedHeight;
 
     protected BigDecimal station;
@@ -14,6 +28,8 @@
     protected BigDecimal soundingWidth;
     protected BigDecimal width;
 
+    protected BedHeightSingleValue peer;
+
 
     public ImportBedHeightSingleValue(
         ImportBedHeightSingle bedHeight,
@@ -32,5 +48,54 @@
         this.soundingWidth = soundingWidth;
         this.width         = width;
     }
+
+
+    public void storeDependencies(BedHeightSingle bedHeight) {
+        getPeer(bedHeight);
+    }
+
+
+    public BedHeightSingleValue getPeer(BedHeightSingle bedHeight) {
+        if (peer == null) {
+            Session session = ImporterSession.getInstance().getDatabaseSession();
+
+            Query query = session.createQuery(
+                "from BedHeightSingleValue where " +
+                "   bedHeight=:bedHeight and " +
+                "   station=:station and " +
+                "   height=:height and " +
+                "   uncertainty=:uncertainty and " +
+                "   dataGap=:dataGap and " +
+                "   soundingWidth=:soundingWidth and " +
+                "   width=:width");
+
+            query.setParameter("bedHeight", bedHeight);
+            query.setParameter("station", station);
+            query.setParameter("height", height);
+            query.setParameter("uncertainty", uncertainty);
+            query.setParameter("dataGap", dataGap);
+            query.setParameter("soundingWidth", soundingWidth);
+            query.setParameter("width", width);
+
+            List<BedHeightSingleValue> values = query.list();
+            if (values.isEmpty()) {
+                peer = new BedHeightSingleValue(
+                    bedHeight,
+                    station,
+                    height,
+                    uncertainty,
+                    dataGap,
+                    soundingWidth,
+                    width
+                );
+                session.save(peer);
+            }
+            else {
+                peer = values.get(0);
+            }
+        }
+
+        return peer;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightType.java	Wed Apr 11 13:12:52 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightType.java	Thu Apr 12 10:42:46 2012 +0000
@@ -1,7 +1,14 @@
 package de.intevation.flys.importer;
 
+import java.util.List;
+
 import org.apache.log4j.Logger;
 
+import org.hibernate.Session;
+import org.hibernate.Query;
+
+import de.intevation.flys.model.BedHeightType;
+
 
 public class ImportBedHeightType {
 
@@ -11,6 +18,8 @@
     protected String name;
     protected String description;
 
+    protected BedHeightType peer;
+
 
     public ImportBedHeightType(String name, String description) {
         this.name        = name;
@@ -18,17 +27,34 @@
     }
 
 
-    public static String getBedHeightName(String description) {
-        if (description.equals("Flächenpeilung")) {
-            return "FP";
+    public void storeDependencies() {
+        BedHeightType type = getPeer();
+    }
+
+
+    public BedHeightType getPeer() {
+        if (peer == null) {
+            Session session = ImporterSession.getInstance().getDatabaseSession();
+
+            Query query = session.createQuery(
+                "from BedHeightType where " +
+                "name=:name and description=:description");
+
+            query.setParameter("name", name);
+            query.setParameter("description", description);
+
+            List<BedHeightType> types = query.list();
+
+            if (types.isEmpty()) {
+                peer = new BedHeightType(name, description);
+                session.save(peer);
+            }
+            else {
+                peer = types.get(0);
+            }
         }
-        else if ("Querprofile".equals(description)) {
-            return "QP";
-        }
-        else {
-            log.warn("Unknown bed height type: " + description);
-            return null;
-        }
+
+        return peer;
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportElevationModel.java	Wed Apr 11 13:12:52 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportElevationModel.java	Thu Apr 12 10:42:46 2012 +0000
@@ -1,17 +1,59 @@
 package de.intevation.flys.importer;
 
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.hibernate.Session;
+import org.hibernate.Query;
+
+import de.intevation.flys.model.ElevationModel;
 
 
 public class ImportElevationModel {
 
+    private static final Logger log =
+        Logger.getLogger(ImportElevationModel.class);
+
     protected String name;
 
     protected ImportUnit unit;
 
+    protected ElevationModel peer;
+
 
     public ImportElevationModel(String name, ImportUnit unit) {
         this.name = name;
         this.unit = unit;
     }
+
+
+    public void storeDependencies() {
+        ElevationModel model = getPeer();
+    }
+
+    public ElevationModel getPeer() {
+        if (peer == null) {
+            Session session = ImporterSession.getInstance().getDatabaseSession();
+            Query query = session.createQuery(
+                "from ElevationModel where " +
+                "name=:name and unit=:unit");
+            query.setParameter("name", name);
+            query.setParameter("unit", unit.getPeer());
+            List<ElevationModel> models = query.list();
+
+            if (models.isEmpty()) {
+                log.info("Create new ElevationModel DB instance.");
+
+                peer = new ElevationModel(name, unit.getPeer());
+                session.save(peer);
+            }
+            else {
+                peer = models.get(0);
+            }
+        }
+
+        return peer;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportLocationSystem.java	Wed Apr 11 13:12:52 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportLocationSystem.java	Thu Apr 12 10:42:46 2012 +0000
@@ -1,16 +1,60 @@
 package de.intevation.flys.importer;
 
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.hibernate.Session;
+import org.hibernate.Query;
+
+import de.intevation.flys.model.LocationSystem;
 
 
 public class ImportLocationSystem {
 
+    private static final Logger log =
+        Logger.getLogger(ImportLocationSystem.class);
+
+
     protected String name;
     protected String description;
 
+    protected LocationSystem peer;
+
 
     public ImportLocationSystem(String name, String description) {
         this.name        = name;
         this.description = description;
     }
+
+    public void storeDependencies() {
+        log.info("store LocationSystem '" + name + "'");
+        LocationSystem ls = getPeer();
+
+        Session session = ImporterSession.getInstance().getDatabaseSession();
+        session.flush();
+    }
+
+    public LocationSystem getPeer() {
+        if (peer == null) {
+            Session session = ImporterSession.getInstance().getDatabaseSession();
+            Query query = session.createQuery(
+                "from LocationSystem where " +
+                "name=:name and description=:description");
+            query.setParameter("name", name);
+            query.setParameter("description", description);
+
+            List<LocationSystem> lss = query.list();
+            if (lss.isEmpty()) {
+                peer = new LocationSystem(name, description);
+                session.save(peer);
+            }
+            else {
+                peer = lss.get(0);
+            }
+        }
+
+        return peer;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java	Wed Apr 11 13:12:52 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java	Thu Apr 12 10:42:46 2012 +0000
@@ -13,6 +13,8 @@
 import java.io.File;
 import java.io.IOException;
 
+import java.sql.SQLException;
+
 import org.apache.log4j.Logger;
 
 import de.intevation.artifacts.common.utils.FileTools;
@@ -32,6 +34,7 @@
 
 import org.hibernate.Session;
 import org.hibernate.Query;
+import org.hibernate.exception.ConstraintViolationException;
 
 public class ImportRiver
 {
@@ -232,7 +235,9 @@
         File epochDir     = new File(bedHeightDir, BED_HEIGHT_EPOCH_DIR);
 
         parseBedHeightSingles(singlesDir);
-        parseBedHeightEpochs(epochDir);
+        //parseBedHeightEpochs(epochDir);
+
+        log.info("Finished parsing bed heights.");
     }
 
 
@@ -702,10 +707,24 @@
 
             if (bedHeightSingles != null) {
                 for (ImportBedHeightSingle single: bedHeightSingles) {
-                    log.debug("name: " + single.getDescription());
-                    single.storeDependencies(river);
+                    String desc = single.getDescription();
+
+                    log.debug("name: " + desc);
+
+                    try {
+                        single.storeDependencies(river);
+                    }
+                    catch (SQLException sqle) {
+                        log.error("File '" + desc + "' is broken!");
+                    }
+                    catch (ConstraintViolationException cve) {
+                        log.error("File '" + desc + "' is broken!");
+                    }
                 }
             }
+            else {
+                log.info("No single bed heights to store.");
+            }
 
             if (bedHeightEpochs != null) {
                 for (ImportBedHeightEpoch epoch: bedHeightEpochs) {
@@ -713,6 +732,9 @@
                     epoch.storeDependencies(river);
                 }
             }
+            else {
+                log.info("No epoch bed heights to store.");
+            }
         }
     }
 
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/BedHeightSingleParser.java	Wed Apr 11 13:12:52 2012 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/BedHeightSingleParser.java	Thu Apr 12 10:42:46 2012 +0000
@@ -28,6 +28,7 @@
 import de.intevation.flys.importer.ImportLocationSystem;
 import de.intevation.flys.importer.ImportRange;
 import de.intevation.flys.importer.ImportUnit;
+import de.intevation.flys.model.BedHeightType;
 
 
 public class BedHeightSingleParser {
@@ -111,6 +112,9 @@
                     handleDataLine(obj, line);
                 }
             }
+
+            log.info("File contained " + obj.getValues().size() + " values.");
+            bedHeights.add(obj);
         }
         finally {
             if (in != null) {
@@ -259,7 +263,7 @@
             String tmp = m.group(1).replace(";", "");
 
             obj.setType(new ImportBedHeightType(
-                ImportBedHeightType.getBedHeightName(tmp),
+                BedHeightType.getBedHeightName(tmp),
                 tmp));
 
             return true;
@@ -334,12 +338,10 @@
 
 
     protected void handleDataLine(ImportBedHeightSingle obj, String line) {
-        log.debug("Handle data line: '" + line + "'");
-
         String[] values = line.split(SEPERATOR_CHAR);
 
         if (values == null || values.length < 6) {
-            log.warn("Error while parsing data line: '" + line + "'");
+            //log.warn("Error while parsing data line: '" + line + "'");
             return;
         }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingle.java	Thu Apr 12 10:42:46 2012 +0000
@@ -0,0 +1,220 @@
+package de.intevation.flys.model;
+
+import java.io.Serializable;
+
+import java.util.List;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Column;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.GenerationType;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
+import javax.persistence.OneToMany;
+
+
+@Entity
+@Table(name = "bed_height_single")
+public class BedHeightSingle implements Serializable {
+
+    private Integer id;
+    private Integer year;
+    private Integer soundingWidth;
+
+    private String evaluationBy;
+    private String description;
+
+    private River river;
+
+    private BedHeightType  type;
+
+    private LocationSystem locationSystem;
+
+    private ElevationModel curElevationModel;
+
+    private ElevationModel oldElevationModel;
+
+    private Range range;
+
+    private List<BedHeightSingleValue> values;
+
+
+    public BedHeightSingle() {
+    }
+
+
+    public BedHeightSingle(
+        River          river,
+        Integer        year,
+        Integer        soundingWidth,
+        BedHeightType  type,
+        LocationSystem locationSystem,
+        ElevationModel curElevationModel,
+        Range          range
+    ) {
+        this(
+            river,
+            year,
+            soundingWidth,
+            type,
+            locationSystem,
+            curElevationModel,
+            null,
+            range,
+            null,
+            null);
+    }
+
+
+    public BedHeightSingle(
+        River          river,
+        Integer        year,
+        Integer        soundingWidth,
+        BedHeightType  type,
+        LocationSystem locationSystem,
+        ElevationModel curElevationModel,
+        ElevationModel oldElevationModel,
+        Range          range,
+        String         evaluationBy,
+        String         description
+    ) {
+        this.river             = river;
+        this.year              = year;
+        this.soundingWidth     = soundingWidth;
+        this.type              = type;
+        this.locationSystem    = locationSystem;
+        this.curElevationModel = curElevationModel;
+        this.oldElevationModel = oldElevationModel;
+        this.range             = range;
+        this.evaluationBy      = evaluationBy;
+        this.description       = description;
+    }
+
+
+    @Id
+    @SequenceGenerator(
+        name           = "SEQUENCE_BED_HEIGHT_SINGLE_ID_SEQ",
+        sequenceName   = "BED_HEIGHT_SINGLE_ID_SEQ",
+        allocationSize = 1)
+    @GeneratedValue(
+        strategy  = GenerationType.SEQUENCE,
+        generator = "SEQUENCE_BED_HEIGHT_SINGLE_ID_SEQ")
+    @Column(name = "id")
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    @OneToOne
+    @JoinColumn(name = "river_id" )
+    public River getRiver() {
+        return river;
+    }
+
+    public void setRiver(River river) {
+        this.river = river;
+    }
+
+    @Column(name = "year")
+    public Integer getYear() {
+        return year;
+    }
+
+    public void setYear(Integer year) {
+        this.year = year;
+    }
+
+    @Column(name = "sounding_width")
+    public Integer getSoundingWidth() {
+        return soundingWidth;
+    }
+
+    public void setSoundingWidth(Integer soundingWidth) {
+        this.soundingWidth = soundingWidth;
+    }
+
+    @OneToOne
+    @JoinColumn(name = "type_id")
+    public BedHeightType getType() {
+        return type;
+    }
+
+    public void setType(BedHeightType type) {
+        this.type = type;
+    }
+
+    @OneToOne
+    @JoinColumn(name = "location_system_id")
+    public LocationSystem getLocationSystem() {
+        return locationSystem;
+    }
+
+    public void setLocationSystem(LocationSystem locationSystem) {
+        this.locationSystem = locationSystem;
+    }
+
+    @OneToOne
+    @JoinColumn(name = "cur_elevation_model_id")
+    public ElevationModel getCurElevationModel() {
+        return curElevationModel;
+    }
+
+    public void setCurElevationModel(ElevationModel curElevationModel) {
+        this.curElevationModel = curElevationModel;
+    }
+
+    @OneToOne
+    @JoinColumn(name = "old_elevation_model_id")
+    public ElevationModel getOldElevationModel() {
+        return oldElevationModel;
+    }
+
+    public void setOldElevationModel(ElevationModel oldElevationModel) {
+        this.oldElevationModel = oldElevationModel;
+    }
+
+    @OneToOne
+    @JoinColumn(name = "range_id")
+    public Range getRange() {
+        return range;
+    }
+
+    public void setRange(Range range) {
+        this.range = range;
+    }
+
+    @Column(name = "evaluation_by")
+    public String getEvaluationBy() {
+        return evaluationBy;
+    }
+
+    public void setEvaluationBy(String evaluationBy) {
+        this.evaluationBy = evaluationBy;
+    }
+
+    @Column(name = "description")
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    @OneToMany
+    @JoinColumn(name = "bed_height_single_id")
+    public List<BedHeightSingleValue> getValues() {
+        return values;
+    }
+
+    public void setValues(List<BedHeightSingleValue> values) {
+        this.values = values;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/BedHeightSingleValue.java	Thu Apr 12 10:42:46 2012 +0000
@@ -0,0 +1,141 @@
+package de.intevation.flys.model;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Column;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.GenerationType;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
+
+import org.apache.log4j.Logger;
+
+
+@Entity
+@Table(name = "bed_height_single_values")
+public class BedHeightSingleValue
+implements   Serializable
+{
+    private static Logger logger =
+        Logger.getLogger(BedHeightSingleValue.class);
+
+    private Integer id;
+
+    private BedHeightSingle bedHeight;
+
+    private BigDecimal station;
+    private BigDecimal height;
+    private BigDecimal uncertainty;
+    private BigDecimal dataGap;
+    private BigDecimal soundingWidth;
+    private BigDecimal width;
+
+
+    public BedHeightSingleValue() {
+    }
+
+    public BedHeightSingleValue(
+        BedHeightSingle bedHeight,
+        BigDecimal station,
+        BigDecimal height,
+        BigDecimal uncertainty,
+        BigDecimal dataGap,
+        BigDecimal soundingWidth,
+        BigDecimal width
+    ) {
+        this.bedHeight     = bedHeight;
+        this.station       = station;
+        this.height        = height;
+        this.uncertainty   = uncertainty;
+        this.dataGap       = dataGap;
+        this.soundingWidth = soundingWidth;
+        this.width         = width;
+    }
+
+    @Id
+    @SequenceGenerator(
+        name           = "SEQUENCE_BED_SINGLE_VALUE_ID_SEQ",
+        sequenceName   = "BED_SINGLE_VALUES_ID_SEQ",
+        allocationSize = 1)
+    @GeneratedValue(
+        strategy  = GenerationType.SEQUENCE,
+        generator = "SEQUENCE_BED_SINGLE_VALUE_ID_SEQ")
+    @Column(name = "id")
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    @OneToOne
+    @JoinColumn(name = "bed_height_single_id" )
+    public BedHeightSingle getBedHeight() {
+        return bedHeight;
+    }
+
+    public void setBedHeight(BedHeightSingle bedHeight) {
+        this.bedHeight = bedHeight;
+    }
+
+    @Column(name = "station")
+    public BigDecimal getStation() {
+        return station;
+    }
+
+    public void setStation(BigDecimal station) {
+        this.station = station;
+    }
+
+    @Column(name = "height")
+    public BigDecimal getHeight() {
+        return height;
+    }
+
+    public void setHeight(BigDecimal height) {
+        this.height = height;
+    }
+
+    @Column(name="uncertainty")
+    public BigDecimal getUncertainty() {
+        return uncertainty;
+    }
+
+    public void setUncertainty(BigDecimal uncertainty) {
+        this.uncertainty = uncertainty;
+    }
+
+    @Column(name="data_gap")
+    public BigDecimal getDataGap() {
+        return dataGap;
+    }
+
+    public void setDataGap(BigDecimal dataGap) {
+        this.dataGap = dataGap;
+    }
+
+    @Column(name="sounding_width")
+    public BigDecimal getSoundingWidth() {
+        return soundingWidth;
+    }
+
+    public void setSoundingWidth(BigDecimal soundingWidth) {
+        this.soundingWidth = soundingWidth;
+    }
+
+    @Column(name="width")
+    public BigDecimal getWidth() {
+        return width;
+    }
+
+    public void setWidth(BigDecimal width) {
+        this.width = width;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/BedHeightType.java	Thu Apr 12 10:42:46 2012 +0000
@@ -0,0 +1,91 @@
+package de.intevation.flys.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Column;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.GenerationType;
+
+import org.apache.log4j.Logger;
+
+
+@Entity
+@Table(name = "bed_height_type")
+public class BedHeightType
+implements   Serializable
+{
+    private static Logger log = Logger.getLogger(BedHeightType.class);
+
+    private Integer id;
+    private String  name;
+    private String  description;
+
+
+    public BedHeightType() {
+    }
+
+    public BedHeightType(String name, String description) {
+        this.name        = name;
+        this.description = description;
+    }
+
+    @Id
+    @SequenceGenerator(
+        name           = "SEQUENCE_BED_HEIGHT_TYPE_ID_SEQ",
+        sequenceName   = "BED_HEIGHT_TYPE_SEQ",
+        allocationSize = 1)
+    @GeneratedValue(
+        strategy  = GenerationType.SEQUENCE,
+        generator = "SEQUENCE_BED_HEIGHT_TYPE_ID_SEQ")
+    @Column(name = "id")
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    @Column(name = "name")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Column(name = "description")
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+
+    public static String getBedHeightName(String description) {
+        if (description.equals("Flächenpeilung")) {
+            return "FP";
+        }
+        else if ("Querprofile".equals(description)) {
+            return "QP";
+        }
+        else if ("TIN".equals(description)) {
+            return "TIN";
+        }
+        else if ("Flächen- u. Querprofilpeilungen".equals(description)) {
+            return "FP-QP";
+        }
+        else {
+            log.warn("Unknown bed height type: " + description);
+            return null;
+        }
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/ElevationModel.java	Thu Apr 12 10:42:46 2012 +0000
@@ -0,0 +1,78 @@
+package de.intevation.flys.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Column;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.GenerationType;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
+
+import org.apache.log4j.Logger;
+
+
+@Entity
+@Table(name = "elevation_model")
+public class ElevationModel
+implements   Serializable
+{
+    private static Logger logger = Logger.getLogger(ElevationModel.class);
+
+    protected Integer id;
+
+    protected String name;
+
+    protected Unit unit;
+
+
+    public ElevationModel() {
+    }
+
+
+    public ElevationModel(String name, Unit unit) {
+        this.name = name;
+        this.unit = unit;
+    }
+
+
+    @Id
+    @SequenceGenerator(
+        name           = "SEQUENCE_ELEVATION_MODE_ID_SEQ",
+        sequenceName   = "ELEVATION_MODEL_SEQ",
+        allocationSize = 1)
+    @GeneratedValue(
+        strategy  = GenerationType.SEQUENCE,
+        generator = "SEQUENCE_ELEVATION_MODE_ID_SEQ")
+    @Column(name = "id")
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    @Column(name = "name")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @OneToOne
+    @JoinColumn(name = "unit_id")
+    public Unit getUnit() {
+        return unit;
+    }
+
+    public void setUnit(Unit unit) {
+        this.unit = unit;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/LocationSystem.java	Thu Apr 12 10:42:46 2012 +0000
@@ -0,0 +1,68 @@
+package de.intevation.flys.model;
+
+import java.io.Serializable;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Column;
+import javax.persistence.SequenceGenerator;
+import javax.persistence.GenerationType;
+
+
+@Entity
+@Table(name = "location_system")
+public class LocationSystem implements Serializable {
+
+    protected Integer id;
+
+    protected String name;
+    protected String description;
+
+
+    public LocationSystem() {
+    }
+
+
+    public LocationSystem(String name, String description) {
+        this.name        = name;
+        this.description = description;
+    }
+
+    @Id
+    @SequenceGenerator(
+        name           = "SEQUENCE_LOCATION_SYSTEM_ID_SEQ",
+        sequenceName   = "LOCATION_SYSTEM_SEQ",
+        allocationSize = 1)
+    @GeneratedValue(
+        strategy  = GenerationType.SEQUENCE,
+        generator = "SEQUENCE_LOCATION_SYSTEM_ID_SEQ")
+    @Column(name = "id")
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    @Column(name = "name")
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    @Column(name = "description")
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org