changeset 2363:a8f408fdf58c

Added model for 'hws' relation and synced postgis with oracle spatial schema. flys-backend/trunk@3200 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 09 Nov 2011 16:01:16 +0000
parents 2649151c9500
children efe19e669092
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/Hws.java
diffstat 4 files changed, 119 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Wed Nov 09 14:59:01 2011 +0000
+++ b/flys-backend/ChangeLog	Wed Nov 09 16:01:16 2011 +0000
@@ -1,3 +1,14 @@
+2011-11-09  Ingo Weinzierl <ingo@intevation.de>
+
+	* doc/schema/postgresql-spatial.sql: Synced "hws" relation with oracle
+	  schema.
+
+	* src/main/java/de/intevation/flys/model/Hws.java: New. A model for the
+	  "hws" relation.
+
+	* src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java:
+	  Registered the Hws model.
+
 2011-11-09  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java:
--- a/flys-backend/doc/schema/postgresql-spatial.sql	Wed Nov 09 14:59:01 2011 +0000
+++ b/flys-backend/doc/schema/postgresql-spatial.sql	Wed Nov 09 16:01:16 2011 +0000
@@ -115,10 +115,9 @@
 CREATE SEQUENCE HWS_ID_SEQ;
 CREATE TABLE hws (
     id int PRIMARY KEY NOT NULL,
-    oid int,
     river_id int REFERENCES rivers(id),
     hws_facility VARCHAR(256),
-    typ VARCHAR(256)
+    type VARCHAR(256)
 );
 SELECT AddGeometryColumn('hws','geom',31466,'LINESTRING',2);
 ALTER TABLE hw ALTER COLUMN id SET DEFAULT NEXTVAL('HWS_ID_SEQ');
--- a/flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java	Wed Nov 09 14:59:01 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/backend/SessionFactoryProvider.java	Wed Nov 09 16:01:16 2011 +0000
@@ -36,6 +36,7 @@
 import de.intevation.flys.model.Fixpoint;
 import de.intevation.flys.model.Floodplain;
 import de.intevation.flys.model.Gauge;
+import de.intevation.flys.model.Hws;
 import de.intevation.flys.model.HYK;
 import de.intevation.flys.model.HYKEntry;
 import de.intevation.flys.model.HYKFormation;
@@ -222,6 +223,7 @@
         cfg.addAnnotatedClass(Fixpoint.class);
         cfg.addAnnotatedClass(Floodplain.class);
         cfg.addAnnotatedClass(Gauge.class);
+        cfg.addAnnotatedClass(Hws.class);
         cfg.addAnnotatedClass(HYK.class);
         cfg.addAnnotatedClass(HYKEntry.class);
         cfg.addAnnotatedClass(HYKFormation.class);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/Hws.java	Wed Nov 09 16:01:16 2011 +0000
@@ -0,0 +1,105 @@
+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.Session;
+import org.hibernate.Query;
+import org.hibernate.annotations.Type;
+
+import com.vividsolutions.jts.geom.LineString;
+
+import de.intevation.flys.backend.SessionHolder;
+
+
+@Entity
+@Table(name = "hws")
+public class Hws
+implements   Serializable
+{
+    private Integer    id;
+    private String     facility;
+    private String     type;
+    private River      river;
+    private LineString geom;
+
+    public Hws() {
+    }
+
+
+    @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 = "hws_facility")
+    public String getFacility() {
+        return facility;
+    }
+
+
+    public void setFacility(String facility) {
+        this.facility = facility;
+    }
+
+
+    @Column(name = "type")
+    public String getType() {
+        return type;
+    }
+
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+
+    @Column(name = "geom")
+    @Type(type = "org.hibernatespatial.GeometryUserType")
+    public LineString getGeom() {
+        return geom;
+    }
+
+
+    public void setGeom(LineString geom) {
+        this.geom = geom;
+    }
+
+
+    public static List<Hws> getHws(int riverId) {
+        Session session = SessionHolder.HOLDER.get();
+
+        Query query = session.createQuery(
+            "from Hws where river.id =:river_id");
+        query.setParameter("river_id", riverId);
+
+        return query.list();
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org