Mercurial > gemma
annotate pkg/models/importbase.go @ 5591:0011f50cf216 surveysperbottleneckid
Removed no longer used alternative api for surveys/ endpoint.
As bottlenecks in the summary for SR imports are now identified by
their id and no longer by the (not guarantied to be unique!) name,
there is no longer the need to request survey data by the name+date
tuple (which isn't reliable anyway). So the workaround was now
reversed.
author | Sascha Wilde <wilde@sha-bang.de> |
---|---|
date | Wed, 06 Apr 2022 13:30:29 +0200 |
parents | 4847ac70103a |
children | 1222b777f51f |
rev | line source |
---|---|
2016
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 // This is Free Software under GNU Affero General Public License v >= 3.0 |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 // without warranty, see README.md and license for details. |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 // |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 // SPDX-License-Identifier: AGPL-3.0-or-later |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 // License-Filename: LICENSES/AGPL-3.0.txt |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 // |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 // Copyright (C) 2018 by via donau |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 // – Österreichische Wasserstraßen-Gesellschaft mbH |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 // Software engineering by Intevation GmbH |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 // |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 // Author(s): |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 package models |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 import ( |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 "encoding/json" |
2036
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
18 "errors" |
2016
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 "time" |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 |
2036
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
21 "gemma.intevation.de/gemma/pkg/common" |
4411
5826d4de0e40
Workarounds for incompatible upstream updates in pgx and cron packages.
Sascha Wilde <wilde@intevation.de>
parents:
3002
diff
changeset
|
22 cron "gopkg.in/robfig/cron.v1" |
2016
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 ) |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 type ( |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 // CronSpec is a string containing a cron line. |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 CronSpec string |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 |
2044
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
29 ConfigTime struct{ time.Time } |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
30 |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
31 ConfigDuration struct{ time.Duration } |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
32 |
2029
8d006afa7c1b
Imports: Stretch imports are not configurabel and scheduable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2025
diff
changeset
|
33 EmailType struct { |
8d006afa7c1b
Imports: Stretch imports are not configurabel and scheduable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2025
diff
changeset
|
34 Email bool `json:"send-email,omitempty"` |
8d006afa7c1b
Imports: Stretch imports are not configurabel and scheduable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2025
diff
changeset
|
35 } |
8d006afa7c1b
Imports: Stretch imports are not configurabel and scheduable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2025
diff
changeset
|
36 |
2016
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 QueueConfigurationType struct { |
2029
8d006afa7c1b
Imports: Stretch imports are not configurabel and scheduable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2025
diff
changeset
|
38 EmailType |
2044
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
39 Trys *int `json:"trys,omitempty"` |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
40 WaitRetry *ConfigDuration `json:"wait-retry,omitempty"` |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
41 Due *ConfigTime `json:"due,omitempty"` |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
42 Cron *CronSpec `json:"cron,omitempty"` |
2016
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 } |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 URLType struct { |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 URL string `json:"url"` |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 Insecure bool `json:"insecure,omitempty"` |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 User *string `json:"user,omitempty"` |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 Password *string `json:"password,omitempty"` |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 } |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 |
2029
8d006afa7c1b
Imports: Stretch imports are not configurabel and scheduable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2025
diff
changeset
|
52 EmailTypeGetter interface { |
8d006afa7c1b
Imports: Stretch imports are not configurabel and scheduable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2025
diff
changeset
|
53 GetEmailType() *EmailType |
8d006afa7c1b
Imports: Stretch imports are not configurabel and scheduable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2025
diff
changeset
|
54 } |
8d006afa7c1b
Imports: Stretch imports are not configurabel and scheduable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2025
diff
changeset
|
55 |
8d006afa7c1b
Imports: Stretch imports are not configurabel and scheduable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2025
diff
changeset
|
56 QueueConfigurationGetter interface { |
8d006afa7c1b
Imports: Stretch imports are not configurabel and scheduable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2025
diff
changeset
|
57 GetQueueConfiguration() *QueueConfigurationType |
8d006afa7c1b
Imports: Stretch imports are not configurabel and scheduable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2025
diff
changeset
|
58 } |
8d006afa7c1b
Imports: Stretch imports are not configurabel and scheduable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2025
diff
changeset
|
59 |
2016
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 URLTypeGetter interface { |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 GetURLType() *URLType |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 } |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 ) |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 func (qct *QueueConfigurationType) GetQueueConfiguration() *QueueConfigurationType { |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 return qct |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 } |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 func (ut *URLType) GetURLType() *URLType { |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 return ut |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 } |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 |
2030
83108e90b223
Imports: Forgot self accessor for new email type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2029
diff
changeset
|
73 func (et *EmailType) GetEmailType() *EmailType { |
83108e90b223
Imports: Forgot self accessor for new email type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2029
diff
changeset
|
74 return et |
83108e90b223
Imports: Forgot self accessor for new email type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2029
diff
changeset
|
75 } |
83108e90b223
Imports: Forgot self accessor for new email type.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2029
diff
changeset
|
76 |
2044
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
77 func (cd *ConfigDuration) UnmarshalJSON(data []byte) error { |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
78 var s string |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
79 if err := json.Unmarshal(data, &s); err != nil { |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
80 return err |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
81 } |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
82 dur, err := time.ParseDuration(s) |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
83 if err != nil { |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
84 return err |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
85 } |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
86 if dur < 0 { |
4847
4847ac70103a
Made staticcheck happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4411
diff
changeset
|
87 return errors.New("duration has to be none negative") |
2044
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
88 } |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
89 *cd = ConfigDuration{dur} |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
90 return nil |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
91 } |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
92 |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
93 func (cd *ConfigDuration) MarshalJSON() ([]byte, error) { |
3002
46ab2cb39471
Fixed serialization of confuguration durations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2298
diff
changeset
|
94 return json.Marshal(cd.Duration.String()) |
2044
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
95 } |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
96 |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
97 func (ct *ConfigTime) UnmarshalJSON(data []byte) error { |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
98 var s string |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
99 if err := json.Unmarshal(data, &s); err != nil { |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
100 return err |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
101 } |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
102 t, err := time.Parse(common.TimeFormat, s) |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
103 if err != nil { |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
104 return err |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
105 } |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
106 *ct = ConfigTime{t} |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
107 return nil |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
108 } |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
109 |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
110 func (ct *ConfigTime) MarshalJSON() ([]byte, error) { |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
111 s := ct.Time.Format(common.TimeFormat) |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
112 return json.Marshal([]byte(s)) |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
113 } |
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
114 |
2016
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
115 // UnmarshalJSON checks if the incoming string is a valid cron line. |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
116 func (cs *CronSpec) UnmarshalJSON(data []byte) error { |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
117 var spec string |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
118 if err := json.Unmarshal(data, &spec); err != nil { |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
119 return err |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
120 } |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
121 if _, err := cron.Parse(spec); err != nil { |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
122 return err |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 } |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
124 *cs = CronSpec(spec) |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
125 return nil |
25967829cf00
Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
126 } |
2036
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
127 |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
128 func (et *EmailType) MarshalAttributes(attrs common.Attributes) error { |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
129 if et.Email { |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
130 attrs.SetBool("email", et.Email) |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
131 } |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
132 return nil |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
133 } |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
134 |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
135 func (et *EmailType) UnmarshalAttributes(attrs common.Attributes) error { |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
136 et.Email = attrs.Bool("email") |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
137 return nil |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
138 } |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
139 |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
140 func (qct *QueueConfigurationType) MarshalAttributes(attrs common.Attributes) error { |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
141 if err := qct.EmailType.MarshalAttributes(attrs); err != nil { |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
142 return err |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
143 } |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
144 if qct.Trys != nil { |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
145 attrs.SetInt("trys", *qct.Trys) |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
146 } |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
147 if qct.WaitRetry != nil { |
2044
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
148 attrs.SetDuration("wait-retry", qct.WaitRetry.Duration) |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
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:
2036
diff
changeset
|
150 if qct.Due != nil { |
2044
ea0b62b7656b
Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2042
diff
changeset
|
151 attrs.SetTime("due", qct.Due.Time) |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
152 } |
2297
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
153 if qct.Cron != nil { |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
154 attrs.Set("cron", string(*qct.Cron)) |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
155 } |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
156 return nil |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
157 } |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
158 |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
159 func (qct *QueueConfigurationType) UnmarshalAttributes(attrs common.Attributes) error { |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
160 if err := qct.EmailType.UnmarshalAttributes(attrs); err != nil { |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
161 return err |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
162 } |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
163 if trys, found := attrs.Int("trys"); found { |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
164 qct.Trys = &trys |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
165 } |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
166 if duration, found := attrs.Duration("wait-retry"); found { |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
167 qct.WaitRetry = &ConfigDuration{duration} |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
168 } |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
169 if due, found := attrs.Time("due"); found { |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
170 qct.Due = &ConfigTime{due} |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
171 } |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
172 if cron, found := attrs.Get("cron"); found { |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
173 cs := CronSpec(cron) |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
174 qct.Cron = &cs |
c8cc875d271c
Import config: Marshalling of so properties got lost somehow.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2044
diff
changeset
|
175 } |
2042
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
176 return nil |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
177 } |
d29ac997eb34
This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2036
diff
changeset
|
178 |
2036
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
179 func (ut *URLType) MarshalAttributes(attrs common.Attributes) error { |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
180 attrs.Set("url", ut.URL) |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
181 if ut.Insecure { |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
182 attrs.SetBool("insecure", ut.Insecure) |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
183 } |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
184 if ut.User != nil { |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
185 attrs.Set("user", *ut.User) |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
186 } |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
187 if ut.Password != nil { |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
188 attrs.Set("password", *ut.Password) |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
189 } |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
190 return nil |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
191 } |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
192 |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
193 func (ut *URLType) UnmarshalAttributes(attrs common.Attributes) error { |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
194 url, found := attrs.Get("url") |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
195 if !found { |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
196 return errors.New("missing 'url' attribute") |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
197 } |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
198 ut.URL = url |
2298
6f56a43b3bb2
Import config: Add another forgotten flag.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2297
diff
changeset
|
199 if insecure := attrs.Bool("insecure"); insecure { |
6f56a43b3bb2
Import config: Add another forgotten flag.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2297
diff
changeset
|
200 ut.Insecure = insecure |
6f56a43b3bb2
Import config: Add another forgotten flag.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2297
diff
changeset
|
201 } |
2036
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
202 if user, found := attrs.Get("user"); found { |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
203 ut.User = &user |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
204 } |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
205 if password, found := attrs.Get("password"); found { |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
206 ut.Password = &password |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
207 } |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
208 return nil |
74e24ae3205a
Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2030
diff
changeset
|
209 } |