# HG changeset patch # User Tom Gottfried # Date 1558618436 -7200 # Node ID 6592396f5061a160d7433c04d926989ffb3451c9 # Parent 34e846f89936aaae1622e26fadb1ab8eaef8f58f Make revisiting time of a bottleneck optional diff -r 34e846f89936 -r 6592396f5061 pkg/imports/bn.go --- 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, diff -r 34e846f89936 -r 6592396f5061 pkg/soap/ifbn/service.go --- 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"` diff -r 34e846f89936 -r 6592396f5061 schema/gemma.sql --- 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?