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
@@ -1,6 +1,8 @@
1
1
  # adiwg mdTranslator
2
2
 
3
3
  # version 2 history
4
+ # 2.6.0 2017-11-09 added data dictionary description
5
+ # 2.6.0 2017-11-09 added readers and writers for geologic age
4
6
  # 2.5.0 2017-11-03 bug fix, add test to verify mdJson reader version is compatible with schema version
5
7
  # 2.5.0 2017-11-03 added support for additional fgdc and bio data dictionary element
6
8
  # 2.4.1 2017-11-02 refactored mdJson writer for added entity, attribute, and domain elements
@@ -44,7 +46,7 @@
44
46
  module ADIWG
45
47
  module Mdtranslator
46
48
  # current mdtranslator version
47
- VERSION = "2.5.0"
49
+ VERSION = "2.6.0"
48
50
  end
49
51
  end
50
52
 
@@ -2,6 +2,7 @@
2
2
  # data dictionary
3
3
 
4
4
  # History:
5
+ # Stan Smith 2017-11-09 add data dictionary description
5
6
  # Stan Smith 2017-04-05 refactored for mdTranslator 2.0
6
7
  # Stan Smith 2015-07-16 refactored to remove global namespace $HtmlNS
7
8
  # Stan Smith 2015-03-26 original script
@@ -32,6 +33,14 @@ module ADIWG
32
33
  domainClass = Html_Domain.new(@html)
33
34
  entityClass = Html_Entity.new(@html)
34
35
 
36
+ # dictionary - description
37
+ unless hDictionary[:description].nil?
38
+ @html.em('Dictionary Description:')
39
+ @html.section(:class => 'block') do
40
+ @html.text!(hDictionary[:description])
41
+ end
42
+ end
43
+
35
44
  # dictionary - subjects []
36
45
  hDictionary[:subjects].each do |subject|
37
46
  @html.em('Subject: ')
@@ -23,11 +23,11 @@ module ADIWG
23
23
 
24
24
  def writeHtml(aDomains)
25
25
 
26
- aDomains.each do |hDomain|
26
+ # classes used
27
+ itemClass = Html_DomainItem.new(@html)
28
+ citationClass = Html_Citation.new(@html)
27
29
 
28
- # classes used
29
- itemClass = Html_DomainItem.new(@html)
30
- citationClass = Html_Citation.new(@html)
30
+ aDomains.each do |hDomain|
31
31
 
32
32
  dName = 'domain'
33
33
  dName = hDomain[:domainCode] unless hDomain[:domainCode].nil?
@@ -25,13 +25,13 @@ module ADIWG
25
25
 
26
26
  def writeHtml(aEntities)
27
27
 
28
- aEntities.each do |hEntity|
28
+ # classes used
29
+ indexClass = Html_EntityIndex.new(@html)
30
+ attributeClass = Html_EntityAttribute.new(@html)
31
+ foreignClass = Html_EntityForeignKey.new(@html)
32
+ citationClass = Html_Citation.new(@html)
29
33
 
30
- # classes used
31
- indexClass = Html_EntityIndex.new(@html)
32
- attributeClass = Html_EntityAttribute.new(@html)
33
- foreignClass = Html_EntityForeignKey.new(@html)
34
- citationClass = Html_Citation.new(@html)
34
+ aEntities.each do |hEntity|
35
35
 
36
36
  eName = 'entity'
37
37
  eName = hEntity[:entityCode] unless hEntity[:entityCode].nil?
