adiwg-mdtranslator 2.12.0 → 2.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -1
  3. data/adiwg-mdtranslator.gemspec +1 -1
  4. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +2 -0
  5. data/lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb +4 -0
  6. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_entityAttribute.rb +1 -1
  7. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_georectifiedRepresentation.rb +7 -12
  8. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_resourceInfo.rb +12 -11
  9. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_source.rb +15 -7
  10. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_taxonomy.rb +1 -6
  11. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_timePeriod.rb +15 -1
  12. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_transferOption.rb +1 -3
  13. data/lib/adiwg/mdtranslator/version.rb +5 -1
  14. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_citation.rb +1 -1
  15. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_contact.rb +4 -2
  16. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_geologicAge.rb +1 -1
  17. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_identification.rb +1 -1
  18. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_method.rb +1 -1
  19. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_source.rb +1 -1
  20. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_taxonomyKeywords.rb +4 -4
  21. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_taxonomySystem.rb +1 -1
  22. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_fcFeatureCatalogue.rb +7 -7
  23. data/lib/adiwg/mdtranslator/writers/iso19110/iso19110_writer.rb +6 -5
  24. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_address.rb +104 -104
  25. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_aggregateInformation.rb +63 -60
  26. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/{class_attributeGroup.rb → class_attribute.rb} +1 -1
  27. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_baseUnit.rb +23 -23
  28. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_boundingBox.rb +64 -60
  29. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_browseGraphic.rb +55 -51
  30. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_citation.rb +24 -14
  31. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_contact.rb +96 -91
  32. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_conventionalUnit.rb +45 -45
  33. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_coverageDescription.rb +104 -77
  34. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_crs.rb +4 -4
  35. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_dataIdentification.rb +23 -8
  36. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_dataQuality.rb +57 -52
  37. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_date.rb +49 -46
  38. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_definitionUnit.rb +20 -20
  39. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_derivedUnit.rb +32 -32
  40. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_dimension.rb +56 -50
  41. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_distribution.rb +1 -1
  42. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_distributor.rb +77 -74
  43. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_enumerationList.rb +34 -34
  44. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_extension.rb +190 -186
  45. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_extent.rb +66 -66
  46. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_feature.rb +50 -45
  47. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_featureCollection.rb +35 -35
  48. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_featureProperties.rb +43 -43
  49. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_format.rb +73 -69
  50. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_fraction.rb +37 -33
  51. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_geographicElement.rb +59 -54
  52. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_geographicExtent.rb +58 -58
  53. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_geometricObjects.rb +49 -46
  54. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_geometryCollection.rb +68 -63
  55. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_georectified.rb +113 -110
  56. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_georeferenceable.rb +78 -75
  57. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_gmlIdentifier.rb +17 -17
  58. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_grid.rb +55 -52
  59. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_gridRepresentation.rb +19 -19
  60. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_hierarchy.rb +47 -47
  61. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_image.rb +132 -132
  62. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_keyword.rb +5 -2
  63. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_lineString.rb +70 -70
  64. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_lineage.rb +55 -55
  65. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_locale.rb +51 -48
  66. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_maintenance.rb +114 -105
  67. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_mdBand.rb +111 -111
  68. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_mdIdentifier.rb +9 -3
  69. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_measure.rb +58 -41
  70. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_medium.rb +104 -104
  71. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_miBand.rb +70 -70
  72. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_miMetadata.rb +51 -16
  73. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_multiLine.rb +70 -70
  74. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_multiPoint.rb +70 -70
  75. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_multiPolygon.rb +70 -70
  76. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_onlineResource.rb +79 -76
  77. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_orderProcess.rb +67 -67
  78. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_phone.rb +67 -67
  79. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_point.rb +8 -8
  80. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_polygon.rb +89 -89
  81. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_processStep.rb +9 -3
  82. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_rangeDimension.rb +59 -54
  83. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_referenceSystem.rb +1 -1
  84. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_resolution.rb +47 -47
  85. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_responsibleParty.rb +111 -105
  86. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_rsIdentifier.rb +71 -65
  87. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_scope.rb +54 -50
  88. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_scopeDescription.rb +45 -42
  89. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_securityConstraints.rb +92 -89
  90. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_series.rb +55 -55
  91. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_source.rb +98 -91
  92. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_spatialRepresentation.rb +42 -42
  93. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_taxonomicClassification.rb +63 -59
  94. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_taxonomicSystem.rb +40 -40
  95. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_taxonomy.rb +133 -130
  96. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_temporalExtent.rb +49 -49
  97. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_timeInstant.rb +60 -60
  98. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_timePeriod.rb +110 -108
  99. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_transferOptions.rb +71 -69
  100. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_unitsOfMeasure.rb +243 -243
  101. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_usage.rb +98 -95
  102. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_useConstraints.rb +38 -38
  103. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_vectorRepresentation.rb +48 -48
  104. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_verticalExtent.rb +74 -70
  105. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_vouchers.rb +56 -53
  106. data/lib/adiwg/mdtranslator/writers/iso19115_2/iso19115_2_writer.rb +61 -11
  107. data/lib/adiwg/mdtranslator/writers/iso19115_2/iso19115_2_writer_messages_eng.yml +109 -0
  108. data/lib/adiwg/mdtranslator/writers/iso19115_2/version.rb +3 -2
  109. data/lib/adiwg/mdtranslator_cli.rb +21 -4
  110. metadata +6 -5
