# HG changeset patch # User Sascha L. Teichmann # Date 1325511747 0 # Node ID 056b3a5aa181c3459447a43373511c71346a7cc5 # Parent 027736510a301a1b7b677f1d4c60cb4c7a5d53e2 Removed "NOT NULL" constraint from gauges.range_id because there are gauges which dont have a Gueltigkeitsbereich. flys-backend/trunk@3564 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 027736510a30 -r 056b3a5aa181 flys-backend/ChangeLog --- a/flys-backend/ChangeLog Wed Dec 28 12:16:52 2011 +0000 +++ b/flys-backend/ChangeLog Mon Jan 02 13:42:27 2012 +0000 @@ -1,3 +1,16 @@ +2012-01-02 Sascha L. Teichmann + + * doc/schema/postgresql.sql: Remove 'NOT NULL' constraint from + gauges.range_id because there are gauges which don't have + a 'Gueltigkeitsbereich' + + To adjust existing PostgreSQL databases use: + + ALTER TABLE gauges ALTER COLUMN range_id DROP NOT NULL; + + * src/main/java/de/intevation/flys/model/River.java: Handle + null references to 'Gueltigkeitsbereiche'. + 2011-12-28 Ingo Weinzierl * src/main/java/de/intevation/flys/model/Wst.java: Added a method diff -r 027736510a30 -r 056b3a5aa181 flys-backend/doc/schema/postgresql.sql --- a/flys-backend/doc/schema/postgresql.sql Wed Dec 28 12:16:52 2011 +0000 +++ b/flys-backend/doc/schema/postgresql.sql Mon Jan 02 13:42:27 2012 +0000 @@ -88,7 +88,7 @@ -- Pegelnullpunkt datum NUMERIC NOT NULL, -- Streckengueltigkeit - range_id int NOT NULL REFERENCES ranges (id), + range_id int REFERENCES ranges (id), UNIQUE (name, river_id), UNIQUE (river_id, station) diff -r 027736510a30 -r 056b3a5aa181 flys-backend/src/main/java/de/intevation/flys/model/River.java --- a/flys-backend/src/main/java/de/intevation/flys/model/River.java Wed Dec 28 12:16:52 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/model/River.java Mon Jan 02 13:42:27 2012 +0000 @@ -231,7 +231,9 @@ * @return the min and max distance of this river. */ public double[] determineMinMaxDistance() { - if (gauges == null) { + List gauges = getGauges(); + + if (gauges == null || gauges.isEmpty()) { return null; } @@ -240,6 +242,10 @@ for (Gauge g: gauges) { Range r = g.getRange(); + if (r == null) { + continue; + } + double a = r.getA().doubleValue(); minmax[0] = minmax[0] < a ? minmax[0] : a;