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
@@ -0,0 +1,84 @@
|
|
1
|
+
# unpack geologic age
|
2
|
+
# Reader - ADIwg JSON to internal data structure
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2017-11-07 original script
|
6
|
+
|
7
|
+
require_relative 'module_citation'
|
8
|
+
|
9
|
+
module ADIWG
|
10
|
+
module Mdtranslator
|
11
|
+
module Readers
|
12
|
+
module MdJson
|
13
|
+
|
14
|
+
module GeologicAge
|
15
|
+
|
16
|
+
def self.unpack(hGeoAge, responseObj)
|
17
|
+
|
18
|
+
# return nil object if input is empty
|
19
|
+
if hGeoAge.empty?
|
20
|
+
responseObj[:readerExecutionMessages] << 'Geologic Age object is empty'
|
21
|
+
responseObj[:readerExecutionPass] = false
|
22
|
+
return nil
|
23
|
+
end
|
24
|
+
|
25
|
+
# instance classes needed in script
|
26
|
+
intMetadataClass = InternalMetadata.new
|
27
|
+
intGeoAge = intMetadataClass.newGeologicAge
|
28
|
+
|
29
|
+
# geologic age - time scale (required)
|
30
|
+
if hGeoAge.has_key?('ageTimeScale')
|
31
|
+
intGeoAge[:ageTimeScale] = hGeoAge['ageTimeScale']
|
32
|
+
end
|
33
|
+
if intGeoAge[:ageTimeScale].nil? || intGeoAge[:ageTimeScale] == ''
|
34
|
+
responseObj[:readerExecutionMessages] << 'Geologic Age is missing time scale'
|
35
|
+
responseObj[:readerExecutionPass] = false
|
36
|
+
return nil
|
37
|
+
end
|
38
|
+
|
39
|
+
# geologic age - age estimate (required)
|
40
|
+
if hGeoAge.has_key?('ageEstimate')
|
41
|
+
intGeoAge[:ageEstimate] = hGeoAge['ageEstimate']
|
42
|
+
end
|
43
|
+
if intGeoAge[:ageEstimate].nil? || intGeoAge[:ageEstimate] == ''
|
44
|
+
responseObj[:readerExecutionMessages] << 'Geologic Age is missing age estimate'
|
45
|
+
responseObj[:readerExecutionPass] = false
|
46
|
+
return nil
|
47
|
+
end
|
48
|
+
|
49
|
+
# geologic age - age uncertainty
|
50
|
+
if hGeoAge.has_key?('ageUncertainty')
|
51
|
+
if hGeoAge['ageUncertainty'] != ''
|
52
|
+
intGeoAge[:ageUncertainty] = hGeoAge['ageUncertainty']
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# geologic age - age explanation
|
57
|
+
if hGeoAge.has_key?('ageExplanation')
|
58
|
+
if hGeoAge['ageExplanation'] != ''
|
59
|
+
intGeoAge[:ageExplanation] = hGeoAge['ageExplanation']
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# geologic age - age reference [] {citation}
|
64
|
+
if hGeoAge.has_key?('ageReference')
|
65
|
+
hGeoAge['ageReference'].each do |hCitation|
|
66
|
+
unless hCitation.empty?
|
67
|
+
hReturn = Citation.unpack(hCitation, responseObj)
|
68
|
+
unless hReturn.nil?
|
69
|
+
intGeoAge[:ageReferences] << hReturn
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
return intGeoAge
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -2,86 +2,98 @@
|
|
2
2
|
# Reader - ADIwg JSON to internal data structure
|
3
3
|
|
4
4
|
# History:
|
5
|
+
# Stan Smith 2017-11-07 add geologic age
|
5
6
|
# Stan Smith 2016-10-24 original script
|
6
7
|
|
7
8
|
require_relative 'module_identifier'
|
8
9
|
require_relative 'module_dateTime'
|
10
|
+
require_relative 'module_geologicAge'
|
9
11
|
|
10
12
|
module ADIWG
|
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
|
-
|
13
|
+
module Mdtranslator
|
14
|
+
module Readers
|
15
|
+
module MdJson
|
16
|
+
|
17
|
+
module TimeInstant
|
18
|
+
|
19
|
+
def self.unpack(hInstant, responseObj)
|
20
|
+
|
21
|
+
# return nil object if input is empty
|
22
|
+
if hInstant.empty?
|
23
|
+
responseObj[:readerExecutionMessages] << 'Time Instant object is empty'
|
24
|
+
responseObj[:readerExecutionPass] = false
|
25
|
+
return nil
|
26
|
+
end
|
27
|
+
|
28
|
+
# instance classes needed in script
|
29
|
+
intMetadataClass = InternalMetadata.new
|
30
|
+
intInstant = intMetadataClass.newTimeInstant
|
31
|
+
|
32
|
+
# time instant - id
|
33
|
+
if hInstant.has_key?('id')
|
34
|
+
if hInstant['id'] != ''
|
35
|
+
intInstant[:timeId] = hInstant['id']
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# time instant - description
|
40
|
+
if hInstant.has_key?('description')
|
41
|
+
if hInstant['description'] != ''
|
42
|
+
intInstant[:description] = hInstant['description']
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# time instant - identifier {Identifier}
|
47
|
+
if hInstant.has_key?('identifier')
|
48
|
+
unless hInstant['identifier'].empty?
|
49
|
+
hReturn = Identifier.unpack(hInstant['identifier'], responseObj)
|
50
|
+
unless hReturn.nil?
|
51
|
+
intInstant[:identifier] = hReturn
|
42
52
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# time instant - instant names []
|
57
|
+
if hInstant.has_key?('instantName')
|
58
|
+
hInstant['instantName'].each do |item|
|
59
|
+
if item != ''
|
60
|
+
intInstant[:instantNames] << item
|
52
61
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# time instant - datetime
|
66
|
+
if hInstant.has_key?('dateTime')
|
67
|
+
if hInstant['dateTime'] != ''
|
68
|
+
hDate = DateTime.unpack(hInstant['dateTime'], responseObj)
|
69
|
+
unless hDate.nil?
|
70
|
+
intInstant[:timeInstant] = hDate
|
61
71
|
end
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
# time instant - geologic age
|
75
|
+
if hInstant.has_key?('geologicAge')
|
76
|
+
unless hInstant['geologicAge'].empty?
|
77
|
+
hGeoAge = GeologicAge.unpack(hInstant['geologicAge'], responseObj)
|
78
|
+
unless hGeoAge.nil?
|
79
|
+
intInstant[:geologicAge] = hGeoAge
|
71
80
|
end
|
72
|
-
|
73
|
-
|
74
|
-
responseObj[:readerExecutionPass] = false
|
75
|
-
return nil
|
76
|
-
end
|
77
|
-
|
78
|
-
return intInstant
|
81
|
+
end
|
82
|
+
end
|
79
83
|
|
80
|
-
|
84
|
+
# time instant must have either a time instant or geologic age
|
85
|
+
if intInstant[:timeInstant].empty? && intInstant[:geologicAge].empty?
|
86
|
+
responseObj[:readerExecutionMessages] << 'Time Instant is missing dateTime or geologic age'
|
87
|
+
responseObj[:readerExecutionPass] = false
|
88
|
+
return nil
|
89
|
+
end
|
81
90
|
|
82
|
-
|
91
|
+
return intInstant
|
83
92
|
|
93
|
+
end
|
84
94
|
end
|
85
|
-
|
86
|
-
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
87
99
|
end
|
@@ -2,119 +2,142 @@
|
|
2
2
|
# Reader - ADIwg JSON to internal data structure
|
3
3
|
|
4
4
|
# History:
|
5
|
+
# Stan Smith 2017-11-07 add geologic age
|
5
6
|
# Stan Smith 2016-10-14 original script
|
6
7
|
|
7
8
|
require_relative 'module_dateTime'
|
8
9
|
require_relative 'module_identifier'
|
10
|
+
require_relative 'module_geologicAge'
|
9
11
|
require_relative 'module_timeInterval'
|
10
12
|
require_relative 'module_duration'
|
11
13
|
|
12
14
|
module ADIWG
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
module Mdtranslator
|
16
|
+
module Readers
|
17
|
+
module MdJson
|
18
|
+
|
19
|
+
module TimePeriod
|
20
|
+
|
21
|
+
def self.unpack(hTimePeriod, responseObj)
|
22
|
+
|
23
|
+
# return nil object if input is empty
|
24
|
+
if hTimePeriod.empty?
|
25
|
+
responseObj[:readerExecutionMessages] << 'Time Period object is empty'
|
26
|
+
responseObj[:readerExecutionPass] = false
|
27
|
+
return nil
|
28
|
+
end
|
29
|
+
|
30
|
+
# instance classes needed in script
|
31
|
+
intMetadataClass = InternalMetadata.new
|
32
|
+
intTimePer = intMetadataClass.newTimePeriod
|
33
|
+
|
34
|
+
# time period - id
|
35
|
+
if hTimePeriod.has_key?('id')
|
36
|
+
if hTimePeriod['id'] != ''
|
37
|
+
intTimePer[:timeId] = hTimePeriod['id']
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# time period - description
|
42
|
+
if hTimePeriod.has_key?('description')
|
43
|
+
if hTimePeriod['description'] != ''
|
44
|
+
intTimePer[:description] = hTimePeriod['description']
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# time period - identifier {Identifier}
|
49
|
+
if hTimePeriod.has_key?('identifier')
|
50
|
+
unless hTimePeriod['identifier'].empty?
|
51
|
+
hReturn = Identifier.unpack(hTimePeriod['identifier'], responseObj)
|
52
|
+
unless hReturn.nil?
|
53
|
+
intTimePer[:identifier] = hReturn
|
26
54
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
if
|
34
|
-
|
35
|
-
intTimePer[:timeId] = hTimePeriod['id']
|
36
|
-
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# time period - period names []
|
59
|
+
if hTimePeriod.has_key?('periodName')
|
60
|
+
hTimePeriod['periodName'].each do |item|
|
61
|
+
if item != ''
|
62
|
+
intTimePer[:periodNames] << item
|
37
63
|
end
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# time period - start datetime
|
68
|
+
if hTimePeriod.has_key?('startDateTime')
|
69
|
+
if hTimePeriod['startDateTime'] != ''
|
70
|
+
hReturn = DateTime.unpack(hTimePeriod['startDateTime'], responseObj)
|
71
|
+
unless hReturn.nil?
|
72
|
+
intTimePer[:startDateTime] = hReturn
|
44
73
|
end
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# time period - end datetime
|
78
|
+
if hTimePeriod.has_key?('endDateTime')
|
79
|
+
if hTimePeriod['endDateTime'] != ''
|
80
|
+
hReturn = DateTime.unpack(hTimePeriod['endDateTime'], responseObj)
|
81
|
+
unless hReturn.nil?
|
82
|
+
intTimePer[:endDateTime] = hReturn
|
54
83
|
end
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# time period - start geologic age
|
88
|
+
if hTimePeriod.has_key?('startGeologicAge')
|
89
|
+
unless hTimePeriod['startGeologicAge'].empty?
|
90
|
+
hReturn = GeologicAge.unpack(hTimePeriod['startGeologicAge'], responseObj)
|
91
|
+
unless hReturn.nil?
|
92
|
+
intTimePer[:startGeologicAge] = hReturn
|
63
93
|
end
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# time period - end geologic age
|
98
|
+
if hTimePeriod.has_key?('endGeologicAge')
|
99
|
+
unless hTimePeriod['endGeologicAge'].empty?
|
100
|
+
hReturn = GeologicAge.unpack(hTimePeriod['endGeologicAge'], responseObj)
|
101
|
+
unless hReturn.nil?
|
102
|
+
intTimePer[:endGeologicAge] = hReturn
|
73
103
|
end
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
# time period - time interval
|
92
|
-
if hTimePeriod.has_key?('timeInterval')
|
93
|
-
unless hTimePeriod['timeInterval'].empty?
|
94
|
-
hReturn = TimeInterval.unpack(hTimePeriod['timeInterval'], responseObj)
|
95
|
-
unless hReturn.nil?
|
96
|
-
intTimePer[:timeInterval] = hReturn
|
97
|
-
end
|
98
|
-
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
if intTimePer[:startDateTime].empty? && intTimePer[:endDateTime].empty? &&
|
108
|
+
intTimePer[:startGeologicAge].empty? && intTimePer[:endGeologicAge].empty?
|
109
|
+
responseObj[:readerExecutionMessages] << 'Time Period is missing a starting or ending time or geologic age'
|
110
|
+
responseObj[:readerExecutionPass] = false
|
111
|
+
return nil
|
112
|
+
end
|
113
|
+
|
114
|
+
# time period - time interval
|
115
|
+
if hTimePeriod.has_key?('timeInterval')
|
116
|
+
unless hTimePeriod['timeInterval'].empty?
|
117
|
+
hReturn = TimeInterval.unpack(hTimePeriod['timeInterval'], responseObj)
|
118
|
+
unless hReturn.nil?
|
119
|
+
intTimePer[:timeInterval] = hReturn
|
99
120
|
end
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# time period - time duration
|
125
|
+
if hTimePeriod.has_key?('duration')
|
126
|
+
unless hTimePeriod['duration'].empty?
|
127
|
+
hReturn = Duration.unpack(hTimePeriod['duration'], responseObj)
|
128
|
+
unless hReturn.nil?
|
129
|
+
intTimePer[:duration] = hReturn
|
109
130
|
end
|
131
|
+
end
|
132
|
+
end
|
110
133
|
|
111
|
-
|
134
|
+
return intTimePer
|
112
135
|
|
113
|
-
|
114
|
-
|
115
|
-
end
|
136
|
+
end
|
116
137
|
|
117
138
|
end
|
118
|
-
|
119
|
-
|
139
|
+
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
120
143
|
end
|