@@ -31,7 +31,7 @@ module ADIWG
31
31
 
32
32
  @xml.tag!('gmd:MD_Distribution') do
33
33
 
34
- # distribution - distributor (required)
34
+ # distribution - distributor
35
35
  aDistributors = hDistribution[:distributor]
36
36
  unless aDistributors.empty?
37
37
  aDistributors.each do |hDistributor|
@@ -2,97 +2,100 @@
2
2
  # 19115-2 writer output in XML
3
3
 
4
4
  # History:
5
- # Stan Smith 2016-12-07 refactored for mdTranslator/mdJson 2.0
6
- # Stan Smith 2015-09-21 added format from distributorTransferOptions
7
- # Stan Smith 2015-07-14 refactored to eliminate namespace globals $WriterNS and $IsoNS
8
- # Stan Smith 2015-07-14 refactored to make iso19110 independent of iso19115_2 classes
9
- # Stan Smith 2015-06-22 replace global ($response) with passed in object (hResponseObj)
10
- # Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
11
- # Stan Smith 2014-07-09 modify require statements to function in RubyGem structure
5
+ # Stan Smith 2018-04-09 add error and warning messaging
6
+ # Stan Smith 2016-12-07 refactored for mdTranslator/mdJson 2.0
7
+ # Stan Smith 2015-09-21 added format from distributorTransferOptions
8
+ # Stan Smith 2015-07-14 refactored to eliminate namespace globals $WriterNS and $IsoNS
9
+ # Stan Smith 2015-07-14 refactored to make iso19110 independent of iso19115_2 classes
10
+ # Stan Smith 2015-06-22 replace global ($response) with passed in object (hResponseObj)
11
+ # Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
12
+ # Stan Smith 2014-07-09 modify require statements to function in RubyGem structure
12
13
  # Stan Smith 2013-09-25 original script
13
14
 
15
+ require_relative '../iso19115_2_writer'
14
16
  require_relative 'class_responsibleParty'
15
17
  require_relative 'class_orderProcess'
16
18
  require_relative 'class_format'
17
19
  require_relative 'class_transferOptions'
18
20
 
19
21
  module ADIWG
20
- module Mdtranslator
21
- module Writers
22
- module Iso19115_2
22
+ module Mdtranslator
23
+ module Writers
24
+ module Iso19115_2
23
25
 
24
- class MD_Distributor
26
+ class MD_Distributor
25
27
 
26
- def initialize(xml, hResponseObj)
27
- @xml = xml
28
- @hResponseObj = hResponseObj
29
- end
28
+ def initialize(xml, hResponseObj)
29
+ @xml = xml
30
+ @hResponseObj = hResponseObj
31
+ @NameSpace = ADIWG::Mdtranslator::Writers::Iso19115_2
32
+ end
30
33
 
