Class: ADIWG::Mdtranslator::Writers::Iso19110::CI_Citation

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

Instance Method Summary collapse

Constructor Details

#initialize(xml, hResponseObj) ⇒ CI_Citation

Returns a new instance of CI_Citation.



22
23
24
25
26
# File 'lib/adiwg/mdtranslator/writers/iso19110/classes/class_citation.rb', line 22

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

Instance Method Details

#writeXML(hCitation) ⇒ Object



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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/adiwg/mdtranslator/writers/iso19110/classes/class_citation.rb', line 28

def writeXML(hCitation)

   unless hCitation.empty?

      # classes used
      codelistClass = MD_Codelist.new(@xml, @hResponseObj)
      rPartyClass = CI_ResponsibleParty.new(@xml, @hResponseObj)
      dateClass = CI_Date.new(@xml, @hResponseObj)
      idClass = MD_Identifier.new(@xml, @hResponseObj)
      seriesClass = CI_Series.new(@xml, @hResponseObj)

      @xml.tag!('gmd:CI_Citation') do

         # citation - title (required)
         s = hCitation[:title]
         if s.nil?
            @NameSpace.issueWarning(1, 'gmd:title')
         else
            @xml.tag!('gmd:title') do
               @xml.tag!('gco:CharacterString', s)
            end
         end

         # citation - alternate title []
         aTitles = hCitation[:alternateTitles]
         aTitles.each do |title|
            @xml.tag!('gmd:alternateTitle') do
               @xml.tag!('gco:CharacterString', title)
            end
         end
         if aTitles.empty? && @hResponseObj[:writerShowTags]
            @xml.tag!('gmd:alternateTitle')
         end

         # citation - date [] (required)
         aDate = hCitation[:dates]
         aDate.each do |hDate|
            @xml.tag!('gmd:date') do
               dateClass.writeXML(hDate)
            end
         end
         if aDate.empty?
            @NameSpace.issueWarning(2,'gmd:date')
         end

         # citation - edition
         s = hCitation[:edition]
         unless s.nil?
            @xml.tag!('gmd:edition') do
               @xml.tag!('gco:CharacterString', s)
            end
         end
         if s.nil? && @hResponseObj[:writerShowTags]
            @xml.tag!('gmd:edition')
         end

         # citation - resource identifier []
         # do not process ISBN and ISSN as MD_identifier(s)
         # ... these are written separately in ISO 19115-x
         isbn = ''
         issn = ''
         aIds = hCitation[:identifiers]
         aIds.each do |hIdentifier|
            unless hIdentifier[:namespace].nil?
               if hIdentifier[:namespace].downcase == 'isbn'
                  isbn = hIdentifier[:identifier]
               elsif hIdentifier[:namespace].downcase == 'issn'
                  issn = hIdentifier[:identifier]
               end
            end
            if issn == '' && isbn == ''
               @xml.tag!('gmd:identifier') do
                  idClass.writeXML(hIdentifier)
               end
            end
         end
         if aIds.empty? && @hResponseObj[:writerShowTags]
            @xml.tag!('gmd:identifier')
         end

         # citation - cited responsible party [{CI_ResponsibleParty}]
         # contacts are grouped by role in the internal object
         # output a separate <gmd:contact> for each role:contact pairing
         aRParties = hCitation[:responsibleParties]
         aRParties.each do |hRParty|
            role = hRParty[:roleName]
            aParties = hRParty[:parties]
            aParties.each do |hParty|
               @xml.tag!('gmd:citedResponsibleParty') do
                  rPartyClass.writeXML(role, hParty)
               end
            end
         end
         if aRParties.empty? && @hResponseObj[:writerShowTags]
            @xml.tag!('gmd:citedResponsibleParty')
         end

         # citation - presentation forms [{CI_PresentationFormCode}]
         aPresForms = hCitation[:presentationForms]
         aPresForms.each do |presForm|
            @xml.tag!('gmd:presentationForm') do
               codelistClass.writeXML('gmd', 'iso_presentationForm', presForm)
            end
         end
         if aPresForms.empty? && @hResponseObj[:writerShowTags]
            @xml.tag!('gmd:presentationForm')
         end

         # citation - series {CI_Series}
         hSeries = hCitation[:series]
         unless hSeries.empty?
            @xml.tag!('gmd:series') do
               seriesClass.writeXML(hSeries)
            end
         end
         if hSeries.empty? && @hResponseObj[:writerShowTags]
            @xml.tag!('gmd:series')
         end

         # citation - other citation details
         aOther = hCitation[:otherDetails]
         unless aOther.empty?
            other = aOther[0]
            @xml.tag!('gmd:otherCitationDetails') do
               @xml.tag!('gco:CharacterString', other)
            end
         end
         if aOther.empty? && @hResponseObj[:writerShowTags]
            @xml.tag!('gmd:otherCitationDetails')
         end

         # citation - ISBN
         unless isbn == ''
            @xml.tag!('gmd:ISBN') do
               @xml.tag!('gco:CharacterString', isbn)
            end
         end
         if isbn == '' && @hResponseObj[:writerShowTags]
            @xml.tag!('gmd:ISBN')
         end

         # citation - ISSN
         unless issn == ''
            @xml.tag!('gmd:ISSN') do
               @xml.tag!('gco:CharacterString', issn)
            end
         end
         if issn == '' && @hResponseObj[:writerShowTags]
            @xml.tag!('gmd:ISSN')
         end

      end
   end

end