adiwg-mdtranslator 2.0.0rc2 → 2.0.0rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -0
- data/adiwg-mdtranslator.gemspec +31 -30
- data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +945 -945
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_keyword.rb +70 -57
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_resourceInfo.rb +338 -336
- data/lib/adiwg/mdtranslator/version.rb +8 -9
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_resourceInfo.rb +1 -1
- data/lib/adiwg/mdtranslator/writers/sbJson/sbJson_writer.rb +40 -118
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_citation.rb +79 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_id.rb +54 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_identifier.rb +24 -17
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_sbJson.rb +57 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/version.rb +13 -9
- metadata +7 -32
@@ -2,7 +2,9 @@
|
|
2
2
|
# Reader - ADIwg JSON to internal data structure
|
3
3
|
|
4
4
|
# History:
|
5
|
-
#
|
5
|
+
# Stan Smith 2017-05-16 deprecated topic category
|
6
|
+
# ... topic category is now handled as keyword list
|
7
|
+
# Stan Smith 2016-11-01 original script
|
6
8
|
|
7
9
|
require_relative 'module_resourceType'
|
8
10
|
require_relative 'module_citation'
|
@@ -24,341 +26,341 @@ require_relative 'module_locale'
|
|
24
26
|
require_relative 'module_maintenance'
|
25
27
|
|
26
28
|
module ADIWG
|
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
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
end
|
29
|
+
module Mdtranslator
|
30
|
+
module Readers
|
31
|
+
module MdJson
|
32
|
+
|
33
|
+
module ResourceInfo
|
34
|
+
|
35
|
+
def self.unpack(hResInfo, responseObj)
|
36
|
+
|
37
|
+
# return nil object if input is empty
|
38
|
+
if hResInfo.empty?
|
39
|
+
responseObj[:readerExecutionMessages] << 'ResourceInfo object is empty'
|
40
|
+
responseObj[:readerExecutionPass] = false
|
41
|
+
return nil
|
42
|
+
end
|
43
|
+
|
44
|
+
# instance classes needed in script
|
45
|
+
intMetadataClass = InternalMetadata.new
|
46
|
+
intResInfo = intMetadataClass.newResourceInfo
|
47
|
+
|
48
|
+
# resource information - resource type [] (required) {resourceType}
|
49
|
+
if hResInfo.has_key?('resourceType')
|
50
|
+
hResInfo['resourceType'].each do |item|
|
51
|
+
unless item.empty?
|
52
|
+
hReturn = ResourceType.unpack(item, responseObj)
|
53
|
+
unless hReturn.nil?
|
54
|
+
intResInfo[:resourceTypes] << hReturn
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
if intResInfo[:resourceTypes].empty?
|
60
|
+
responseObj[:readerExecutionMessages] << 'ResourceInfo is missing resourceType'
|
61
|
+
responseObj[:readerExecutionPass] = false
|
62
|
+
return nil
|
63
|
+
end
|
64
|
+
|
65
|
+
# resource information - citation {citation} (required)
|
66
|
+
if hResInfo.has_key?('citation')
|
67
|
+
hObject = hResInfo['citation']
|
68
|
+
unless hObject.empty?
|
69
|
+
hReturn = Citation.unpack(hObject, responseObj)
|
70
|
+
unless hReturn.nil?
|
71
|
+
intResInfo[:citation] = hReturn
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
if intResInfo[:citation].empty?
|
76
|
+
responseObj[:readerExecutionMessages] << 'ResourceInfo is missing citation'
|
77
|
+
responseObj[:readerExecutionPass] = false
|
78
|
+
return nil
|
79
|
+
end
|
80
|
+
|
81
|
+
# resource information - abstract (required)
|
82
|
+
if hResInfo.has_key?('abstract')
|
83
|
+
intResInfo[:abstract] = hResInfo['abstract']
|
84
|
+
end
|
85
|
+
if intResInfo[:abstract].nil? || intResInfo[:abstract] == ''
|
86
|
+
responseObj[:readerExecutionMessages] << 'ResourceInfo is missing abstract'
|
87
|
+
responseObj[:readerExecutionPass] = false
|
88
|
+
return nil
|
89
|
+
end
|
90
|
+
|
91
|
+
# resource information - short abstract
|
92
|
+
if hResInfo.has_key?('shortAbstract')
|
93
|
+
if hResInfo['shortAbstract'] != ''
|
94
|
+
intResInfo[:shortAbstract] = hResInfo['shortAbstract']
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# resource information - purpose
|
99
|
+
if hResInfo.has_key?('purpose')
|
100
|
+
if hResInfo['purpose'] != ''
|
101
|
+
intResInfo[:purpose] = hResInfo['purpose']
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# resource information - credits []
|
106
|
+
if hResInfo.has_key?('credit')
|
107
|
+
hResInfo['credit'].each do |item|
|
108
|
+
if item != ''
|
109
|
+
intResInfo[:credits] << item
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# resource information - resource time period {timePeriod}
|
115
|
+
if hResInfo.has_key?('timePeriod')
|
116
|
+
hObject = hResInfo['timePeriod']
|
117
|
+
unless hObject.empty?
|
118
|
+
hReturn = TimePeriod.unpack(hObject, responseObj)
|
119
|
+
unless hReturn.nil?
|
120
|
+
intResInfo[:timePeriod] = hReturn
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# resource information - status [] (required)
|
126
|
+
if hResInfo.has_key?('status')
|
127
|
+
hResInfo['status'].each do |item|
|
128
|
+
if item != ''
|
129
|
+
intResInfo[:status] << item
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
if intResInfo[:status].empty?
|
134
|
+
responseObj[:readerExecutionMessages] << 'ResourceInfo is missing status'
|
135
|
+
responseObj[:readerExecutionPass] = false
|
136
|
+
return nil
|
137
|
+
end
|
138
|
+
|
139
|
+
# resource information - topic category (deprecated)
|
140
|
+
if hResInfo.has_key?('topicCategory')
|
141
|
+
unless hResInfo['topicCategory'].empty?
|
142
|
+
responseObj[:readerExecutionMessages] << 'TopicCategory is deprecated, use keyword type isoTopicCategory instead'
|
143
|
+
responseObj[:readerExecutionPass] = false
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# resource information - point of contact [] {responsibleParty} (required)
|
148
|
+
if hResInfo.has_key?('pointOfContact')
|
149
|
+
aItems = hResInfo['pointOfContact']
|
150
|
+
aItems.each do |item|
|
151
|
+
hReturn = ResponsibleParty.unpack(item, responseObj)
|
152
|
+
unless hReturn.nil?
|
153
|
+
intResInfo[:pointOfContacts] << hReturn
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
if intResInfo[:pointOfContacts].empty?
|
158
|
+
responseObj[:readerExecutionMessages] << 'ResourceInfo object is missing pointOfContact'
|
159
|
+
responseObj[:readerExecutionPass] = false
|
160
|
+
return nil
|
161
|
+
end
|
162
|
+
|
163
|
+
# resource information - spatial reference system [] {spatialReference}
|
164
|
+
if hResInfo.has_key?('spatialReferenceSystem')
|
165
|
+
aItems = hResInfo['spatialReferenceSystem']
|
166
|
+
aItems.each do |item|
|
167
|
+
hReturn = SpatialReferenceSystem.unpack(item, responseObj)
|
168
|
+
unless hReturn.nil?
|
169
|
+
intResInfo[:spatialReferenceSystems] << hReturn
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
# resource information - spatial representation type []
|
175
|
+
if hResInfo.has_key?('spatialRepresentationType')
|
176
|
+
hResInfo['spatialRepresentationType'].each do |item|
|
177
|
+
if item != ''
|
178
|
+
intResInfo[:spatialRepresentationTypes] << item
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
# resource information - spatial representation [] {spatialRepresentation}
|
184
|
+
if hResInfo.has_key?('spatialRepresentation')
|
185
|
+
aItems = hResInfo['spatialRepresentation']
|
186
|
+
aItems.each do |item|
|
187
|
+
hReturn = SpatialRepresentation.unpack(item, responseObj)
|
188
|
+
unless hReturn.nil?
|
189
|
+
intResInfo[:spatialRepresentations] << hReturn
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
# resource information - spatial resolution [] {spatialResolution}
|
195
|
+
if hResInfo.has_key?('spatialResolution')
|
196
|
+
aItems = hResInfo['spatialResolution']
|
197
|
+
aItems.each do |item|
|
198
|
+
hReturn = SpatialResolution.unpack(item, responseObj)
|
199
|
+
unless hReturn.nil?
|
200
|
+
intResInfo[:spatialResolutions] << hReturn
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
# resource information - temporal resolution [] {duration}
|
206
|
+
if hResInfo.has_key?('temporalResolution')
|
207
|
+
aItems = hResInfo['temporalResolution']
|
208
|
+
aItems.each do |item|
|
209
|
+
hReturn = Duration.unpack(item, responseObj)
|
210
|
+
unless hReturn.nil?
|
211
|
+
intResInfo[:temporalResolutions] << hReturn
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
# resource information - extent [] {extent}
|
217
|
+
if hResInfo.has_key?('extent')
|
218
|
+
aItems = hResInfo['extent']
|
219
|
+
aItems.each do |item|
|
220
|
+
hReturn = Extent.unpack(item, responseObj)
|
221
|
+
unless hReturn.nil?
|
222
|
+
intResInfo[:extents] << hReturn
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
# resource information - content information [] {contentInformation}
|
228
|
+
if hResInfo.has_key?('coverageDescription')
|
229
|
+
aItems = hResInfo['coverageDescription']
|
230
|
+
aItems.each do |item|
|
231
|
+
hReturn = CoverageDescription.unpack(item, responseObj)
|
232
|
+
unless hReturn.nil?
|
233
|
+
intResInfo[:coverageDescriptions] << hReturn
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
# resource information - taxonomy {taxonomy}
|
239
|
+
if hResInfo.has_key?('taxonomy')
|
240
|
+
hObject = hResInfo['taxonomy']
|
241
|
+
unless hObject.empty?
|
242
|
+
hReturn = Taxonomy.unpack(hObject, responseObj)
|
243
|
+
unless hReturn.nil?
|
244
|
+
intResInfo[:taxonomy] = hReturn
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
# resource information - graphic overview [] {graphicOverview}
|
250
|
+
if hResInfo.has_key?('graphicOverview')
|
251
|
+
aItems = hResInfo['graphicOverview']
|
252
|
+
aItems.each do |item|
|
253
|
+
hReturn = Graphic.unpack(item, responseObj)
|
254
|
+
unless hReturn.nil?
|
255
|
+
intResInfo[:graphicOverviews] << hReturn
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
# resource information - resource format [] {format}
|
261
|
+
if hResInfo.has_key?('resourceFormat')
|
262
|
+
aItems = hResInfo['resourceFormat']
|
263
|
+
aItems.each do |item|
|
264
|
+
hReturn = Format.unpack(item, responseObj)
|
265
|
+
unless hReturn.nil?
|
266
|
+
intResInfo[:resourceFormats] << hReturn
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
# resource information - keyword [] {keyword}
|
272
|
+
if hResInfo.has_key?('keyword')
|
273
|
+
aItems = hResInfo['keyword']
|
274
|
+
aItems.each do |item|
|
275
|
+
hReturn = Keyword.unpack(item, responseObj)
|
276
|
+
unless hReturn.nil?
|
277
|
+
intResInfo[:keywords] << hReturn[0]
|
278
|
+
intResInfo[:topicCategories] = intResInfo[:topicCategories] | hReturn[1]
|
279
|
+
end
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
# resource information - resource usage [] {resourceUsage}
|
284
|
+
if hResInfo.has_key?('resourceUsage')
|
285
|
+
aItems = hResInfo['resourceUsage']
|
286
|
+
aItems.each do |item|
|
287
|
+
hReturn = ResourceUsage.unpack(item, responseObj)
|
288
|
+
unless hReturn.nil?
|
289
|
+
intResInfo[:resourceUsages] << hReturn
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
# resource information - constraint [] {constraint}
|
295
|
+
if hResInfo.has_key?('constraint')
|
296
|
+
aCons = hResInfo['constraint']
|
297
|
+
aCons.each do |hItem|
|
298
|
+
hReturn = Constraint.unpack(hItem, responseObj)
|
299
|
+
unless hReturn.nil?
|
300
|
+
intResInfo[:constraints] << hReturn
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
# resource information - default resource locale {locale} (required)
|
306
|
+
if hResInfo.has_key?('defaultResourceLocale')
|
307
|
+
hObject = hResInfo['defaultResourceLocale']
|
308
|
+
unless hObject.empty?
|
309
|
+
hReturn = Locale.unpack(hObject, responseObj)
|
310
|
+
unless hReturn.nil?
|
311
|
+
intResInfo[:defaultResourceLocale] = hReturn
|
312
|
+
end
|
313
|
+
end
|
314
|
+
end
|
315
|
+
if intResInfo[:defaultResourceLocale].empty?
|
316
|
+
responseObj[:readerExecutionMessages] << 'ResourceInfo object is missing defaultResourceLocale'
|
317
|
+
responseObj[:readerExecutionPass] = false
|
318
|
+
return nil
|
319
|
+
end
|
320
|
+
|
321
|
+
# resource information - other resource locale [] {locale}
|
322
|
+
if hResInfo.has_key?('otherResourceLocale')
|
323
|
+
aItems = hResInfo['otherResourceLocale']
|
324
|
+
aItems.each do |item|
|
325
|
+
hReturn = Locale.unpack(item, responseObj)
|
326
|
+
unless hReturn.nil?
|
327
|
+
intResInfo[:otherResourceLocales] << hReturn
|
328
|
+
end
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
332
|
+
# resource information - resource maintenance [] {maintenance}
|
333
|
+
if hResInfo.has_key?('resourceMaintenance')
|
334
|
+
aItems = hResInfo['resourceMaintenance']
|
335
|
+
aItems.each do |item|
|
336
|
+
hReturn = Maintenance.unpack(item, responseObj)
|
337
|
+
unless hReturn.nil?
|
338
|
+
intResInfo[:resourceMaintenance] << hReturn
|
339
|
+
end
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
# resource information - environment description
|
344
|
+
if hResInfo.has_key?('environmentDescription')
|
345
|
+
if hResInfo['environmentDescription'] != ''
|
346
|
+
intResInfo[:environmentDescription] = hResInfo['environmentDescription']
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
# resource information - supplemental information
|
351
|
+
if hResInfo.has_key?('supplementalInfo')
|
352
|
+
if hResInfo['supplementalInfo'] != ''
|
353
|
+
intResInfo[:supplementalInfo] = hResInfo['supplementalInfo']
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
return intResInfo
|
358
|
+
|
359
|
+
end
|
360
360
|
|
361
361
|
end
|
362
|
-
|
363
|
-
|
362
|
+
|
363
|
+
end
|
364
|
+
end
|
365
|
+
end
|
364
366
|
end
|