31
- def writeXML(hDistributor)
34
+ def writeXML(hDistributor)
32
35
 
33
- # classes used
34
- partyClass = CI_ResponsibleParty.new(@xml, @hResponseObj)
35
- orderClass = MD_StandardOrderProcess.new(@xml, @hResponseObj)
36
- formatClass = MD_Format.new(@xml, @hResponseObj)
37
- transferClass = MD_DigitalTransferOptions.new(@xml, @hResponseObj)
36
+ # classes used
37
+ partyClass = CI_ResponsibleParty.new(@xml, @hResponseObj)
38
+ orderClass = MD_StandardOrderProcess.new(@xml, @hResponseObj)
39
+ formatClass = MD_Format.new(@xml, @hResponseObj)
40
+ transferClass = MD_DigitalTransferOptions.new(@xml, @hResponseObj)
38
41
 
39
- @xml.tag!('gmd:MD_Distributor') do
42
+ @xml.tag!('gmd:MD_Distributor') do
40
43
 
41
- # distributor - contact (required) {CI_ResponsibleParty}
42
- role = 'distributor'
43
- hParty = hDistributor[:contact][:parties][0]
44
- unless hParty.nil?
45
- @xml.tag!('gmd:distributorContact') do
46
- partyClass.writeXML(role, hParty)
47
- end
48
- end
49
- if hParty.nil?
50
- @xml.tag!('gmd:distributorContact', {'gco:nilReason'=>'missing'})
51
- end
44
+ # distributor - contact (required) {CI_ResponsibleParty}
45
+ role = 'distributor'
46
+ hParty = hDistributor[:contact][:parties][0]
47
+ unless hParty.nil?
48
+ @xml.tag!('gmd:distributorContact') do
49
+ partyClass.writeXML(role, hParty, 'distributor')
50
+ end
51
+ end
52
+ if hParty.nil?
53
+ @NameSpace.issueWarning(90, 'gmd:distributorContact')
54
+ end
52
55
 
53
- # distributor - order process [{MD_StandardOrderProcess}]
54
- aDistOrderProc = hDistributor[:orderProcess]
55
- aDistOrderProc.each do |hOrder|
56
- @xml.tag!('gmd:distributionOrderProcess') do
57
- orderClass.writeXML(hOrder)
58
- end
59
- end
60
- if aDistOrderProc.empty? && @hResponseObj[:writerShowTags]
61
- @xml.tag!('gmd:distributionOrderProcess')
62
- end
56
+ # distributor - order process [{MD_StandardOrderProcess}]
57
+ aDistOrderProc = hDistributor[:orderProcess]
58
+ aDistOrderProc.each do |hOrder|
59
+ @xml.tag!('gmd:distributionOrderProcess') do
60
+ orderClass.writeXML(hOrder)
61
+ end
62
+ end
63
+ if aDistOrderProc.empty? && @hResponseObj[:writerShowTags]
64
+ @xml.tag!('gmd:distributionOrderProcess')
65
+ end
63
66
 
64
- # distributor - format [{MD_Format}]
65
- format = false
66
- aOptions = hDistributor[:transferOptions]
67
- aOptions.each do |hOption|
68
- aFormats = hOption[:distributionFormats]
69
- aFormats.each do |hFormat|
70
- format = true
71
- @xml.tag!('gmd:distributorFormat') do
72
- formatClass.writeXML(hFormat)
73
- end
74
- end
75
- end
76
- if !format && @hResponseObj[:writerShowTags]
77
- @xml.tag!('gmd:distributorFormat')
78
- end
67
+ # distributor - format [{MD_Format}]
68
+ format = false
69
+ aOptions = hDistributor[:transferOptions]
70
+ aOptions.each do |hOption|
71
+ aFormats = hOption[:distributionFormats]
72
+ aFormats.each do |hFormat|
73
+ format = true
74
+ @xml.tag!('gmd:distributorFormat') do
75
+ formatClass.writeXML(hFormat)
76
+ end
77
+ end
78
+ end
79
+ if !format && @hResponseObj[:writerShowTags]
80
+ @xml.tag!('gmd:distributorFormat')
81
+ end
79
82
 
