adiwg-mdtranslator 2.10.0 → 2.12.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -1
  3. data/adiwg-mdtranslator.gemspec +1 -1
  4. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +23 -24
  5. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_identification.rb +2 -1
  6. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_localSystem.rb +2 -1
  7. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonClass.rb +4 -2
  8. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_allocation.rb +13 -0
  9. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_contactPostprocess.rb +38 -0
  10. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_entityAttribute.rb +2 -2
  11. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_mdJson.rb +5 -0
  12. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_projectionParameters.rb +2 -1
  13. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_resourceInfo.rb +17 -6
  14. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_spatialResolution.rb +1 -2
  15. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_taxonomicClassification.rb +24 -5
  16. data/lib/adiwg/mdtranslator/version.rb +8 -1
  17. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_address.rb +10 -10
  18. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_attribute.rb +21 -16
  19. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_browse.rb +8 -7
  20. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_citation.rb +11 -11
  21. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_constraint.rb +6 -4
  22. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_contact.rb +14 -14
  23. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_dataDomain.rb +18 -18
  24. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_dateRange.rb +10 -7
  25. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_dateSingle.rb +5 -2
  26. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_description.rb +10 -4
  27. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_dictionary.rb +7 -9
  28. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_digitalForm.rb +7 -4
  29. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_distribution.rb +9 -5
  30. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_entityDetail.rb +15 -11
  31. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_entityOverview.rb +7 -4
  32. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_fgdc.rb +1 -1
  33. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_geodeticReference.rb +7 -6
  34. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_geographicResolution.rb +8 -7
  35. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_geologicAge.rb +5 -4
  36. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_geologicRange.rb +6 -5
  37. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_identification.rb +22 -18
  38. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_keyword.rb +32 -12
  39. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_lineage.rb +4 -2
  40. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_localSystem.rb +17 -6
  41. data/lib/adiwg/mdtranslator/writers/fgdc/classes/{class_mapProjection.rb → class_mapProjectionTags.rb} +33 -57
  42. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_metadataInfo.rb +9 -12
  43. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_method.rb +7 -8
  44. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_methodKeywords.rb +16 -8
  45. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_offlineOption.rb +24 -19
  46. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_onlineOption.rb +7 -4
  47. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_orderProcess.rb +8 -5
  48. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_phone.rb +6 -3
  49. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_planarGrid.rb +146 -0
  50. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_planarInfo.rb +168 -0
  51. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_planarLocal.rb +42 -0
  52. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_planarMap.rb +294 -0
  53. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_planarReference.rb +47 -328
  54. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_process.rb +6 -6
  55. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_publisher.rb +6 -4
  56. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_quality.rb +3 -2
  57. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_security.rb +5 -6
  58. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_series.rb +4 -4
  59. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_source.rb +11 -14
  60. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_spatialDomain.rb +8 -8
  61. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_spatialOrganization.rb +5 -2
  62. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_spatialReference.rb +22 -7
  63. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_status.rb +8 -7
  64. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_taxonomy.rb +4 -2
  65. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_taxonomyClassification.rb +5 -4
  66. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_taxonomyKeywords.rb +17 -10
  67. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_taxonomySystem.rb +11 -15
  68. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_timePeriod.rb +9 -7
  69. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_transferInfo.rb +4 -2
  70. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_verticalDatum.rb +11 -17
  71. data/lib/adiwg/mdtranslator/writers/fgdc/fgdc_writer.rb +53 -3
  72. data/lib/adiwg/mdtranslator/writers/fgdc/fgdc_writer_messages_eng.yml +213 -0
  73. data/lib/adiwg/mdtranslator/writers/fgdc/version.rb +3 -2
  74. data/lib/adiwg/mdtranslator/writers/html/sections/html_allocation.rb +13 -1
  75. data/lib/adiwg/mdtranslator/writers/html/sections/html_resourceInfo.rb +11 -1
  76. data/lib/adiwg/mdtranslator/writers/html/sections/html_taxonomy.rb +10 -10
  77. data/lib/adiwg/mdtranslator/writers/html/sections/html_taxonomyClass.rb +4 -4
  78. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_baseUnit.rb +27 -27
  79. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_citation.rb +5 -2
  80. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_codelist.rb +38 -38
  81. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_contact.rb +79 -79
  82. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_conventionalUnit.rb +49 -49
  83. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_date.rb +5 -2
  84. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_definitionUnit.rb +24 -24
  85. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_derivedUnit.rb +36 -36
  86. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_domain.rb +28 -21
  87. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_fcFeatureCatalogue.rb +12 -9
  88. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_featureAttribute.rb +9 -3
  89. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_featureType.rb +8 -3
  90. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_listedValue.rb +7 -4
  91. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_locale.rb +52 -49
  92. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_mdIdentifier.rb +4 -1
  93. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_multiplicity.rb +15 -0
  94. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_onlineResource.rb +79 -76
  95. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_phone.rb +67 -67
  96. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_responsibleParty.rb +117 -108
  97. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_unitsOfMeasure.rb +246 -246
  98. data/lib/adiwg/mdtranslator/writers/iso19110/iso19110_writer.rb +44 -6
  99. data/lib/adiwg/mdtranslator/writers/iso19110/iso19110_writer_messages_eng.yml +40 -0
  100. data/lib/adiwg/mdtranslator/writers/iso19110/version.rb +6 -5
  101. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_dataIdentification.rb +13 -6
  102. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_extension.rb +1 -1
  103. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_allocation.rb +3 -0
  104. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_resourceInfo.rb +5 -4
  105. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_taxonomicClassification.rb +6 -4
  106. data/lib/adiwg/mdtranslator_cli.rb +18 -8
  107. metadata +14 -8
  108. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_mapCoordinateInfo.rb +0 -167
