Module: ADIWG::Mdtranslator::Readers::Fgdc::CodeSet

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

Class Method Summary collapse

Class Method Details

.unpack(axDomains, code, hResponseObj) ⇒ Object



18
19
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
# File 'lib/adiwg/mdtranslator/readers/fgdc/modules/module_codeSet.rb', line 18

def self.unpack(axDomains, code, hResponseObj)

   # instance classes needed in script
   intMetadataClass = InternalMetadata.new

   aDomains = []

   axCodeSets = axDomains.xpath('./codesetd')
   unless axCodeSets.empty?
      axCodeSets.each do |xCodeSet|

         hDomain = intMetadataClass.newDictionaryDomain
         hDomain[:domainId] = UUIDTools::UUID.random_create.to_s
         hDomain[:domainCode] = code
         hDomain[:domainDescription] = 'FGDC codeSet domain'


         # entity attribute 5.1.2.4.3.1 (codesetn) - codeset name (required)
         # -> dataDictionary.domains.commonName
         name = xCodeSet.xpath('./codesetn').text
         unless name.empty?
            hDomain[:domainName] = name
         end
         if name.empty?
            hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: codeset domain name is missing'
         end

         # entity attribute 5.1.2.4.3.2 (codesets) - codeset source name (required)
         # -> dataDictionary.domains.domainReference.title
         hCitation = intMetadataClass.newCitation
         title = xCodeSet.xpath('./codesets').text
         unless title.empty?
            hCitation[:title] = title
            hDomain[:domainReference] = hCitation
         end
         if title.empty?
            hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: codeset domain source is missing'
         end

         aDomains << hDomain

      end

   end

   return aDomains

end