adiwg-mdtranslator 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +51 -1
  3. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +33 -2
  4. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_attribute.rb +68 -35
  5. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_codeSet.rb +66 -0
  6. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entity.rb +7 -1
  7. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entityOverview.rb +10 -1
  8. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_enumerated.rb +38 -19
  9. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_range.rb +68 -19
  10. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_transferInfo.rb +3 -0
  11. data/lib/adiwg/mdtranslator/readers/mdJson/mdJson_reader.rb +4 -2
  12. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_domain.rb +87 -79
  13. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_entity.rb +150 -115
  14. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_entityAttribute.rb +184 -113
  15. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_valueRange.rb +56 -0
  16. data/lib/adiwg/mdtranslator/version.rb +7 -1
  17. data/lib/adiwg/mdtranslator/writers/html/sections/html_body.rb +3 -3
  18. data/lib/adiwg/mdtranslator/writers/html/sections/html_dataDictionary.rb +6 -6
  19. data/lib/adiwg/mdtranslator/writers/html/sections/html_domain.rb +74 -38
  20. data/lib/adiwg/mdtranslator/writers/html/sections/html_ellipsoidParameters.rb +68 -0
  21. data/lib/adiwg/mdtranslator/writers/html/sections/html_entity.rb +130 -76
  22. data/lib/adiwg/mdtranslator/writers/html/sections/html_entityAttribute.rb +78 -0
  23. data/lib/adiwg/mdtranslator/writers/html/sections/html_identifier.rb +1 -1
  24. data/lib/adiwg/mdtranslator/writers/html/sections/html_obliqueLinePoint.rb +37 -0
  25. data/lib/adiwg/mdtranslator/writers/html/sections/html_projectionParameters.rb +229 -0
  26. data/lib/adiwg/mdtranslator/writers/html/sections/html_referenceSystemParameters.rb +65 -0
  27. data/lib/adiwg/mdtranslator/writers/html/sections/html_spatialReference.rb +19 -1
  28. data/lib/adiwg/mdtranslator/writers/html/sections/html_verticalDatumParameters.rb +69 -0
  29. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_address.rb +103 -103
  30. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_citation.rb +185 -0
  31. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_date.rb +60 -0
  32. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_definitionReference.rb +45 -0
  33. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_domain.rb +107 -0
  34. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_fcFeatureCatalogue.rb +187 -187
  35. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_featureAttribute.rb +123 -117
  36. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_featureType.rb +155 -141
  37. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_gcoDateTime.rb +48 -0
  38. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_listedValue.rb +54 -55
  39. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_mdIdentifier.rb +56 -0
  40. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_series.rb +63 -0
  41. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_attributeGroup.rb +51 -50
  42. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_citation.rb +181 -180
  43. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_crs.rb +96 -0
  44. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_ellipsoidParameters.rb +62 -0
  45. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_keyword.rb +54 -54
  46. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_miMetadata.rb +301 -298
  47. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_obliqueLinePoint.rb +53 -0
  48. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_projectionParameters.rb +229 -0
  49. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_referenceSystem.rb +49 -32
  50. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_domain.rb +5 -2
  51. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_entity.rb +7 -1
  52. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_entityAttribute.rb +18 -2
  53. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_valueRange.rb +28 -0
  54. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_budget.rb +33 -13
  55. metadata +22 -4
  56. data/lib/adiwg/mdtranslator/readers/mdJson/version.rb +0 -16
