adiwg-mdtranslator 2.8.0 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -1
  3. data/adiwg-mdtranslator.gemspec +1 -1
  4. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +552 -500
  5. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_attribute.rb +1 -0
  6. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_contact.rb +63 -16
  7. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_distribution.rb +7 -16
  8. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entity.rb +1 -1
  9. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entityOverview.rb +1 -0
  10. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_enumerated.rb +7 -1
  11. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_fgdc.rb +2 -2
  12. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_identification.rb +4 -1
  13. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_metadataInfo.rb +4 -3
  14. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_transferInfo.rb +15 -11
  15. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_constraint.rb +134 -134
  16. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_dataDictionary.rb +9 -4
  17. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_distribution.rb +52 -36
  18. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_domainItem.rb +65 -51
  19. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_metadataInfo.rb +133 -121
  20. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_resourceInfo.rb +1 -1
  21. data/lib/adiwg/mdtranslator/version.rb +4 -1
  22. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_attribute.rb +178 -0
  23. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_dataDomain.rb +122 -0
  24. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_dictionary.rb +66 -0
  25. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_digitalForm.rb +81 -0
  26. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_distribution.rb +156 -0
  27. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_entityDetail.rb +78 -0
  28. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_entityOverview.rb +48 -0
  29. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_fgdc.rb +41 -4
  30. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_metadataInfo.rb +215 -0
  31. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_offlineOption.rb +86 -0
  32. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_onlineOption.rb +77 -0
  33. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_orderProcess.rb +100 -0
  34. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_timePeriod.rb +9 -7
  35. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_transferInfo.rb +135 -0
  36. data/lib/adiwg/mdtranslator/writers/html/sections/html_dataDictionary.rb +4 -4
  37. data/lib/adiwg/mdtranslator/writers/html/sections/html_distribution.rb +18 -0
  38. data/lib/adiwg/mdtranslator/writers/html/sections/html_domainItem.rb +18 -3
  39. data/lib/adiwg/mdtranslator/writers/html/sections/html_metadataInfo.rb +20 -0
  40. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_fcFeatureCatalogue.rb +1 -1
  41. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_listedValue.rb +14 -0
  42. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_dataIdentification.rb +21 -2
  43. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_distribution.rb +44 -44
  44. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_legalConstraints.rb +67 -66
  45. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_mdIdentifier.rb +53 -54
  46. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_miMetadata.rb +51 -23
  47. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dictionary.rb +1 -1
  48. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_distribution.rb +2 -0
  49. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_domainItem.rb +4 -0
  50. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_metadataInfo.rb +2 -0
  51. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_rights.rb +7 -1
  52. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_sbJson.rb +12 -1
  53. metadata +16 -4
@@ -3,7 +3,7 @@
3
3
 
4
4
  # History:
5
5
  # Stan Smith 2017-05-16 deprecated topic category
6
- # ... topic category is now handled as keyword list
6
+ # ... topic category is now handled as keyword list
7
7
  # Stan Smith 2016-11-01 original script
8
8
 
9
9
  require 'adiwg/mdtranslator/internal/internal_metadata_obj'
@@ -1,6 +1,9 @@
1
1
  # adiwg mdTranslator
2
2
 
3
3
  # version 2 history
4
+ # 2.9.0 2018-02-01 added fgdc writer distribution information section
5
+ # 2.9.0 2018-01-26 deprecate dictionaryFormat in favor of dictionaryFunctionalLanguage
6
+ # 2.9.0 2018-01-25 added fgdc writer entity and attribute section
4
7
  # 2.8.0 2018-01-17 added fgdc writer spatial reference section
5
8
  # 2.7.1 2018-01-05 fix issue #171, fully implement deprecation of topicCategories[]
6
9
  # 2.7.0 2017-12-28 reinstate schema validation checks for schema 2.4.1
@@ -58,7 +61,7 @@
58
61
  module ADIWG
59
62
  module Mdtranslator
60
63
  # current mdtranslator version
61
- VERSION = "2.8.0"
64
+ VERSION = "2.9.0"
62
65
  end
63
66
  end
64
67
 
