view pkg/imports/wp.go @ 2072:b4d8d320feab

Waterway profile import: Added import stub and changed database.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 30 Jan 2019 17:11:10 +0100
parents
children dacf79a0658e
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"
	"errors"
	"os"

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

type WaterwayProfiles struct {
	Dir string `json:"dir"`
}

const WPJobKind JobKind = "wp"

type wpJobCreator struct{}

func init() {
	RegisterJobCreator(WPJobKind, wpJobCreator{})
}

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

func (wpJobCreator) AutoAccept() bool { return false }

func (wpJobCreator) Description() string {
	return "waterway profiles"
}

func (wpJobCreator) Depends() []string {
	return []string{
		"waterway_profiles",
	}
}

func (wpJobCreator) StageDone(
	ctx context.Context,
	tx *sql.Tx,
	id int64,
) error {
	// TODO: Implement me!
	return nil
}

func (wp *WaterwayProfiles) CleanUp() error {
	return os.RemoveAll(wp.Dir)
}

func (wp *WaterwayProfiles) Do(
	ctx context.Context,
	importID int64,
	conn *sql.Conn,
	feedback Feedback,
) (interface{}, error) {
	// TODO: Implement me!
	return nil, errors.New("Not implemented, yet!")
}