@@ -0,0 +1,48 @@
1
+ # ISO <<Class>> Date, DateTime
2
+ # 19115-2 writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2017-11-02 original script
6
+
7
+ module ADIWG
8
+ module Mdtranslator
9
+ module Writers
10
+ module Iso19110
11
+
12
+ class GcoDateTime
13
+
14
+ def initialize(xml, hResponseObj)
15
+ @xml = xml
16
+ @hResponseObj = hResponseObj
17
+ end
18
+
19
+ def writeXML(hDate)
20
+
21
+ date = hDate[:date]
22
+ dateRes = hDate[:dateResolution]
23
+
24
+ # date - date (required)
25
+ unless date.nil?
26
+ case dateRes
27
+ when 'Y', 'YM', 'YMD'
28
+ dateStr = AdiwgDateTimeFun.stringDateFromDateTime(date, dateRes)
29
+ @xml.tag!('gco:Date', dateStr)
30
+ when 'YMDh', 'YMDhm', 'YMDhms'
31
+ dateStr = AdiwgDateTimeFun.stringDateTimeFromDateTime(date, 'YMDhms')
32
+ @xml.tag!('gco:DateTime', dateStr)
33
+ when 'YMDhZ', 'YMDhmZ', 'YMDhmsZ'
34
+ dateStr = AdiwgDateTimeFun.stringDateTimeFromDateTime(date, 'YMDhmsZ')
35
+ @xml.tag!('gco:DateTime', dateStr)
36
+ else
37
+ dateStr = AdiwgDateTimeFun.stringDateTimeFromDateTime(date, dateRes)
38
+ @xml.tag!('gco:DateTime', dateStr)
39
+ end
40
+ end
41
+
42
+ end # write XML
43
+ end # Date class
44
+
45
+ end
46
+ end
47
+ end
48
+ end
@@ -3,70 +3,69 @@
3
3
  # to define the domain of an attribute
4
4
 
5
5
  # History:
6
- # Stan Smith 2017-02-03 refactored for mdJson/mdTranslator 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 (responseObj)
10
- # Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
11
- # Stan Smith 2014-12-02 original script.
6
+ # Stan Smith 2017-02-03 refactored for mdJson/mdTranslator 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 (responseObj)
10
+ # Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
11
+ # Stan Smith 2014-12-02 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 FC_ListedValue
18
+ class FC_ListedValue
19
19
 
20
- def initialize(xml, responseObj)
21
- @xml = xml
22
- @hResponseObj = responseObj
23
- end
20
+ def initialize(xml, responseObj)
21
+ @xml = xml
22
+ @hResponseObj = responseObj
23
+ end
24
24
 
25
- def writeXML(hItem)
25
+ def writeXML(hItem)
26
26
 
27
- @xml.tag!('gfc:FC_ListedValue') do
27
+ @xml.tag!('gfc:FC_ListedValue') do
28
28
 
29
- # listed value - label (required)
30
- # used for domain item name
31
- s = hItem[:itemName]
32
- unless s.nil?
33
- @xml.tag!('gfc:label') do
34
- @xml.tag!('gco:CharacterString', s)
35
- end
36
- end
37
- if s.nil?
38
- @xml.tag!('gfc:label', {'gco:nilReason' => 'missing'})
39
- end
29
+ # listed value - label (required)
30
+ # used for domain item name
31
+ s = hItem[:itemName]
32
+ unless s.nil?
33
+ @xml.tag!('gfc:label') do
34
+ @xml.tag!('gco:CharacterString', s)
35
+ end
36
+ end
37
+ if s.nil?
38
+ @xml.tag!('gfc:label', {'gco:nilReason' => 'missing'})
39
+ end
40
40
 
41
- # listed value - code
42
- # used for domain item value
43
- s = hItem[:itemValue]
44
- unless s.nil?
45
- @xml.tag!('gfc:code') do
46
- @xml.tag!('gco:CharacterString', s)
47
- end
48
- end
49
- if s.nil? && @hResponseObj[:writerShowTags]
50
- @xml.tag!('gfc:code')
51
- end
41
+ # listed value - code
42
+ # used for domain item value
43
+ s = hItem[:itemValue]
44
+ unless s.nil?
45
+ @xml.tag!('gfc:code') do
46
+ @xml.tag!('gco:CharacterString', s)
47
+ end
48
+ end
49
+ if s.nil? && @hResponseObj[:writerShowTags]
50
+ @xml.tag!('gfc:code')
51
+ end
52
52
 
