Class: CI_ResponsibleParty

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

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ CI_ResponsibleParty

Returns a new instance of CI_ResponsibleParty.



14
15
16
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_responsibleParty.rb', line 14

def initialize(xml)
  @xml = xml
end

Instance Method Details

#writeXML(rParty) ⇒ 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_responsibleParty.rb', line 18

def writeXML(rParty)

  # classes used in MD_Metadata
  ciContactClass = CI_Contact.new(@xml)
  ciRoleCode = CI_RoleCode.new(@xml)

  # search array of responsible party for matches in contact object
  rpID = rParty[:contactID]
  unless rpID.nil?
    hContact = ciContactClass.getContact(rpID)
    unless hContact.empty?
      @xml.tag!('gmd:CI_ResponsibleParty') do

        # responsible party - individual name
        s = hContact[:indName]
        if !s.nil?
          @xml.tag!('gmd:individualName') do
            @xml.tag!('gco:CharacterString', hContact[:indName])
          end
        elsif $showAllTags
          @xml.tag!('gmd:individualName')
        end

        # responsible party - organization name
        s = hContact[:orgName]
        if !s.nil?
          @xml.tag!('gmd:organisationName') do
            @xml.tag!('gco:CharacterString', hContact[:orgName])
          end
        elsif $showAllTags
          @xml.tag!('gmd:organisationName')
        end

        # responsible party - position name
        s = hContact[:position]
        if !s.nil?
          @xml.tag!('gmd:positionName') do
            @xml.tag!('gco:CharacterString', hContact[:position])
          end
        elsif $showAllTags
          @xml.tag!('gmd:positionName')
        end

        # responsible party - contact info
        # the following elements belong to CI_Contact
        if !(hContact[:phones].empty? &&
           hContact[:address].empty? &&
           hContact[:onlineRes].empty? &&
           hContact[:contactInstructions].nil?)
          @xml.tag!('gmd:contactInfo') do
            ciContactClass.writeXML(hContact)
          end
        elsif $showAllTags
          @xml.tag!('gmd:contactInfo')
        end

        # responsible party - role - required
        s = rParty[:roleName]
        if s.nil?
          xml.tag!('gmd:role', {'gco:nilReason' => 'missing'})
        else
          @xml.tag! 'gmd:role' do
            ciRoleCode.writeXML(s)
          end
        end

      end
    end
  end

end