@@ -2,97 +2,100 @@
2
2
  # 19110 writer output in XML
3
3
 
4
4
  # History:
5
- # Stan Smith 2017-01-23 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 (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-08-14 added protocol to onlineResource
12
- # Stan Smith 2014-07-08 modify require statements to function in RubyGem structure
5
+ # Stan Smith 2018-04-02 refactored error and warning messaging
6
+ # Stan Smith 2017-01-23 refactored for mdTranslator/mdJson 2.0
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 2015-06-11 change all codelists to use 'class_codelist' method
11
+ # Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
12
+ # Stan Smith 2014-08-14 added protocol to onlineResource
13
+ # Stan Smith 2014-07-08 modify require statements to function in RubyGem structure
13
14
  # Stan Smith 2013-08-14 original script.
14
15
 
16
+ require_relative '../iso19110_writer'
15
17
  require_relative 'class_codelist'
16
18
 
17
19
  module ADIWG
18
- module Mdtranslator
19
- module Writers
20
- module Iso19110
20
+ module Mdtranslator
21
+ module Writers
22
+ module Iso19110
21
23
 
22
- class CI_OnlineResource
24
+ class CI_OnlineResource
23
25
 
24
- def initialize(xml, hResponseObj)
25
- @xml = xml
26
- @hResponseObj = hResponseObj
27
- end
26
+ def initialize(xml, hResponseObj)
27
+ @xml = xml
28
+ @hResponseObj = hResponseObj
29
+ @NameSpace = ADIWG::Mdtranslator::Writers::Iso19110
30
+ end
28
31
 
29
- def writeXML(hOlResource)
32
+ def writeXML(hOlResource)
30
33
 
31
- # classes used
32
- codelistClass = MD_Codelist.new(@xml, @hResponseObj)
34
+ # classes used
35
+ codelistClass = MD_Codelist.new(@xml, @hResponseObj)
33
36
 
34
- @xml.tag! 'gmd:CI_OnlineResource' do
37
+ @xml.tag! 'gmd:CI_OnlineResource' do
35
38
 
36
- # online resource - link - required
37
- s = hOlResource[:olResURI]
38
- unless s.nil?
39
- @xml.tag!('gmd:linkage') do
40
- @xml.tag!('gmd:URL', s)
41
- end
42
- end
43
- if s.nil?
44
- @xml.tag!('gmd:linkage', {'gco:nilReason' => 'missing'})
45
- end
39
+ # online resource - link (required)
40
+ s = hOlResource[:olResURI]
41
+ unless s.nil?
42
+ @xml.tag!('gmd:linkage') do
43
+ @xml.tag!('gmd:URL', s)
44
+ end
45
+ end
46
+ if s.nil?
47
+ @NameSpace.issueError(10)
48
+ end
46
49
 
