/
soma_handler_tree_keeper__startup_vars.go
219 lines (214 loc) · 11.2 KB
/
soma_handler_tree_keeper__startup_vars.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
package main
var tkStmtLoadSystemPropInstances = `
SELECT CASE WHEN srsp.instance_id IS NOT NULL THEN srsp.instance_id
ELSE CASE WHEN sbsp.instance_id IS NOT NULL THEN sbsp.instance_id
ELSE CASE WHEN sgsp.instance_id IS NOT NULL THEN sgsp.instance_id
ELSE CASE WHEN scsp.instance_id IS NOT NULL THEN scsp.instance_id
ELSE CASE WHEN snsp.instance_id IS NOT NULL THEN snsp.instance_id
ELSE '00000000-0000-0000-0000-000000000000'
END
END
END
END
END AS "instance_id",
CASE WHEN srsp.object_type IS NOT NULL THEN srsp.object_type
ELSE CASE WHEN sbsp.object_type IS NOT NULL THEN sbsp.object_type
ELSE CASE WHEN sgsp.object_type IS NOT NULL THEN sgsp.object_type
ELSE CASE WHEN scsp.object_type IS NOT NULL THEN scsp.object_type
ELSE CASE WHEN snsp.object_type IS NOT NULL THEN snsp.object_type
ELSE 'MAGIC_NO_RESULT_VALUE'
END
END
END
END
END AS "object_type",
CASE WHEN srsp.repository_id IS NOT NULL THEN srsp.repository_id
ELSE CASE WHEN sbsp.bucket_id IS NOT NULL THEN sbsp.bucket_id
ELSE CASE WHEN sgsp.group_id IS NOT NULL THEN sgsp.group_id
ELSE CASE WHEN scsp.cluster_id IS NOT NULL THEN scsp.cluster_id
ELSE CASE WHEN snsp.node_id IS NOT NULL THEN snsp.node_id
ELSE '00000000-0000-0000-0000-000000000000'
END
END
END
END
END AS "object_id"
FROM soma.property_instances spi
LEFT JOIN soma.repository_system_properties srsp
ON spi.instance_id = srsp.instance_id
AND spi.source_instance_id = srsp.source_instance_id
LEFT JOIN soma.bucket_system_properties sbsp
ON spi.instance_id = sbsp.instance_id
AND spi.source_instance_id = sbsp.source_instance_id
LEFT JOIN soma.group_system_properties sgsp
ON spi.instance_id = sgsp.instance_id
AND spi.source_instance_id = sgsp.source_instance_id
LEFT JOIN soma.cluster_system_properties scsp
ON spi.instance_id = scsp.instance_id
AND spi.source_instance_id = scsp.source_instance_id
LEFT JOIN soma.node_system_properties snsp
ON spi.instance_id = snsp.instance_id
AND spi.source_instance_id = snsp.source_instance_id
WHERE spi.instance_id != spi.source_instance_id
AND spi.repository_id = $1::uuid
AND spi.source_instance_id = $2::uuid;`
var tkStmtLoadCustomPropInstances = `
SELECT CASE WHEN srsp.instance_id IS NOT NULL THEN srsp.instance_id
ELSE CASE WHEN sbsp.instance_id IS NOT NULL THEN sbsp.instance_id
ELSE CASE WHEN sgsp.instance_id IS NOT NULL THEN sgsp.instance_id
ELSE CASE WHEN scsp.instance_id IS NOT NULL THEN scsp.instance_id
ELSE CASE WHEN snsp.instance_id IS NOT NULL THEN snsp.instance_id
ELSE '00000000-0000-0000-0000-000000000000'
END
END
END
END
END AS "instance_id",
CASE WHEN srsp.instance_id IS NOT NULL THEN 'repository'
ELSE CASE WHEN sbsp.instance_id IS NOT NULL THEN 'bucket'
ELSE CASE WHEN sgsp.instance_id IS NOT NULL THEN 'group'
ELSE CASE WHEN scsp.instance_id IS NOT NULL THEN 'cluster'
ELSE CASE WHEN snsp.instance_id IS NOT NULL THEN 'node'
ELSE 'MAGIC_NO_RESULT_VALUE'
END
END
END
END
END AS "object_type",
CASE WHEN srsp.repository_id IS NOT NULL THEN srsp.repository_id
ELSE CASE WHEN sbsp.bucket_id IS NOT NULL THEN sbsp.bucket_id
ELSE CASE WHEN sgsp.group_id IS NOT NULL THEN sgsp.group_id
ELSE CASE WHEN scsp.cluster_id IS NOT NULL THEN scsp.cluster_id
ELSE CASE WHEN snsp.node_id IS NOT NULL THEN snsp.node_id
ELSE '00000000-0000-0000-0000-000000000000'
END
END
END
END
END AS "object_id"
FROM soma.property_instances spi
LEFT JOIN soma.repository_custom_properties srsp
ON spi.instance_id = srsp.instance_id
AND spi.source_instance_id = srsp.source_instance_id
LEFT JOIN soma.bucket_custom_properties sbsp
ON spi.instance_id = sbsp.instance_id
AND spi.source_instance_id = sbsp.source_instance_id
LEFT JOIN soma.group_custom_properties sgsp
ON spi.instance_id = sgsp.instance_id
AND spi.source_instance_id = sgsp.source_instance_id
LEFT JOIN soma.cluster_custom_properties scsp
ON spi.instance_id = scsp.instance_id
AND spi.source_instance_id = scsp.source_instance_id
LEFT JOIN soma.node_custom_properties snsp
ON spi.instance_id = snsp.instance_id
AND spi.source_instance_id = snsp.source_instance_id
WHERE spi.instance_id != spi.source_instance_id
AND spi.repository_id = $1::uuid
AND spi.source_instance_id = $2::uuid;`
var tkStmtLoadServicePropInstances = `
SELECT CASE WHEN srsp.instance_id IS NOT NULL THEN srsp.instance_id
ELSE CASE WHEN sbsp.instance_id IS NOT NULL THEN sbsp.instance_id
ELSE CASE WHEN sgsp.instance_id IS NOT NULL THEN sgsp.instance_id
ELSE CASE WHEN scsp.instance_id IS NOT NULL THEN scsp.instance_id
ELSE CASE WHEN snsp.instance_id IS NOT NULL THEN snsp.instance_id
ELSE '00000000-0000-0000-0000-000000000000'
END
END
END
END
END AS "instance_id",
CASE WHEN srsp.instance_id IS NOT NULL THEN 'repository'
ELSE CASE WHEN sbsp.instance_id IS NOT NULL THEN 'bucket'
ELSE CASE WHEN sgsp.instance_id IS NOT NULL THEN 'group'
ELSE CASE WHEN scsp.instance_id IS NOT NULL THEN 'cluster'
ELSE CASE WHEN snsp.instance_id IS NOT NULL THEN 'node'
ELSE 'MAGIC_NO_RESULT_VALUE'
END
END
END
END
END AS "object_type",
CASE WHEN srsp.repository_id IS NOT NULL THEN srsp.repository_id
ELSE CASE WHEN sbsp.bucket_id IS NOT NULL THEN sbsp.bucket_id
ELSE CASE WHEN sgsp.group_id IS NOT NULL THEN sgsp.group_id
ELSE CASE WHEN scsp.cluster_id IS NOT NULL THEN scsp.cluster_id
ELSE CASE WHEN snsp.node_id IS NOT NULL THEN snsp.node_id
ELSE '00000000-0000-0000-0000-000000000000'
END
END
END
END
END AS "object_id"
FROM soma.property_instances spi
LEFT JOIN soma.repository_service_properties srsp
ON spi.instance_id = srsp.instance_id
AND spi.source_instance_id = srsp.source_instance_id
LEFT JOIN soma.bucket_service_properties sbsp
ON spi.instance_id = sbsp.instance_id
AND spi.source_instance_id = sbsp.source_instance_id
LEFT JOIN soma.group_service_properties sgsp
ON spi.instance_id = sgsp.instance_id
AND spi.source_instance_id = sgsp.source_instance_id
LEFT JOIN soma.cluster_service_properties scsp
ON spi.instance_id = scsp.instance_id
AND spi.source_instance_id = scsp.source_instance_id
LEFT JOIN soma.node_service_properties snsp
ON spi.instance_id = snsp.instance_id
AND spi.source_instance_id = snsp.source_instance_id
WHERE spi.instance_id != spi.source_instance_id
AND spi.repository_id = $1::uuid
AND spi.source_instance_id = $2::uuid;`
var tkStmtLoadOncallPropInstances = `
SELECT CASE WHEN srsp.instance_id IS NOT NULL THEN srsp.instance_id
ELSE CASE WHEN sbsp.instance_id IS NOT NULL THEN sbsp.instance_id
ELSE CASE WHEN sgsp.instance_id IS NOT NULL THEN sgsp.instance_id
ELSE CASE WHEN scsp.instance_id IS NOT NULL THEN scsp.instance_id
ELSE CASE WHEN snsp.instance_id IS NOT NULL THEN snsp.instance_id
ELSE '00000000-0000-0000-0000-000000000000'
END
END
END
END
END AS "instance_id",
CASE WHEN srsp.instance_id IS NOT NULL THEN 'repository'
ELSE CASE WHEN sbsp.instance_id IS NOT NULL THEN 'bucket'
ELSE CASE WHEN sgsp.instance_id IS NOT NULL THEN 'group'
ELSE CASE WHEN scsp.instance_id IS NOT NULL THEN 'cluster'
ELSE CASE WHEN snsp.instance_id IS NOT NULL THEN 'node'
ELSE 'MAGIC_NO_RESULT_VALUE'
END
END
END
END
END AS "object_type",
CASE WHEN srsp.repository_id IS NOT NULL THEN srsp.repository_id
ELSE CASE WHEN sbsp.bucket_id IS NOT NULL THEN sbsp.bucket_id
ELSE CASE WHEN sgsp.group_id IS NOT NULL THEN sgsp.group_id
ELSE CASE WHEN scsp.cluster_id IS NOT NULL THEN scsp.cluster_id
ELSE CASE WHEN snsp.node_id IS NOT NULL THEN snsp.node_id
ELSE '00000000-0000-0000-0000-000000000000'
END
END
END
END
END AS "object_id"
FROM soma.property_instances spi
LEFT JOIN soma.repository_oncall_properties srsp
ON spi.instance_id = srsp.instance_id
AND spi.source_instance_id = srsp.source_instance_id
LEFT JOIN soma.bucket_oncall_properties sbsp
ON spi.instance_id = sbsp.instance_id
AND spi.source_instance_id = sbsp.source_instance_id
LEFT JOIN soma.group_oncall_properties sgsp
ON spi.instance_id = sgsp.instance_id
AND spi.source_instance_id = sgsp.source_instance_id
LEFT JOIN soma.cluster_oncall_properties scsp
ON spi.instance_id = scsp.instance_id
AND spi.source_instance_id = scsp.source_instance_id
LEFT JOIN soma.node_oncall_property snsp
ON spi.instance_id = snsp.instance_id
AND spi.source_instance_id = snsp.source_instance_id
WHERE spi.instance_id != spi.source_instance_id
AND spi.repository_id = $1::uuid
AND spi.source_instance_id = $2::uuid;`
// vim: ts=4 sw=4 sts=4 noet fenc=utf-8 ffs=unix