adiwg-mdtranslator 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -1
- data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +5 -3
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_dateTime.rb +6 -6
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_geologicAge.rb +66 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_identification.rb +4 -6
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_timeInstant.rb +23 -6
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_timePeriod.rb +87 -24
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_dataDictionary.rb +135 -126
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geologicAge.rb +84 -0
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_timeInstant.rb +80 -68
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_timePeriod.rb +118 -95
- data/lib/adiwg/mdtranslator/version.rb +3 -1
- data/lib/adiwg/mdtranslator/writers/html/sections/html_dataDictionary.rb +9 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_domain.rb +4 -4
- data/lib/adiwg/mdtranslator/writers/html/sections/html_entity.rb +6 -6
- data/lib/adiwg/mdtranslator/writers/html/sections/html_geologicAge.rb +71 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_temporalExtent.rb +20 -21
- data/lib/adiwg/mdtranslator/writers/html/sections/html_timeInstant.rb +8 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_timePeriod.rb +23 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dictionary.rb +5 -3
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_geologicAge.rb +34 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_timeInstant.rb +4 -1
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_timePeriod.rb +6 -2
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_id.rb +0 -2
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_sbJson.rb +23 -2
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 237525902d612d3bf3f8c5a81c373a789d27b9c8
|
4
|
+
data.tar.gz: caa5edd6722337501c2698e0ea7ee4a61b0eccea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79a9d0abadec138c139b287b3e306033eee12b9d0467b1ee0ce3e010a121f1aff03b88e4e715f05147ea48e58c277eea536631e88142f430eace7f6e6a37779a
|
7
|
+
data.tar.gz: c459062d8d426ac181db0cc1f279811d5567e773c9f1bec809c3487e96920fcb11dad897343a60411ee8f7de31ea2986924953f09a295cf485c7e48bbc65e7e8
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,18 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
-
## [v2.
|
3
|
+
## [v2.6.0](https://github.com/adiwg/mdTranslator/tree/v2.6.0) (2017-11-10)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/adiwg/mdTranslator/compare/v2.5.0...v2.6.0)
|
6
|
+
|
7
|
+
**Fixed bugs:**
|
8
|
+
|
9
|
+
- mdJSON reader version is stale [\#158](https://github.com/adiwg/mdTranslator/issues/158)
|
4
10
|
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- Add Geologic Age to timeInstant and timePeriod [\#161](https://github.com/adiwg/mdTranslator/pull/161) ([stansmith907](https://github.com/stansmith907))
|
14
|
+
|
15
|
+
## [v2.5.0](https://github.com/adiwg/mdTranslator/tree/v2.5.0) (2017-11-06)
|
5
16
|
[Full Changelog](https://github.com/adiwg/mdTranslator/compare/v2.4.0...v2.5.0)
|
6
17
|
|
7
18
|
**Fixed bugs:**
|
@@ -534,7 +534,8 @@ class InternalMetadata
|
|
534
534
|
description: nil,
|
535
535
|
identifier: {},
|
536
536
|
instantNames: [],
|
537
|
-
timeInstant: {}
|
537
|
+
timeInstant: {},
|
538
|
+
geologicAge: {}
|
538
539
|
}
|
539
540
|
end
|
540
541
|
|
@@ -559,7 +560,7 @@ class InternalMetadata
|
|
559
560
|
ageEstimate: nil,
|
560
561
|
ageUncertainty: nil,
|
561
562
|
ageExplanation: nil,
|
562
|
-
|
563
|
+
ageReferences: []
|
563
564
|
}
|
564
565
|
end
|
565
566
|
|
@@ -712,8 +713,9 @@ class InternalMetadata
|
|
712
713
|
|
713
714
|
def newDataDictionary
|
714
715
|
{
|
715
|
-
|
716
|
+
description: nil,
|
716
717
|
subjects: [],
|
718
|
+
citation: {},
|
717
719
|
recommendedUses: [],
|
718
720
|
locales: [],
|
719
721
|
responsibleParty: {},
|
@@ -23,7 +23,7 @@ module ADIWG
|
|
23
23
|
hDateTime = intMetadataClass.newDateTime
|
24
24
|
|
25
25
|
if date.nil? || date == ''
|
26
|
-
hResponseObj[:readerExecutionMessages] << 'date string is missing from dateTime
|
26
|
+
hResponseObj[:readerExecutionMessages] << 'date string is missing from dateTime'
|
27
27
|
hResponseObj[:readerExecutionPass] = false
|
28
28
|
return nil
|
29
29
|
end
|
@@ -74,12 +74,12 @@ module ADIWG
|
|
74
74
|
else
|
75
75
|
timeOffset = Time.now.gmt_offset
|
76
76
|
aOffset = timeOffset.divmod(3600)
|
77
|
-
|
78
|
-
|
79
|
-
if
|
80
|
-
zone = '+' + '%02d' %
|
77
|
+
hourOff = aOffset[0]
|
78
|
+
minOff = aOffset[1] * 60
|
79
|
+
if hourOff >= 0
|
80
|
+
zone = '+' + '%02d' % hourOff + ':' + '%02d' % minOff
|
81
81
|
else
|
82
|
-
zone = '%03d' %
|
82
|
+
zone = '%03d' % hourOff + ':' + '%02d' % minOff
|
83
83
|
end
|
84
84
|
dtIn = dtIn + zone
|
85
85
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Reader - fgdc to internal data structure
|
2
|
+
# unpack fgdc bio geologic age
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2017-11-06 original script
|
6
|
+
|
7
|
+
require 'nokogiri'
|
8
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
9
|
+
require_relative 'module_citation'
|
10
|
+
|
11
|
+
module ADIWG
|
12
|
+
module Mdtranslator
|
13
|
+
module Readers
|
14
|
+
module Fgdc
|
15
|
+
|
16
|
+
module GeologicAge
|
17
|
+
|
18
|
+
def self.unpack(xGeoAge, hResponseObj)
|
19
|
+
|
20
|
+
# instance classes needed in script
|
21
|
+
intMetadataClass = InternalMetadata.new
|
22
|
+
intGeoAge = intMetadataClass.newGeologicAge
|
23
|
+
|
24
|
+
# geologic age bio (geolscal) - time scale (required)
|
25
|
+
scale = xGeoAge.xpath('./geolscal').text
|
26
|
+
unless scale.empty?
|
27
|
+
intGeoAge[:ageTimeScale] = scale
|
28
|
+
end
|
29
|
+
|
30
|
+
# geologic age bio (geolest) - age estimate (required)
|
31
|
+
estimate = xGeoAge.xpath('./geolest').text
|
32
|
+
unless estimate.empty?
|
33
|
+
intGeoAge[:ageEstimate] = estimate
|
34
|
+
end
|
35
|
+
|
36
|
+
# geologic age bio (geolun) - age estimate uncertainty
|
37
|
+
uncertain = xGeoAge.xpath('./geolun').text
|
38
|
+
unless uncertain.empty?
|
39
|
+
intGeoAge[:ageUncertainty] = uncertain
|
40
|
+
end
|
41
|
+
|
42
|
+
# geologic age bio (geolexpl) - explanation
|
43
|
+
explain = xGeoAge.xpath('./geolexpl').text
|
44
|
+
unless explain.empty?
|
45
|
+
intGeoAge[:ageExplanation] = explain
|
46
|
+
end
|
47
|
+
|
48
|
+
# geologic age bio (geolcit) - age references [] {citation}
|
49
|
+
axReferences = xGeoAge.xpath('./geolcit')
|
50
|
+
unless axReferences.empty?
|
51
|
+
axReferences.each do |xCitation|
|
52
|
+
hCitation = Citation.unpack(xCitation, hResponseObj)
|
53
|
+
intGeoAge[:ageReferences] << hCitation unless hCitation.nil?
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
return intGeoAge
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -60,20 +60,18 @@ module ADIWG
|
|
60
60
|
xTimePeriod = xIdInfo.xpath('./timeperd')
|
61
61
|
unless xTimePeriod.empty?
|
62
62
|
|
63
|
-
# time period for single date and date range
|
63
|
+
# time period for single date, multi-date, and date range {resource timePeriod}
|
64
64
|
hTimePeriod = TimePeriod.unpack(xTimePeriod, hResponseObj)
|
65
65
|
hResourceInfo[:timePeriod] = hTimePeriod unless hTimePeriod.nil?
|
66
66
|
|
67
|
-
# time period
|
67
|
+
# time period multi-date also placed in temporalExtent
|
68
68
|
axMultiple = xTimePeriod.xpath('./timeinfo/mdattim/sngdate')
|
69
69
|
unless axMultiple.empty?
|
70
70
|
current = xTimePeriod.xpath('./current').text
|
71
71
|
hExtent = intMetadataClass.newExtent
|
72
|
-
hExtent[:description] = 'FGDC resource time period multiple date/times'
|
72
|
+
hExtent[:description] = 'FGDC resource time period for multiple date/times/geological age'
|
73
73
|
axMultiple.each do |xDateTime|
|
74
|
-
|
75
|
-
time = xDateTime.xpath('./time').text
|
76
|
-
hInstant = TimeInstant.unpack(date, time, hResponseObj)
|
74
|
+
hInstant = TimeInstant.unpack(xDateTime, hResponseObj)
|
77
75
|
unless hInstant.nil?
|
78
76
|
hTempExtent = intMetadataClass.newTemporalExtent
|
79
77
|
hInstant[:description] = current
|
@@ -2,11 +2,13 @@
|
|
2
2
|
# unpack fgdc time instant
|
3
3
|
|
4
4
|
# History:
|
5
|
+
# Stan Smith 2017-11-07 add geologic age
|
5
6
|
# Stan Smith 2017-08-21 original script
|
6
7
|
|
7
8
|
require 'nokogiri'
|
8
9
|
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
9
10
|
require_relative 'module_dateTime'
|
11
|
+
require_relative 'module_geologicAge'
|
10
12
|
|
11
13
|
module ADIWG
|
12
14
|
module Mdtranslator
|
@@ -15,17 +17,32 @@ module ADIWG
|
|
15
17
|
|
16
18
|
module TimeInstant
|
17
19
|
|
18
|
-
def self.unpack(
|
20
|
+
def self.unpack(xDateTime, hResponseObj)
|
19
21
|
|
20
22
|
# instance classes needed in script
|
21
23
|
intMetadataClass = InternalMetadata.new
|
22
24
|
hTimeInstant = intMetadataClass.newTimeInstant
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
date = xDateTime.xpath('./caldate').text
|
27
|
+
time = xDateTime.xpath('./time').text
|
28
|
+
xGeoAge = xDateTime.xpath('./geolage')
|
29
|
+
|
30
|
+
# time instant - date-time
|
31
|
+
unless date.empty?
|
32
|
+
hDateTime = DateTime.unpack(date, time, hResponseObj)
|
33
|
+
unless hDateTime.nil?
|
34
|
+
hTimeInstant[:timeInstant] = hDateTime
|
35
|
+
return hTimeInstant
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# time instant - geological age
|
40
|
+
unless xGeoAge.empty?
|
41
|
+
hGeoAge = GeologicAge.unpack(xGeoAge, hResponseObj)
|
42
|
+
unless hGeoAge.nil?
|
43
|
+
hTimeInstant[:geologicAge] = hGeoAge
|
44
|
+
return hTimeInstant
|
45
|
+
end
|
29
46
|
end
|
30
47
|
|
31
48
|
return nil
|
@@ -2,11 +2,13 @@
|
|
2
2
|
# unpack fgdc time period
|
3
3
|
|
4
4
|
# History:
|
5
|
+
# Stan Smith 2017-11-06 add geologic time
|
5
6
|
# Stan Smith 2017-08-17 original script
|
6
7
|
|
7
8
|
require 'nokogiri'
|
8
9
|
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
9
10
|
require_relative 'module_dateTime'
|
11
|
+
require_relative 'module_geologicAge'
|
10
12
|
|
11
13
|
module ADIWG
|
12
14
|
module Mdtranslator
|
@@ -25,13 +27,12 @@ module ADIWG
|
|
25
27
|
xTimeInfo = xTimePeriod.xpath('./timeinfo')
|
26
28
|
|
27
29
|
# current may have different element tags depending on timePeriod source
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
xFoundIt = xTimePeriod.at('./srccurr')
|
30
|
+
xCurrent = xTimePeriod.at('./current')
|
31
|
+
if xCurrent.nil?
|
32
|
+
xCurrent = xTimePeriod.at('./srccurr')
|
32
33
|
end
|
33
|
-
unless
|
34
|
-
|
34
|
+
unless xCurrent.nil?
|
35
|
+
hTimePeriod[:description] = xCurrent.text
|
35
36
|
end
|
36
37
|
|
37
38
|
unless xTimeInfo.empty?
|
@@ -43,36 +44,80 @@ module ADIWG
|
|
43
44
|
# single date 9.1.1/9.1.2 (caldate/time) - single date/time {date} (required) {time}
|
44
45
|
date = xSingle.xpath('./caldate').text
|
45
46
|
time = xSingle.xpath('./time').text
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
unless date.empty?
|
48
|
+
hDateTime = DateTime.unpack(date, time, hResponseObj)
|
49
|
+
unless hDateTime.nil?
|
50
|
+
hTimePeriod[:endDateTime] = hDateTime
|
51
|
+
return hTimePeriod
|
52
|
+
end
|
49
53
|
end
|
50
|
-
hTimePeriod[:description] = current
|
51
54
|
|
52
|
-
|
55
|
+
# or bio extension's geologic age
|
56
|
+
xGeoAge = xSingle.xpath('./geolage')
|
57
|
+
unless xGeoAge.empty?
|
58
|
+
hGeoAge = GeologicAge.unpack(xGeoAge, hResponseObj)
|
59
|
+
unless hGeoAge.nil?
|
60
|
+
hTimePeriod[:endGeologicAge] = hGeoAge
|
61
|
+
return hTimePeriod
|
62
|
+
end
|
63
|
+
end
|
53
64
|
|
54
65
|
end
|
55
66
|
|
56
67
|
# time period 9.2 (mdattim) - multiple date times
|
57
|
-
# take first date
|
58
68
|
xMulti = xTimeInfo.xpath('./mdattim')
|
59
69
|
unless xMulti.empty?
|
60
|
-
axSingle = xMulti.xpath('./sngdate')
|
61
70
|
|
62
|
-
# use first occurrence of the multiple date
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
unless
|
69
|
-
hTimePeriod[:startDateTime] =
|
71
|
+
# use first occurrence of the multiple date-times as start date
|
72
|
+
xStart = xMulti.xpath('//sngdate').first
|
73
|
+
startDate = xStart.xpath('./caldate').text
|
74
|
+
startTime = xStart.xpath('./time').text
|
75
|
+
unless startDate.empty?
|
76
|
+
hStartDateTime = DateTime.unpack(startDate, startTime, hResponseObj)
|
77
|
+
unless hStartDateTime.nil?
|
78
|
+
hTimePeriod[:startDateTime] = hStartDateTime
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# use last occurrence of the multiple date-times as end date
|
83
|
+
xEnd = xMulti.xpath('//sngdate').last
|
84
|
+
endDate = xEnd.xpath('./caldate').text
|
85
|
+
endTime = xEnd.xpath('./time').text
|
86
|
+
unless endDate.empty?
|
87
|
+
hEndDateTime = DateTime.unpack(endDate, endTime, hResponseObj)
|
88
|
+
unless hEndDateTime.nil?
|
89
|
+
hTimePeriod[:endDateTime] = hEndDateTime
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# and/or bio extension's geologic age
|
94
|
+
axGeoAge = xMulti.xpath('//geolage')
|
95
|
+
unless axGeoAge.empty?
|
96
|
+
|
97
|
+
# use first occurrence of the multiple geologic age as start age
|
98
|
+
xGeoAge = axGeoAge.xpath('//geolage').first
|
99
|
+
unless xGeoAge.nil?
|
100
|
+
hGeoAge = GeologicAge.unpack(xGeoAge, hResponseObj)
|
101
|
+
unless hGeoAge.nil?
|
102
|
+
hTimePeriod[:startGeologicAge] = hGeoAge
|
103
|
+
end
|
70
104
|
end
|
71
|
-
hTimePeriod[:description] = current
|
72
105
|
|
73
|
-
|
106
|
+
# use lase occurrence of the multiple geologic age as end age
|
107
|
+
if axGeoAge.length > 1
|
108
|
+
xGeoAge = axGeoAge.xpath('//geolage').last
|
109
|
+
unless xGeoAge.nil?
|
110
|
+
hGeoAge = GeologicAge.unpack(xGeoAge, hResponseObj)
|
111
|
+
unless hGeoAge.nil?
|
112
|
+
hTimePeriod[:endGeologicAge] = hGeoAge
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
74
116
|
|
75
117
|
end
|
118
|
+
|
119
|
+
return hTimePeriod
|
120
|
+
|
76
121
|
end
|
77
122
|
|
78
123
|
# time period 9.3 (rngdates) - range of dates
|
@@ -96,7 +141,25 @@ module ADIWG
|
|
96
141
|
unless hDateTime.nil?
|
97
142
|
hTimePeriod[:endDateTime] = hDateTime
|
98
143
|
end
|
99
|
-
|
144
|
+
|
145
|
+
# and/or bio extension's geologic age
|
146
|
+
# start geologic age
|
147
|
+
xBegGeoAge = xRange.xpath('./beggeol')
|
148
|
+
unless xBegGeoAge.empty?
|
149
|
+
hGeoAge = GeologicAge.unpack(xBegGeoAge, hResponseObj)
|
150
|
+
unless hGeoAge.nil?
|
151
|
+
hTimePeriod[:startGeologicAge] = hGeoAge
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
# end geologic age
|
156
|
+
xEndGeoAge = xRange.xpath('./endgeol')
|
157
|
+
unless xEndGeoAge.empty?
|
158
|
+
hGeoAge = GeologicAge.unpack(xEndGeoAge, hResponseObj)
|
159
|
+
unless hGeoAge.nil?
|
160
|
+
hTimePeriod[:endGeologicAge] = hGeoAge
|
161
|
+
end
|
162
|
+
end
|
100
163
|
|
101
164
|
return hTimePeriod
|
102
165
|
|
@@ -2,10 +2,11 @@
|
|
2
2
|
# Reader - ADIwg JSON to internal data structure
|
3
3
|
|
4
4
|
# History:
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
5
|
+
# Stan Smith 2017-11-09 add dictionary description
|
6
|
+
# Stan Smith 2017-01-20 refactored for mdJson/mdTranslator 2.0
|
7
|
+
# Stan Smith 2015-07-14 refactored to remove global namespace constants
|
8
|
+
# Stan Smith 2015-06-22 replace global ($response) with passed in object (responseObj)
|
9
|
+
# Stan Smith 2014-12-15 refactored to handle namespacing readers and writers
|
9
10
|
# Stan Smith 2014-12-01 original script
|
10
11
|
|
11
12
|
require_relative 'module_citation'
|
@@ -15,137 +16,145 @@ require_relative 'module_locale'
|
|
15
16
|
require_relative 'module_responsibleParty'
|
16
17
|
|
17
18
|
module ADIWG
|
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
|
-
# dictionary - subject [] (required)
|
54
|
-
if hDictionary.has_key?('subject')
|
55
|
-
aSubjects = hDictionary['subject']
|
56
|
-
aSubjects.each do |item|
|
57
|
-
if item != ''
|
58
|
-
intDictionary[:subjects] << item
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
if intDictionary[:subjects].empty?
|
63
|
-
responseObj[:readerExecutionMessages] << 'Data Dictionary subject is missing'
|
64
|
-
responseObj[:readerExecutionPass] = false
|
65
|
-
return nil
|
66
|
-
end
|
67
|
-
|
68
|
-
# dictionary - recommended use []
|
69
|
-
if hDictionary.has_key?('recommendedUse')
|
70
|
-
aUses = hDictionary['recommendedUse']
|
71
|
-
aUses.each do |item|
|
72
|
-
if item != ''
|
73
|
-
intDictionary[:recommendedUses] << item
|
74
|
-
end
|
75
|
-
end
|
19
|
+
module Mdtranslator
|
20
|
+
module Readers
|
21
|
+
module MdJson
|
22
|
+
|
23
|
+
module DataDictionary
|
24
|
+
|
25
|
+
def self.unpack(hDictionary, responseObj)
|
26
|
+
|
27
|
+
# return nil object if input is empty
|
28
|
+
if hDictionary.empty?
|
29
|
+
responseObj[:readerExecutionMessages] << 'Data Dictionary object is empty'
|
30
|
+
responseObj[:readerExecutionPass] = false
|
31
|
+
return nil
|
32
|
+
end
|
33
|
+
|
34
|
+
# instance classes needed in script
|
35
|
+
intMetadataClass = InternalMetadata.new
|
36
|
+
intDictionary = intMetadataClass.newDataDictionary
|
37
|
+
|
38
|
+
# dictionary - description
|
39
|
+
if hDictionary.has_key?('description')
|
40
|
+
s = hDictionary['description']
|
41
|
+
unless s == ''
|
42
|
+
intDictionary[:description] = s
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# dictionary - citation (required by mdJson) {citation}
|
47
|
+
if hDictionary.has_key?('citation')
|
48
|
+
hCitation = hDictionary['citation']
|
49
|
+
unless hCitation.empty?
|
50
|
+
hReturn = Citation.unpack(hCitation, responseObj)
|
51
|
+
unless hReturn.nil?
|
52
|
+
intDictionary[:citation] = hReturn
|
76
53
|
end
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
54
|
+
end
|
55
|
+
end
|
56
|
+
if intDictionary[:citation].empty?
|
57
|
+
responseObj[:readerExecutionMessages] << 'Data Dictionary citation is empty'
|
58
|
+
responseObj[:readerExecutionPass] = false
|
59
|
+
return nil
|
60
|
+
end
|
61
|
+
|
62
|
+
# dictionary - subject [] (required)
|
63
|
+
if hDictionary.has_key?('subject')
|
64
|
+
aSubjects = hDictionary['subject']
|
65
|
+
aSubjects.each do |item|
|
66
|
+
if item != ''
|
67
|
+
intDictionary[:subjects] << item
|
87
68
|
end
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
69
|
+
end
|
70
|
+
end
|
71
|
+
if intDictionary[:subjects].empty?
|
72
|
+
responseObj[:readerExecutionMessages] << 'Data Dictionary subject is missing'
|
73
|
+
responseObj[:readerExecutionPass] = false
|
74
|
+
return nil
|
75
|
+
end
|
76
|
+
|
77
|
+
# dictionary - recommended use []
|
78
|
+
if hDictionary.has_key?('recommendedUse')
|
79
|
+
aUses = hDictionary['recommendedUse']
|
80
|
+
aUses.each do |item|
|
81
|
+
if item != ''
|
82
|
+
intDictionary[:recommendedUses] << item
|
98
83
|
end
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
intDictionary[:dictionaryFormat] = s
|
110
|
-
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# dictionary - locale [] {locale}
|
88
|
+
if hDictionary.has_key?('locale')
|
89
|
+
aLocales = hDictionary['locale']
|
90
|
+
aLocales.each do |hItem|
|
91
|
+
hReturn = Locale.unpack(hItem, responseObj)
|
92
|
+
unless hReturn.nil?
|
93
|
+
intDictionary[:locales] << hReturn
|
111
94
|
end
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# dictionary - responsible party (required) {responsibleParty}
|
99
|
+
if hDictionary.has_key?('responsibleParty')
|
100
|
+
hRParty = hDictionary['responsibleParty']
|
101
|
+
unless hRParty.empty?
|
102
|
+
hReturn = ResponsibleParty.unpack(hRParty, responseObj)
|
103
|
+
unless hReturn.nil?
|
104
|
+
intDictionary[:responsibleParty] = hReturn
|
118
105
|
end
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
106
|
+
end
|
107
|
+
end
|
108
|
+
if intDictionary[:responsibleParty].empty?
|
109
|
+
responseObj[:readerExecutionMessages] << 'Data Dictionary responsible party is empty'
|
110
|
+
responseObj[:readerExecutionPass] = false
|
111
|
+
return nil
|
112
|
+
end
|
113
|
+
|
114
|
+
# dictionary - dictionary format
|
115
|
+
if hDictionary.has_key?('dictionaryFormat')
|
116
|
+
s = hDictionary['dictionaryFormat']
|
117
|
+
unless s == ''
|
118
|
+
intDictionary[:dictionaryFormat] = s
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
# dictionary - dictionary included with resource
|
123
|
+
if hDictionary.has_key?('dictionaryIncludedWithResource')
|
124
|
+
if hDictionary['dictionaryIncludedWithResource'] === true
|
125
|
+
intDictionary[:includedWithDataset] = hDictionary['dictionaryIncludedWithResource']
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# dictionary - domains [] {domain}
|
130
|
+
if hDictionary.has_key?('domain')
|
131
|
+
aDomains = hDictionary['domain']
|
132
|
+
aDomains.each do |hItem|
|
133
|
+
hReturn = Domain.unpack(hItem, responseObj)
|
134
|
+
unless hReturn.nil?
|
135
|
+
intDictionary[:domains] << hReturn
|
129
136
|
end
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
# dictionary - entity [] {entity}
|
141
|
+
if hDictionary.has_key?('entity')
|
142
|
+
aEntities = hDictionary['entity']
|
143
|
+
aEntities.each do |hItem|
|
144
|
+
hReturn = Entity.unpack(hItem, responseObj)
|
145
|
+
unless hReturn.nil?
|
146
|
+
intDictionary[:entities] << hReturn
|
140
147
|
end
|
148
|
+
end
|
149
|
+
end
|
141
150
|
|
142
|
-
|
151
|
+
return intDictionary
|
143
152
|
|
144
|
-
|
145
|
-
|
146
|
-
end
|
153
|
+
end
|
147
154
|
|
148
155
|
end
|
149
|
-
|
150
|
-
|
156
|
+
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
151
160
|
end
|