Class: ADIWG::Mdtranslator::Writers::Iso19110::CI_ResponsibleParty

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

Instance Method Summary collapse

Constructor Details

#initialize(xml, hResponseObj) ⇒ CI_ResponsibleParty

Returns a new instance of CI_ResponsibleParty.



27
28
29
30
31
# File 'lib/adiwg/mdtranslator/writers/iso19110/classes/class_responsibleParty.rb', line 27

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

Instance Method Details

#writeXML(role, hParty) ⇒ Object



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
# File 'lib/adiwg/mdtranslator/writers/iso19110/classes/class_responsibleParty.rb', line 33

def writeXML(role, hParty)

   # classes used
   codelistClass = MD_Codelist.new(@xml, @hResponseObj)
   contactClass = CI_Contact.new(@xml, @hResponseObj)

   contactId = hParty[:contactId]
   hContact = ADIWG::Mdtranslator::Writers::Iso19110.getContact(contactId)
   unless hContact.empty?
      isOrg = hContact[:isOrganization]
      @xml.tag!('gmd:CI_ResponsibleParty') do

         # ISO19110 follows ISO19115-2 rules and requires either an individual
         # or organization name and allows for both.  Since mdJson 2+ patterns
         # after ISO19115-3 only one name is maintained.  So individual name
         # becomes required for individual and organization name for organization.

         # responsible party - (if individual)
         unless isOrg

            # individual name (required)
            s = hContact[:name]
            unless s.nil?
               @xml.tag!('gmd:individualName') do
                  @xml.tag!('gco:CharacterString', s)
               end
            end
            if s.nil?
               @NameSpace.issueWarning(22, 'gmd:individualName')
            end

            # position name
            s = hContact[:positionName]
            unless s.nil?
               @xml.tag!('gmd:positionName') do
                  @xml.tag!('gco:CharacterString', s)
               end
            end
            if s.nil? && @hResponseObj[:writerShowTags]
               @xml.tag!('gmd:positionName')
            end

         end

         # responsible party - (if organization)
         if isOrg

            # organization name (required)
            s = hContact[:name]
            unless s.nil?
               @xml.tag!('gmd:organisationName') do
                  @xml.tag!('gco:CharacterString', s)
               end
            end
            if s.nil?
               @NameSpace.issueWarning(21, 'gmd:organisationName')
            end

         end

         # responsible party - contact info
         haveInfo = false
         haveInfo = true unless hContact[:phones].empty?
         haveInfo = true unless hContact[:addresses].empty?
         haveInfo = true unless hContact[:eMailList].empty?
         haveInfo = true unless hContact[:onlineResources].empty?
         haveInfo = true unless hContact[:hoursOfService].empty?
         haveInfo = true unless hContact[:contactInstructions].nil?
         if haveInfo
            @xml.tag!('gmd:contactInfo') do
               contactClass.writeXML(hContact)
            end
         elsif @hResponseObj[:writerShowTags]
            @xml.tag!('gmd:contactInfo')
         end

         # responsible party - role (required)
         s = role
         unless s.nil?
            @xml.tag! 'gmd:role' do
               codelistClass.writeXML('gmd', 'iso_role', s)
            end
         end
         if s.nil?
            @NameSpace.issueWarning(20, 'gmd:role')
         end

      end # CI_ResponsibleParty tag
   end # valid contact returned
end