Mercurial > gemma
comparison pkg/imports/report.go @ 5326:96ceb150ea46 extented-report
Added infrastructure for report 'import'.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 30 May 2021 13:18:10 +0200 |
parents | |
children | bc8c082487b2 |
comparison
equal
deleted
inserted
replaced
5322:80d9fd782f00 | 5326:96ceb150ea46 |
---|---|
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 | |
21 "gemma.intevation.de/gemma/pkg/common" | |
22 ) | |
23 | |
24 type Report struct { | |
25 Name string `json:"Name"` | |
26 } | |
27 | |
28 const ReportJobKind JobKind = "report" | |
29 | |
30 type reportJobCreator struct{} | |
31 | |
32 func init() { RegisterJobCreator(ReportJobKind, ReportJobKind{}) } | |
33 | |
34 func (reportJobCreator) Description() string { return "report" } | |
35 | |
36 func (reportJobCreator) AutoAccept() bool { return true } | |
37 | |
38 func (reportJobCreator) Create() Job { return new(Report) } | |
39 | |
40 func (reportJobCreator) Depends() [2][]string { return [2][]string{{}, {}} } | |
41 | |
42 func (reportJobCreator) StageDone(context.Context, *sql.Tx, int64, Feedback) error { | |
43 return nil | |
44 } | |
45 | |
46 func (r *Report) Description() (string, error) { return r.Name, nil } | |
47 | |
48 func (r *Report) MarshalAttributes(attrs common.Attributes) error { | |
49 attrs.Set("name", r.Name) | |
50 return nil | |
51 } | |
52 | |
53 func (r *Report) UnmarshalAttributes(attrs common.Attributes) error { | |
54 name, found := attrs.Get("name") | |
55 if !found { | |
56 return errors.New("missing 'name' attribute") | |
57 } | |
58 r.Name = name | |
59 return nil | |
60 } | |
61 | |
62 func (r *Report) Do( | |
63 ctx context.Context, | |
64 importID int64, | |
65 conn *sql.Conn, | |
66 feedback Feedback, | |
67 ) (interface{}, error) { | |
68 | |
69 // TODO: Implement me! | |
70 | |
71 return nil, nil | |
72 } |