class ADIWG::Mdtranslator::Writers::Iso19115_2::MD_TaxonSys

Public Class Methods

new(xml, hResponseObj) click to toggle source
# 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

Public Instance Methods

writeXML(hSystem) click to toggle source
# 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