changeset 1237:774dff3ee546

Added relation and hibernate classes for floodplains (german 'Talaue'). flys-backend/trunk@2615 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 31 Aug 2011 08:50:20 +0000
parents 324cb486db9f
children 35740d675866
files flys-backend/ChangeLog flys-backend/doc/schema/postgresql-spatial.sql flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java flys-backend/src/main/java/de/intevation/flys/model/Floodplain.java
diffstat 4 files changed, 102 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Wed Aug 31 07:46:59 2011 +0000
+++ b/flys-backend/ChangeLog	Wed Aug 31 08:50:20 2011 +0000
@@ -1,3 +1,14 @@
+2011-08-31  Ingo Weinzierl <ingo@intevation.de>
+
+	* doc/schema/postgresql-spatial.sql: New relation for floodplains (german
+	  "Talaue").
+
+	* src/main/java/de/intevation/flys/model/Floodplain.java: New. Model class
+	  that represents a floodplain.
+
+	* src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java:
+	  Registered the Floodplain mapping.
+
 2011-08-31  Ingo Weinzierl <ingo@intevation.de>
 
 	* doc/schema/postgresql-spatial.sql: Added a relation for DGMs. Note, that
--- a/flys-backend/doc/schema/postgresql-spatial.sql	Wed Aug 31 07:46:59 2011 +0000
+++ b/flys-backend/doc/schema/postgresql-spatial.sql	Wed Aug 31 08:50:20 2011 +0000
@@ -48,6 +48,14 @@
 SELECT AddGeometryColumn('fixpoints', 'geom', 31466, 'POINT', 2);
 
 
+-- Talaue
+CREATE TABLE floodplain (
+    id       SERIAL PRIMARY KEY NOT NULL,
+    river_id int REFERENCES rivers(id)
+);
+SELECT AddGeometryColumn('floodplain', 'geom', 31466, 'MULTIPOLYGON', 2);
+
+
 CREATE TABLE dgm (
     id       SERIAL PRIMARY KEY NOT NULL,
     river_id int REFERENCES rivers(id),
--- a/flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java	Wed Aug 31 07:46:59 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java	Wed Aug 31 08:50:20 2011 +0000
@@ -22,6 +22,7 @@
 import de.intevation.flys.model.DischargeTableValue;
 import de.intevation.flys.model.Edge;
 import de.intevation.flys.model.Fixpoint;
+import de.intevation.flys.model.Floodplain;
 import de.intevation.flys.model.Gauge;
 import de.intevation.flys.model.HYK;
 import de.intevation.flys.model.HYKEntry;
@@ -163,6 +164,7 @@
         cfg.addAnnotatedClass(DischargeTableValue.class);
         cfg.addAnnotatedClass(Edge.class);
         cfg.addAnnotatedClass(Fixpoint.class);
+        cfg.addAnnotatedClass(Floodplain.class);
         cfg.addAnnotatedClass(Gauge.class);
         cfg.addAnnotatedClass(HYK.class);
         cfg.addAnnotatedClass(HYKEntry.class);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/Floodplain.java	Wed Aug 31 08:50:20 2011 +0000
@@ -0,0 +1,81 @@
+package de.intevation.flys.model;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.annotations.Type;
+
+import com.vividsolutions.jts.geom.MultiPolygon;
+
+import de.intevation.flys.backend.SessionHolder;
+
+
+@Entity
+@Table(name = "floodplain")
+public class Floodplain
+implements   Serializable
+{
+    private Integer id;
+
+    private River   river;
+
+    private MultiPolygon geom;
+
+
+    public Floodplain() {
+    }
+
+
+    @Id
+    @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 = "geom")
+    @Type(type = "org.hibernatespatial.GeometryUserType")
+    public MultiPolygon getGeom() {
+        return geom;
+    }
+
+    public void setGeom(MultiPolygon geom) {
+        this.geom = geom;
+    }
+
+
+    public static Floodplain getFloodplain(String river) {
+        Session session = SessionHolder.HOLDER.get();
+
+        Query query = session.createQuery(
+            "from Floodplain where river.name =:river");
+        query.setParameter("river", river);
+
+        List<Floodplain> result = query.list();
+
+        return result.isEmpty() ? null : result.get(0);
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org