Mercurial > gemma
annotate pkg/imports/config.go @ 3800:26325370ba18 yworks-svg2pdf
client: improve pdf generation
* Refactor AvailableFairwayDepth.vue and AvailableFairwayDepthLNWL.vue
to use generatedPDF() from mixins.js.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Thu, 04 Jul 2019 10:43:12 +0200 |
parents | c64c47ff2ab1 |
children | 8b75ac5e243e |
rev | line source |
---|---|
1627
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 // This is Free Software under GNU Affero General Public License v >= 3.0 |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 // without warranty, see README.md and license for details. |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 // |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 // SPDX-License-Identifier: AGPL-3.0-or-later |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 // License-Filename: LICENSES/AGPL-3.0.txt |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 // |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 // Copyright (C) 2018 by via donau |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 // – Österreichische Wasserstraßen-Gesellschaft mbH |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 // Software engineering by Intevation GmbH |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 // |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 // Author(s): |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 package imports |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 import ( |
1653
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
17 "context" |
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
18 "database/sql" |
1627
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 "encoding/json" |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 "fmt" |
2051
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
21 "sort" |
1627
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 |
1653
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
23 "gemma.intevation.de/gemma/pkg/auth" |
1708
49e047c2106e
Imports: Made imports re-runnable if they fail.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1705
diff
changeset
|
24 "gemma.intevation.de/gemma/pkg/common" |
1627
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 ) |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 type ( |
1696
ad5e1cddaa09
Imports: Resolved the remaining golint issues with this package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1653
diff
changeset
|
28 // ImportKind is a string which has to be one |
ad5e1cddaa09
Imports: Resolved the remaining golint issues with this package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1653
diff
changeset
|
29 // of the registered import types. |
1627
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 ImportKind string |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
32 ImportConfigIn struct { |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
33 Kind ImportKind `json:"kind"` |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
34 Config json.RawMessage `json:"config"` |
1627
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 } |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
37 ImportConfigOut struct { |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
38 ID int64 `json:"id"` |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
39 Kind ImportKind `json:"kind"` |
2049
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
40 User string `json:"user"` |
2045
10a1e139d2e8
Imports: Re-enabled running configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
41 Config interface{} `json:"config,omitempty"` |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
42 } |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
43 |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
44 PersistentConfig struct { |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
45 ID int64 |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
46 User string |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
47 Kind string |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
48 Attributes common.Attributes |
1627
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 } |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 ) |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 |
1696
ad5e1cddaa09
Imports: Resolved the remaining golint issues with this package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1653
diff
changeset
|
52 // UnmarshalJSON checks if the incoming string |
ad5e1cddaa09
Imports: Resolved the remaining golint issues with this package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1653
diff
changeset
|
53 // is a registered import type. |
1627
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 func (ik *ImportKind) UnmarshalJSON(data []byte) error { |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 var s string |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 if err := json.Unmarshal(data, &s); err != nil { |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 return err |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 } |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 if !HasImportKindName(s) { |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 return fmt.Errorf("Unknown kind '%s'", s) |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 } |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 *ik = ImportKind(s) |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 return nil |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 } |
b10aa02d7819
Refactored: Moved REST /api/imports/scheduler to /api/imports/config
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 |
1653
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
69 const ( |
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
70 configUser = "sys_admin" |
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
71 |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
72 loadPersistentConfigSQL = ` |
1653
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
73 SELECT |
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
74 username, |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
75 kind |
1995
59055c8301df
Move import queue to its own database namespace
Tom Gottfried <tom@intevation.de>
parents:
1754
diff
changeset
|
76 FROM import.import_configuration |
1653
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
77 WHERE id = $1` |
1702
49b89575ab31
Import configuration: [WIP] Added table for extra configuration attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1696
diff
changeset
|
78 |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
79 loadPersistentConfigAttributesSQL = ` |
1702
49b89575ab31
Import configuration: [WIP] Added table for extra configuration attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1696
diff
changeset
|
80 SELECT k, v |
1995
59055c8301df
Move import queue to its own database namespace
Tom Gottfried <tom@intevation.de>
parents:
1754
diff
changeset
|
81 FROM import.import_configuration_attributes |
1702
49b89575ab31
Import configuration: [WIP] Added table for extra configuration attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1696
diff
changeset
|
82 WHERE import_configuration_id = $1` |
2049
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
83 |
2050
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
84 hasImportConfigurationSQL = ` |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
85 SELECT true FROM import.import_configuration |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
86 WHERE id = $1` |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
87 |
2049
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
88 deleteImportConfiguationAttributesSQL = ` |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
89 DELETE FROM import.import_configuration_attributes |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
90 WHERE import_configuration_id = $1` |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
91 |
2050
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
92 deleteImportConfiguationSQL = ` |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
93 DELETE FROM import.import_configuration |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
94 WHERE id = $1` |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
95 |
2049
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
96 updateImportConfigurationSQL = ` |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
97 UPDATE import.import_configuration SET |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
98 username = $2, |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
99 kind = $3 |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
100 WHERE id = $1` |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
101 |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
102 selectImportConfigurationsByID = ` |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
103 SELECT |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
104 c.id AS id, |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
105 username, |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
106 kind, |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
107 a.k, |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
108 a.v |
2090
4882f01c8592
Imports config: Fixed listing of stored configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2060
diff
changeset
|
109 FROM import.import_configuration c LEFT JOIN |
2049
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
110 import.import_configuration_attributes a |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
111 ON c.id = a.import_configuration_id |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
112 ORDER by c.id` |
2051
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
113 |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
114 insertImportConfigurationSQL = ` |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
115 INSERT INTO import.import_configuration |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
116 (username, kind) |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
117 VALUES ($1, $2) |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
118 RETURNING id` |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
119 |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
120 insertImportConfigurationAttributeSQL = ` |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
121 INSERT INTO import.import_configuration_attributes |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
122 (import_configuration_id, k, v) |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
123 VALUES ($1, $2, $3)` |
1653
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
124 ) |
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
125 |
2052
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
126 func (pc *PersistentConfig) UpdateContext(ctx context.Context, tx *sql.Tx) error { |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
127 if _, err := tx.ExecContext( |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
128 ctx, |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
129 updateImportConfigurationSQL, |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
130 pc.ID, pc.User, pc.Kind, |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
131 ); err != nil { |
2049
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
132 return err |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
133 } |
2052
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
134 if _, err := tx.ExecContext( |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
135 ctx, |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
136 deleteImportConfiguationAttributesSQL, |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
137 pc.ID, |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
138 ); err != nil { |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
139 return err |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
140 } |
0b203a3b3e8e
Imports: Re-enabled /imports/config/{id} PATCH.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2051
diff
changeset
|
141 return storeConfigAttributes(ctx, tx, pc.ID, pc.Attributes) |
2049
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
142 } |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
143 |
2050
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
144 func LoadPersistentConfigContext( |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
145 ctx context.Context, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
146 conn *sql.Conn, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
147 id int64, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
148 ) (*PersistentConfig, error) { |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
149 |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
150 cfg := &PersistentConfig{ID: id} |
1653
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
151 |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
152 err := conn.QueryRowContext(ctx, loadPersistentConfigSQL, id).Scan( |
1739
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
153 &cfg.User, |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
154 &cfg.Kind, |
1739
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
155 ) |
1653
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
156 |
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
157 switch { |
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
158 case err == sql.ErrNoRows: |
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
159 return nil, nil |
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
160 case err != nil: |
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
161 return nil, err |
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
162 } |
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
163 |
1739
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
164 // load the extra attributes. |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
165 rows, err := conn.QueryContext(ctx, loadPersistentConfigAttributesSQL, id) |
1739
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
166 if err != nil { |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
167 return nil, err |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
168 } |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
169 defer rows.Close() |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
170 var attributes common.Attributes |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
171 for rows.Next() { |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
172 var k, v string |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
173 if err = rows.Scan(&k, &v); err != nil { |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
174 return nil, err |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
175 } |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
176 if attributes == nil { |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
177 attributes = common.Attributes{} |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
178 } |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
179 attributes[k] = v |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
180 } |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
181 if err = rows.Err(); err != nil { |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
182 return nil, err |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
183 } |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
184 if len(attributes) > 0 { |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
185 cfg.Attributes = attributes |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
186 } |
1653
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
187 return cfg, nil |
06f08458d666
Scheduled imports: Load configuration from database when triggered by cron.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1627
diff
changeset
|
188 } |
1739
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
189 |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
190 func loadPersistentConfig(id int64) (*PersistentConfig, error) { |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
191 return loadPersistentConfigContext(context.Background(), id) |
1739
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
192 } |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
193 |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
194 func loadPersistentConfigContext(ctx context.Context, id int64) (*PersistentConfig, error) { |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
195 var cfg *PersistentConfig |
1739
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
196 err := auth.RunAs(ctx, configUser, func(conn *sql.Conn) error { |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
197 var err error |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2016
diff
changeset
|
198 cfg, err = LoadPersistentConfigContext(ctx, conn, id) |
1739
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
199 return err |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
200 }) |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
201 return cfg, err |
61fa62f01f20
Configured imports: When GET an import deliver the extra attributes, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
202 } |
2049
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
203 |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
204 func ListAllPersistentConfigurationsContext( |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
205 ctx context.Context, |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
206 conn *sql.Conn, |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
207 fn func(*ImportConfigOut) error, |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
208 ) error { |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
209 |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
210 rows, err := conn.QueryContext(ctx, selectImportConfigurationsByID) |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
211 if err != nil { |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
212 return err |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
213 } |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
214 defer rows.Close() |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
215 |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
216 var ( |
2090
4882f01c8592
Imports config: Fixed listing of stored configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2060
diff
changeset
|
217 first = true |
4882f01c8592
Imports config: Fixed listing of stored configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2060
diff
changeset
|
218 pc PersistentConfig |
2049
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
219 ) |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
220 |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
221 send := func() error { |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
222 kind := JobKind(pc.Kind) |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
223 ctor := ImportModelForJobKind(kind) |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
224 if ctor == nil { |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
225 return fmt.Errorf("unable to deserialize kind '%s'", pc.Kind) |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
226 } |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
227 config := ctor() |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
228 pc.Attributes.Unmarshal(config) |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
229 return fn(&ImportConfigOut{ |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
230 ID: pc.ID, |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
231 Kind: ImportKind(pc.Kind), |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
232 User: pc.User, |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
233 Config: config, |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
234 }) |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
235 } |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
236 |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
237 for rows.Next() { |
2090
4882f01c8592
Imports config: Fixed listing of stored configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2060
diff
changeset
|
238 var ( |
4882f01c8592
Imports config: Fixed listing of stored configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2060
diff
changeset
|
239 id int64 |
4882f01c8592
Imports config: Fixed listing of stored configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2060
diff
changeset
|
240 user, kind string |
4882f01c8592
Imports config: Fixed listing of stored configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2060
diff
changeset
|
241 k, v sql.NullString |
4882f01c8592
Imports config: Fixed listing of stored configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2060
diff
changeset
|
242 ) |
2060
f9d13ce57893
Imports: Fixed SQL scanning in listing all configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2052
diff
changeset
|
243 if err := rows.Scan( |
2090
4882f01c8592
Imports config: Fixed listing of stored configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2060
diff
changeset
|
244 &id, |
4882f01c8592
Imports config: Fixed listing of stored configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2060
diff
changeset
|
245 &user, |
4882f01c8592
Imports config: Fixed listing of stored configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2060
diff
changeset
|
246 &kind, |
2060
f9d13ce57893
Imports: Fixed SQL scanning in listing all configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2052
diff
changeset
|
247 &k, &v, |
f9d13ce57893
Imports: Fixed SQL scanning in listing all configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2052
diff
changeset
|
248 ); err != nil { |
2049
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
249 return err |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
250 } |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
251 if !first { |
2090
4882f01c8592
Imports config: Fixed listing of stored configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2060
diff
changeset
|
252 if pc.ID != id { |
2049
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
253 if err := send(); err != nil { |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
254 return err |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
255 } |
2090
4882f01c8592
Imports config: Fixed listing of stored configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2060
diff
changeset
|
256 pc.ID = id |
4882f01c8592
Imports config: Fixed listing of stored configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2060
diff
changeset
|
257 pc.User = user |
4882f01c8592
Imports config: Fixed listing of stored configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2060
diff
changeset
|
258 pc.Kind = kind |
2049
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
259 pc.Attributes = nil |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
260 } |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
261 } else { |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
262 first = false |
2090
4882f01c8592
Imports config: Fixed listing of stored configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2060
diff
changeset
|
263 pc.ID = id |
4882f01c8592
Imports config: Fixed listing of stored configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2060
diff
changeset
|
264 pc.User = user |
4882f01c8592
Imports config: Fixed listing of stored configurations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2060
diff
changeset
|
265 pc.Kind = kind |
2049
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
266 } |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
267 |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
268 if k.Valid && v.Valid { |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
269 if pc.Attributes == nil { |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
270 pc.Attributes = common.Attributes{} |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
271 } |
3515
c64c47ff2ab1
import: fix for passwordleakage. No passwords are received/sent if configuration is edited.
Thomas Junk <thomas.junk@intevation.de>
parents:
2090
diff
changeset
|
272 // Prevent sending the `password` back to the client. |
c64c47ff2ab1
import: fix for passwordleakage. No passwords are received/sent if configuration is edited.
Thomas Junk <thomas.junk@intevation.de>
parents:
2090
diff
changeset
|
273 // (See importconfig.infoImportConfig() for the other place |
c64c47ff2ab1
import: fix for passwordleakage. No passwords are received/sent if configuration is edited.
Thomas Junk <thomas.junk@intevation.de>
parents:
2090
diff
changeset
|
274 // where this is done.) |
c64c47ff2ab1
import: fix for passwordleakage. No passwords are received/sent if configuration is edited.
Thomas Junk <thomas.junk@intevation.de>
parents:
2090
diff
changeset
|
275 if k.String != "password" { |
c64c47ff2ab1
import: fix for passwordleakage. No passwords are received/sent if configuration is edited.
Thomas Junk <thomas.junk@intevation.de>
parents:
2090
diff
changeset
|
276 pc.Attributes.Set(k.String, v.String) |
c64c47ff2ab1
import: fix for passwordleakage. No passwords are received/sent if configuration is edited.
Thomas Junk <thomas.junk@intevation.de>
parents:
2090
diff
changeset
|
277 } |
2049
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
278 } |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
279 } |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
280 |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
281 if err := rows.Err(); err != nil { |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
282 return err |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
283 } |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
284 |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
285 err = nil |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
286 if !first { |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
287 err = send() |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
288 } |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
289 return err |
d1a680be7ae4
Imports. Re-enabled /imports/config GET.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2045
diff
changeset
|
290 } |
2050
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
291 |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
292 func DeletePersistentConfigurationContext( |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
293 ctx context.Context, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
294 tx *sql.Tx, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
295 id int64, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
296 ) error { |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
297 var found bool |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
298 if err := tx.QueryRowContext( |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
299 ctx, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
300 hasImportConfigurationSQL, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
301 id, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
302 ).Scan(&found); err != nil { |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
303 return err |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
304 } |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
305 if !found { |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
306 return sql.ErrNoRows |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
307 } |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
308 if _, err := tx.ExecContext( |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
309 ctx, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
310 deleteImportConfiguationAttributesSQL, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
311 id, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
312 ); err != nil { |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
313 return nil |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
314 } |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
315 _, err := tx.ExecContext( |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
316 ctx, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
317 deleteImportConfiguationSQL, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
318 id, |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
319 ) |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
320 return err |
a3ccef8ec304
Imports: Re-enabled /imports/config/{id} DELETE.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2049
diff
changeset
|
321 } |
2051
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
322 |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
323 func storeConfigAttributes( |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
324 ctx context.Context, |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
325 tx *sql.Tx, |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
326 id int64, |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
327 attrs common.Attributes, |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
328 ) error { |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
329 if len(attrs) == 0 { |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
330 return nil |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
331 } |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
332 attrStmt, err := tx.PrepareContext(ctx, insertImportConfigurationAttributeSQL) |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
333 if err != nil { |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
334 return err |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
335 } |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
336 defer attrStmt.Close() |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
337 // Sort to make it deterministic |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
338 keys := make([]string, len(attrs)) |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
339 i := 0 |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
340 for key := range attrs { |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
341 keys[i] = key |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
342 i++ |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
343 } |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
344 sort.Strings(keys) |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
345 for _, key := range keys { |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
346 if _, err := attrStmt.ExecContext(ctx, id, key, attrs[key]); err != nil { |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
347 return err |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
348 } |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
349 } |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
350 return nil |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
351 } |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
352 |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
353 func (pc *PersistentConfig) StoreContext(ctx context.Context, tx *sql.Tx) (int64, error) { |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
354 var id int64 |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
355 if err := tx.QueryRowContext( |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
356 ctx, |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
357 insertImportConfigurationSQL, |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
358 pc.User, |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
359 pc.Kind, |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
360 ).Scan(&id); err != nil { |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
361 return 0, err |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
362 } |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
363 |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
364 if err := storeConfigAttributes(ctx, tx, id, pc.Attributes); err != nil { |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
365 return 0, err |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
366 } |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
367 pc.ID = id |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
368 return id, nil |
7d627258e045
Imports: Re-enabled /imports/config POST.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2050
diff
changeset
|
369 } |