Class: ADIWG::Mdtranslator::Writers::Iso19115_2::MD_TaxonSys

Inherits:
Object
  • Object
show all
Defined in:
lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_taxonomy.rb

Instance Method Summary collapse

Constructor Details

#initialize(xml, hResponseObj) ⇒ MD_TaxonSys

Returns a new instance of MD_TaxonSys.



30
31
32
33
34
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_taxonomy.rb', line 30

def initialize(xml, hResponseObj)
   @xml = xml
   @hResponseObj = hResponseObj
   @NameSpace = ADIWG::Mdtranslator::Writers::Iso19115_2
end

Instance Method Details

#writeXML(hSystem) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_taxonomy.rb', line 36

def writeXML(hSystem)

   # classes used
   intMetadataClass = InternalMetadata.new
   taxonomicClass = TaxonomicSystem.new(@xml, @hResponseObj)
   identifierClass = RS_Identifier.new(@xml, @hResponseObj)
   partyClass = CI_ResponsibleParty.new(@xml, @hResponseObj)
   voucherClass = MD_Vouchers.new(@xml, @hResponseObj)
   taxonClass = MD_TaxonCl.new(@xml, @hResponseObj)

   @xml.tag!('gmd:MD_TaxonSys') do

      # taxon system - classification system (required) [{TaxonomicSystem}]
      aSystems = hSystem[:taxonSystem]
      aSystems.each do |hSystem|
         @xml.tag!('gmd:classSys') do
            taxonomicClass.writeXML(hSystem)
         end
      end
      if aSystems.empty?
         @NameSpace.issueWarning(310, 'gmd:classSys')
      end

      # taxon system - general scope
      s = hSystem[:generalScope]
      unless s.nil?
         @xml.tag!('gmd:taxongen') do
            @xml.tag!('gco:CharacterString', s)
         end
      end
      if s.nil? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:taxongen')
      end

      # taxon system - identification reference [] (required) {citation}
      # convert to RS_Identifier
      aCitations = hSystem[:idReferences]
      aCitations.each do |hCitation|
         unless hCitation.empty?
            hIdentifier = intMetadataClass.newIdentifier
            hIdentifier[:identifier] = 'missing'
            hIdentifier[:citation] = hCitation
            @xml.tag!('gmd:idref') do
               identifierClass.writeXML(hIdentifier, 'taxon identification reference')
            end
         end
      end
      if aCitations.empty?
         @NameSpace.issueWarning(311, 'gmd:idref')
      end

      # taxon system - observers [] {CI_ResponsibleParty}
      aObservers = hSystem[:observers]
      aObservers.each do |hObserver|
         role = hObserver[:roleName]
         aParties = hObserver[:parties]
         aParties.each do |hParty|
            @xml.tag!('gmd:obs') do
               partyClass.writeXML(role, hParty, 'taxon observer')
            end
         end
      end
      if aObservers.empty? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:obs')
      end

      # taxon system - taxon identification procedures (required)
      s = hSystem[:idProcedure]
      if s.nil?
         @NameSpace.issueWarning(313, 'gmd:taxonpro')
      else
         @xml.tag!('gmd:taxonpro') do
            @xml.tag!('gco:CharacterString', s)
         end
      end

      # taxon system - completeness
      s = hSystem[:idCompleteness]
      unless s.nil?
         @xml.tag!('gmd:taxoncom') do
            @xml.tag!('gco:CharacterString', s)
         end
      end
      if s.nil? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:taxoncom')
      end

      # taxon system - voucher {MD_Voucher}
      aVouchers = hSystem[:vouchers]
      unless aVouchers.empty?
         unless aVouchers[0].nil?
            @xml.tag!('gmd:voucher') do
               voucherClass.writeXML(aVouchers[0])
            end
         end
      end
      if aVouchers.empty? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:voucher')
      end

      # taxon system - taxonomy classification [0] (required)
      aTaxClass = hSystem[:taxonClasses]
      unless aTaxClass.empty?
         @xml.tag!('gmd:taxonCl') do
            taxonClass.writeXML(aTaxClass[0])
         end
         if aTaxClass.length > 1
            @NameSpace.issueNotice(315, 'taxonomy')
            @NameSpace.issueNotice(316, 'taxonomy')
         end
      end
      if aTaxClass.empty?
         @NameSpace.issueWarning(314, 'gmd:taxonCl')
      end

   end # gmd:MD_TaxonSys tag
end