80
- # distributor - transfer options [{MD_DigitalTransferOptions}]
81
- aOptions = hDistributor[:transferOptions]
82
- aOptions.each do |hOption|
83
- @xml.tag!('gmd:distributorTransferOptions') do
84
- transferClass.writeXML(hOption)
85
- end
86
- end
87
- if aOptions.empty? && @hResponseObj[:writerShowTags]
88
- @xml.tag!('gmd:distributorTransferOptions')
89
- end
83
+ # distributor - transfer options [{MD_DigitalTransferOptions}]
84
+ aOptions = hDistributor[:transferOptions]
85
+ aOptions.each do |hOption|
86
+ @xml.tag!('gmd:distributorTransferOptions') do
87
+ transferClass.writeXML(hOption)
88
+ end
89
+ end
90
+ if aOptions.empty? && @hResponseObj[:writerShowTags]
91
+ @xml.tag!('gmd:distributorTransferOptions')
92
+ end
90
93
 
91
- end # gmd:MD_Distributor tag
92
- end # writeXML
93
- end # MD_Distributor class
94
+ end # gmd:MD_Distributor tag
95
+ end # writeXML
96
+ end # MD_Distributor class
94
97
 
95
- end
96
- end
97
- end
98
+ end
99
+ end
100
+ end
98
101
  end
@@ -2,51 +2,51 @@
2
2
  # 19115-2 writer output in XML
3
3
 
4
4
  # History:
5
- # Stan Smith 2016-12-12 refactored for mdTranslator/mdJson 2.0
6
- # Stan Smith 2015-07-14 refactored to eliminate namespace globals $WriterNS and $IsoNS
7
- # Stan Smith 2015-07-14 refactored to make iso19110 independent of iso19115_2 classes
8
- # Stan Smith 2015-06-22 replace global ($response) with passed in object (responseObj)
9
- # Stan Smith 2015-06-12 refactored to use mdCodes gem for codelist contents
10
- # Stan Smith 2014-12-15 replaced NOAA CT_CodelistCatalogue with mdTranslator CT_CodelistCatalogue
11
- # Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
12
- # Stan Smith 2014-10-15 allow non-ISO codesNames to be rendered
5
+ # Stan Smith 2016-12-12 refactored for mdTranslator/mdJson 2.0
6
+ # Stan Smith 2015-07-14 refactored to eliminate namespace globals $WriterNS and $IsoNS
7
+ # Stan Smith 2015-07-14 refactored to make iso19110 independent of iso19115_2 classes
8
+ # Stan Smith 2015-06-22 replace global ($response) with passed in object (responseObj)
9
+ # Stan Smith 2015-06-12 refactored to use mdCodes gem for codelist contents
10
+ # Stan Smith 2014-12-15 replaced NOAA CT_CodelistCatalogue with mdTranslator CT_CodelistCatalogue
11
+ # Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
12
+ # Stan Smith 2014-10-15 allow non-ISO codesNames to be rendered
13
13
  # Stan Smith 2013-08-09 original script
14
14
 
15
15
  require 'adiwg-mdcodes'
16
16
 
17
17
  module ADIWG
18
- module Mdtranslator
19
- module Writers
20
- module Iso19115_2
18
+ module Mdtranslator
19
+ module Writers
20
+ module Iso19115_2
21
21
 
22
- class MD_EnumerationList
22
+ class MD_EnumerationList
23
23
 
24
- def initialize(xml, responseObj)
25
- @xml = xml
26
- @hResponseObj = responseObj
27
- end
24
+ def initialize(xml, responseObj)
25
+ @xml = xml
26
+ @hResponseObj = responseObj
27
+ end
28
28
 
29
- def writeXML(codeList, codeName)
29
+ def writeXML(codeList, codeName)
30
30
 
31
- # get requested codelist from the adiwg-mdcodes gem
32
- mdCodelist = ADIWG::Mdcodes.getCodelistDetail(codeList)
31
+ # get requested codelist from the adiwg-mdcodes gem
32
+ mdCodelist = ADIWG::Mdcodes.getCodelistDetail(codeList)
33
33
 