@@ -0,0 +1,71 @@
1
+ # HTML writer
2
+ # geologic age
3
+
4
+ # History:
5
+ # Stan Smith 2017-11-09 original script
6
+
7
+ require_relative 'html_citation'
8
+
9
+ module ADIWG
10
+ module Mdtranslator
11
+ module Writers
12
+ module Html
13
+
14
+ class Html_GeologicAge
15
+
16
+ def initialize(html)
17
+ @html = html
18
+ end
19
+
20
+ def writeHtml(hGeoAge)
21
+
22
+ # classes used
23
+ citationClass = Html_Citation.new(@html)
24
+
25
+ # geologic age - age time scale
26
+ unless hGeoAge[:ageTimeScale].nil?
27
+ @html.em('Age Time Scale: ')
28
+ @html.text!(hGeoAge[:ageTimeScale])
29
+ @html.br
30
+ end
31
+
32
+ # geologic age - age estimate
33
+ unless hGeoAge[:ageEstimate].nil?
34
+ @html.em('Age Estimate: ')
35
+ @html.text!(hGeoAge[:ageEstimate])
36
+ @html.br
37
+ end
38
+
39
+ # geologic age - age uncertainty
40
+ unless hGeoAge[:ageUncertainty].nil?
41
+ @html.em('Age Uncertainty: ')
42
+ @html.section(:class => 'block') do
43
+ @html.text!(hGeoAge[:ageUncertainty])
44
+ end
45
+ end
46
+
47
+ # geologic age - age explanation
48
+ unless hGeoAge[:ageExplanation].nil?
49
+ @html.em('Age Determination Methodology: ')
50
+ @html.section(:class => 'block') do
51
+ @html.text!(hGeoAge[:ageExplanation])
52
+ end
53
+ end
54
+
55
+ # geologic age - age references [] {citation}
56
+ hGeoAge[:ageReferences].each do |hCitation|
57
+ @html.details do
58
+ @html.summary('Age Reference', {'class' => 'h5'})
59
+ @html.section(:class => 'block') do
60
+ citationClass.writeHtml(hCitation)
61
+ end
62
+ end
63
+ end
64
+
65
+ end # writeHtml
66
+ end # Html_GeologicAge
67
+
68
+ end
69
+ end
70
+ end
71
+ end
@@ -2,11 +2,12 @@
2
2
  # temporal extent
3
3
 
4
4
  # History:
5
+ # Stan Smith 2017-11-09 remove subheadings
6
+ # Stan Smith 2017-11-09 add geologic age
5
7
  # Stan Smith 2017-03-25 refactored for mdTranslator 2.0
6
8
  # Stan Smith 2015-07-16 refactored to remove global namespace $HtmlNS
7
9
  # Stan Smith 2015-04-03 original script
8
10
 
9
- require_relative 'html_datetime'
10
11
  require_relative 'html_timePeriod'
11
12
  require_relative 'html_timeInstant'
12
13
 
@@ -24,37 +25,35 @@ module ADIWG
24
25
  def writeHtml(hExtent)
25
26
 
26
27
  # classes used
27
- datetimeClass = Html_Datetime.new(@html)
28
28
  periodClass = Html_TimePeriod.new(@html)
29
29
  instantClass = Html_TimeInstant.new(@html)
30
30
 
31
31
  # temporal element - time instant {timeInstant}
32
32
  unless hExtent[:timeInstant].empty?
33
- @html.details do
34
- dateStr = datetimeClass.writeHtml(hExtent[:timeInstant][:timeInstant])
35
- @html.summary('Time ' + dateStr + ' ', 'class' => 'h5')
36
- @html.section(:class => 'block') do
37
- instantClass.writeHtml(hExtent[:timeInstant])
38
- end
33
+ hInstant = hExtent[:timeInstant][:timeInstant]
34
+ hGeoAge = hExtent[:timeInstant][:geologicAge]
35
+ unless hInstant.empty?
36
+ @html.h5('Time Instant')
39
37
  end
38
+ unless hGeoAge.empty?
39
+ @html.h5('Geologic Age')
40
+ end
41
+ instantClass.writeHtml(hExtent[:timeInstant])
40
42
  end
41
43
 
42
44
  # temporal element - time period {timePeriod}
43
45
  unless hExtent[:timePeriod].empty?
