changeset 1212:dd948530fd57

Schema: Added missing columns in HYK tables. flys-backend/trunk@2338 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 15 Jul 2011 14:33:12 +0000
parents f08fe480092c
children cc88db4a5b34
files flys-backend/ChangeLog flys-backend/doc/schema/postgresql.sql flys-backend/src/main/java/de/intevation/flys/model/HYK.java flys-backend/src/main/java/de/intevation/flys/model/HYKEntry.java
diffstat 4 files changed, 76 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Fri Jul 15 13:07:45 2011 +0000
+++ b/flys-backend/ChangeLog	Fri Jul 15 14:33:12 2011 +0000
@@ -1,3 +1,17 @@
+2011-07-15	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* doc/schema/postgresql.sql: Added missing columns.
+	  To update existing databases:
+	  BEGIN;
+	    ALTER TABLE hyks ADD COLUMN measure TIMESTAMP;
+	    ALTER TABLE hyk_entries ADD COLUMN distance_vl NUMERIC NOT NULL;
+	    ALTER TABLE hyk_entries ADD COLUMN distance_hf NUMERIC NOT NULL;
+	    ALTER TABLE hyk_entries ADD COLUMN distance_vr NUMERIC NOT NULL;
+	  COMMIT;
+	* src/main/java/de/intevation/flys/model/HYKEntry.java,
+	  src/main/java/de/intevation/flys/model/HYK.java:
+	  Adjusted Hibernate models.
+
 2011-07-15	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/importer/parsers/*.java:
--- a/flys-backend/doc/schema/postgresql.sql	Fri Jul 15 13:07:45 2011 +0000
+++ b/flys-backend/doc/schema/postgresql.sql	Fri Jul 15 14:33:12 2011 +0000
@@ -298,15 +298,19 @@
 CREATE TABLE hyks (
     id          int PRIMARY KEY NOT NULL,
     river_id    int             NOT NULL,
+    measure     TIMESTAMP,
     description VARCHAR(256)    NOT NULL
 );
 
 CREATE SEQUENCE HYK_ENTRIES_ID_SEQ;
 
 CREATE TABLE hyk_entries (
-    id     int PRIMARY KEY NOT NULL,
-    hyk_id int             NOT NULL REFERENCES hyks(id),
-    km     NUMERIC         NOT NULL,
+    id          int PRIMARY KEY NOT NULL,
+    hyk_id      int             NOT NULL REFERENCES hyks(id),
+    km          NUMERIC         NOT NULL,
+    distance_vl NUMERIC         NOT NULL,
+    distance_hf NUMERIC         NOT NULL,
+    distance_vr NUMERIC         NOT NULL,
     UNIQUE (hyk_id, km)
 );
 
--- a/flys-backend/src/main/java/de/intevation/flys/model/HYK.java	Fri Jul 15 13:07:45 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/HYK.java	Fri Jul 15 14:33:12 2011 +0000
@@ -3,6 +3,7 @@
 import java.io.Serializable;
 
 import java.util.List;
+import java.util.Date;
 
 import javax.persistence.Entity;
 import javax.persistence.Id;
@@ -23,6 +24,7 @@
 {
     private Integer id;
     private River   river;
+    private Date    measure;
     private String  description;
 
     private List<HYKEntry> entries;
@@ -30,8 +32,9 @@
     public HYK() {
     }
 
-    public HYK(River river, String description) {
+    public HYK(River river, Date measure, String description) {
         this.river       = river;
+        this.measure     = measure;
         this.description = description;
     }
 
@@ -71,6 +74,15 @@
         this.description = description;
     }
 
+    @Column(name = "measure")
+    public Date getMeasure() {
+        return measure;
+    }
+
+    public void setMeasure(Date measure) {
+        this.measure = measure;
+    }
+
     @OneToMany
     @OrderBy("km")
     @JoinColumn(name="hyk_id")
--- a/flys-backend/src/main/java/de/intevation/flys/model/HYKEntry.java	Fri Jul 15 13:07:45 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/HYKEntry.java	Fri Jul 15 14:33:12 2011 +0000
@@ -26,15 +26,27 @@
     private Integer    id;
     private HYK        hyk;
     private BigDecimal km;
+    private BigDecimal distanceVL;
+    private BigDecimal distanceHF;
+    private BigDecimal distanceVR;
 
     private List<HYKFormation> formations;
 
     public HYKEntry() {
     }
 
-    public HYKEntry(HYK hyk, BigDecimal km) {
-        this.hyk = hyk;
-        this.km  = km;
+    public HYKEntry(
+        HYK        hyk,
+        BigDecimal km,
+        BigDecimal distanceVL,
+        BigDecimal distanceHF,
+        BigDecimal distanceVR
+    ) {
+        this.hyk        = hyk;
+        this.km         = km;
+        this.distanceVL = distanceVL;
+        this.distanceHF = distanceHF;
+        this.distanceVR = distanceVR;
     }
 
     @Id
@@ -73,6 +85,33 @@
         this.km = km;
     }
 
+    @Column(name = "distance_vl")
+    public BigDecimal getDistanceVL() {
+        return distanceVL;
+    }
+
+    public void setDistanceVL(BigDecimal distanceVL) {
+        this.distanceVL = distanceVL;
+    }
+
+    @Column(name = "distance_hf")
+    public BigDecimal getDistanceHF() {
+        return distanceHF;
+    }
+
+    public void setDistanceHF(BigDecimal distanceHF) {
+        this.distanceHF = distanceHF;
+    }
+
+    @Column(name = "distance_vr")
+    public BigDecimal getDistanceVR() {
+        return distanceVR;
+    }
+
+    public void setDistanceVR(BigDecimal distanceVR) {
+        this.distanceVR = distanceVR;
+    }
+
     @OneToMany
     @OrderBy("formation_num")
     @JoinColumn(name="hyk_entry_id")

http://dive4elements.wald.intevation.org