@@ -0,0 +1,178 @@
1
+ # FGDC <<Class>> Attribute
2
+ # FGDC CSDGM writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2018-01-24 original script
6
+
7
+ require 'adiwg/mdtranslator/internal/module_dateTimeFun'
8
+ require_relative 'class_dataDomain'
9
+
10
+ module ADIWG
11
+ module Mdtranslator
12
+ module Writers
13
+ module Fgdc
14
+
15
+ class Attribute
16
+
17
+ def initialize(xml, hResponseObj)
18
+ @xml = xml
19
+ @hResponseObj = hResponseObj
20
+ end
21
+
22
+ def writeXML(hAttribute)
23
+
24
+ # classes used
25
+ domainClass = DataDomain.new(@xml, @hResponseObj)
26
+
27
+ # attribute 5.1.2.1 (attrlabl) - attribute label (required)
28
+ # <- attribute.attributeCode
29
+ unless hAttribute[:attributeCode].nil?
30
+ @xml.tag!('attrlabl', hAttribute[:attributeCode])
31
+ end
32
+ if hAttribute[:attributeCode].nil?
33
+ @hResponseObj[:writerPass] = false
34
+ @hResponseObj[:writerMessages] << 'Attribute Detail missing label'
35
+ end
36
+
37
+ # attribute 5.1.2.2 (attrdef) - attribute definition (required)
38
+ # <- attribute.attributeDefinition
39
+ unless hAttribute[:attributeDefinition].nil?
40
+ @xml.tag!('attrdef', hAttribute[:attributeDefinition])
41
+ end
42
+ if hAttribute[:attributeDefinition].nil?
43
+ @hResponseObj[:writerPass] = false
44
+ @hResponseObj[:writerMessages] << 'Attribute missing definition'
45
+ end
46
+
47
+ # attribute 5.1.2.3 (attrdefs) - attribute definition source (required)
48
+ # <- take title from first attributeReference {citation}
49
+ unless hAttribute[:attributeReference].empty?
50
+ unless hAttribute[:attributeReference].empty?
51
+ @xml.tag!('attrdefs', hAttribute[:attributeReference][:title])
52
+ end
53
+ end
54
+ if hAttribute[:attributeReference].empty?
55
+ @hResponseObj[:writerPass] = false
56
+ @hResponseObj[:writerMessages] << 'Attribute missing definition citation'
57
+ end
58
+
59
+ # attribute 5.1.2.4 (attrdomv) - attribute domain value
60
+ # enumerated domain <- dictionary.domainItems[]
61
+ # codeset domain <- dictionary.domainReference and no dictionary.domainItems[]
62
+ # unrepresented domain <- dictionary.domainDescription and no dictionary.domainItems[]
63
+ unless hAttribute[:domainId].nil?
64
+ domainClass.writeXML(hAttribute[:domainId])
65
+ end
66
+
67
+ # attribute 5.1.2.4 (attrdomv) - attribute domain value
68
+ # attribute 5.1.2.4.2 (rdom) - value range
69
+ # <- attribute.valueRange[]
70
+ hAttribute[:valueRange].each do |hRange|
71
+ unless hRange.empty?
72
+ @xml.tag!('attrdomv') do
73
+ @xml.tag!('rdom') do
74
+
75
+ # value range 5.1.2.4.2.1 (rdommin) - range minimum (required)
76
+ # <- valueRange[].minRangeValue
77
+ unless hRange[:minRangeValue].nil?
78
+ @xml.tag!('rdommin', hRange[:minRangeValue])
79
+ end
80
+ if hRange[:minRangeValue].nil?
81
+ @hResponseObj[:writerPass] = false
82
+ @hResponseObj[:writerMessages] << 'Attribute Range Value missing minimum'
83
+ end
84
+
85
+ # value range 5.1.2.4.2.2 (rdommax) - range maximum (required)
86
+ # <- valueRange[].maxRangeValue
87
+ unless hRange[:maxRangeValue].nil?
88
+ @xml.tag!('rdommax', hRange[:maxRangeValue])
89
+ end
90
+ if hRange[:maxRangeValue].nil?
91
+ @hResponseObj[:writerPass] = false
92
+ @hResponseObj[:writerMessages] << 'Attribute Range Value missing maximum'
93
+ end
94
+
95
+ # value range 5.1.2.4.2.3 (attrunit) - unit of measure
96
+ # <- attribute.unitOfMeasure
97
+ unless hAttribute[:unitOfMeasure].nil?
98
+ @xml.tag!('attrunit', hAttribute[:unitOfMeasure])
99
+ end
100
+ if hAttribute[:unitOfMeasure].nil? && @hResponseObj[:writerShowTags]
101
+ @xml.tag!('attrunit')
102
+ end
103
+
104
+ # value range 5.1.2.4.2.4 (attrmres) - unit of measure resolution
105
+ # <- attribute.measureResolution
106
+ unless hAttribute[:measureResolution].nil?
107
+ @xml.tag!('attrmres', hAttribute[:measureResolution])
108
+ end
109
+ if hAttribute[:measureResolution].nil? && @hResponseObj[:writerShowTags]
110
+ @xml.tag!('attrmres')
111
+ end
112
+
113
+ end
114
+ end
115
+ end
116
+ end
117
+
118
+ # attribute 5.1.2.5 & 5.1.2.6 (begdatea & enddatea) - attribute value date range
119
+ # <- attribute.timePeriod[]
120
+ hAttribute[:timePeriod].each do |hTimePeriod|
121
+
122
+ # date range 5.1.2.5 (begdatea) - begin date range
123
+ # <- timePeriod.startDateTime
124
+ unless hTimePeriod[:startDateTime].empty?
125
+ hDate = hTimePeriod[:startDateTime]
126
+ begDate = AdiwgDateTimeFun.stringDateFromDateTime(hDate[:dateTime], hDate[:dateResolution])
127
+ begDate.gsub!(/[-]/,'')
128
+ unless begDate == 'ERROR'
129
+ @xml.tag!('begdatea', begDate)
130
+ end
131
+ if begDate == 'ERROR'
132
+ @hResponseObj[:writerPass] = false
133
+ @hResponseObj[:writerMessages] << 'Attribute Beginning Range Date error'
134
+ end
135
+ end
136
+ if hTimePeriod[:startDateTime].empty? && @hResponseObj[:writerShowTags]
137
+ @xml.tag!('begdatea')
138
+ end
139
+
140
+ # date range 5.1.2.6 (enddatea) - end date range
141
+ # <- timePeriod.endDateTime
142
+ unless hTimePeriod[:endDateTime].empty?
143
+ hDate = hTimePeriod[:endDateTime]
144
+ endDate = AdiwgDateTimeFun.stringDateFromDateTime(hDate[:dateTime], hDate[:dateResolution])
145
+ endDate.gsub!(/[-]/,'')
146
+ unless endDate == 'ERROR'
147
+ @xml.tag!('enddatea', endDate)
148
+ end
149
+ if endDate == 'ERROR'
150
+ @hResponseObj[:writerPass] = false
151
+ @hResponseObj[:writerMessages] << 'Attribute Ending Range Date error'
152
+ end
153
+ end
154
+ if hTimePeriod[:endDateTime].empty? && @hResponseObj[:writerShowTags]
155
+ @xml.tag!('enddatea')
156
+ end
157
+
158
+ end
159
+
160
+ # attribute 5.1.2.7 (attrvai) - attribute value accuracy information
161
+ # not supported
162
+
163
+ # entity attribute 5.1.2.7.1 (attrva) - attribute value accuracy
164
+ # -> not supported
165
+
166
+ # entity attribute 5.1.2.7.2 (attrvae) - attribute value accuracy explanation
167
+ # -> not supported
168
+
169
+ # entity attribute 5.1.2.8 (attrmfrq) - attribute measurement frequency
170
+ # -> not supported; same as resource maintenance but at attribute level
171
+
172
+ end # writeXML
173
+ end # Attribute
174
+
175
+ end
176
+ end
177
+ end
178
+ end
@@ -0,0 +1,122 @@
1
+ # FGDC <<Class>> DataDomain
2
+ # FGDC CSDGM writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2018-01-24 original script
6
+
7
+ require_relative '../fgdc_writer'
8
+
9
+ module ADIWG
10
+ module Mdtranslator
11
+ module Writers
12
+ module Fgdc
13
+
14
+ class DataDomain
15
+
16
+ def initialize(xml, hResponseObj)
17
+ @xml = xml
18
+ @hResponseObj = hResponseObj
19
+ end
20
+
21
+ def writeXML(domainId)
22
+
23
+ # classes used
24
+
25
+ # get the domain
26
+ hIntObj = ADIWG::Mdtranslator::Writers::Fgdc.get_intObj
27
+ hDictionary = hIntObj[:dataDictionaries][0]
28
+ hDomain = {}
29
+ hDictionary[:domains].each do |hItem|
30
+ if hItem[:domainId] == domainId
31
+ hDomain = hItem
32
+ end
33
+ end
34
+ if hDomain.empty?
35
+ @hResponseObj[:writerPass] = false
36
+ @hResponseObj[:writerMessages] << "Dictionary Domain #{domainId} not found"
37
+ return
38
+ end
39
+
40
+ # attribute 5.1.2.4.1 (edom) - enumerated domain
41
+ hDomain[:domainItems].each do |hItem|
42
+ @xml.tag!('attrdomv') do
43
+ @xml.tag!('edom') do
44
+
45
+ # value 5.1.2.4.1.1 (edomv) - enumerated value (required)
46
+ unless hItem[:itemValue].nil?
47
+ @xml.tag!('edomv', hItem[:itemValue])
48
+ end
49
+ if hItem[:itemValue].nil?
50
+ @hResponseObj[:writerPass] = false
51
+ @hResponseObj[:writerMessages] << 'Enumerated Domain Value missing value'
52
+ end
53
+
54
+ # definition 5.1.2.4.1.2 (edomvd) - enumerated value definition (required)
55
+ unless hItem[:itemDefinition].nil?
56
+ @xml.tag!('edomvd', hItem[:itemDefinition])
57
+ end
58
+ if hItem[:itemDefinition].nil?
59
+ @hResponseObj[:writerPass] = false
60
+ @hResponseObj[:writerMessages] << 'Enumerated Domain Value missing definition'
61
+ end
62
+
63
+ # source 5.1.2.4.1.3 (edomvds) - enumerated value definition source (default='author defined')
64
+ unless hItem[:itemReference].empty?
65
+ @xml.tag!('edomvds', hItem[:itemReference][:title])
66
+ end
67
+ if hItem[:itemReference].empty?
68
+ @xml.tag!('edomvds', 'author defined')
69
+ end
70
+
71
+ end
72
+ end
73
+ end
74
+
75
+ # attribute 5.1.2.4.3 (codesetd) - codeset domain
76
+ unless hDomain[:domainReference].empty?
77
+ @xml.tag!('attrdomv') do
78
+ @xml.tag!('codesetd') do
79
+
80
+ # codeset 5.1.2.4.3.1 (codesetn) - codeset name (required)
81
+ # <- domain.name
82
+ unless hDomain[:domainName].nil?
83
+ @xml.tag!('codesetn', hDomain[:domainName])
84
+ end
85
+ if hDomain[:domainName].nil?
86
+ @hResponseObj[:writerPass] = false
87
+ @hResponseObj[:writerMessages] << 'Codeset Domain missing domain name'
88
+ end
89
+
90
+ # codeset 5.1.2.4.3.2 (codesets) - codeset source (required)
91
+ # <- domain.domainReference.title
92
+ unless hDomain[:domainReference][:title].nil?
93
+ @xml.tag!('codesets', hDomain[:domainReference][:title])
94
+ end
95
+ unless hDomain[:domainReference][:title].nil?
96
+ @hResponseObj[:writerPass] = false
97
+ @hResponseObj[:writerMessages] << 'Codeset Domain missing domain reference citation title'
98
+ end
99
+
100
+ end
101
+ end
102
+ end
103
+
104
+
105
+ # attribute 5.1.2.4.4 (4dom) - unrepresented domain
106
+ if hDomain[:domainItems].empty?
107
+ if hDomain[:domainReference].empty?
108
+ unless hDomain[:domainDescription].nil?
109
+ @xml.tag!('attrdomv') do
110
+ @xml.tag!('udom', hDomain[:domainDescription])
111
+ end
112
+ end
113
+ end
114
+ end
115
+
116
+ end # writeXML
117
+ end # DataDomain
118
+
119
+ end
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,66 @@
1
+ # FGDC <<Class>> Series
2
+ # FGDC CSDGM writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2018-01-21 original script
6
+
7
+ require_relative 'class_entityDetail'
8
+ require_relative 'class_entityOverview'
9
+
10
+ module ADIWG
11
+ module Mdtranslator
12
+ module Writers
13
+ module Fgdc
14
+
15
+ class DataDictionary
16
+
17
+ def initialize(xml, hResponseObj)
18
+ @xml = xml
19
+ @hResponseObj = hResponseObj
20
+ end
21
+
22
+ def writeXML(hDictionary)
23
+
24
+ # classes used
25
+ detailClass = EntityDetail.new(@xml, @hResponseObj)
26
+ overviewClass = EntityOverview.new(@xml, @hResponseObj)
27
+
28
+ haveDescription = false
29
+ hDictionary[:entities].each do |hEntity|
30
+ unless hEntity.empty?
31
+
32
+ # dictionary 5.1 (detailed) - detailed description
33
+ # <- hDictionary.entity[].entityCode != 'overview'
34
+ unless hEntity[:entityCode] == 'overview'
35
+ @xml.tag!('detailed') do
36
+ detailClass.writeXML(hEntity)
37
+ end
38
+ haveDescription = true
39
+ end
40
+
41
+ # dictionary 5.2 (overview) - overview description
42
+ # <- hDictionary.entity[].entityCode == 'overview'
43
+ if hEntity[:entityCode] == 'overview'
44
+ @xml.tag!('overview') do
45
+ overviewClass.writeXML(hEntity)
46
+ end
47
+ haveDescription = true
48
+ end
49
+
50
+ end
51
+
52
+ end
53
+
54
+ # must have at least on detailed description or overview description
55
+ unless haveDescription
56
+ @hResponseObj[:writerPass] = false
57
+ @hResponseObj[:writerMessages] << 'Data Dictionary requires at least one detail or overview description'
58
+ end
59
+
60
+ end # writeXML
61
+ end # Series
62
+
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,81 @@
1
+ # FGDC <<Class>> DigitalForm
2
+ # FGDC CSDGM writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2018-01-31 original script
6
+
7
+ require_relative 'class_transferInfo'
8
+ require_relative 'class_onlineOption'
9
+ require_relative 'class_offlineOption'
10
+
11
+ module ADIWG
12
+ module Mdtranslator
13
+ module Writers
14
+ module Fgdc
15
+
16
+ class DigitalFormat
17
+
18
+ def initialize(xml, hResponseObj)
19
+ @xml = xml
20
+ @hResponseObj = hResponseObj
21
+ end
22
+
23
+ def writeXML(hTransOpt)
24
+
25
+ # classes used
26
+ transClass = TransferInformation.new(@xml, @hResponseObj)
27
+ onClass = OnlineOption.new(@xml, @hResponseObj)
28
+ offClass = OfflineOption.new(@xml, @hResponseObj)
29
+
30
+ # digital format 6.4.2.1 (digtinfo) - digital transfer information
31
+ @xml.tag!('digtinfo') do
32
+ transClass.writeXML(hTransOpt)
33
+ end
34
+
35
+ # digital format 6.4.2.2 (digtopt) - digital transfer option
36
+ aOnline = hTransOpt[:onlineOptions]
37
+ aOffline = hTransOpt[:offlineOptions]
38
+ unless aOffline.empty? && aOnline.empty?
39
+ @xml.tag!('digtopt') do
40
+
41
+ # online option 6.4.2.2.1 (onlinopt) - online option
42
+ aOnline.each do |hOnline|
43
+ unless hOnline.empty?
44
+ @xml.tag!('onlinopt') do
45
+ onClass.writeXML(hOnline)
46
+ end
47
+ end
48
+ end
49
+
50
+ # offline option 6.4.2.2.2 (offoptn) - offline option
51
+ aOffline.each do |hOffline|
52
+ unless hOffline.empty?
53
+
54
+ # skip offlineOptions handled as non-digital media
55
+ isNonDig = false
56
+ isNonDig = true unless hOffline[:note].nil?
57
+ isNonDig = false unless hOffline[:mediumSpecification].empty?
58
+ isNonDig = false unless hOffline[:density].nil?
59
+ isNonDig = false unless hOffline[:units].nil?
60
+ isNonDig = false unless hOffline[:numberOfVolumes].nil?
61
+ isNonDig = false unless hOffline[:mediumFormat].empty?
62
+ isNonDig = false unless hOffline[:identifier].empty?
63
+ unless isNonDig
64
+ @xml.tag!('offoptn') do
65
+ offClass.writeXML(hOffline)
66
+ end
67
+ end
68
+
69
+ end
70
+ end
71
+
72
+ end
73
+ end
74
+
75
+ end # writeXML
76
+ end # DigitalFormat
77
+
78
+ end
79
+ end
80
+ end
81
+ end