Mercurial > gemma
annotate pkg/imports/scheduled.go @ 1927:5a37ee321651
client: make isolines legend graphic internally availableo
* Add isolines legend graphic to vuex store. Rename it to reflect
it being a dataURL now.
* License header: for store/map.js add 2019 and author BER.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Mon, 21 Jan 2019 10:56:14 +0100 |
parents | 427f86518097 |
children | 8eeb0b5eb340 |
rev | line source |
---|---|
1551
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 // This is Free Software under GNU Affero General Public License v >= 3.0 |
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 // without warranty, see README.md and license for details. |
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 // |
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 // SPDX-License-Identifier: AGPL-3.0-or-later |
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 // License-Filename: LICENSES/AGPL-3.0.txt |
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 // |
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 // Copyright (C) 2018 by via donau |
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 // – Österreichische Wasserstraßen-Gesellschaft mbH |
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 // Software engineering by Intevation GmbH |
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 // |
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 // Author(s): |
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> |
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 package imports |
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 import ( |
1748
c11807dc6940
Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1746
diff
changeset
|
17 "context" |
c11807dc6940
Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1746
diff
changeset
|
18 "database/sql" |
1705
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
19 "errors" |
1729
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
20 "fmt" |
1551
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 "log" |
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 |
1661
51a0ba4ede41
Scheduled imports: Made gauge measurement import able to be scheduled.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1654
diff
changeset
|
23 "gemma.intevation.de/gemma/pkg/common" |
1551
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 "gemma.intevation.de/gemma/pkg/scheduler" |
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 ) |
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 |
1729
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
27 // JobKindSetups maps JobKinds to special setup functions. |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
28 var JobKindSetups = map[JobKind]func(*IDConfig) (interface{}, error){ |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
29 |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
30 GMJobKind: func(cfg *IDConfig) (interface{}, error) { |
1665
da0d1a19ebe6
Fairway availability import: Made schedulable, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1661
diff
changeset
|
31 log.Println("info: schedule 'gm' import") |
1705
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
32 insecure := cfg.Attributes.Bool("insecure") |
1665
da0d1a19ebe6
Fairway availability import: Made schedulable, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1661
diff
changeset
|
33 return &GaugeMeasurement{ |
da0d1a19ebe6
Fairway availability import: Made schedulable, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1661
diff
changeset
|
34 URL: *cfg.URL, |
1705
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
35 Insecure: insecure, |
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
36 }, nil |
1729
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
37 }, |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
38 |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
39 FAJobKind: func(cfg *IDConfig) (interface{}, error) { |
1665
da0d1a19ebe6
Fairway availability import: Made schedulable, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1661
diff
changeset
|
40 log.Println("info: schedule 'fa' import") |
1705
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
41 insecure := cfg.Attributes.Bool("insecure") |
1665
da0d1a19ebe6
Fairway availability import: Made schedulable, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1661
diff
changeset
|
42 return &FairwayAvailability{ |
da0d1a19ebe6
Fairway availability import: Made schedulable, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1661
diff
changeset
|
43 URL: *cfg.URL, |
1705
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
44 Insecure: insecure, |
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
45 }, nil |
1729
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
46 }, |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
47 |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
48 BNJobKind: func(cfg *IDConfig) (interface{}, error) { |
1666
56b29406a163
Bottleneck import: Made schedulable, too. Even if it's not required.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1665
diff
changeset
|
49 log.Println("info: schedule 'bn' import") |
1705
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
50 insecure := cfg.Attributes.Bool("insecure") |
1666
56b29406a163
Bottleneck import: Made schedulable, too. Even if it's not required.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1665
diff
changeset
|
51 return &Bottleneck{ |
56b29406a163
Bottleneck import: Made schedulable, too. Even if it's not required.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1665
diff
changeset
|
52 URL: *cfg.URL, |
1705
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
53 Insecure: insecure, |
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
54 }, nil |
1729
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
55 }, |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
56 |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
57 WXJobKind: func(cfg *IDConfig) (interface{}, error) { |
1678
8fdb57173e3f
Waterway axis import: Made schedulable, too. TODO: Remove hard-coded parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
58 log.Println("info: schedule 'wx' import") |
1705
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
59 ft, found := cfg.Attributes.Get("feature-type") |
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
60 if !found { |
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
61 return nil, errors.New("cannot find 'feature-type' attribute") |
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
62 } |
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
63 sb, found := cfg.Attributes.Get("sort-by") |
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
64 if !found { |
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
65 return nil, errors.New("cannot find 'sort-by' attribute") |
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
66 } |
1678
8fdb57173e3f
Waterway axis import: Made schedulable, too. TODO: Remove hard-coded parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
67 return &WaterwayAxis{ |
8fdb57173e3f
Waterway axis import: Made schedulable, too. TODO: Remove hard-coded parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1666
diff
changeset
|
68 URL: *cfg.URL, |
1705
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
69 FeatureType: ft, |
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
70 SortBy: sb, |
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
71 }, nil |
1729
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
72 }, |
1785
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1754
diff
changeset
|
73 |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1754
diff
changeset
|
74 WAJobKind: func(cfg *IDConfig) (interface{}, error) { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1754
diff
changeset
|
75 log.Println("info: schedule 'wa' import") |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1754
diff
changeset
|
76 ft, found := cfg.Attributes.Get("feature-type") |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1754
diff
changeset
|
77 if !found { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1754
diff
changeset
|
78 return nil, errors.New("cannot find 'feature-type' attribute") |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1754
diff
changeset
|
79 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1754
diff
changeset
|
80 sb, found := cfg.Attributes.Get("sort-by") |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1754
diff
changeset
|
81 if !found { |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1754
diff
changeset
|
82 return nil, errors.New("cannot find 'sort-by' attribute") |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1754
diff
changeset
|
83 } |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1754
diff
changeset
|
84 return &WaterwayArea{ |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1754
diff
changeset
|
85 URL: *cfg.URL, |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1754
diff
changeset
|
86 FeatureType: ft, |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1754
diff
changeset
|
87 SortBy: sb, |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1754
diff
changeset
|
88 }, nil |
614c6c766691
Waterway area import: Implemented.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
1754
diff
changeset
|
89 }, |
1808
77582da3adb0
Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
90 |
1856
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
91 FDJobKind: func(cfg *IDConfig) (interface{}, error) { |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
92 log.Println("info: schedule 'fd' import") |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
93 ft, found := cfg.Attributes.Get("feature-type") |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
94 if !found { |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
95 return nil, errors.New("cannot find 'feature-type' attribute") |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
96 } |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
97 sb, found := cfg.Attributes.Get("sort-by") |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
98 if !found { |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
99 return nil, errors.New("cannot find 'sort-by' attribute") |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
100 } |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
101 los, found := cfg.Attributes.Int("los") |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
102 if !found { |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
103 return nil, errors.New("cannot find 'los' attribute") |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
104 } |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
105 minWidth, found := cfg.Attributes.Int("min-width") |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
106 if !found { |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
107 return nil, errors.New("cannot find 'min-width' attribute") |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
108 } |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
109 maxWidth, found := cfg.Attributes.Int("max-width") |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
110 if !found { |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
111 return nil, errors.New("cannot find 'max-width' attribute") |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
112 } |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
113 depth, found := cfg.Attributes.Int("depth") |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
114 if !found { |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
115 return nil, errors.New("cannot find 'depth' attribute") |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
116 } |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
117 sourceOrganization, found := cfg.Attributes.Get("source-organization") |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
118 if !found { |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
119 return nil, errors.New("cannot find 'source-organization' attribute") |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
120 } |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
121 |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
122 return &FairwayDimension{ |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
123 URL: *cfg.URL, |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
124 FeatureType: ft, |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
125 SortBy: sb, |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
126 LOS: los, |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
127 MinWidth: minWidth, |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
128 MaxWidth: maxWidth, |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
129 Depth: depth, |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
130 SourceOrganization: sourceOrganization, |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
131 }, nil |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
132 }, |
5996b50d154a
Fairway dimension import: Added missing scheduled configuration.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1855
diff
changeset
|
133 |
1808
77582da3adb0
Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
134 WGJobKind: func(cfg *IDConfig) (interface{}, error) { |
77582da3adb0
Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
135 log.Println("info: schedule 'wg' import") |
77582da3adb0
Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
136 username, _ := cfg.Attributes.Get("username") |
77582da3adb0
Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
137 password, _ := cfg.Attributes.Get("password") |
77582da3adb0
Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
138 insecure := cfg.Attributes.Bool("insecure") |
77582da3adb0
Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
139 return &WaterwayGauge{ |
77582da3adb0
Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
140 URL: *cfg.URL, |
77582da3adb0
Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
141 Username: username, |
77582da3adb0
Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
142 Password: password, |
77582da3adb0
Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
143 Insecure: insecure, |
77582da3adb0
Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
144 }, nil |
77582da3adb0
Waterway gauges import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1785
diff
changeset
|
145 }, |
1855
bbd653a43a6a
Distance marks virtual import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1808
diff
changeset
|
146 |
bbd653a43a6a
Distance marks virtual import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1808
diff
changeset
|
147 DMVJobKind: func(cfg *IDConfig) (interface{}, error) { |
bbd653a43a6a
Distance marks virtual import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1808
diff
changeset
|
148 log.Println("info: schedule 'dvm' import") |
bbd653a43a6a
Distance marks virtual import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1808
diff
changeset
|
149 username, _ := cfg.Attributes.Get("username") |
bbd653a43a6a
Distance marks virtual import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1808
diff
changeset
|
150 password, _ := cfg.Attributes.Get("password") |
bbd653a43a6a
Distance marks virtual import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1808
diff
changeset
|
151 insecure := cfg.Attributes.Bool("insecure") |
bbd653a43a6a
Distance marks virtual import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1808
diff
changeset
|
152 return &DistanceMarksVirtual{ |
bbd653a43a6a
Distance marks virtual import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1808
diff
changeset
|
153 URL: *cfg.URL, |
bbd653a43a6a
Distance marks virtual import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1808
diff
changeset
|
154 Username: username, |
bbd653a43a6a
Distance marks virtual import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1808
diff
changeset
|
155 Password: password, |
bbd653a43a6a
Distance marks virtual import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1808
diff
changeset
|
156 Insecure: insecure, |
bbd653a43a6a
Distance marks virtual import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1808
diff
changeset
|
157 }, nil |
bbd653a43a6a
Distance marks virtual import: Added stub.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1808
diff
changeset
|
158 }, |
1862
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1856
diff
changeset
|
159 DMAJobKind: func(cfg *IDConfig) (interface{}, error) { |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1856
diff
changeset
|
160 log.Println("info: schedule 'dma' import") |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1856
diff
changeset
|
161 ft, found := cfg.Attributes.Get("feature-type") |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1856
diff
changeset
|
162 if !found { |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1856
diff
changeset
|
163 return nil, errors.New("cannot find 'feature-type' attribute") |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1856
diff
changeset
|
164 } |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1856
diff
changeset
|
165 sb, found := cfg.Attributes.Get("sort-by") |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1856
diff
changeset
|
166 if !found { |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1856
diff
changeset
|
167 return nil, errors.New("cannot find 'sort-by' attribute") |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1856
diff
changeset
|
168 } |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1856
diff
changeset
|
169 return &DistanceMarksAshore{ |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1856
diff
changeset
|
170 URL: *cfg.URL, |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1856
diff
changeset
|
171 FeatureType: ft, |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1856
diff
changeset
|
172 SortBy: sb, |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1856
diff
changeset
|
173 }, nil |
427f86518097
Added distance marks importer in backend.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1856
diff
changeset
|
174 }, |
1551
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
175 } |
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
176 |
1729
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
177 func init() { |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
178 run := func(cfgID int64) { |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
179 jobID, err := RunConfiguredImport(cfgID) |
1665
da0d1a19ebe6
Fairway availability import: Made schedulable, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1661
diff
changeset
|
180 if err != nil { |
1729
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
181 log.Printf("error: running scheduled import failed: %v\n", err) |
1705
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
182 return |
dcbe2a7dc532
Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1678
diff
changeset
|
183 } |
1665
da0d1a19ebe6
Fairway availability import: Made schedulable, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1661
diff
changeset
|
184 log.Printf("info: added import #%d to queue\n", jobID) |
1661
51a0ba4ede41
Scheduled imports: Made gauge measurement import able to be scheduled.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1654
diff
changeset
|
185 } |
51a0ba4ede41
Scheduled imports: Made gauge measurement import able to be scheduled.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1654
diff
changeset
|
186 |
1729
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
187 for kind := range JobKindSetups { |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
188 scheduler.RegisterAction(string(kind), run) |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
189 } |
1551
d9eba69f6515
Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
190 } |
1729
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
191 |
1748
c11807dc6940
Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1746
diff
changeset
|
192 // RunConfiguredImportContext runs an import configured from the database. |
c11807dc6940
Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1746
diff
changeset
|
193 func RunConfiguredImportContext(ctx context.Context, conn *sql.Conn, id int64) (int64, error) { |
c11807dc6940
Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1746
diff
changeset
|
194 cfg, err := LoadIDConfigContext(ctx, conn, id) |
c11807dc6940
Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1746
diff
changeset
|
195 return runConfiguredImport(id, cfg, err) |
c11807dc6940
Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1746
diff
changeset
|
196 } |
c11807dc6940
Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1746
diff
changeset
|
197 |
1729
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
198 // RunConfiguredImport runs an import configured from the database. |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
199 func RunConfiguredImport(id int64) (int64, error) { |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
200 cfg, err := loadIDConfig(id) |
1748
c11807dc6940
Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1746
diff
changeset
|
201 return runConfiguredImport(id, cfg, err) |
c11807dc6940
Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1746
diff
changeset
|
202 } |
c11807dc6940
Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1746
diff
changeset
|
203 |
c11807dc6940
Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1746
diff
changeset
|
204 func runConfiguredImport(id int64, cfg *IDConfig, err error) (int64, error) { |
c11807dc6940
Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1746
diff
changeset
|
205 |
1729
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
206 if err != nil { |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
207 return 0, err |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
208 } |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
209 if cfg == nil { |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
210 return 0, fmt.Errorf("no config found for id %d.\n", id) |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
211 } |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
212 if cfg.URL == nil { |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
213 return 0, errors.New("error: No URL specified") |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
214 } |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
215 |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
216 kind := JobKind(cfg.Kind) |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
217 |
1746
09f51f2b3b0d
Cosmetics.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1729
diff
changeset
|
218 setup := JobKindSetups[kind] |
09f51f2b3b0d
Cosmetics.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1729
diff
changeset
|
219 if setup == nil { |
1729
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
220 return 0, fmt.Errorf("unknown job kind: %s", cfg.Kind) |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
221 } |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
222 |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
223 what, err := setup(cfg) |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
224 if err != nil { |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
225 return 0, err |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
226 } |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
227 |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
228 var serialized string |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
229 if serialized, err = common.ToJSONString(what); err != nil { |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
230 return 0, err |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
231 } |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
232 |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
233 due, _ := cfg.Attributes.Time("due") |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
234 |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
235 retries, found := cfg.Attributes.Int("retries") |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
236 if !found { |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
237 retries = -1 |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
238 } |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
239 |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
240 var jobID int64 |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
241 if jobID, err = AddJob( |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
242 kind, |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
243 due, retries, |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
244 cfg.User, |
1754
807569b08513
Import queue: Auto acceptance is now a property of the import kind itself and is not configurable any more.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1748
diff
changeset
|
245 cfg.SendEMail, |
1729
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
246 serialized, |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
247 ); err != nil { |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
248 return 0, err |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
249 } |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
250 |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
251 return jobID, nil |
74f7d4c531bc
Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1708
diff
changeset
|
252 } |