changeset 3423:6592396f5061

Make revisiting time of a bottleneck optional
author Tom Gottfried <tom@intevation.de>
date Thu, 23 May 2019 15:33:56 +0200
parents 34e846f89936
children 0a666ba899fa
files pkg/imports/bn.go pkg/soap/ifbn/service.go schema/gemma.sql
diffstat 3 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/imports/bn.go	Thu May 23 15:33:23 2019 +0200
+++ b/pkg/imports/bn.go	Thu May 23 15:33:56 2019 +0200
@@ -146,14 +146,6 @@
 	return &m[1], &m[2]
 }
 
-func revisitingTime(s string) int {
-	v, err := strconv.Atoi(s)
-	if err != nil {
-		v = 0
-	}
-	return v
-}
-
 // Do executes the actual bottleneck import.
 func (bn *Bottleneck) Do(
 	ctx context.Context,
@@ -275,6 +267,17 @@
 
 	rb, lb := splitRBLB(bn.Rb_lb)
 
+	var revisitingTime *int
+	if bn.Revisiting_time != nil {
+		i, err := strconv.Atoi(*bn.Revisiting_time)
+		if err != nil {
+			feedback.Warn("Cannot convert '%s' to number of months",
+				*bn.Revisiting_time)
+		} else {
+			revisitingTime = &i
+		}
+	}
+
 	var limiting, country string
 
 	if bn.Limiting_factor != nil {
@@ -297,7 +300,7 @@
 		rb,
 		lb,
 		country,
-		revisitingTime(bn.Revisiting_time),
+		revisitingTime,
 		limiting,
 		bn.Date_Info,
 		bn.Source,
--- a/pkg/soap/ifbn/service.go	Thu May 23 15:33:23 2019 +0200
+++ b/pkg/soap/ifbn/service.go	Thu May 23 15:33:56 2019 +0200
@@ -77,7 +77,7 @@
 
 	Responsible_country *CountryCode `xml:"responsible_country,omitempty"`
 
-	Revisiting_time string `xml:"revisiting_time,omitempty"`
+	Revisiting_time *string `xml:"revisiting_time,omitempty"`
 
 	SURTYP *SurtypEnum `xml:"SURTYP,omitempty"`
 
--- a/schema/gemma.sql	Thu May 23 15:33:23 2019 +0200
+++ b/schema/gemma.sql	Thu May 23 15:33:56 2019 +0200
@@ -485,9 +485,6 @@
     --
     -- Bottlenecks
     --
-    -- XXX: Nullability differs between DRC (attributes marked "O") and WSDL
-    -- (minOccurs=0; nillable seems to be set arbitrarily as even bottleneck_id and
-    -- fk_g_fid (both mandatory, i.e. marked "M" in DRC) have nillable="true" in WSDL)
     CREATE TABLE bottlenecks (
         id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
         bottleneck_id varchar UNIQUE NOT NULL,
@@ -504,7 +501,7 @@
         rb char(2) REFERENCES countries, -- from rb_lb in interface
         lb char(2) REFERENCES countries, -- from rb_lb in interface
         responsible_country char(2) NOT NULL REFERENCES countries,
-        revisiting_time smallint NOT NULL,
+        revisiting_time smallint,
         limiting varchar NOT NULL REFERENCES limiting_factors,
         -- surtyp varchar NOT NULL REFERENCES survey_types,
         -- XXX: Also an attribut of sounding result?