Mercurial > gemma
diff pkg/imports/ubn.go @ 2191:4b9496752d89
Upload bottleneck import: Added stub.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 12 Feb 2019 10:44:00 +0100 |
parents | |
children | 3437ceee1529 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pkg/imports/ubn.go Tue Feb 12 10:44:00 2019 +0100 @@ -0,0 +1,73 @@ +// 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 <sascha.teichmann@intevation.de> + +package imports + +import ( + "context" + "database/sql" + "errors" + "os" +) + +type UploadedBottleneck struct { + Dir string `json:"dir"` +} + +// UBNJobKind is the import queue type identifier. +const UBNJobKind JobKind = "ubn" + +type ubnJobCreator struct{} + +func init() { + RegisterJobCreator(UBNJobKind, ubnJobCreator{}) +} + +func (ubnJobCreator) Description() string { return "uploaded bottlenecks" } + +func (ubnJobCreator) AutoAccept() bool { return false } + +func (ubnJobCreator) Create() Job { return new(UploadedBottleneck) } + +func (ubnJobCreator) Depends() []string { + return []string{ + "gauges", + "bottlenecks", + } +} + +// StageDone moves the imported bottleneck out of the staging area. +func (ubnJobCreator) StageDone( + ctx context.Context, + tx *sql.Tx, + id int64, +) error { + // TODO: Implement me! + return nil +} + +// CleanUp of a uploaded bottleneck import removes the temp dir. +func (ubn *UploadedBottleneck) CleanUp() error { + return os.RemoveAll(ubn.Dir) +} + +// Do executes the actual uploaded bottleneck import. +func (ubn *UploadedBottleneck) Do( + ctx context.Context, + importID int64, + conn *sql.Conn, + feedback Feedback, +) (interface{}, error) { + // TODO: Implement me! + return nil, errors.New("Not implemented, yet!") +}