Class: ADIWG::Mdtranslator::Writers::Iso19115_3::MD_DataIdentification
- Inherits:
-
Object
- Object
- ADIWG::Mdtranslator::Writers::Iso19115_3::MD_DataIdentification
- Defined in:
- lib/adiwg/mdtranslator/writers/iso19115_3/classes/class_dataIdentification.rb
Instance Method Summary collapse
-
#initialize(xml, hResponseObj) ⇒ MD_DataIdentification
constructor
A new instance of MD_DataIdentification.
- #writeXML(hMetadata) ⇒ Object
Constructor Details
#initialize(xml, hResponseObj) ⇒ MD_DataIdentification
Returns a new instance of MD_DataIdentification.
32 33 34 35 36 |
# File 'lib/adiwg/mdtranslator/writers/iso19115_3/classes/class_dataIdentification.rb', line 32 def initialize(xml, hResponseObj) @xml = xml @hResponseObj = hResponseObj @NameSpace = ADIWG::Mdtranslator::Writers::Iso19115_3 end |
Instance Method Details
#writeXML(hMetadata) ⇒ Object
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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
# File 'lib/adiwg/mdtranslator/writers/iso19115_3/classes/class_dataIdentification.rb', line 38 def writeXML(hMetadata) # classes used intMetadataClass = InternalMetadata.new codelistClass = MD_Codelist.new(@xml, @hResponseObj) citationClass = CI_Citation.new(@xml, @hResponseObj) responsibilityClass = CI_Responsibility.new(@xml, @hResponseObj) resolutionClass = MD_Resolution.new(@xml, @hResponseObj) extentClass = EX_Extent.new(@xml, @hResponseObj) documentClass = AdditionalDocument.new(@xml, @hResponseObj) maintClass = MD_MaintenanceInformation.new(@xml, @hResponseObj) graphicClass = MD_BrowseGraphic.new(@xml, @hResponseObj) formatClass = MD_Format.new(@xml, @hResponseObj) keywordClass = MD_Keywords.new(@xml, @hResponseObj) useClass = MD_Usage.new(@xml, @hResponseObj) constraintClass = Constraint.new(@xml, @hResponseObj) associatedClass = MD_AssociatedResource.new(@xml, @hResponseObj) localeClass = PT_Locale.new(@xml, @hResponseObj) # resolutionClass = MD_Resolution.new(@xml, @hResponseObj) # create shortcuts to sections of internal object hResource = hMetadata[:resourceInfo] aAssocRes = hMetadata[:associatedResources] # data identification @xml.tag!('mri:MD_DataIdentification') do # data identification - citation {CI_Citation} (required) hCitation = hResource[:citation] unless hCitation.empty? @xml.tag!('mri:citation') do citationClass.writeXML(hCitation, 'main resource') end end if hCitation.empty? @NameSpace.issueWarning(50, 'mri:citation') end # data identification - abstract (required) unless hResource[:abstract].nil? @xml.tag!('mri:abstract') do @xml.tag!('gco:CharacterString', hResource[:abstract]) end end if hResource[:abstract].nil? @NameSpace.issueWarning(51, 'mri:abstract') end # data identification - purpose unless hResource[:purpose].nil? @xml.tag!('mri:purpose') do @xml.tag!('gco:CharacterString', hResource[:purpose]) end end if hResource[:purpose].nil? && @hResponseObj[:writerShowTags] @xml.tag!('mri:purpose') end # data identification - credit [] aCredits = hResource[:credits] aCredits.each do |credit| @xml.tag!('mri:credit') do @xml.tag!('gco:CharacterString', credit) end end if aCredits.empty? && @hResponseObj[:writerShowTags] @xml.tag!('mri:credit') end # data identification - status [] {MD_ProgressCode} aStatus = hResource[:status] aStatus.each do |code| @xml.tag!('mri:status') do codelistClass.writeXML('mcc', 'iso_progress', code) end end if aStatus.empty? && @hResponseObj[:writerShowTags] @xml.tag!('mri:status') end # data identification - point of contact [] {CI_Responsibility} aContacts = hResource[:pointOfContacts] aContacts.each do |hContact| unless hContact.empty? @xml.tag!('mri:pointOfContact') do responsibilityClass.writeXML(hContact, 'metadata information') end end end if aContacts.empty? && @hResponseObj[:writerShowTags] @NameSpace.issueWarning(52, 'mri:pointOfContact') end # data identification - spatial representation type [] {MD_SpatialRepresentationTypeCode} aSpatialTypes = hResource[:spatialRepresentationTypes] aSpatialTypes.each do |code| @xml.tag!('mri:spatialRepresentationType') do codelistClass.writeXML('mcc', 'iso_spatialRepresentation', code) end end if aSpatialTypes.empty? && @hResponseObj[:writerShowTags] @xml.tag!('mri:spatialRepresentationType') end # data identification - spatial resolution [] {MD_Resolution} aSpatialRes = hResource[:spatialResolutions] aSpatialRes.each do |hResolution| @xml.tag!('mri:spatialResolution') do resolutionClass.writeXML(hResolution, 'resource information') end end if aSpatialRes.empty? && @hResponseObj[:writerShowTags] @xml.tag!('mri:spatialResolution') end # data identification - temporal resolution [] {TM_PeriodDuration} aTemporalRes = hResource[:temporalResolutions] aTemporalRes.each do |hResolution| @xml.tag!('mri:temporalResolution') do duration = AdiwgDateTimeFun.writeDuration(hResolution) @xml.tag!('gco:TM_PeriodDuration', duration) end end if aTemporalRes.empty? && @hResponseObj[:writerShowTags] @xml.tag!('mri:temporalResolution') end # data identification - topic category [] {MD_TopicCategoryCode} # get from hData.keywords where keywordType='isoTopicCategory' aTopics = [] aKeywords = hResource[:keywords] aKeywords.each do |hKeyword| if hKeyword[:keywordType] == 'isoTopicCategory' hKeyword[:keywords].each do |hKeyObj| aTopics << hKeyObj[:keyword] end end end # only allow valid ISO 19115-3 topic categories to be written aTopics.each do |topic| if CodelistFun.validateItem('iso_topicCategory', topic) @xml.tag!('mri:topicCategory') do @xml.tag!('mri:MD_TopicCategoryCode', topic) end else @NameSpace.issueWarning(400, 'mri:topicCategory', "#{topic}") end end if aTopics.empty? && @hResponseObj[:writerShowTags] @xml.tag!('mri:topicCategory') end # package mdJson time period {timePeriod} as a temporal extent unless hResource[:timePeriod].empty? hExtent = intMetadataClass.newExtent hTempExtent = intMetadataClass.newTemporalExtent hTempExtent[:timePeriod] = hResource[:timePeriod] hExtent[:temporalExtents] << hTempExtent hResource[:extents] << hExtent end # data identification - extent [] {EX_Extent} aExtents = hResource[:extents] aExtents.each do |hExtent| @xml.tag!('mri:extent') do extentClass.writeXML(hExtent) end end if aExtents.empty? && @hResponseObj[:writerShowTags] @xml.tag!('mri:extent') end # data identification - additional documentation [] {AdditionalDocument} aDocuments = hMetadata[:additionalDocuments] aDocuments.each do |hDoc| unless hDoc.empty? documentClass.writeXML(hDoc) end end if aDocuments.empty? && @hResponseObj[:writerShowTags] @xml.tag!('mri:additionalDocumentation') end # data identification - processing level {MD_Identifier} - not implemented # data identification - resource maintenance [] {MD_MaintenanceInformation} aMaint = hResource[:resourceMaintenance] aMaint.each do |hMaint| @xml.tag!('mri:resourceMaintenance') do maintClass.writeXML(hMaint, 'resource information') end end if aMaint.empty? && @hResponseObj[:writerShowTags] @xml.tag!('mri:resourceMaintenance') end # data identification - graphic overview [] aGraphics = hResource[:graphicOverviews] aGraphics.each do |hGraphic| @xml.tag!('mri:graphicOverview') do graphicClass.writeXML(hGraphic, 'resource information') end end if aGraphics.empty? && @hResponseObj[:writerShowTags] @xml.tag!('mri:graphicOverview') end # data identification - resource format [] {MD_Format} aFormats = hResource[:resourceFormats] aFormats.each do |hFormat| @xml.tag!('mri:resourceFormat') do formatClass.writeXML(hFormat) end end if aFormats.empty? && @hResponseObj[:writerShowTags] @xml.tag!('mri:resourceFormat') end # data identification - descriptive keywords [] {MD_Keywords} aKeywords = hResource[:keywords] aKeywords.each do |hKeyword| @xml.tag!('mri:descriptiveKeywords') do keywordClass.writeXML(hKeyword) end end if aKeywords.empty? && @hResponseObj[:writerShowTags] @xml.tag!('mir:descriptiveKeywords') end # data identification - resource specific usage [] {MD_Usage} aUses = hResource[:resourceUsages] aUses.each do |hResUse| @xml.tag!('mri:resourceSpecificUsage') do useClass.writeXML(hResUse) end end if aUses.empty? && @hResponseObj[:writerShowTags] @xml.tag!('mri:resourceSpecificUsage') end # data identification - resource constraints [] {MD_Constraints} aConstraint = hResource[:constraints] aConstraint.each do |hCon| @xml.tag!('mri:resourceConstraints') do constraintClass.writeXML(hCon, 'resource information') end end if aConstraint.empty? && @hResponseObj[:writerShowTags] @xml.tag!('mri:resourceConstraints') end # data identification - associated resource [] {MD_AssociatedResource} aAssocRes.each do |hAssocRes| @xml.tag!('mri:associatedResource') do associatedClass.writeXML(hAssocRes, 'resource information') end end if aAssocRes.empty? && @hResponseObj[:writerShowTags] @xml.tag!('mri:associatedResource') end # data identification - default locale {PT_Locale} unless hResource[:defaultResourceLocale].empty? @xml.tag!('mri:defaultLocale') do localeClass.writeXML(hResource[:defaultResourceLocale], 'resource information default') end end if hResource[:defaultResourceLocale].empty? && @hResponseObj[:writerShowTags] @xml.tag!('mri:defaultLocale') end # data identification - other locales [] {PT_Locale} aLocales = hResource[:otherResourceLocales] aLocales.each do |hLocale| @xml.tag!('mri:otherLocale') do localeClass.writeXML(hLocale, 'resource information other') end end if aLocales.empty? && @hResponseObj[:writerShowTags] @xml.tag!('mri:otherLocale') end # data identification - environment description unless hResource[:environmentDescription].nil? @xml.tag!('mri:environmentDescription') do @xml.tag!('gco:CharacterString', hResource[:environmentDescription]) end end if hResource[:environmentDescription].nil? && @hResponseObj[:writerShowTags] @xml.tag!('mri:environmentDescription') end # data identification - supplemental info unless hResource[:supplementalInfo].nil? @xml.tag!('mri:supplementalInformation') do @xml.tag!('gco:CharacterString', hResource[:supplementalInfo]) end end if hResource[:supplementalInfo].nil? && @hResponseObj[:writerShowTags] @xml.tag!('mri:supplementalInformation') end end # mri:MD_DataIdentification tag end |