53
- # listed value - code
54
- # used for domain item value
55
- s = hItem[:itemDefinition]
56
- unless s.nil?
57
- @xml.tag!('gfc:definition') do
58
- @xml.tag!('gco:CharacterString', s)
59
- end
60
- end
61
- if s.nil? && @hResponseObj[:writerShowTags]
62
- @xml.tag!('gfc:definition')
63
- end
53
+ # listed value - definition
54
+ s = hItem[:itemDefinition]
55
+ unless s.nil?
56
+ @xml.tag!('gfc:definition') do
57
+ @xml.tag!('gco:CharacterString', s)
58
+ end
59
+ end
60
+ if s.nil? && @hResponseObj[:writerShowTags]
61
+ @xml.tag!('gfc:definition')
62
+ end
64
63
 
65
- end # gfc:FC_ListedValue tag
66
- end # writeXML
67
- end # FC_ListedValue class
64
+ end # gfc:FC_ListedValue tag
65
+ end # writeXML
66
+ end # FC_ListedValue class
68
67
 
69
- end
70
- end
71
- end
68
+ end
69
+ end
70
+ end
72
71
  end
@@ -0,0 +1,56 @@
1
+ # ISO <<Class>> MD_Identifier
2
+ # 19115-2 output for ISO 19115-2 XML
3
+
4
+ # History:
5
+ # Stan Smith 2017-11-02 original script
6
+
7
+ require_relative 'class_citation'
8
+
9
+ module ADIWG
10
+ module Mdtranslator
11
+ module Writers
12
+ module Iso19110
13
+
14
+ class MD_Identifier
15
+
16
+ def initialize(xml, hResponseObj)
17
+ @xml = xml
18
+ @hResponseObj = hResponseObj
19
+ end
20
+
21
+ def writeXML(hIdentifier)
22
+
23
+ # classes used in MD_Metadata
24
+ citationClass = CI_Citation.new(@xml, @hResponseObj)
25
+
26
+ @xml.tag!('gmd:MD_Identifier') do
27
+
28
+ # identifier - authority
29
+ hCitation = hIdentifier[:citation]
30
+ unless hCitation.empty?
31
+ @xml.tag!('gmd:authority') do
32
+ citationClass.writeXML(hCitation)
33
+ end
34
+ end
35
+ if hCitation.empty? && @hResponseObj[:writerShowTags]
36
+ @xml.tag!('gmd:authority')
37
+ end
38
+
39
+ # identifier - code (required)
40
+ s = hIdentifier[:identifier]
41
+ if s.nil?
42
+ @xml.tag!('gmd:code', {'gco:nilReason' => 'missing'})
43
+ else
44
+ @xml.tag!('gmd:code') do
45
+ @xml.tag!('gco:CharacterString', s)
46
+ end
47
+ end
48
+
49
+ end # MD_Identifier tag
50
+ end # writeXML
51
+ end # MD_Identifier class
52
+
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,63 @@
1
+ # ISO <<Class>> CI_Series
2
+ # 19115-2 writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2017-11-02 original script
6
+
7
+ module ADIWG
8
+ module Mdtranslator
9
+ module Writers
10
+ module Iso19110
11
+
12
+ class CI_Series
13
+
14
+ def initialize(xml, hResponseObj)
15
+ @xml = xml
16
+ @hResponseObj = hResponseObj
17
+ end
18
+
19
+ def writeXML(hSeries)
20
+
21
+ @xml.tag!('gmd:CI_Series') do
22
+
23
+ # series - name
24
+ s = hSeries[:seriesName]
25
+ unless s.nil?
26
+ @xml.tag!('gmd:name') do
27
+ @xml.tag!('gco:CharacterString', s)
28
+ end
29
+ end
30
+ if s.nil? && @hResponseObj[:writerShowTags]
31
+ @xml.tag!('gmd:name')
32
+ end
33
+
34
+ # series - issue identification
35
+ s = hSeries[:seriesIssue]
36
+ unless s.nil?
37
+ @xml.tag!('gmd:issueIdentification') do
38
+ @xml.tag!('gco:CharacterString', s)
39
+ end
40
+ end
41
+ if s.nil? && @hResponseObj[:writerShowTags]
42
+ @xml.tag!('gmd:issueIdentification')
43
+ end
44
+
45
+ # series - page
46
+ s = hSeries[:issuePage]
47
+ unless s.nil?
48
+ @xml.tag!('gmd:page') do
49
+ @xml.tag!('gco:CharacterString', s)
50
+ end
51
+ end
52
+ if s.nil? && @hResponseObj[:writerShowTags]
53
+ @xml.tag!('gmd:page')
54
+ end
55
+
56
+ end # CI_Series tag
57
+ end # writeXML
58
+ end # CI_Series class
59
+
60
+ end
61
+ end
62
+ end
63
+ end
@@ -2,69 +2,70 @@
2
2
  # 19115-2 writer output in XML
