# HG changeset patch # User Sascha L. Teichmann # Date 1545817577 -3600 # Node ID 53304db8588826da548ba9a680bd8564af0c68d3 # Parent 4407ecaa219257e38563f11c6d772eb0a233cc65 Waterway axis import: Added route for manual import. diff -r 4407ecaa2192 -r 53304db85888 pkg/controllers/manualimports.go --- a/pkg/controllers/manualimports.go Wed Dec 26 10:30:19 2018 +0100 +++ b/pkg/controllers/manualimports.go Wed Dec 26 10:46:17 2018 +0100 @@ -52,6 +52,16 @@ return fa, fai.SendEmail, true } +func importWaterwayAxis(input interface{}) (interface{}, bool, bool) { + wxi := input.(*models.WaterwayAxisImport) + wx := &imports.WaterwayAxis{ + URL: wxi.URL, + FeatureType: wxi.FeatureType, + SortBy: wxi.SortBy, + } + return wx, wxi.SendEmail, true +} + func manualImport( kind imports.JobKind, setup func(interface{}) (interface{}, bool, bool), diff -r 4407ecaa2192 -r 53304db85888 pkg/controllers/routes.go --- a/pkg/controllers/routes.go Wed Dec 26 10:30:19 2018 +0100 +++ b/pkg/controllers/routes.go Wed Dec 26 10:46:17 2018 +0100 @@ -189,6 +189,12 @@ NoConn: true, })).Methods(http.MethodPost) + api.Handle("/imports/waterwayaxis", waterwayAdmin(&JSONHandler{ + Input: func() interface{} { return new(models.WaterwayAxisImport) }, + Handle: manualImport(imports.WXJobKind, importWaterwayAxis), + NoConn: true, + })).Methods(http.MethodPost) + // Import scheduler configuration api.Handle("/imports/config/{id:[0-9]+}", waterwayAdmin(&JSONHandler{ diff -r 4407ecaa2192 -r 53304db85888 pkg/imports/wx.go --- a/pkg/imports/wx.go Wed Dec 26 10:30:19 2018 +0100 +++ b/pkg/imports/wx.go Wed Dec 26 10:46:17 2018 +0100 @@ -21,8 +21,9 @@ ) type WaterwayAxis struct { - URL string `json:"url"` - SortBy string `json:"sort-by"` + URL string `json:"url"` + FeatureType string `json:"feature-type"` + SortBy string `json:"sort-by"` } const WXJobKind JobKind = "wx" diff -r 4407ecaa2192 -r 53304db85888 pkg/models/waterway.go --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/models/waterway.go Wed Dec 26 10:46:17 2018 +0100 @@ -0,0 +1,21 @@ +// This is Free Software under GNU Affero General Public License v >= 3.0 +// without warranty, see README.md and license for details. +// +// SPDX-License-Identifier: AGPL-3.0-or-later +// License-Filename: LICENSES/AGPL-3.0.txt +// +// Copyright (C) 2018 by via donau +// – Österreichische Wasserstraßen-Gesellschaft mbH +// Software engineering by Intevation GmbH +// +// Author(s): +// * Sascha L. Teichmann + +package models + +type WaterwayAxisImport struct { + URL string `json:"url"` + FeatureType string `json:"feature-type"` + SortBy string `json:"sort-by"` + SendEmail bool `json:"send-email"` +}