Module: ADIWG::Mdtranslator::Readers::MdJson::TaxonomicClassification

Defined in:
lib/adiwg/mdtranslator/readers/mdJson/modules/module_taxonomicClassification.rb

Class Method Summary collapse

Class Method Details

.unpack(hTaxClass, responseObj) ⇒ 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
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
# File 'lib/adiwg/mdtranslator/readers/mdJson/modules/module_taxonomicClassification.rb', line 20

def self.unpack(hTaxClass, responseObj)

   @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson

   # return nil object if input is empty
   if hTaxClass.empty?
      @MessagePath.issueWarning(810, responseObj)
      return nil
   end

   # instance classes needed in script
   intMetadataClass = .new
   intTaxClass = intMetadataClass.newTaxonClass

   # taxonomic classification - system ID
   if hTaxClass.has_key?('taxonomicSystemId')
      unless hTaxClass['taxonomicSystemId'] == ''
         intTaxClass[:taxonId] = hTaxClass['taxonomicSystemId']
      end
   end

   # taxonomic classification - taxon level (required)
   # renamed from 'taxonomicRank'
   if hTaxClass.has_key?('taxonomicLevel')
      intTaxClass[:taxonRank] = hTaxClass['taxonomicLevel']
   end
   # support deprecation until schema version 3.0
   if hTaxClass.has_key?('taxonomicRank')
      intTaxClass[:taxonRank] = hTaxClass['taxonomicRank']
      @MessagePath.issueNotice(811, responseObj)
   end
   if intTaxClass[:taxonRank].nil? || intTaxClass[:taxonRank] == ''
      @MessagePath.issueError(812, responseObj)
   end

   # taxonomic classification - taxonomic name (required)
   # renamed from 'latinName'
   if hTaxClass.has_key?('taxonomicName')
      intTaxClass[:taxonValue] = hTaxClass['taxonomicName']
   end
   # support deprecation until schema version 3.0
   if hTaxClass.has_key?('latinName')
      intTaxClass[:taxonValue] = hTaxClass['latinName']
      @MessagePath.issueNotice(813, responseObj)
   end
   if intTaxClass[:taxonValue].nil? || intTaxClass[:taxonValue] == ''
      @MessagePath.issueError(814, responseObj)
   end

   # taxonomic classification - common name []
   if hTaxClass.has_key?('commonName')
      hTaxClass['commonName'].each do |item|
         unless item == ''
            intTaxClass[:commonNames] << item
         end
      end
   end

   # taxonomic classification - taxonomic classification [taxonomicClassification]
   if hTaxClass.has_key?('subClassification')
      aItems = hTaxClass['subClassification']
      aItems.each do |item|
         hReturn = TaxonomicClassification.unpack(item, responseObj)
         unless hReturn.nil?
            intTaxClass[:subClasses] << hReturn
         end
      end
   end

   return intTaxClass

end