Mercurial > gemma
changeset 5615:f6179b31e0a9 erdms2
Use a type alias on date type to not loose XML serialisation.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 10 Nov 2022 19:19:21 +0100 |
parents | 0abc65720804 |
children | a4ecd66b5940 |
files | pkg/imports/wg.go pkg/soap/erdms2/service.go |
diffstat | 2 files changed, 20 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/imports/wg.go Thu Nov 10 10:18:55 2022 +0100 +++ b/pkg/imports/wg.go Thu Nov 10 19:19:21 2022 +0100 @@ -23,7 +23,6 @@ "gemma.intevation.de/gemma/pkg/models" "gemma.intevation.de/gemma/pkg/pgxutils" - "gemma.intevation.de/gemma/pkg/soap" erdms "gemma.intevation.de/gemma/pkg/soap/erdms2" ) @@ -241,9 +240,10 @@ // We need a valid, non-empty time range to identify gauge versions if dr.Enddate != nil && dr.Startdate != nil { - ed := soap.XSDDateTime(*dr.Enddate) - sd := soap.XSDDateTime(*dr.Startdate) - if !ed.ToGoTime().After(sd.ToGoTime()) { + ed := dr.Enddate.ToGoTime() + sd := dr.Startdate.ToGoTime() + // log.Debugf("start date: %v end date: %v\n", sd, ed) + if !ed.After(sd) { feedback.Error("End date not after start date") unchanged++ continue @@ -268,9 +268,8 @@ var tfrom, tto, dateInfo pgtype.Timestamptz if dr.Startdate != nil { - sd := soap.XSDDateTime(*dr.Startdate) tfrom = pgtype.Timestamptz{ - Time: sd.ToGoTime(), + Time: dr.Startdate.ToGoTime(), Status: pgtype.Present, } } else { @@ -280,9 +279,8 @@ } if dr.Enddate != nil { - ed := soap.XSDDateTime(*dr.Enddate) tto = pgtype.Timestamptz{ - Time: ed.ToGoTime(), + Time: dr.Enddate.ToGoTime(), Status: pgtype.Present, } } else { @@ -300,9 +298,8 @@ } if dr.Infodate != nil { - id := soap.XSDDateTime(*dr.Infodate) dateInfo = pgtype.Timestamptz{ - Time: id.ToGoTime(), + Time: dr.Infodate.ToGoTime(), Status: pgtype.Present, } } else { @@ -348,7 +345,11 @@ unchanged++ continue case isNew: - lu := soap.XSDDateTime(*dr.Lastupdate) + var lu *time.Time + if dr.Lastupdate != nil { + t := dr.Lastupdate.ToGoTime() + lu = &t + } // insert gauge version entry if _, err = tx.StmtContext(ctx, insertStmt).ExecContext(ctx, code.CountryCode, @@ -365,7 +366,7 @@ geodref, &dateInfo, source, - lu.ToGoTime(), + lu, ); err != nil { feedback.Error(pgxutils.ReadableError{Err: err}.Error()) if err2 := tx.Rollback(); err2 != nil { @@ -376,7 +377,11 @@ } feedback.Info("insert new version") case !isNew: - lu := soap.XSDDateTime(*dr.Lastupdate) + var lu *time.Time + if dr.Lastupdate != nil { + t := dr.Lastupdate.ToGoTime() + lu = &t + } // try to update var dummy int err2 := tx.StmtContext(ctx, updateStmt).QueryRowContext(ctx, @@ -393,7 +398,7 @@ geodref, &dateInfo, source, - lu.ToGoTime(), + lu, &validity, ).Scan(&dummy) switch {
--- a/pkg/soap/erdms2/service.go Thu Nov 10 10:18:55 2022 +0100 +++ b/pkg/soap/erdms2/service.go Thu Nov 10 19:19:21 2022 +0100 @@ -207,7 +207,7 @@ // record // -type LastupdateType soap.XSDDateTime +type LastupdateType = soap.XSDDateTime // one of the supported languages (basic and // additional set), based on ISO 639-1