3
3
 
4
4
  # History:
5
- # Stan Smith 2016-11-29 original script.
5
+ # Stan Smith 2016-11-29 original script.
6
6
 
7
7
  require_relative 'class_rangeDimension'
8
8
  require_relative 'class_mdBand'
9
9
  require_relative 'class_miBand'
10
10
 
11
11
  module ADIWG
12
- module Mdtranslator
13
- module Writers
14
- module Iso19115_2
12
+ module Mdtranslator
13
+ module Writers
14
+ module Iso19115_2
15
15
 
16
- class AttributeGroup
16
+ class AttributeGroup
17
17
 
18
- def initialize(xml, hResponseObj)
19
- @xml = xml
20
- @hResponseObj = hResponseObj
21
- end
18
+ def initialize(xml, hResponseObj)
19
+ @xml = xml
20
+ @hResponseObj = hResponseObj
21
+ end
22
22
 
23
- def writeXML(hAttribute)
23
+ def writeXML(hAttribute)
24
24
 
25
- # classes used
26
- rangeClass = MD_RangeDimension.new(@xml, @hResponseObj)
27
- mdBandClass = MD_Band.new(@xml, @hResponseObj)
28
- miBandClass = MI_Band.new(@xml, @hResponseObj)
25
+ # classes used
26
+ rangeClass = MD_RangeDimension.new(@xml, @hResponseObj)
27
+ mdBandClass = MD_Band.new(@xml, @hResponseObj)
28
+ miBandClass = MI_Band.new(@xml, @hResponseObj)
29
29
 
30
- # determine attribute classes to write
31
- if !(hAttribute[:bandBoundaryDefinition].nil? &&
32
- hAttribute[:nominalSpatialResolution].nil? &&
33
- hAttribute[:transferFunctionType].nil? &&
34
- hAttribute[:transmittedPolarization].nil? &&
35
- hAttribute[:detectedPolarization].nil?)
36
- dimClass = 'gmi:MI_Band'
37
- elsif !(hAttribute[:maxValue].nil? &&
38
- hAttribute[:minValue].nil? &&
39
- hAttribute[:units].nil? &&
40
- hAttribute[:peakResponse].nil? &&
41
- hAttribute[:bitsPerValue].nil? &&
42
- hAttribute[:toneGradations].nil? &&
43
- hAttribute[:scaleFactor].nil? &&
44
- hAttribute[:offset].nil?)
45
- dimClass = 'gmd:MD_Band'
46
- else
47
- dimClass = 'gmd:MD_RangeDimension'
48
- end
30
+ # determine attribute classes to write
31
+ if !(hAttribute[:bandBoundaryDefinition].nil? &&
32
+ hAttribute[:nominalSpatialResolution].nil? &&
33
+ hAttribute[:transferFunctionType].nil? &&
34
+ hAttribute[:transmittedPolarization].nil? &&
35
+ hAttribute[:detectedPolarization].nil?)
36
+ dimClass = 'gmi:MI_Band'
37
+ elsif !(hAttribute[:maxValue].nil? &&
38
+ hAttribute[:minValue].nil? &&
39
+ hAttribute[:units].nil? &&
40
+ hAttribute[:peakResponse].nil? &&
41
+ hAttribute[:bitsPerValue].nil? &&
42
+ hAttribute[:toneGradations].nil? &&
43
+ hAttribute[:scaleFactor].nil? &&
44
+ hAttribute[:offset].nil?)
45
+ dimClass = 'gmd:MD_Band'
46
+ else
47
+ dimClass = 'gmd:MD_RangeDimension'
48
+ end
49
49
 
