Module: ADIWG::Mdtranslator::Readers::Fgdc::Publication

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

Class Method Summary collapse

Class Method Details

.unpack(xPublication, 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
# File 'lib/adiwg/mdtranslator/readers/fgdc/modules/module_publication.rb', line 18

def self.unpack(xPublication, hResponseObj)

   # instance classes needed in script
   intMetadataClass = .new
   hResponsibility = nil
   contactId = nil

   # publication information 8.2 (publish) - publisher {contact} (required)
   publisher = xPublication.xpath('./publish').text
   unless publisher.empty?
      contactId = Fgdc.find_contact_by_name(publisher)
      if contactId.nil?
         contactId = Fgdc.add_contact(publisher, true)
      end
      hResponsibility = Responsibility.unpack([contactId], 'publisher', hResponseObj)
   end
   if publisher.nil?
      hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: citation publisher contact is missing'
   end

   # publication information 8.1 (pubplace) - place of publication (required)
   place = xPublication.xpath('./pubplace').text
   unless place.empty?
      unless contactId.nil?
         hContact = Fgdc.get_contact_by_id(contactId)
         unless hContact.nil?
            if hContact[:addresses].empty?
               hAddress = intMetadataClass.newAddress
               hContact[:addresses] << hAddress
            else
               hAddress = hContact[:addresses][0]
            end
            hAddress[:addressTypes] << 'mailing'
            hAddress[:description] = place
            Fgdc.set_contact(hContact)
         end
      end
   end
   if place.nil?
      hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: citation publication place is missing'
   end

   return hResponsibility

end