Module: ADIWG::Mdtranslator::Readers::Fgdc::Taxonomy

Defined in:
lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonomy.rb

Class Method Summary collapse

Class Method Details

.unpack(xTaxonomy, hResourceInfo, hResponseObj) ⇒ Object



20
21
22
23
24
25
26
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
# File 'lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonomy.rb', line 20

def self.unpack(xTaxonomy, hResourceInfo, hResponseObj)

   # instance classes needed in script
   intMetadataClass = .new
   hTaxonomy = intMetadataClass.newTaxonomy

   # taxonomy bio.1 (keywtax) - taxonomic keywords [] {keyword} (required)
   # -> resourceInfo.keywords
   axKeywords = xTaxonomy.xpath('./keywtax')
   unless axKeywords.empty?
      axKeywords.each do |xKeyword|
         Keyword.unpack(xKeyword, hResourceInfo, hResponseObj)
      end
   end
   if axKeywords.empty?
      hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: BIO taxonomy keywords are missing'
   end

   # taxonomy bio.2 (taxonsys) - taxonomic system
   xSystem = xTaxonomy.xpath('./taxonsys')
   unless xSystem.empty?
      TaxonSystem.unpack(xSystem, hTaxonomy, hResponseObj)
   end

   # taxonomy bio.3 (taxongen) - general taxonomic coverage
   # -> resourceInfo.taxonomy.generalScope
   general = xTaxonomy.xpath('./taxongen').text
   unless general.empty?
      hTaxonomy[:generalScope] = general
   end

   # taxonomy bio.4 (taxoncl) - taxonomic classification (required)
   # -> resourceInfo.taxonomy.taxonClass
   xTaxClass = xTaxonomy.xpath('./taxoncl')
   unless xTaxClass.empty?
      hTaxonClass = TaxonClass.unpack(xTaxClass, hResponseObj)
      unless hTaxonClass.nil?
         hTaxonomy[:taxonClasses] << hTaxonClass
      end
   end
   if xTaxClass.empty?
      hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: BIO taxonomy classification is missing'
   end

   return hTaxonomy

end