Class: ADIWG::Mdtranslator::Writers::Iso19115_2::MD_MaintenanceInformation

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

Instance Method Summary collapse

Constructor Details

#initialize(xml, hResponseObj) ⇒ MD_MaintenanceInformation

Returns a new instance of MD_MaintenanceInformation.



29
30
31
32
33
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_maintenance.rb', line 29

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

Instance Method Details

#writeXML(hMaintenance, inContext = nil) ⇒ Object



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/iso19115_2/classes/class_maintenance.rb', line 35

def writeXML(hMaintenance, inContext = nil)

   # classes used
   codelistClass = MD_Codelist.new(@xml, @hResponseObj)
   partyClass = CI_ResponsibleParty.new(@xml, @hResponseObj)
   dateTimeClass = GcoDateTime.new(@xml, @hResponseObj)

   outContext = 'maintenance information'
   outContext = inContext + ' maintenance information' unless inContext.nil?

   @xml.tag! 'gmd:MD_MaintenanceInformation' do

      # maintenance information - frequency code (required)
      s = hMaintenance[:frequency]
      unless s.nil?
         @xml.tag!('gmd:maintenanceAndUpdateFrequency') do
            codelistClass.writeXML('gmd', 'iso_maintenanceFrequency', s)
         end
      end
      if s.nil?
         @NameSpace.issueWarning(220, 'gmd:maintenanceAndUpdateFrequency', inContext)
      end

      # maintenance information - date of next update
      found = false
      aDates = hMaintenance[:dates]
      aDates.each do |hDate|
         if hDate[:dateType] == 'nextUpdate'
            found = true
            @xml.tag!('gmd:dateOfNextUpdate') do
               dateTimeClass.writeXML(hDate)
            end
         end
      end
      if !found && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:dateOfNextUpdate')
      end

      # maintenance information - user defined maintenance frequency (not supported)

      # maintenance information - update scope [{MD_ScopeCode}]
      haveScope = false
      aScopes = hMaintenance[:scopes]
      aScopes.each do |hScope|
         s = hScope[:scopeCode]
         haveScope = true
         @xml.tag!('gmd:updateScope') do
            codelistClass.writeXML('gmd', 'iso_scope', s)
         end
      end
      if !haveScope && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:updateScope')
      end

      # maintenance information - update scope description [] (dropped)
      # according to XSD content type is 'element only' - so tag only, no text within
      # allowed tags are [featureInstances, attributes, features, other, attributeInstances, dataset]
      # not collecting this info in mdJson
      # this field was dropped in 19115-1

      # maintenance information - note []
      aNotes = hMaintenance[:notes]
      aNotes.each do |note|
         @xml.tag!('gmd:maintenanceNote') do
            @xml.tag!('gco:CharacterString', note)
         end
      end
      if aNotes.empty? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:maintenanceNote')
      end

      # maintenance information - contact [{CI_ResponsibleParty}]
      aParties = hMaintenance[:contacts]
      aParties.each do |hRParty|
         role = hRParty[:roleName]
         aParties = hRParty[:parties]
         aParties.each do |hParty|
            @xml.tag!('gmd:contact') do
               partyClass.writeXML(role, hParty, outContext)
            end
         end
      end
      if aParties.empty? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:contact')
      end

   end # gmd:MD_MaintenanceInformation tag
end