44
- startStr = datetimeClass.writeHtml(hExtent[:timePeriod][:startDateTime])
45
- endStr = datetimeClass.writeHtml(hExtent[:timePeriod][:endDateTime])
46
- @html.details do
47
- if startStr == ''
48
- @html.summary('Period Ending ' + endStr, 'class' => 'h5')
49
- elsif endStr == ''
50
- @html.summary('Period Beginning ' + startStr, 'class' => 'h5')
51
- else
52
- @html.summary('Period ' + startStr + ' to ' + endStr, 'class' => 'h5')
53
- end
54
- @html.section(:class => 'block') do
55
- periodClass.writeHtml(hExtent[:timePeriod])
56
- end
46
+ hStartDate = hExtent[:timePeriod][:startDateTime]
47
+ hEndDate = hExtent[:timePeriod][:endDateTime]
48
+ hStartAge = hExtent[:timePeriod][:startGeologicAge]
49
+ hEndAge = hExtent[:timePeriod][:endGeologicAge]
50
+ unless hStartDate.empty? && hEndDate.empty?
51
+ @html.h5('Time Period')
52
+ end
53
+ unless hStartAge.empty? && hEndAge.empty?
54
+ @html.h5('Geologic Period')
57
55
  end
56
+ periodClass.writeHtml(hExtent[:timePeriod])
58
57
  end
59
58
 
60
59
  end # writeHtml
@@ -2,12 +2,14 @@
2
2
  # time instant
3
3
 
4
4
  # History:
5
+ # Stan Smith 2017-11-09 add geologic age
5
6
  # Stan Smith 2017-03-26 refactored for mdTranslator 2.0
6
7
  # Stan Smith 2015-07-16 refactored to remove global namespace $HtmlNS
7
8
  # Stan Smith 2015-04-03 original script
8
9
 
9
10
  require_relative 'html_identifier'
10
11
  require_relative 'html_datetime'
12
+ require_relative 'html_geologicAge'
11
13
 
12
14
  module ADIWG
13
15
  module Mdtranslator
@@ -25,6 +27,7 @@ module ADIWG
25
27
  # classes used
26
28
  identifierClass = Html_Identifier.new(@html)
27
29
  datetimeClass = Html_Datetime.new(@html)
30
+ geoAgeClass = Html_GeologicAge.new(@html)
28
31
 
29
32
  # time instant - id
30
33
  unless hInstant[:timeId].nil?
@@ -55,6 +58,11 @@ module ADIWG
55
58
  end
56
59
  end
57
60
 
61
+ # time instant - geologic age
62
+ unless hInstant[:geologicAge].empty?
63
+ geoAgeClass.writeHtml(hInstant[:geologicAge])
64
+ end
65
+
58
66
  # time instant - identifier {identifier}
59
67
  unless hInstant[:identifier].empty?
60
68
  @html.details do
@@ -2,11 +2,13 @@
2
2
  # time period
3
3
 
4
4
  # History:
5
+ # Stan Smith 2017-11-09 add geologic age
5
6
  # Stan Smith 2017-03-26 refactored for mdTranslator 2.0
6
7
  # Stan Smith 2015-07-16 refactored to remove global namespace $HtmlNS
7
8
  # Stan Smith 2015-03-23 original script
8
9
 
9
10
  require_relative 'html_datetime'
11
+ require_relative 'html_geologicAge'
10
12
  require_relative 'html_identifier'
11
13
  require_relative 'html_timeInterval'
12
14
  require_relative 'html_duration'
@@ -26,6 +28,7 @@ module ADIWG
26
28
 
27
29
  # classes used
28
30
  datetimeClass = Html_Datetime.new(@html)
31
+ geoAgeClass = Html_GeologicAge.new(@html)
29
32
  identifierClass = Html_Identifier.new(@html)
30
33
  intervalClass = Html_TimeInterval.new(@html)
31
34
  durationClass = Html_Duration.new(@html)
@@ -66,6 +69,26 @@ module ADIWG
66
69
  end
67
70
  end
68
71
 
72
+ # time period - start geologic age {geologic age}
73
+ unless hPeriod[:startGeologicAge].empty?
74
+ @html.details do
75
+ @html.summary('Starting Geologic Age', 'class' => 'h5')
76
+ @html.section(:class => 'block') do
77
+ geoAgeClass.writeHtml(hPeriod[:startGeologicAge])
78
+ end
79
+ end
80
+ end
81
+
82
+ # time period - end geologic age {geologic age}
83
+ unless hPeriod[:endGeologicAge].empty?
84
+ @html.details do
85
+ @html.summary('Ending Geologic Age', 'class' => 'h5')
86
+ @html.section(:class => 'block') do
87
+ geoAgeClass.writeHtml(hPeriod[:endGeologicAge])
88
+ end
89
+ end
90
+ end
91
+
69
92
  # time period - identifier {identifier}