50
- @xml.tag!(dimClass) do
50
+ @xml.tag!(dimClass) do
51
51
 
52
- if dimClass == 'gmi:MI_Band'
53
- rangeClass.writeXML(hAttribute)
54
- mdBandClass.writeXML(hAttribute)
55
- miBandClass.writeXML(hAttribute)
56
- elsif dimClass =='gmd:MD_Band'
57
- rangeClass.writeXML(hAttribute)
58
- mdBandClass.writeXML(hAttribute)
59
- else
60
- rangeClass.writeXML(hAttribute)
61
- end
52
+ if dimClass == 'gmi:MI_Band'
53
+ rangeClass.writeXML(hAttribute)
54
+ mdBandClass.writeXML(hAttribute)
55
+ miBandClass.writeXML(hAttribute)
56
+ elsif dimClass =='gmd:MD_Band'
57
+ rangeClass.writeXML(hAttribute)
58
+ mdBandClass.writeXML(hAttribute)
59
+ else
60
+ rangeClass.writeXML(hAttribute)
61
+ end
62
62
 
63
- end # dimClass tag
64
- end # writeXML
65
- end # AttributeGroup class
63
+ end # dimClass tag
66
64
 
67
- end
68
- end
69
- end
65
+ end # writeXML
66
+ end # AttributeGroup class
67
+
68
+ end
69
+ end
70
+ end
70
71
  end
@@ -2,19 +2,19 @@
2
2
  # 19115-2 writer output in XML
3
3
 
4
4
  # History:
5
- # Stan Smith 2016-11-29 refactored for mdTranslator/mdJson 2.0
6
- # Stan Smith 2015-08-28 added alternate title
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-15 refactored to handle namespacing readers and writers
12
- # Stan Smith 2014-08-18 process isbn and ISSN from identifier section per 0.6.0
13
- # Stan Smith 2014-08-18 modify identifier section for schema 0.6.0
14
- # Stan Smith 2014-07-08 modify require statements to function in RubyGem structure
15
- # Stan Smith 2014-05-28 modified for json schema 0.5.0
16
- # Stan Smith 2014-05-16 added MD_Identifier
17
- # Stan Smith 2014-05-16 modified for JSON schema 0.4.0
5
+ # Stan Smith 2016-11-29 refactored for mdTranslator/mdJson 2.0
6
+ # Stan Smith 2015-08-28 added alternate title
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-15 refactored to handle namespacing readers and writers
12
+ # Stan Smith 2014-08-18 process isbn and ISSN from identifier section per 0.6.0
13
+ # Stan Smith 2014-08-18 modify identifier section for schema 0.6.0
14
+ # Stan Smith 2014-07-08 modify require statements to function in RubyGem structure
15
+ # Stan Smith 2014-05-28 modified for json schema 0.5.0
16
+ # Stan Smith 2014-05-16 added MD_Identifier
17
+ # Stan Smith 2014-05-16 modified for JSON schema 0.4.0
18
18
  # Stan Smith 2013-12-30 added ISBN, ISSN
19
19
  # Stan Smith 2013-08-26 original script
20
20
 
@@ -25,171 +25,172 @@ require_relative 'class_mdIdentifier'
25
25
  require_relative 'class_series'
26
26
 
27
27
  module ADIWG