34
- sourceName = mdCodelist['sourceName']
35
- codelist = mdCodelist['codelist']
34
+ sourceName = mdCodelist['sourceName']
35
+ codelist = mdCodelist['codelist']
36
36
 
37
- # search the codelist for a matching codeName
38
- # only valid enumeration values can be written in ISO
39
- codelist.each do |code|
40
- if code['codeName'] == codeName
41
- @xml.tag!('gmd:' + "#{sourceName}", codeName)
42
- break
43
- end
44
- end
37
+ # search the codelist for a matching codeName
38
+ # only valid enumeration values can be written in ISO
39
+ codelist.each do |code|
40
+ if code['codeName'] == codeName
41
+ @xml.tag!('gmd:' + "#{sourceName}", codeName)
42
+ break
43
+ end
44
+ end
45
45
 
46
- end # writeXML
47
- end # MD_EnumerationList class
46
+ end # writeXML
47
+ end # MD_EnumerationList class
48
48
 
49
- end
50
- end
51
- end
49
+ end
50
+ end
51
+ end
52
52
  end
@@ -2,198 +2,202 @@
2
2
  # 19115-2 writer output in XML
3
3
 
4
4
  # History:
5
+ # Stan Smith 2018-04-09 add error and warning messaging
6
+ # Stan Smith 2015-07-14 refactored to eliminate namespace globals $WriterNS and $IsoNS
7
+ # Stan Smith 2015-07-14 refactored to make iso19110 independent of iso19115_2 classes
8
+ # Stan Smith 2015-06-22 replace global ($response) with passed in object (hResponseObj)
9
+ # Stan Smith 2015-06-11 change all codelists to use 'class_codelist' method
10
+ # Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
11
+ # Stan Smith 2014-07-08 modify require statements to function in RubyGem structure
5
12
  # Stan Smith 2013-11-22 original script.
6
- # Stan Smith 2014-07-08 modify require statements to function in RubyGem structure
7
- # Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
8
- # Stan Smith 2015-06-11 change all codelists to use 'class_codelist' method
9
- # Stan Smith 2015-06-22 replace global ($response) with passed in object (hResponseObj)
10
- # Stan Smith 2015-07-14 refactored to make iso19110 independent of iso19115_2 classes
11
- # Stan Smith 2015-07-14 refactored to eliminate namespace globals $WriterNS and $IsoNS
12
13
 
14
+ require_relative '../iso19115_2_writer'
13
15
  require_relative 'class_codelist'
14
16
  require_relative 'class_enumerationList'
15
17
  require_relative 'class_onlineResource'
16
- require_relative 'class_responsibleParty'
17
18
 
18
19
  module ADIWG
