changeset 1059:a435b9fd1d85

Set default in data model instead of on generation of Probe objects.
author Tom Gottfried <tom@intevation.de>
date Fri, 23 Sep 2016 19:13:40 +0200
parents 0d0362fe7619
children cf5a2de206e3
files db_schema/lada_schema.sql src/main/java/de/intevation/lada/factory/ProbeFactory.java src/main/java/de/intevation/lada/model/land/Messprogramm.java
diffstat 3 files changed, 8 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/db_schema/lada_schema.sql	Fri Sep 23 18:47:17 2016 +0200
+++ b/db_schema/lada_schema.sql	Fri Sep 23 19:13:40 2016 +0200
@@ -582,7 +582,7 @@
     probenintervall character varying(2) NOT NULL,
     teilintervall_von integer NOT NULL,
     teilintervall_bis integer NOT NULL,
-    intervall_offset integer,
+    intervall_offset integer NOT NULL DEFAULT 0,
     gueltig_von integer NOT NULL CHECK(gueltig_von BETWEEN 0 AND 364),
     gueltig_bis integer NOT NULL CHECK(gueltig_bis BETWEEN 0 AND 364),
     probe_nehmer_id integer,
--- a/src/main/java/de/intevation/lada/factory/ProbeFactory.java	Fri Sep 23 18:47:17 2016 +0200
+++ b/src/main/java/de/intevation/lada/factory/ProbeFactory.java	Fri Sep 23 19:13:40 2016 +0200
@@ -161,8 +161,7 @@
         Calendar start,
         Calendar end
     ) {
-        int offset = messprogramm.getIntervallOffset() == null ?
-            0 : messprogramm.getIntervallOffset();
+        int offset = messprogramm.getIntervallOffset();
         int teilVon = messprogramm.getTeilintervallVon() - 1;
         int teilBis = messprogramm.getTeilintervallBis();
         int manualDuration = teilBis - teilVon;
@@ -204,8 +203,7 @@
         Calendar start,
         Calendar end
     ) {
-        int offset = messprogramm.getIntervallOffset() == null ?
-            0 : messprogramm.getIntervallOffset();
+        int offset = messprogramm.getIntervallOffset();
         int teilVon = messprogramm.getTeilintervallVon() - 1;
         int teilBis = messprogramm.getTeilintervallBis();
         int manualDuration = teilBis - teilVon;
@@ -247,8 +245,7 @@
         Calendar start,
         Calendar end
     ) {
-        int offset = messprogramm.getIntervallOffset() == null ?
-            0 : messprogramm.getIntervallOffset();
+        int offset = messprogramm.getIntervallOffset();
         int teilVon = messprogramm.getTeilintervallVon() - 1;
         int teilBis = messprogramm.getTeilintervallBis();
         int manualDuration = teilBis - teilVon;
@@ -291,8 +288,7 @@
         Calendar end,
         int days
     ) {
-        int offset = messprogramm.getIntervallOffset() == null ?
-            0 : messprogramm.getIntervallOffset();
+        int offset = messprogramm.getIntervallOffset();
         int startDay = start.get(Calendar.DAY_OF_YEAR) +
             messprogramm.getTeilintervallVon() - 1 + offset;
         int endDay = end.get(Calendar.DAY_OF_YEAR);
--- a/src/main/java/de/intevation/lada/model/land/Messprogramm.java	Fri Sep 23 18:47:17 2016 +0200
+++ b/src/main/java/de/intevation/lada/model/land/Messprogramm.java	Fri Sep 23 19:13:40 2016 +0200
@@ -33,6 +33,9 @@
         if (baId == null) {
             baId = 1;
         }
+        if (intervallOffset == null) {
+            intervallOffset = 0;
+        }
     }
 
     @Id
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)