70
93
  unless hPeriod[:identifier].empty?
71
94
  @html.details do
@@ -1,8 +1,9 @@
1
1
  # mdJson 2.0 writer - dictionary
2
2
 
3
3
  # History:
4
- # Stan Smith 2017-03-11 refactored for mdJson/mdTranslator 2.0
5
- # Josh Bradley original script
4
+ # Stan Smith 2017-11-09 add data dictionary description
5
+ # Stan Smith 2017-03-11 refactored for mdJson/mdTranslator 2.0
6
+ # Josh Bradley original script
6
7
 
7
8
  require 'jbuilder'
8
9
  require_relative 'mdJson_citation'
@@ -23,8 +24,9 @@ module ADIWG
23
24
  def self.build(hDictionary)
24
25
 
25
26
  Jbuilder.new do |json|
26
- json.citation Citation.build(hDictionary[:citation]) unless hDictionary[:citation].empty?
27
+ json.description hDictionary[:description]
27
28
  json.subject hDictionary[:subjects] unless hDictionary[:subjects].empty?
29
+ json.citation Citation.build(hDictionary[:citation]) unless hDictionary[:citation].empty?
28
30
  json.recommendedUse hDictionary[:recommendedUses] unless hDictionary[:recommendedUses].empty?
29
31
  json.locale @Namespace.json_map(hDictionary[:locales], Locale)
30
32
  json.responsibleParty ResponsibleParty.build(hDictionary[:responsibleParty])
@@ -0,0 +1,34 @@
1
+ # mdJson 2.0 writer - geologic age
2
+
3
+ # History:
4
+ # Stan Smith 2017-11-08 original script
5
+
6
+ require 'jbuilder'
7
+ require_relative 'mdJson_citation'
8
+
9
+ module ADIWG
10
+ module Mdtranslator
11
+ module Writers
12
+ module MdJson
13
+
14
+ module GeologicAge
15
+
16
+ def self.build(hGeoAge)
17
+
18
+ @Namespace = ADIWG::Mdtranslator::Writers::MdJson
19
+
20
+ Jbuilder.new do |json|
21
+ json.ageTimeScale hGeoAge[:ageTimeScale]
22
+ json.ageEstimate hGeoAge[:ageEstimate]
23
+ json.ageUncertainty hGeoAge[:ageUncertainty]
24
+ json.ageExplanation hGeoAge[:ageExplanation]
25
+ json.ageReference @Namespace.json_map(hGeoAge[:ageReferences], Citation)
26
+ end
27
+
28
+ end # build
29
+ end # GeologicAge
30
+
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,11 +1,13 @@
1
1
  # mdJson 2.0 writer - time instant
2
2
 
3
3
  # History:
4
- # Stan Smith 2017-03-15 original script
4
+ # Stan Smith 2017-11-08 add geologic age
5
+ # Stan Smith 2017-03-15 original script
5
6
 
6
7
  require 'jbuilder'
7
8
  require_relative 'mdJson_identifier'
8
9
  require_relative 'mdJson_dateTime'
10
+ require_relative 'mdJson_geologicAge'
9
11
 
10
12
  module ADIWG
11
13
  module Mdtranslator
@@ -22,6 +24,7 @@ module ADIWG
22
24
  json.identifier Identifier.build(hTimeInstant[:identifier]) unless hTimeInstant[:identifier].empty?
23
25
  json.instantName hTimeInstant[:instantNames] unless hTimeInstant[:instantNames].empty?
24
26
  json.dateTime DateTime.build(hTimeInstant[:timeInstant]) unless hTimeInstant[:timeInstant].empty?
27
+ json.geologicAge GeologicAge.build(hTimeInstant[:geologicAge]) unless hTimeInstant[:geologicAge].empty?
25
28
  end
26
29
 
27
30
  end # build
@@ -1,12 +1,14 @@
1
1
  # mdJson 2.0 writer - time period
2
2
 
3
3
  # History:
4
- # Stan Smith 2017-03-14 refactored for mdJson/mdTranslator 2.0
5
- # Josh Bradley original script
4
+ # Stan Smith 2017-11-08 add geologic age
5
+ # Stan Smith 2017-03-14 refactored for mdJson/mdTranslator 2.0
6
+ # Josh Bradley original script
6
7
 