47
- # online resource - protocol
48
- s = hOlResource[:olResProtocol]
49
- unless s.nil?
50
- @xml.tag!('gmd:protocol') do
51
- @xml.tag!('gco:CharacterString', s)
52
- end
53
- end
54
- if s.nil? && @hResponseObj[:writerShowTags]
55
- @xml.tag!('gmd:protocol')
56
- end
50
+ # online resource - protocol
51
+ s = hOlResource[:olResProtocol]
52
+ unless s.nil?
53
+ @xml.tag!('gmd:protocol') do
54
+ @xml.tag!('gco:CharacterString', s)
55
+ end
56
+ end
57
+ if s.nil? && @hResponseObj[:writerShowTags]
58
+ @xml.tag!('gmd:protocol')
59
+ end
57
60
 
58
- # online resource - link name
59
- s = hOlResource[:olResName]
60
- unless s.nil?
61
- @xml.tag!('gmd:name') do
62
- @xml.tag!('gco:CharacterString', s)
63
- end
64
- end
65
- if s.nil? && @hResponseObj[:writerShowTags]
66
- @xml.tag!('gmd:name')
67
- end
61
+ # online resource - link name
62
+ s = hOlResource[:olResName]
63
+ unless s.nil?
64
+ @xml.tag!('gmd:name') do
65
+ @xml.tag!('gco:CharacterString', s)
66
+ end
67
+ end
68
+ if s.nil? && @hResponseObj[:writerShowTags]
69
+ @xml.tag!('gmd:name')
70
+ end
68
71
 
69
- # online resource - link description
70
- s = hOlResource[:olResDesc]
71
- unless s.nil?
72
- @xml.tag!('gmd:description') do
73
- @xml.tag!('gco:CharacterString', s)
74
- end
75
- end
76
- if s.nil? && @hResponseObj[:writerShowTags]
77
- @xml.tag!('gmd:description')
78
- end
72
+ # online resource - link description
73
+ s = hOlResource[:olResDesc]
74
+ unless s.nil?
75
+ @xml.tag!('gmd:description') do
76
+ @xml.tag!('gco:CharacterString', s)
77
+ end
78
+ end
79
+ if s.nil? && @hResponseObj[:writerShowTags]
80
+ @xml.tag!('gmd:description')
81
+ end
79
82
 
80
- # online resource - link function {CI_OnLineFunctionCode}
81
- s = hOlResource[:olResFunction]
82
- unless s.nil?
83
- @xml.tag!('gmd:function') do
84
- codelistClass.writeXML('gmd', 'iso_onlineFunction',s)
85
- end
86
- end
87
- if s.nil? && @hResponseObj[:writerShowTags]
88
- @xml.tag!('gmd:function')
89
- end
83
+ # online resource - link function {CI_OnLineFunctionCode}
84
+ s = hOlResource[:olResFunction]
85
+ unless s.nil?
86
+ @xml.tag!('gmd:function') do
87
+ codelistClass.writeXML('gmd', 'iso_onlineFunction', s)
88
+ end
89
+ end
90
+ if s.nil? && @hResponseObj[:writerShowTags]
91
+ @xml.tag!('gmd:function')
92
+ end
90
93
 
91
- end # CI_OnlineResource tag
92
- end # write XML
93
- end # CI_OnlineResource class
94
+ end # CI_OnlineResource tag
95
+ end # write XML
96
+ end # CI_OnlineResource class
94
97
 
95
- end
96
- end
97
- end
98
+ end
99
+ end
100
+ end
98
101
  end
@@ -2,82 +2,82 @@
2
2
  # 19110 writer output in XML
3
3
 
4
4
  # History:
5
- # Stan Smith 2017-01-23 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 (hResponseObj)
9
- # Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
10
- # Stan Smith 2014-05-14 reorganized for JSON schema 0.4.0
5
+ # Stan Smith 2017-01-23 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 (hResponseObj)
9
+ # Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
10
+ # Stan Smith 2014-05-14 reorganized for JSON schema 0.4.0
11
11
  # Stan Smith 2013-08-12 original script.
12
12
 
13
13
  module ADIWG
