Class: ADIWG::Mdtranslator::Writers::Iso19115_2::CI_Citation
- Inherits:
-
Object
- Object
- ADIWG::Mdtranslator::Writers::Iso19115_2::CI_Citation
- Defined in:
- lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_citation.rb
Instance Method Summary collapse
-
#initialize(xml, hResponseObj) ⇒ CI_Citation
constructor
A new instance of CI_Citation.
- #writeXML(hCitation, inContext = nil) ⇒ Object
Constructor Details
#initialize(xml, hResponseObj) ⇒ CI_Citation
Returns a new instance of CI_Citation.
36 37 38 39 40 |
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_citation.rb', line 36 def initialize(xml, hResponseObj) @xml = xml @hResponseObj = hResponseObj @NameSpace = ADIWG::Mdtranslator::Writers::Iso19115_2 end |
Instance Method Details
#writeXML(hCitation, inContext = nil) ⇒ Object
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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_citation.rb', line 42 def writeXML(hCitation, inContext = nil) # 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) outContext = 'citation' outContext = inContext + ' citation' unless inContext.nil? @xml.tag!('gmd:CI_Citation') do # citation - title (required) s = hCitation[:title] if s.nil? @NameSpace.issueWarning(30, 'gmd:title', inContext) 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, outContext) end end if aDate.empty? @NameSpace.issueWarning(31, 'gmd:date', outContext) 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 [] # process ISBN and ISSN as MD_identifier(s) # ... then also write separately in ISBN or ISSN tag 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 @xml.tag!('gmd:identifier') do idClass.writeXML(hIdentifier, outContext) end end if aIds.empty? && @hResponseObj[:writerShowTags] @xml.tag!('gmd:identifier') end # citation - cited responsible party [{CI_ResponsibleParty}] # responsibilities are grouped by role in the internal object # to output in ISO ... # create a separate record for each role-contact pair # check for duplicates and eliminate aRoleParty = [] aRParties = hCitation[:responsibleParties] aRParties.each do |hRParty| role = hRParty[:roleName] aParties = hRParty[:parties] aParties.each do |hParty| aRoleParty << {role: role, hParty: hParty} end end aRoleParty.uniq! aRoleParty.each do |hRoleParty| @xml.tag!('gmd:citedResponsibleParty') do rPartyClass.writeXML(hRoleParty[:role], hRoleParty[:hParty], outContext) end end if aRoleParty.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 # CI_Citation tag end |