Class: ADIWG::Mdtranslator::Writers::Fgdc::Taxonomy

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

Instance Method Summary collapse

Constructor Details

#initialize(xml, hResponseObj) ⇒ Taxonomy

Returns a new instance of Taxonomy.



21
22
23
24
25
# File 'lib/adiwg/mdtranslator/writers/fgdc/classes/class_taxonomy.rb', line 21

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

Instance Method Details

#writeXML(hTaxonomy, aKeywords) ⇒ Object



27
28
29
30
31
32
33
34
35
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
# File 'lib/adiwg/mdtranslator/writers/fgdc/classes/class_taxonomy.rb', line 27

def writeXML(hTaxonomy, aKeywords)

   # classes used
   keywordClass = TaxonomyKeyword.new(@xml, @hResponseObj)
   taxSystemClass = TaxonomySystem.new(@xml, @hResponseObj)
   taxClassClass = TaxonomyClassification.new(@xml, @hResponseObj)

   # taxonomy bio (keywtax) - taxonomic keywords (required)
   unless aKeywords.empty?
      keywordClass.writeXML(aKeywords)
   end
   if aKeywords.empty? && @hResponseObj[:writerShowTags]
      @xml.tag!('keywtax')
   end

   # taxonomy bio (taxonsys) - taxonomic system
   # section is not required for fgdc, but is required by mdJson
   # so section will always be present
   @xml.tag!('taxonsys') do
      taxSystemClass.writeXML(hTaxonomy)
   end

   # taxonomy (taxongen) - general scope
   unless hTaxonomy[:generalScope].nil?
      @xml.tag!('taxongen', hTaxonomy[:generalScope])
   end
   if hTaxonomy[:generalScope].nil? && @hResponseObj[:writerShowTags]
      @xml.tag!('taxongen')
   end

   # taxonomy bio (taxoncl) - taxonomic classification [0] {required}
   unless hTaxonomy[:taxonClasses].empty?
      @xml.tag!('taxoncl') do
         taxClassClass.writeXML(hTaxonomy[:taxonClasses][0])
      end
   end
   if hTaxonomy[:taxonClasses].length > 1
      @NameSpace.issueNotice(401)
      @NameSpace.issueNotice(402)
   end
   if hTaxonomy[:taxonClasses].empty?
      @NameSpace.issueWarning(400, 'taxoncl')
   end

end