14
- module Mdtranslator
15
- module Writers
16
- module Iso19110
14
+ module Mdtranslator
15
+ module Writers
16
+ module Iso19110
17
17
 
18
- class CI_Telephone
18
+ class CI_Telephone
19
19
 
20
- def initialize(xml, hResponseObj)
21
- @xml = xml
22
- @hResponseObj = hResponseObj
23
- end
20
+ def initialize(xml, hResponseObj)
21
+ @xml = xml
22
+ @hResponseObj = hResponseObj
23
+ end
24
24
 
25
- def writeXML(aPhones)
25
+ def writeXML(aPhones)
26
26
 
27
- # ISO requires phones to be grouped in order (voice, fax)
28
- @xml.tag!('gmd:CI_Telephone') do
27
+ # ISO requires phones to be grouped in order (voice, fax)
28
+ @xml.tag!('gmd:CI_Telephone') do
29
29
 
30
- # voice phones
31
- voiceCount = 0
32
- aPhones.each do |hPhone|
33
- if hPhone[:phoneServiceTypes].empty?
34
- hPhone[:phoneServiceTypes] << 'voice'
35
- end
36
- if hPhone[:phoneServiceTypes].include?('voice')
37
- pName = hPhone[:phoneName]
38
- pNumber = hPhone[:phoneNumber]
39
- if pName.nil?
40
- s = pNumber
41
- else
42
- s = pName + ': ' + pNumber
43
- end
44
- @xml.tag!('gmd:voice') do
45
- @xml.tag!('gco:CharacterString', s)
46
- voiceCount += 1
47
- end
48
- end
49
- end
50
- if voiceCount == 0 && @hResponseObj[:writerShowTags]
51
- @xml.tag!('gmd:voice')
52
- end
30
+ # voice phones
31
+ voiceCount = 0
32
+ aPhones.each do |hPhone|
33
+ if hPhone[:phoneServiceTypes].empty?
34
+ hPhone[:phoneServiceTypes] << 'voice'
35
+ end
36
+ if hPhone[:phoneServiceTypes].include?('voice')
37
+ pName = hPhone[:phoneName]
38
+ pNumber = hPhone[:phoneNumber]
39
+ if pName.nil?
40
+ s = pNumber
41
+ else
42
+ s = pName + ': ' + pNumber
43
+ end
44
+ @xml.tag!('gmd:voice') do
45
+ @xml.tag!('gco:CharacterString', s)
46
+ voiceCount += 1
47
+ end
48
+ end
49
+ end
50
+ if voiceCount == 0 && @hResponseObj[:writerShowTags]
51
+ @xml.tag!('gmd:voice')
52
+ end
53
53
 
54
- # fax phones
55
- faxCount = 0
56
- aPhones.each do |hPhone|
57
- if hPhone[:phoneServiceTypes].include?('fax') ||
58
- hPhone[:phoneServiceTypes].include?('facsimile')
59
- pName = hPhone[:phoneName]
60
- pNumber = hPhone[:phoneNumber]
61
- if pName.nil?
62
- s = pNumber
63
- else
64
- s = pName + ': ' + pNumber
65
- end
66
- @xml.tag!('gmd:facsimile') do
67
- @xml.tag!('gco:CharacterString', s)
68
- faxCount += 1
69
- end
70
- end
71
- end
72
- if faxCount == 0 && @hResponseObj[:writerShowTags]
73
- @xml.tag!('gmd:facsimile')
74
- end
54
+ # fax phones
55
+ faxCount = 0
56
+ aPhones.each do |hPhone|
57
+ if hPhone[:phoneServiceTypes].include?('fax') ||
58
+ hPhone[:phoneServiceTypes].include?('facsimile')
59
+ pName = hPhone[:phoneName]
60
+ pNumber = hPhone[:phoneNumber]
61
+ if pName.nil?
62
+ s = pNumber
63
+ else
64
+ s = pName + ': ' + pNumber
65
+ end
66
+ @xml.tag!('gmd:facsimile') do
67
+ @xml.tag!('gco:CharacterString', s)
68
+ faxCount += 1
69
+ end
70
+ end
71
+ end
72
+ if faxCount == 0 && @hResponseObj[:writerShowTags]
73
+ @xml.tag!('gmd:facsimile')
74
+ end
75
75
 
