# HG changeset patch # User Sascha L. Teichmann # Date 1310898260 0 # Node ID d5e39c16fd2a755617a6b5863119496a9e9675a2 # Parent f8b5c37f15e45c94b835aaef7b42cfa8b43a8d61 Schema: Fixed location of 'Peilungsjahre' in HYKs flys-backend/trunk@2343 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r f8b5c37f15e4 -r d5e39c16fd2a flys-backend/ChangeLog --- 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 + + * 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 * 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, diff -r f8b5c37f15e4 -r d5e39c16fd2a flys-backend/doc/schema/postgresql.sql --- 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) ); diff -r f8b5c37f15e4 -r d5e39c16fd2a flys-backend/src/main/java/de/intevation/flys/model/HYK.java --- 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 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") diff -r f8b5c37f15e4 -r d5e39c16fd2a flys-backend/src/main/java/de/intevation/flys/model/HYKEntry.java --- 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 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")