19
- module Mdtranslator
20
- module Writers
21
- module Iso19115_2
22
-
23
- class MD_MetadataExtensionInformation
24
-
25
- def initialize(xml, hResponseObj)
26
- @xml = xml
27
- @hResponseObj = hResponseObj
28
- end
29
-
30
- def writeXML(hExtension)
31
-
32
- # classes used
33
- codelistClass = MD_Codelist.new(@xml, @hResponseObj)
34
- enumerationClass = MD_EnumerationList.new(@xml, @hResponseObj)
35
- olResClass = CI_OnlineResource.new(@xml, @hResponseObj)
36
- partyClass = CI_ResponsibleParty.new(@xml, @hResponseObj)
37
-
38
- @xml.tag!('gmd:MD_MetadataExtensionInformation') do
39
-
40
- # metadata extension - online resource {CI_OnLineResource}
41
- hOLResource = hExtension[:onLineResource]
42
- unless hOLResource.empty?
43
- @xml.tag!('gmd:extensionOnLineResource') do
44
- olResClass.writeXML(hOLResource)
45
- end
46
- end
47
- if hOLResource.empty? && @hResponseObj[:writerShowTags]
48
- @xml.tag!('gmd:extensionOnLineResource')
49
- end
50
-
51
- # metadata extension = extended element information
52
- @xml.tag!('gmd:extendedElementInformation') do
53
- @xml.tag!('gmd:MD_ExtendedElementInformation') do
54
-
55
- # extended element info - name (required)
56
- s = hExtension[:name]
57
- unless s.nil?
58
- @xml.tag!('gmd:name') do
59
- @xml.tag!('gco:CharacterString', s)
60
- end
61
- end
62
- if s.nil?
63
- @xml.tag!('gmd:name', {'gco:nilReason' => 'missing'})
64
- end
65
-
66
- # extended element info - short name
67
- s = hExtension[:shortName]
68
- unless s.nil?
69
- @xml.tag!('gmd:shortName') do
70
- @xml.tag!('gco:CharacterString', s)
71
- end
72
- end
73
- if s.nil? && @hResponseObj[:writerShowTags]
74
- @xml.tag!('gmd:shortName')
75
- end
76
-
77
- # extended element info - definition (required)
78
- s = hExtension[:definition]
79
- unless s.nil?
80
- @xml.tag!('gmd:definition') do
81
- @xml.tag!('gco:CharacterString', s)
82
- end
83
- end
84
- if s.nil?
85
- @xml.tag!('gmd:definition', {'gco:nilReason' => 'missing'})
86
- end
87
-
88
- # extended element info - obligation
89
- s = hExtension[:obligation]
90
- unless s.nil?
91
- @xml.tag!('gmd:obligation') do
92
- enumerationClass.writeXML('iso_obligation',s)
93
- end
94
- end
95
- if s.nil? && @hResponseObj[:writerShowTags]
96
- @xml.tag!('gmd:obligation')
97
- end
98
-
99
- # extended element info - data type (required)
100
- s = hExtension[:dataType]
101
- unless s.nil?
102
- @xml.tag!('gmd:dataType') do
103
- codelistClass.writeXML('gmd', 'iso_entityClass',s)
104
- end
105
- end
106
- if s.nil?
107
- @xml.tag!('gmd:dataType', {'gco:nilReason' => 'missing'})
108
- end
109
-
110
- # extended element info - maximum occurrence
111
- s = hExtension[:maxOccurrence]
112
- unless s.nil?
113
- @xml.tag!('gmd:maximumOccurrence') do
114
- @xml.tag!('gco:CharacterString', s)
115
- end
116
- end
117
- if s.nil? && @hResponseObj[:writerShowTags]
118
- @xml.tag!('gmd:maximumOccurrence')
119
- end
120
-
121
- # extended element info - parent entity [] (required)
122
- aParents = hExtension[:parentEntities]
123
- aParents.each do |parent|
124
- @xml.tag!('gmd:parentEntity') do
125
- @xml.tag!('gco:CharacterString', parent)
126
- end
127
- end
128
- if aParents.empty?
129
- @xml.tag!('gmd:parentEntity', {'gco:nilReason' => 'missing'})
130
- end
131
-
132
- # extended element info - rule
133
- s = hExtension[:rule]
134
- unless s.nil?
135
- @xml.tag!('gmd:rule') do
136
- @xml.tag!('gco:CharacterString', s)
137
- end
138
- end
139
- if s.nil?
140
- @xml.tag!('gmd:rule', {'gco:nilReason' => 'missing'})
141
- end
142
-
143
- # extended element info - rationale []
144
- aRations = hExtension[:rationales]
145
- aRations.each do |ration|
146
- @xml.tag!('gmd:rationale') do
147
- @xml.tag!('gco:CharacterString', ration)
148
- end
149
- end
150
- if aRations.empty? && @hResponseObj[:writerShowTags]
151
- @xml.tag!('gmd:rationale')
152
- end
153
-
154
- # extended element info - source [] (required)
155
- # only allowing 1 for now
156
- role = hExtension[:sourceRole]
157
- unless role.nil?
158
- @xml.tag!('gmd:source') do
159
- @xml.tag!('gmd:CI_ResponsibleParty') do
160
- orgName = hExtension[:sourceOrganization]
161
- unless orgName.nil?
162
- @xml.tag!('gmd:organisationName') do
163
- @xml.tag!('gco:CharacterString', orgName)
164
- end
165
- end
166
- uri = hExtension[:sourceURI]
167
- unless uri.nil?
168
- @xml.tag!('gmd:contactInfo') do
169
- @xml.tag!('gmd:CI_Contact') do
170
- @xml.tag!('gmd:onlineResource') do
171
- @xml.tag!('gmd:CI_OnlineResource') do
172
- @xml.tag!('gmd:linkage') do
173
- @xml.tag!('gmd:URL', uri)
174
- end
175
- end
176
- end
177
- end
178
- end
179
- end
180
- @xml.tag!('gmd:role') do
181
- codelistClass.writeXML('gmd', 'iso_role', role)
20
+ module Mdtranslator
21
+ module Writers
22
+ module Iso19115_2
23
+
24
+ class MD_MetadataExtensionInformation
25
+
26
+ def initialize(xml, hResponseObj)
27
+ @xml = xml
28
+ @hResponseObj = hResponseObj
29
+ @NameSpace = ADIWG::Mdtranslator::Writers::Iso19115_2
30
+ end
31
+
32
+ def writeXML(hExtension)
33
+
34
+ # classes used
35
+ codelistClass = MD_Codelist.new(@xml, @hResponseObj)
36
+ enumerationClass = MD_EnumerationList.new(@xml, @hResponseObj)
37
+ olResClass = CI_OnlineResource.new(@xml, @hResponseObj)
38
+
39
+ outContext = 'extension information'
40
+ outContext = 'extension name ' + hExtension[:name] unless hExtension[:name].nil?
41
+
42
+ @xml.tag!('gmd:MD_MetadataExtensionInformation') do
43
+
44
+ # metadata extension - online resource {CI_OnLineResource}
45
+ hOLResource = hExtension[:onLineResource]
46
+ unless hOLResource.empty?
47
+ @xml.tag!('gmd:extensionOnLineResource') do
48
+ olResClass.writeXML(hOLResource, outContext)
49
+ end
50
+ end
51
+ if hOLResource.empty? && @hResponseObj[:writerShowTags]
52
+ @xml.tag!('gmd:extensionOnLineResource')
53
+ end
54
+
55
+ # metadata extension = extended element information
56
+ @xml.tag!('gmd:extendedElementInformation') do
57
+ @xml.tag!('gmd:MD_ExtendedElementInformation') do
58
+
59
+ # extended element info - name (required)
60
+ s = hExtension[:name]
61
+ unless s.nil?
62
+ @xml.tag!('gmd:name') do
63
+ @xml.tag!('gco:CharacterString', s)
64
+ end
65
+ end
66
+ if s.nil?
67
+ @NameSpace.issueWarning(100, 'gmd:name')
68
+ end
69
+
70
+ # extended element info - short name
71
+ s = hExtension[:shortName]
72
+ unless s.nil?
73
+ @xml.tag!('gmd:shortName') do
74
+ @xml.tag!('gco:CharacterString', s)
75
+ end
76
+ end
77
+ if s.nil? && @hResponseObj[:writerShowTags]
78
+ @xml.tag!('gmd:shortName')
79
+ end
80
+
81
+ # extended element info - definition (required)
82
+ s = hExtension[:definition]
83
+ unless s.nil?
84
+ @xml.tag!('gmd:definition') do
85
+ @xml.tag!('gco:CharacterString', s)
86
+ end
87
+ end
88
+ if s.nil?
89
+ @NameSpace.issueWarning(101, 'gmd:definition', outContext)
90
+ end
91
+
92
+ # extended element info - obligation
93
+ s = hExtension[:obligation]
94
+ unless s.nil?
95
+ @xml.tag!('gmd:obligation') do
96
+ enumerationClass.writeXML('iso_obligation', s)
97
+ end
98
+ end
99
+ if s.nil? && @hResponseObj[:writerShowTags]
100
+ @xml.tag!('gmd:obligation')
101
+ end
102
+
103
+ # extended element info - data type (required)
104
+ s = hExtension[:dataType]
105
+ unless s.nil?
106
+ @xml.tag!('gmd:dataType') do
107
+ codelistClass.writeXML('gmd', 'iso_entityClass', s)
108
+ end
109
+ end
110
+ if s.nil?
111
+ @NameSpace.issueWarning(102, 'gmd:dataType', outContext)
112
+ end
113
+
114
+ # extended element info - maximum occurrence
115
+ s = hExtension[:maxOccurrence]
116
+ unless s.nil?
117
+ @xml.tag!('gmd:maximumOccurrence') do
118
+ @xml.tag!('gco:CharacterString', s)
119
+ end
120
+ end
121
+ if s.nil? && @hResponseObj[:writerShowTags]
122
+ @xml.tag!('gmd:maximumOccurrence')
123
+ end
124
+
125
+ # extended element info - parent entity [] (required)
126
+ aParents = hExtension[:parentEntities]
127
+ aParents.each do |parent|
128
+ @xml.tag!('gmd:parentEntity') do
129
+ @xml.tag!('gco:CharacterString', parent)
130
+ end
131
+ end
132
+ if aParents.empty?
133
+ @NameSpace.issueWarning(103, 'gmd:parentEntity', outContext)
134
+ end
135
+
136
+ # extended element info - rule
137
+ s = hExtension[:rule]
138
+ unless s.nil?
139
+ @xml.tag!('gmd:rule') do
140
+ @xml.tag!('gco:CharacterString', s)
141
+ end
142
+ end
143
+ if s.nil?
144
+ @NameSpace.issueWarning(104, 'gmd:rule', outContext)
145
+ end
146
+
147
+ # extended element info - rationale []
148
+ aRations = hExtension[:rationales]
149
+ aRations.each do |ration|
150
+ @xml.tag!('gmd:rationale') do
151
+ @xml.tag!('gco:CharacterString', ration)
152
+ end
153
+ end
154
+ if aRations.empty? && @hResponseObj[:writerShowTags]
155
+ @xml.tag!('gmd:rationale')
156
+ end
157
+
158
+ # extended element info - source [] (required)
159
+ # only allowing 1 for now
160
+ role = hExtension[:sourceRole]
161
+ unless role.nil?
162
+ @xml.tag!('gmd:source') do
163
+ @xml.tag!('gmd:CI_ResponsibleParty') do
164
+ orgName = hExtension[:sourceOrganization]
165
+ unless orgName.nil?
166
+ @xml.tag!('gmd:organisationName') do
167
+ @xml.tag!('gco:CharacterString', orgName)
168
+ end
169
+ end
170
+ uri = hExtension[:sourceURI]
171
+ unless uri.nil?
172
+ @xml.tag!('gmd:contactInfo') do
173
+ @xml.tag!('gmd:CI_Contact') do
174
+ @xml.tag!('gmd:onlineResource') do
175
+ @xml.tag!('gmd:CI_OnlineResource') do
176
+ @xml.tag!('gmd:linkage') do
177
+ @xml.tag!('gmd:URL', uri)
178
+ end
182
179
  end
183
- end
184
- end
185
- end
186
- if role.nil?
187
- xml.tag!('gmd:source', {'gco:nilReason' => 'missing'})
188
- end
189
-
190
- end # gmd:MD_ExtendedElementInformation tag
191
- end # gmd:extendedElementInformation
192
- end # gmd:MD_MetadataExtensionInformation
193
- end # writeXML
194
- end # MD_MetadataExtensionInformation class
195
-
196
- end
197
- end
198
- end
180
+ end
181
+ end
182
+ end
183
+ end
184
+ @xml.tag!('gmd:role') do
185
+ codelistClass.writeXML('gmd', 'iso_role', role)
186
+ end
187
+ end
188
+ end
189
+ end
190
+ if role.nil?
191
+ @NameSpace.issueWarning(105, 'gmd:source', outContext)
192
+ end
193
+
194
+ end # gmd:MD_ExtendedElementInformation tag
195
+ end # gmd:extendedElementInformation
196
+ end # gmd:MD_MetadataExtensionInformation
197
+ end # writeXML
198
+ end # MD_MetadataExtensionInformation class
199
+
200
+ end
201
+ end
202
+ end
199
203
  end