comparison 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
comparison
equal deleted inserted replaced
2071:5c6816780bf5 2072:b4d8d320feab
1 // This is Free Software under GNU Affero General Public License v >= 3.0
2 // without warranty, see README.md and license for details.
3 //
4 // SPDX-License-Identifier: AGPL-3.0-or-later
5 // License-Filename: LICENSES/AGPL-3.0.txt
6 //
7 // Copyright (C) 2018 by via donau
8 // – Österreichische Wasserstraßen-Gesellschaft mbH
9 // Software engineering by Intevation GmbH
10 //
11 // Author(s):
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de>
13
14 package imports
15
16 import (
17 "context"
18 "database/sql"
19 "errors"
20 "os"
21
22 "gemma.intevation.de/gemma/pkg/common"
23 )
24
25 type WaterwayProfiles struct {
26 Dir string `json:"dir"`
27 }
28
29 const WPJobKind JobKind = "wp"
30
31 type wpJobCreator struct{}
32
33 func init() {
34 RegisterJobCreator(WPJobKind, wpJobCreator{})
35 }
36
37 func (wpJobCreator) Create(_ JobKind, data string) (Job, error) {
38 wp := new(WaterwayProfiles)
39 if err := common.FromJSONString(data, wp); err != nil {
40 return nil, err
41 }
42 return wp, nil
43 }
44
45 func (wpJobCreator) AutoAccept() bool { return false }
46
47 func (wpJobCreator) Description() string {
48 return "waterway profiles"
49 }
50
51 func (wpJobCreator) Depends() []string {
52 return []string{
53 "waterway_profiles",
54 }
55 }
56
57 func (wpJobCreator) StageDone(
58 ctx context.Context,
59 tx *sql.Tx,
60 id int64,
61 ) error {
62 // TODO: Implement me!
63 return nil
64 }
65
66 func (wp *WaterwayProfiles) CleanUp() error {
67 return os.RemoveAll(wp.Dir)
68 }
69
70 func (wp *WaterwayProfiles) Do(
71 ctx context.Context,
72 importID int64,
73 conn *sql.Conn,
74 feedback Feedback,
75 ) (interface{}, error) {
76 // TODO: Implement me!
77 return nil, errors.New("Not implemented, yet!")
78 }