# HG changeset patch # User Sascha L. Teichmann # Date 1567508529 -7200 # Node ID f9bb06f2dbe38a10437b5ebba49b2cd1c145a156 # Parent 3d69410468585091d639e749c3f235db6b949ad0 Added stub for a shape upload stretch import. POST /api/imports/stsh diff -r 3d6941046858 -r f9bb06f2dbe3 pkg/controllers/routes.go --- a/pkg/controllers/routes.go Mon Sep 02 22:36:31 2019 +0200 +++ b/pkg/controllers/routes.go Tue Sep 03 13:02:09 2019 +0200 @@ -229,6 +229,9 @@ api.Handle("/imports/ugm", waterwayAdmin( importUploadedGaugeMeasurement())).Methods(http.MethodPost) + api.Handle("/imports/stsh", sysAdmin( + importUploadedStretchShape())).Methods(http.MethodPost) + api.Handle("/imports/{kind:st}", sysAdmin(&mw.JSONHandler{ Input: importModel, Handle: manualImport, diff -r 3d6941046858 -r f9bb06f2dbe3 pkg/controllers/uploadedimports.go --- a/pkg/controllers/uploadedimports.go Mon Sep 02 22:36:31 2019 +0200 +++ b/pkg/controllers/uploadedimports.go Tue Sep 03 13:02:09 2019 +0200 @@ -135,6 +135,16 @@ ) } +func importUploadedStretchShape() http.HandlerFunc { + return uploadedImport( + imports.STSHJobKind, + "stretch.zip", + func(_ *http.Request, dir string) (imports.Job, error) { + return &imports.StretchShape{Dir: dir}, nil + }, + ) +} + func (bup badUploadParameterError) Error() string { return string(bup) } diff -r 3d6941046858 -r f9bb06f2dbe3 pkg/imports/st.go --- a/pkg/imports/st.go Mon Sep 02 22:36:31 2019 +0200 +++ b/pkg/imports/st.go Tue Sep 03 13:02:09 2019 +0200 @@ -40,9 +40,7 @@ type stJobCreator struct{} -func init() { - RegisterJobCreator(STJobKind, stJobCreator{}) -} +func init() { RegisterJobCreator(STJobKind, stJobCreator{}) } func (stJobCreator) Description() string { return "stretch" } diff -r 3d6941046858 -r f9bb06f2dbe3 pkg/imports/stsh.go --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/imports/stsh.go Tue Sep 03 13:02:09 2019 +0200 @@ -0,0 +1,66 @@ +// 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) 2019 by via donau +// – Österreichische Wasserstraßen-Gesellschaft mbH +// Software engineering by Intevation GmbH +// +// Author(s): +// * Sascha L. Teichmann + +package imports + +import ( + "context" + "database/sql" + "os" +) + +type StretchShape struct { + Dir string `json:"dir"` +} + +const STSHJobKind JobKind = "stsh" + +type stshJobCreator struct{} + +func init() { RegisterJobCreator(STSHJobKind, stshJobCreator{}) } + +func (stshJobCreator) Description() string { return "stretch from shape" } + +func (stshJobCreator) AutoAccept() bool { return false } + +func (stshJobCreator) Create() Job { return new(StretchShape) } + +func (stshJobCreator) Depends() [2][]string { + return [2][]string{ + {"stretches", "stretch_countries"}, + {}, + } +} + +func (stshJobCreator) StageDone( + ctx context.Context, + tx *sql.Tx, + id int64, +) error { + // TODO: Implement me! + return nil +} + +func (stsh *StretchShape) CleanUp() error { + return os.RemoveAll(stsh.Dir) +} + +func (stsh *StretchShape) Do( + ctx context.Context, + importID int64, + conn *sql.Conn, + feedback Feedback, +) (interface{}, error) { + // TODO: Implement me! + return nil, nil +}