28
- module Mdtranslator
29
- module Writers
30
- module Iso19115_2
31
-
32
- class CI_Citation
33
-
34
- def initialize(xml, hResponseObj)
35
- @xml = xml
36
- @hResponseObj = hResponseObj
37
- end
38
-
39
- def writeXML(hCitation)
40
-
41
- # classes used
42
- codelistClass = MD_Codelist.new(@xml, @hResponseObj)
43
- rPartyClass = CI_ResponsibleParty.new(@xml, @hResponseObj)
44
- dateClass = CI_Date.new(@xml, @hResponseObj)
45
- idClass = MD_Identifier.new(@xml, @hResponseObj)
46
- seriesClass = CI_Series.new(@xml, @hResponseObj)
47
-
48
- @xml.tag!('gmd:CI_Citation') do
49
-
50
- # citation - title (required)
51
- s = hCitation[:title]
52
- if s.nil?
53
- @xml.tag!('gmd:title', {'gco:nilReason' => 'missing'})
54
- else
55
- @xml.tag!('gmd:title') do
56
- @xml.tag!('gco:CharacterString', s)
57
- end
58
- end
59
-
60
- # citation - alternate title []
61
- aTitles = hCitation[:alternateTitles]
62
- aTitles.each do |title|
63
- @xml.tag!('gmd:alternateTitle') do
64
- @xml.tag!('gco:CharacterString', title)
65
- end
66
- end
67
- if aTitles.empty? && @hResponseObj[:writerShowTags]
68
- @xml.tag!('gmd:alternateTitle')
69
- end
70
-
71
- # citation - date [] (required)
72
- aDate = hCitation[:dates]
73
- aDate.each do |hDate|
74
- @xml.tag!('gmd:date') do
75
- dateClass.writeXML(hDate)
76
- end
77
- end
78
- if aDate.empty?
79
- @xml.tag!('gmd:date', {'gco:nilReason' => 'missing'})
80
- end
81
-
82
- # citation - edition
83
- s = hCitation[:edition]
84
- unless s.nil?
85
- @xml.tag!('gmd:edition') do
86
- @xml.tag!('gco:CharacterString', s)
87
- end
88
- end
89
- if s.nil? && @hResponseObj[:writerShowTags]
90
- @xml.tag!('gmd:edition')
91
- end
92
-
93
- # citation - resource identifier []
94
- # do not process ISBN and ISSN as MD_identifier(s)
95
- # ... these are written separately in ISO 19115-x
96
- isbn = ''
97
- issn = ''
98
- aIds = hCitation[:identifiers]
99
- aIds.each do |hIdentifier|
100
- unless hIdentifier[:namespace].nil?
101
- if hIdentifier[:namespace].downcase == 'isbn'
102
- isbn = hIdentifier[:identifier]
103
- elsif hIdentifier[:namespace].downcase == 'issn'
104
- issn = hIdentifier[:identifier]
105
- end
106
- end
107
- if issn == '' && isbn == ''
108
- @xml.tag!('gmd:identifier') do
109
- idClass.writeXML(hIdentifier)
110
- end
111
- end
112
- end
113
- if aIds.empty? && @hResponseObj[:writerShowTags]
114
- @xml.tag!('gmd:identifier')
115
- end
116
-
117
- # citation - cited responsible party [{CI_ResponsibleParty}]
118
- # contacts are grouped by role in the internal object
119
- # output a separate <gmd:contact> for each role:contact pairing
120
- aRParties = hCitation[:responsibleParties]
121
- aRParties.each do |hRParty|
122
- role = hRParty[:roleName]
123
- aParties = hRParty[:parties]
124
- aParties.each do |hParty|
125
- @xml.tag!('gmd:citedResponsibleParty') do
126
- rPartyClass.writeXML(role, hParty)
127
- end
128
- end
129
- end
130
- if aRParties.empty? && @hResponseObj[:writerShowTags]
131
- @xml.tag!('gmd:citedResponsibleParty')
132
- end
133
-
134
- # citation - presentation forms [{CI_PresentationFormCode}]
135
- aPresForms = hCitation[:presentationForms]
136
- aPresForms.each do |presForm|
137
- @xml.tag!('gmd:presentationForm') do
138
- codelistClass.writeXML('gmd', 'iso_presentationForm', presForm)
139
- end
140
- end
141
- if aPresForms.empty? && @hResponseObj[:writerShowTags]
142
- @xml.tag!('gmd:presentationForm')
143
- end
144
-
145
- # citation - series {CI_Series}
146
- hSeries = hCitation[:series]
147
- unless hSeries.empty?
148
- @xml.tag!('gmd:series') do
149
- seriesClass.writeXML(hSeries)
150
- end
151
- end
152
- if hSeries.empty? && @hResponseObj[:writerShowTags]
153
- @xml.tag!('gmd:series')
154
- end
155
-
156
- # citation - other citation details
157
- aOther = hCitation[:otherDetails]
158
- unless aOther.empty?
159
- other = aOther[0]
160
- @xml.tag!('gmd:otherCitationDetails') do
161
- @xml.tag!('gco:CharacterString', other)
162
- end
163
- end
164
- if aOther.empty? && @hResponseObj[:writerShowTags]
165
- @xml.tag!('gmd:otherCitationDetails')
166
- end
167
-
168
- # citation - ISBN
169
- unless isbn == ''
170
- @xml.tag!('gmd:ISBN') do
171
- @xml.tag!('gco:CharacterString', isbn)
172
- end
173
- end
174
- if isbn == '' && @hResponseObj[:writerShowTags]
175
- @xml.tag!('gmd:ISBN')
176
- end
177
-
178
- # citation - ISSN
179
- unless issn == ''
180
- @xml.tag!('gmd:ISSN') do
181
- @xml.tag!('gco:CharacterString', issn)
182
- end
183
- end
184
- if issn == '' && @hResponseObj[:writerShowTags]
185
- @xml.tag!('gmd:ISSN')
186
- end
187
-
188
- end # CI_Citation tag
189
- end # writeXML
190
- end # CI_Citation class
191
-
192
- end
193
- end
194
- end
28
+ module Mdtranslator
29
+ module Writers
30
+ module Iso19115_2
31
+
32
+ class CI_Citation
33
+
34
+ def initialize(xml, hResponseObj)
35
+ @xml = xml
36
+ @hResponseObj = hResponseObj
37
+ end
38
+
39
+ def writeXML(hCitation)
40
+
41
+ # classes used
42
+ codelistClass = MD_Codelist.new(@xml, @hResponseObj)
43
+ rPartyClass = CI_ResponsibleParty.new(@xml, @hResponseObj)
44
+ dateClass = CI_Date.new(@xml, @hResponseObj)
45
+ idClass = MD_Identifier.new(@xml, @hResponseObj)
46
+ seriesClass = CI_Series.new(@xml, @hResponseObj)
47
+
48
+ @xml.tag!('gmd:CI_Citation') do
49
+
50
+ # citation - title (required)
51
+ s = hCitation[:title]
52
+ if s.nil?
53
+ @xml.tag!('gmd:title', {'gco:nilReason' => 'missing'})
54
+ else
55
+ @xml.tag!('gmd:title') do
56
+ @xml.tag!('gco:CharacterString', s)
57
+ end
58
+ end
59
+
60
+ # citation - alternate title []
61
+ aTitles = hCitation[:alternateTitles]
62
+ aTitles.each do |title|
63
+ @xml.tag!('gmd:alternateTitle') do
64
+ @xml.tag!('gco:CharacterString', title)
65
+ end
66
+ end
67
+ if aTitles.empty? && @hResponseObj[:writerShowTags]
68
+ @xml.tag!('gmd:alternateTitle')
69
+ end
70
+
71
+ # citation - date [] (required)
72
+ aDate = hCitation[:dates]
73
+ aDate.each do |hDate|
74
+ @xml.tag!('gmd:date') do
75
+ dateClass.writeXML(hDate)
76
+ end
77
+ end
78
+ if aDate.empty?
79
+ @xml.tag!('gmd:date', {'gco:nilReason' => 'missing'})
80
+ end
81
+
82
+ # citation - edition
83
+ s = hCitation[:edition]
84
+ unless s.nil?
85
+ @xml.tag!('gmd:edition') do
86
+ @xml.tag!('gco:CharacterString', s)
87
+ end
88
+ end
89
+ if s.nil? && @hResponseObj[:writerShowTags]
90
+ @xml.tag!('gmd:edition')
91
+ end
92
+
93
+ # citation - resource identifier []
94
+ # do not process ISBN and ISSN as MD_identifier(s)
95
+ # ... these are written separately in ISO 19115-x
96
+ isbn = ''
97
+ issn = ''
98
+ aIds = hCitation[:identifiers]
99
+ aIds.each do |hIdentifier|
100
+ unless hIdentifier[:namespace].nil?
101
+ if hIdentifier[:namespace].downcase == 'isbn'
102
+ isbn = hIdentifier[:identifier]
103
+ elsif hIdentifier[:namespace].downcase == 'issn'
104
+ issn = hIdentifier[:identifier]
105
+ end
106
+ end
107
+ if issn == '' && isbn == ''
108
+ @xml.tag!('gmd:identifier') do
109
+ idClass.writeXML(hIdentifier)
110
+ end
111
+ end
112
+ end
113
+ if aIds.empty? && @hResponseObj[:writerShowTags]
114
+ @xml.tag!('gmd:identifier')
115
+ end
116
+
117
+ # citation - cited responsible party [{CI_ResponsibleParty}]
118
+ # contacts are grouped by role in the internal object
119
+ # output a separate <gmd:contact> for each role:contact pairing
120
+ aRParties = hCitation[:responsibleParties]
121
+ aRParties.each do |hRParty|
122
+ role = hRParty[:roleName]
123
+ aParties = hRParty[:parties]
124
+ aParties.each do |hParty|
125
+ @xml.tag!('gmd:citedResponsibleParty') do
126
+ rPartyClass.writeXML(role, hParty)
127
+ end
128
+ end
129
+ end
130
+ if aRParties.empty? && @hResponseObj[:writerShowTags]
131
+ @xml.tag!('gmd:citedResponsibleParty')
132
+ end
133
+
134
+ # citation - presentation forms [{CI_PresentationFormCode}]
135
+ aPresForms = hCitation[:presentationForms]
136
+ aPresForms.each do |presForm|
137
+ @xml.tag!('gmd:presentationForm') do
138
+ codelistClass.writeXML('gmd', 'iso_presentationForm', presForm)
139
+ end
140
+ end
141
+ if aPresForms.empty? && @hResponseObj[:writerShowTags]
142
+ @xml.tag!('gmd:presentationForm')
143
+ end
144
+
145
+ # citation - series {CI_Series}
146
+ hSeries = hCitation[:series]
147
+ unless hSeries.empty?
148
+ @xml.tag!('gmd:series') do
149
+ seriesClass.writeXML(hSeries)
150
+ end
151
+ end
152
+ if hSeries.empty? && @hResponseObj[:writerShowTags]
153
+ @xml.tag!('gmd:series')
154
+ end
155
+
156
+ # citation - other citation details
157
+ aOther = hCitation[:otherDetails]
158
+ unless aOther.empty?
159
+ other = aOther[0]
160
+ @xml.tag!('gmd:otherCitationDetails') do
161
+ @xml.tag!('gco:CharacterString', other)
162
+ end
163
+ end
164
+ if aOther.empty? && @hResponseObj[:writerShowTags]
165
+ @xml.tag!('gmd:otherCitationDetails')
166
+ end
167
+
168
+ # citation - ISBN
169
+ unless isbn == ''
170
+ @xml.tag!('gmd:ISBN') do
171
+ @xml.tag!('gco:CharacterString', isbn)
172
+ end
173
+ end
174
+ if isbn == '' && @hResponseObj[:writerShowTags]
175
+ @xml.tag!('gmd:ISBN')
176
+ end
177
+
178
+ # citation - ISSN
179
+ unless issn == ''
180
+ @xml.tag!('gmd:ISSN') do
181
+ @xml.tag!('gco:CharacterString', issn)
182
+ end
183
+ end
184
+ if issn == '' && @hResponseObj[:writerShowTags]
185
+ @xml.tag!('gmd:ISSN')
186
+ end
187
+
188
+ end # CI_Citation tag
189
+
190
+ end # writeXML
191
+ end # CI_Citation class
192
+
193
+ end
194
+ end
195
+ end
195
196
  end