changeset 1217:d5e39c16fd2a

Schema: Fixed location of 'Peilungsjahre' in HYKs flys-backend/trunk@2343 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Sun, 17 Jul 2011 10:24:20 +0000
parents f8b5c37f15e4
children 00e37d22a589
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, 34 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/ChangeLog	Sun Jul 17 10:00:13 2011 +0000
+++ b/flys-backend/ChangeLog	Sun Jul 17 10:24:20 2011 +0000
@@ -1,3 +1,17 @@
+2011-07-17	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
+
+	* doc/schema/postgresql.sql: Each entry in a HYK can have
+	  an optional 'Peilungsjahr' (measure) not only the whole HYK.
+	  To update existing databases:
+	  BEGIN;
+	    ALTER TABLE hyks DROP COLUMN measure;
+	    ALTER TABLE hyk_entries ADD COLUMN measure TIMESTAMP;
+	  COMMIT;
+
+	  * src/main/java/de/intevation/flys/model/HYKEntry.java,
+	    src/main/java/de/intevation/flys/model/HYK.java:
+	    Adjusted Hibernate models.
+
 2011-07-17	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/importer/parsers/HYKParser.java:
@@ -24,9 +38,9 @@
 	    ALTER TABLE hyk_entries DROP COLUMN distance_vl;
 	    ALTER TABLE hyk_entries DROP COLUMN distance_hf;
 	    ALTER TABLE hyk_entries DROP COLUMN distance_vr;
-		ALTER TABLE hyk_formations ADD COLUMN distance_vl NUMERIC NOT NULL;
-		ALTER TABLE hyk_formations ADD COLUMN distance_hf NUMERIC NOT NULL;
-		ALTER TABLE hyk_formations ADD COLUMN distance_vr NUMERIC NOT NULL;
+	    ALTER TABLE hyk_formations ADD COLUMN distance_vl NUMERIC NOT NULL;
+	    ALTER TABLE hyk_formations ADD COLUMN distance_hf NUMERIC NOT NULL;
+	    ALTER TABLE hyk_formations ADD COLUMN distance_vr NUMERIC NOT NULL;
 	  COMMIT;
 
 	* src/main/java/de/intevation/flys/model/HYKFormation.java,
--- a/flys-backend/doc/schema/postgresql.sql	Sun Jul 17 10:00:13 2011 +0000
+++ b/flys-backend/doc/schema/postgresql.sql	Sun Jul 17 10:24:20 2011 +0000
@@ -298,7 +298,6 @@
 CREATE TABLE hyks (
     id          int PRIMARY KEY NOT NULL,
     river_id    int             NOT NULL,
-    measure     TIMESTAMP,
     description VARCHAR(256)    NOT NULL
 );
 
@@ -308,6 +307,7 @@
     id          int PRIMARY KEY NOT NULL,
     hyk_id      int             NOT NULL REFERENCES hyks(id),
     km          NUMERIC         NOT NULL,
+    measure     TIMESTAMP,
     UNIQUE (hyk_id, km)
 );
 
--- a/flys-backend/src/main/java/de/intevation/flys/model/HYK.java	Sun Jul 17 10:00:13 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/HYK.java	Sun Jul 17 10:24:20 2011 +0000
@@ -3,7 +3,6 @@
 import java.io.Serializable;
 
 import java.util.List;
-import java.util.Date;
 
 import javax.persistence.Entity;
 import javax.persistence.Id;
@@ -24,7 +23,6 @@
 {
     private Integer id;
     private River   river;
-    private Date    measure;
     private String  description;
 
     private List<HYKEntry> entries;
@@ -32,9 +30,8 @@
     public HYK() {
     }
 
-    public HYK(River river, Date measure, String description) {
+    public HYK(River river, String description) {
         this.river       = river;
-        this.measure     = measure;
         this.description = description;
     }
 
@@ -74,15 +71,6 @@
         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	Sun Jul 17 10:00:13 2011 +0000
+++ b/flys-backend/src/main/java/de/intevation/flys/model/HYKEntry.java	Sun Jul 17 10:24:20 2011 +0000
@@ -4,6 +4,7 @@
 
 import java.math.BigDecimal;
 
+import java.util.Date;
 import java.util.List;
 
 import javax.persistence.Entity;
@@ -26,15 +27,17 @@
     private Integer    id;
     private HYK        hyk;
     private BigDecimal km;
+    private Date       measure;
 
     private List<HYKFormation> formations;
 
     public HYKEntry() {
     }
 
-    public HYKEntry(HYK hyk, BigDecimal km) {
-        this.hyk = hyk;
-        this.km  = km;
+    public HYKEntry(HYK hyk, BigDecimal km, Date measure) {
+        this.hyk     = hyk;
+        this.km      = km;
+        this.measure = measure;
     }
 
     @Id
@@ -73,6 +76,15 @@
         this.km = km;
     }
 
+    @Column(name = "measure")
+    public Date getMeasure() {
+        return measure;
+    }
+
+    public void setMeasure(Date measure) {
+        this.measure = measure;
+    }
+
     @OneToMany
     @OrderBy("formation_num")
     @JoinColumn(name="hyk_entry_id")

http://dive4elements.wald.intevation.org