76
- end # CI_Telephone tag
77
- end # write XML
78
- end # CI_Telephone class
76
+ end # CI_Telephone tag
77
+ end # write XML
78
+ end # CI_Telephone class
79
79
 
80
- end
81
- end
82
- end
80
+ end
81
+ end
82
+ end
83
83
  end
@@ -2,118 +2,127 @@
2
2
  # 19110 writer output in XML
3
3
 
4
4
  # History:
5
- # Stan Smith 2017-01-23 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 (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
12
- # Stan Smith 2014-05-14 modified for JSON schema 0.4.0
5
+ # Stan Smith 2018-04-03 refactored error and warning messaging
6
+ # Stan Smith 2017-01-23 refactored for mdTranslator/mdJson 2.0
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 2015-06-11 change all codelists to use 'class_codelist' method
11
+ # Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
12
+ # Stan Smith 2014-07-08 modify require statements to function in RubyGem structure
13
+ # Stan Smith 2014-05-14 modified for JSON schema 0.4.0
13
14
  # Stan Smith 2013-08-13 original script.
14
15
 
16
+ require_relative '../iso19110_writer'
15
17
  require_relative 'class_codelist'
16
18
  require_relative 'class_contact'
17
19
 
18
20
  module ADIWG
19
- module Mdtranslator
20
- module Writers
21
- module Iso19110
22
-
23
- class CI_ResponsibleParty
24
-
25
- def initialize(xml, hResponseObj)
26
- @xml = xml
27
- @hResponseObj = hResponseObj
28
- end
29
-
30
- def writeXML(role, hParty)
31
-
32
- # classes used
33
- codelistClass = MD_Codelist.new(@xml, @hResponseObj)
34
- contactClass = CI_Contact.new(@xml, @hResponseObj)
35
-
36
- contactId = hParty[:contactId]
37
- hContact = ADIWG::Mdtranslator::Writers::Iso19110.getContact(contactId)
38
- unless hContact.empty?
39
- isOrg = hContact[:isOrganization]
40
- @xml.tag!('gmd:CI_ResponsibleParty') do
41
-
42
- # responsible party - (if individual)
43
- unless isOrg
44
-
45
- # individual name
46
- s = hContact[:name]
47
- unless s.nil?
48
- @xml.tag!('gmd:individualName') do
49
- @xml.tag!('gco:CharacterString', s)
50
- end
51
- end
52
- if s.nil? && @hResponseObj[:writerShowTags]
53
- @xml.tag!('gmd:individualName')
54
- end
55
-
56
- # position name
57
- s = hContact[:positionName]
58
- unless s.nil?
59
- @xml.tag!('gmd:positionName') do
60
- @xml.tag!('gco:CharacterString', s)
61
- end
62
- end
63
- if s.nil? && @hResponseObj[:writerShowTags]
64
- @xml.tag!('gmd:positionName')
65
- end
66
-
67
- end
68
-
69
- # responsible party - (if organization)
70
- if isOrg
71
-
72
- # organization name
73
- s = hContact[:name]
74
- unless s.nil?
75
- @xml.tag!('gmd:organisationName') do
76
- @xml.tag!('gco:CharacterString', s)
77
- end
78
- end
79
- if s.nil? && @hResponseObj[:writerShowTags]
80
- @xml.tag!('gmd:organisationName')
81
- end
82
-
83
- end
84
-
85
- # responsible party - contact info
86
- if !hContact[:phones].empty? ||
87
- !hContact[:addresses].empty? ||
88
- !hContact[:eMailList].empty? ||
89
- !hContact[:onlineResources].empty? ||
90
- !hContact[:hoursOfService].empty? ||
91
- !hContact[:contactInstructions].nil?
92
-
93
- @xml.tag!('gmd:contactInfo') do
94
- contactClass.writeXML(hContact)
95
- end
96
- elsif @hResponseObj[:writerShowTags]
97
- @xml.tag!('gmd:contactInfo')
98
- end
99
-
100
- # responsible party - role (required)
101
- s = role
102
- unless s.nil?
103
- @xml.tag! 'gmd:role' do
104
- codelistClass.writeXML('gmd', 'iso_role', s)
105
- end
106
- end
107
- if s.nil?
108
- @xml.tag!('gmd:role', {'gco:nilReason' => 'missing'})
109
- end
110
-
111
- end# CI_ResponsibleParty tag
112
- end # valid contact returned
113
- end # write XML
114
- end # CI_ResponsibleParty class
115
-
116
- end
117
- end
118
- end
21
+ module Mdtranslator
22
+ module Writers
23
+ module Iso19110
24
+
25
+ class CI_ResponsibleParty
26
+
27
+ def initialize(xml, hResponseObj)
28
+ @xml = xml
29
+ @hResponseObj = hResponseObj
30
+ @NameSpace = ADIWG::Mdtranslator::Writers::Iso19110
31
+ end
32
+
33
+ def writeXML(role, hParty)
34
+
35
+ # classes used
36
+ codelistClass = MD_Codelist.new(@xml, @hResponseObj)
37
+ contactClass = CI_Contact.new(@xml, @hResponseObj)
38
+
39
+ contactId = hParty[:contactId]
40
+ hContact = ADIWG::Mdtranslator::Writers::Iso19110.getContact(contactId)
41
+ unless hContact.empty?
42
+ isOrg = hContact[:isOrganization]
43
+ @xml.tag!('gmd:CI_ResponsibleParty') do
44
+
45
+ # ISO19110 follows ISO19115-2 rules and requires either an individual
46
+ # or organization name and allows for both. Since mdJson 2+ patterns
47
+ # after ISO19115-3 only one name is maintained. So individual name
48
+ # becomes required for individual and organization name for organization.
49
+
50
+ # responsible party - (if individual)
51
+ unless isOrg
52
+
53
+ # individual name (required)
54
+ s = hContact[:name]
55
+ unless s.nil?
56
+ @xml.tag!('gmd:individualName') do
57
+ @xml.tag!('gco:CharacterString', s)
58
+ end
59
+ end
60
+ if s.nil?
61
+ @NameSpace.issueWarning(22, 'gmd:individualName')
62
+ end
63
+
64
+ # position name
65
+ s = hContact[:positionName]
66
+ unless s.nil?
67
+ @xml.tag!('gmd:positionName') do
68
+ @xml.tag!('gco:CharacterString', s)
69
+ end
70
+ end
71
+ if s.nil? && @hResponseObj[:writerShowTags]
72
+ @xml.tag!('gmd:positionName')
73
+ end
74
+
75
+ end
76
+
77
+ # responsible party - (if organization)
78
+ if isOrg
79
+
80
+ # organization name (required)
81
+ s = hContact[:name]
82
+ unless s.nil?
83
+ @xml.tag!('gmd:organisationName') do
84
+ @xml.tag!('gco:CharacterString', s)
85
+ end
86
+ end
87
+ if s.nil?
88
+ @NameSpace.issueWarning(21, 'gmd:organisationName')
89
+ end
90
+
91
+ end
92
+
93
+ # responsible party - contact info
94
+ haveInfo = false
95
+ haveInfo = true unless hContact[:phones].empty?
96
+ haveInfo = true unless hContact[:addresses].empty?
97
+ haveInfo = true unless hContact[:eMailList].empty?
98
+ haveInfo = true unless hContact[:onlineResources].empty?
99
+ haveInfo = true unless hContact[:hoursOfService].empty?
100
+ haveInfo = true unless hContact[:contactInstructions].nil?
101
+ if haveInfo
102
+ @xml.tag!('gmd:contactInfo') do
103
+ contactClass.writeXML(hContact)
104
+ end
105
+ elsif @hResponseObj[:writerShowTags]
106
+ @xml.tag!('gmd:contactInfo')
107
+ end
108
+
109
+ # responsible party - role (required)
110
+ s = role
111
+ unless s.nil?
112
+ @xml.tag! 'gmd:role' do
113
+ codelistClass.writeXML('gmd', 'iso_role', s)
114
+ end
115
+ end
116
+ if s.nil?
117
+ @NameSpace.issueWarning(20, 'gmd:role')
118
+ end
119
+
120
+ end # CI_ResponsibleParty tag
121
+ end # valid contact returned
122
+ end # write XML
123
+ end # CI_ResponsibleParty class
124
+
125
+ end
126
+ end
127
+ end
119
128
  end