7
8
  require 'jbuilder'
8
9
  require_relative 'mdJson_identifier'
9
10
  require_relative 'mdJson_dateTime'
11
+ require_relative 'mdJson_geologicAge'
10
12
  require_relative 'mdJson_timeInterval'
11
13
  require_relative 'mdJson_duration'
12
14
 
@@ -26,6 +28,8 @@ module ADIWG
26
28
  json.periodName hTimePeriod[:periodNames] unless hTimePeriod[:periodNames].empty?
27
29
  json.startDateTime DateTime.build(hTimePeriod[:startDateTime]) unless hTimePeriod[:startDateTime].empty?
28
30
  json.endDateTime DateTime.build(hTimePeriod[:endDateTime]) unless hTimePeriod[:endDateTime].empty?
31
+ json.startGeologicAge GeologicAge.build(hTimePeriod[:startGeologicAge]) unless hTimePeriod[:startGeologicAge].empty?
32
+ json.endGeologicAge GeologicAge.build(hTimePeriod[:endGeologicAge]) unless hTimePeriod[:endGeologicAge].empty?
29
33
  json.timeInterval TimeInterval.build(hTimePeriod[:timeInterval]) unless hTimePeriod[:timeInterval].empty?
30
34
  json.duration Duration.build(hTimePeriod[:duration]) unless hTimePeriod[:duration].empty?
31
35
  end
@@ -4,8 +4,6 @@
4
4
  # Stan Smith 2017-05-15 refactored for mdJson/mdTranslator 2.0
5
5
  # Josh Bradley original script
6
6
 
7
- require 'uuidtools'
8
-
9
7
  module ADIWG
10
8
  module Mdtranslator
11
9
  module Writers
@@ -1,6 +1,8 @@
1
1
  # sbJson 1.0 writer
2
2
 
3
3
  # History:
4
+ # Stan Smith 2017-11-09 add metadata identifier to output identifiers
5
+ # Stan Smith 2017-11-08 remove identifier which is the primary resource
4
6
  # Stan Smith 2017-05-12 refactored for mdJson/mdTranslator 2.0
5
7
  # Josh Bradley original script
6
8
 
@@ -38,13 +40,32 @@ module ADIWG
38
40
 
39
41
  Jbuilder.new do |json|
40
42
 
41
- json.id Id.build(intObj)
43
+ resourceId = Id.build(intObj)
44
+ json.id resourceId
42
45
  json.title hCitation[:title] unless hCitation.empty?
43
46
  json.alternateTitles hCitation[:alternateTitles] unless hCitation[:alternateTitles].empty?
44
47
  json.body Abstract.build(resourceInfo[:abstract])
45
48
  json.summary resourceInfo[:shortAbstract]
46
49
  json.citation Citation.build(hCitation) unless hCitation.empty?
47
- json.identifiers @Namespace.json_map(hCitation[:identifiers], Identifier) unless hCitation.empty?
50
+
51
+ # gather all identifiers
52
+ # include the metadataIdentifier if it is not in the 'gov.sciencebase.catalog' namespace
53
+ aIdentifiers = []
54
+ unless metadataInfo[:metadataIdentifier].empty?
55
+ unless metadataInfo[:metadataIdentifier][:namespace] == 'gov.sciencebase.catalog'
56
+ aIdentifiers << metadataInfo[:metadataIdentifier]
57
+ end
58
+ end
59
+ # do not duplicate the identifier which is the primary resource
60
+ unless hCitation.empty?
61
+ hCitation[:identifiers].each do |hIdentifier|
62
+ unless hIdentifier[:identifier] == resourceId
63
+ aIdentifiers << hIdentifier
64
+ end
65
+ end
66
+ end
67
+ json.identifiers @Namespace.json_map(aIdentifiers, Identifier) unless aIdentifiers.empty?
68
+
48
69
  json.purpose resourceInfo[:purpose]
49
70
  json.rights Rights.build(resourceInfo[:constraints]) unless resourceInfo[:constraints].empty?
50
71
  json.provenance Provenance.build