adiwg-mdtranslator 2.5.0 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -1
  3. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +5 -3
  4. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_dateTime.rb +6 -6
  5. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_geologicAge.rb +66 -0
  6. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_identification.rb +4 -6
  7. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_timeInstant.rb +23 -6
  8. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_timePeriod.rb +87 -24
  9. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_dataDictionary.rb +135 -126
  10. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geologicAge.rb +84 -0
  11. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_timeInstant.rb +80 -68
  12. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_timePeriod.rb +118 -95
  13. data/lib/adiwg/mdtranslator/version.rb +3 -1
  14. data/lib/adiwg/mdtranslator/writers/html/sections/html_dataDictionary.rb +9 -0
  15. data/lib/adiwg/mdtranslator/writers/html/sections/html_domain.rb +4 -4
  16. data/lib/adiwg/mdtranslator/writers/html/sections/html_entity.rb +6 -6
  17. data/lib/adiwg/mdtranslator/writers/html/sections/html_geologicAge.rb +71 -0
  18. data/lib/adiwg/mdtranslator/writers/html/sections/html_temporalExtent.rb +20 -21
  19. data/lib/adiwg/mdtranslator/writers/html/sections/html_timeInstant.rb +8 -0
  20. data/lib/adiwg/mdtranslator/writers/html/sections/html_timePeriod.rb +23 -0
  21. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dictionary.rb +5 -3
  22. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_geologicAge.rb +34 -0
  23. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_timeInstant.rb +4 -1
  24. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_timePeriod.rb +6 -2
  25. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_id.rb +0 -2
  26. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_sbJson.rb +23 -2
  27. 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
- module Mdtranslator
12
- module Readers
13
- module MdJson
14
-
15
- module TimeInstant
16
-
17
- def self.unpack(hInstant, responseObj)
18
-
19
- # return nil object if input is empty
20
- if hInstant.empty?
21
- responseObj[:readerExecutionMessages] << 'Time Instant object is empty'
22
- responseObj[:readerExecutionPass] = false
23
- return nil
24
- end
25
-
26
- # instance classes needed in script
27
- intMetadataClass = InternalMetadata.new
28
- intInstant = intMetadataClass.newTimeInstant
29
-
30
- # time instant - id
31
- if hInstant.has_key?('id')
32
- if hInstant['id'] != ''
33
- intInstant[:timeId] = hInstant['id']
34
- end
35
- end
36
-
37
- # time instant - description
38
- if hInstant.has_key?('description')
39
- if hInstant['description'] != ''
40
- intInstant[:description] = hInstant['description']
41
- end
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
- # time instant - identifier {Identifier}
45
- if hInstant.has_key?('identifier')
46
- unless hInstant['identifier'].empty?
47
- hReturn = Identifier.unpack(hInstant['identifier'], responseObj)
48
- unless hReturn.nil?
49
- intInstant[:identifier] = hReturn
50
- end
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
- # time instant - instant names []
55
- if hInstant.has_key?('instantName')
56
- hInstant['instantName'].each do |item|
57
- if item != ''
58
- intInstant[:instantNames] << item
59
- end
60
- end
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
- # time instant - datetime
64
- if hInstant.has_key?('dateTime')
65
- if hInstant['dateTime'] != ''
66
- hDate = DateTime.unpack(hInstant['dateTime'], responseObj)
67
- unless hDate.nil?
68
- intInstant[:timeInstant] = hDate
69
- end
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
- if intInstant[:timeInstant].empty?
73
- responseObj[:readerExecutionMessages] << 'Time Instant is missing dateTime'
74
- responseObj[:readerExecutionPass] = false
75
- return nil
76
- end
77
-
78
- return intInstant
81
+ end
82
+ end
79
83
 
80
- end
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
- end
91
+ return intInstant
83
92
 
93
+ end
84
94
  end
85
- end
86
- end
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
- module Mdtranslator
14
- module Readers
15
- module MdJson
16
-
17
- module TimePeriod
18
-
19
- def self.unpack(hTimePeriod, responseObj)
20
-
21
- # return nil object if input is empty
22
- if hTimePeriod.empty?
23
- responseObj[:readerExecutionMessages] << 'Time Period object is empty'
24
- responseObj[:readerExecutionPass] = false
25
- return nil
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
- # instance classes needed in script
29
- intMetadataClass = InternalMetadata.new
30
- intTimePer = intMetadataClass.newTimePeriod
31
-
32
- # time period - id
33
- if hTimePeriod.has_key?('id')
34
- if hTimePeriod['id'] != ''
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
- # time period - description
40
- if hTimePeriod.has_key?('description')
41
- if hTimePeriod['description'] != ''
42
- intTimePer[:description] = hTimePeriod['description']
43
- end
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
- # time period - identifier {Identifier}
47
- if hTimePeriod.has_key?('identifier')
48
- unless hTimePeriod['identifier'].empty?
49
- hReturn = Identifier.unpack(hTimePeriod['identifier'], responseObj)
50
- unless hReturn.nil?
51
- intTimePer[:identifier] = hReturn
52
- end
53
- end
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
- # time period - period names []
57
- if hTimePeriod.has_key?('periodName')
58
- hTimePeriod['periodName'].each do |item|
59
- if item != ''
60
- intTimePer[:periodNames] << item
61
- end
62
- end
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
- # time period - start datetime
66
- if hTimePeriod.has_key?('startDateTime')
67
- if hTimePeriod['startDateTime'] != ''
68
- hReturn = DateTime.unpack(hTimePeriod['startDateTime'], responseObj)
69
- unless hReturn.nil?
70
- intTimePer[:startDateTime] = hReturn
71
- end
72
- end
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
- # time period - end datetime
76
- if hTimePeriod.has_key?('endDateTime')
77
- if hTimePeriod['endDateTime'] != ''
78
- hReturn = DateTime.unpack(hTimePeriod['endDateTime'], responseObj)
79
- unless hReturn.nil?
80
- intTimePer[:endDateTime] = hReturn
81
- end
82
- end
83
- end
84
-
85
- if intTimePer[:startDateTime].empty? && intTimePer[:endDateTime].empty?
86
- responseObj[:readerExecutionMessages] << 'Time Period is missing both a start and an end time'
87
- responseObj[:readerExecutionPass] = false
88
- return nil
89
- end
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
- # time period - time duration
102
- if hTimePeriod.has_key?('duration')
103
- unless hTimePeriod['duration'].empty?
104
- hReturn = Duration.unpack(hTimePeriod['duration'], responseObj)
105
- unless hReturn.nil?
106
- intTimePer[:duration] = hReturn
107
- end
108
- end
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
- return intTimePer
134
+ return intTimePer
112
135
 
113
- end
114
-
115
- end
136
+ end
116
137
 
117
138
  end
118
- end
119
- end
139
+
140
+ end
141
+ end
142
+ end
120
143
  end