Class: ADIWG::Mdtranslator::Writers::Fgdc::TaxonomySystem

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

Instance Method Summary collapse

Constructor Details

#initialize(xml, hResponseObj) ⇒ TaxonomySystem

Returns a new instance of TaxonomySystem.



19
20
21
22
23
# File 'lib/adiwg/mdtranslator/writers/fgdc/classes/class_taxonomySystem.rb', line 19

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

Instance Method Details

#writeXML(hTaxonomy) ⇒ Object



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
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
# File 'lib/adiwg/mdtranslator/writers/fgdc/classes/class_taxonomySystem.rb', line 25

def writeXML(hTaxonomy)

   # classes used
   citationClass = Citation.new(@xml, @hResponseObj)
   contactClass = Contact.new(@xml, @hResponseObj)

   # taxonomic system (classsys) - classification system [] (required)
   hTaxonomy[:taxonSystem].each do |hSystem|
      @xml.tag!('classsys') do

         # taxonomic system (classcit) - system citation (required) {citation}
         unless hSystem[:citation].empty?
            @xml.tag!('classcit') do
               citationClass.writeXML(hSystem[:citation], [], 'taxonomic classification system')
            end
         end
         if hSystem[:citation].empty?
            @NameSpace.issueWarning(430, nil)
         end

         # taxonomic system (classmod) - system modifications
         unless hSystem[:modifications].nil?
            @xml.tag!('classmod', hSystem[:modifications])
         end
         if hSystem[:modifications].nil? && @hResponseObj[:writerShowTags]
            @xml.tag!('classmod')
         end

      end
   end
   if hTaxonomy[:taxonSystem].empty?
      @NameSpace.issueWarning(431, nil)
   end

   # taxonomic system (idref) - identification reference [] {citation}
   hTaxonomy[:idReferences].each do |hCitation|
      unless hCitation.empty?
         @xml.tag!('idref') do
            citationClass.writeXML(hCitation, [])
         end
      end
   end

   # taxonomic system (ider) - observer
   # <- hTaxonomy[:observers] role = 'observer'
   haveObserver = false
   aRParties = hTaxonomy[:observers]
   aObservers = @NameSpace.find_responsibility(aRParties, 'observer')
   aObservers.each do |contactId|
      hContact = @NameSpace.get_contact(contactId)
      unless hContact.empty?
         @xml.tag!('ider') do
            contactClass.writeXML(hContact)
            haveObserver = true
         end
      end
   end
   if !haveObserver && @hResponseObj[:writerShowTags]
      @xml.tag!('ider')
   end

   # taxonomic system (taxonpro) - taxonomic procedures (required)
   unless hTaxonomy[:idProcedure].nil?
      @xml.tag!('taxonpro', hTaxonomy[:idProcedure])
   end
   if hTaxonomy[:idProcedure].nil?
      @NameSpace.issueWarning(432, 'taxonpro')
   end

   # taxonomic system (taxoncom) - taxonomic identification completeness
   unless hTaxonomy[:idCompleteness].nil?
      @xml.tag!('taxoncom', hTaxonomy[:idCompleteness])
   end
   if hTaxonomy[:idCompleteness].nil? && @hResponseObj[:writerShowTags]
      @xml.tag!('taxoncom')
   end

   # taxonomic system (vouchers) - taxonomic voucher []
   hTaxonomy[:vouchers].each do |hVoucher|
      @xml.tag!('vouchers') do

         # voucher (specimen) - specimen (required)
         unless hVoucher[:specimen].nil?
            @xml.tag!('specimen', hVoucher[:specimen])
         end
         if hVoucher[:specimen].nil?
            @NameSpace.issueWarning(433, 'specimen')
         end

         # voucher (repository) - repository (required)
         # take first party as repository custodian
         unless hVoucher[:repository].empty?
            aRParties = hVoucher[:repository][:parties]
            contactId = aRParties[0][:contactId]
            hContact = @NameSpace.get_contact(contactId)
            unless hContact.empty?
               @xml.tag!('repository') do
                  contactClass.writeXML(hContact)
               end
            end
            if hContact.empty?
               @NameSpace.issueWarning(434, nil)
            end
         end
         if hVoucher[:repository].empty?
            @NameSpace.issueWarning(434, nil)
         end

      end
      if hTaxonomy[:vouchers].empty? && @hResponseObj[:writerShowTags]
         @xml.tag!('vouchers')
      end

   end

end