annotate pkg/models/importbase.go @ 2044:ea0b62b7656b unify_imports

Imports: Unified JSON marshaling of times and durations in imports.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 25 Jan 2019 17:54:02 +0100
parents d29ac997eb34
children c8cc875d271c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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"
2016
25967829cf00 Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 "github.com/robfig/cron"
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 {
ea0b62b7656b Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
87 return errors.New("duration has to be none negative.")
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) {
ea0b62b7656b Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
94 s := cd.Duration.String()
ea0b62b7656b Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
95 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
96 }
ea0b62b7656b Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
97
ea0b62b7656b Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
98 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
99 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
100 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
101 return err
ea0b62b7656b Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
102 }
ea0b62b7656b Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
103 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
104 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
105 return err
ea0b62b7656b Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
106 }
ea0b62b7656b Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
107 *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
108 return nil
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
ea0b62b7656b Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
111 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
112 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
113 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
114 }
ea0b62b7656b Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
115
2016
25967829cf00 Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
116 // 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
117 func (cs *CronSpec) UnmarshalJSON(data []byte) error {
25967829cf00 Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
118 var spec string
25967829cf00 Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
119 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
120 return err
25967829cf00 Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
121 }
25967829cf00 Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
122 if _, err := cron.Parse(spec); err != nil {
25967829cf00 Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
123 return err
25967829cf00 Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
124 }
25967829cf00 Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
125 *cs = CronSpec(spec)
25967829cf00 Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
126 return nil
25967829cf00 Started to simplify the import models.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
127 }
2036
74e24ae3205a Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2030
diff changeset
128
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
129 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
130 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
131 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
132 }
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 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
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
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 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
137 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
138 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
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
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 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
142 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
143 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
144 }
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 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
146 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
147 }
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
148 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
149 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
150 }
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
151 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
152 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
153 }
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
154 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
155 }
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
156
2036
74e24ae3205a Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2030
diff changeset
157 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
158 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
159 if ut.Insecure {
74e24ae3205a Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2030
diff changeset
160 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
161 }
74e24ae3205a Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2030
diff changeset
162 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
163 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
164 }
74e24ae3205a Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2030
diff changeset
165 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
166 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
167 }
74e24ae3205a Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2030
diff changeset
168 return nil
74e24ae3205a Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2030
diff changeset
169 }
74e24ae3205a Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2030
diff changeset
170
74e24ae3205a Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2030
diff changeset
171 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
172 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
173 if !found {
74e24ae3205a Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2030
diff changeset
174 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
175 }
74e24ae3205a Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2030
diff changeset
176 ut.URL = url
74e24ae3205a Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2030
diff changeset
177 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
178 ut.User = &user
74e24ae3205a Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2030
diff changeset
179 }
74e24ae3205a Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2030
diff changeset
180 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
181 ut.Password = &password
74e24ae3205a Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2030
diff changeset
182 }
74e24ae3205a Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2030
diff changeset
183 return nil
74e24ae3205a Imports: Added a persistent model for the extra attributes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2030
diff changeset
184 }