view pkg/imports/wx.go @ 1677:53304db85888

Waterway axis import: Added route for manual import.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 26 Dec 2018 10:46:17 +0100
parents 8fec3887c7e5
children 2dc7768be0e4
line wrap: on
line source

// 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"

	"gemma.intevation.de/gemma/pkg/common"
)

type WaterwayAxis struct {
	URL         string `json:"url"`
	FeatureType string `json:"feature-type"`
	SortBy      string `json:"sort-by"`
}

const WXJobKind JobKind = "wx"

type wxJobCreator struct{}

func init() {
	RegisterJobCreator(WXJobKind, wxJobCreator{})
}

func (wxJobCreator) Description() string {
	return "waterway axis"
}

func (wxJobCreator) Create(_ JobKind, data string) (Job, error) {
	wx := new(WaterwayAxis)
	if err := common.FromJSONString(data, wx); err != nil {
		return nil, err
	}
	return wx, nil
}

func (wxJobCreator) Depends() []string {
	return []string{
		"waterway_axis",
	}
}

// StageDone is a NOP for waterway axis imports.
func (wxJobCreator) StageDone(context.Context, *sql.Tx, int64) error {
	return nil
}

// CleanUp for waterway imports is a NOP.
func (*WaterwayAxis) CleanUp() error { return nil }

// Do executes the actual waterway exis import.
func (wx *WaterwayAxis) Do(
	ctx context.Context,
	importID int64,
	conn *sql.Conn,
	feedback Feedback,
) (interface{}, error) {

	// TODO: Implement me!
	return nil, nil
}