Class: ADIWG::Mdtranslator::Writers::Iso19110::Domain

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

Instance Method Summary collapse

Constructor Details

#initialize(xml, responseObj) ⇒ Domain

Returns a new instance of Domain.



20
21
22
23
24
# File 'lib/adiwg/mdtranslator/writers/iso19110/classes/class_domain.rb', line 20

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

Instance Method Details

#writeXML(hDomain, inContext) ⇒ Object



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

def writeXML(hDomain, inContext)

   # classes used
   listClass = FC_ListedValue.new(@xml, @hResponseObj)
   defRefClass = FC_DefinitionReference.new(@xml, @hResponseObj)

   outContext = hDomain[:domainCode]

   # if have domainItems treat as enumerated list
   aItems = hDomain[:domainItems]
   unless aItems.empty?
      aItems.each do |hItem|
         @xml.tag!('gfc:listedValue') do
            listClass.writeXML(hItem, outContext)
         end
      end
      return
   end

   # if have domainReference treat as codeList reference
   hCitation = hDomain[:domainReference]
   unless hCitation.empty?
      @xml.tag!('gfc:listedValue') do
         @xml.tag!('gfc:FC_ListedValue') do

            # label
            if hDomain[:domainName].nil?
               @NameSpace.issueWarning(100, 'gfc:label')
            else
               @xml.tag!('gfc:label') do
                  @xml.tag!('gco:CharacterString', hDomain[:domainName])
               end
            end

            # definition
            unless hDomain[:domainDescription].nil?
               @xml.tag!('gfc:definition') do
                  @xml.tag!('gco:CharacterString', hDomain[:domainDescription])
               end
            end
            if hDomain[:domainDescription].empty? && @hResponseObj[:writerShowTags]
               @xml.tag!('gfc:definition')
            end

            # definition reference
            @xml.tag!('gfc:definitionReference') do
               defRefClass.writeXML(hCitation)
            end

         end
      end
      return
   end

   # if have definition only treat as unrepresentable domain
   unless hDomain[:domainDescription].nil?
      @xml.tag!('gfc:listedValue') do
         @xml.tag!('gfc:FC_ListedValue') do

            # label
            if hDomain[:domainName].nil?
               @NameSpace.issueWarning(101, 'gfc:label')
            else
               @xml.tag!('gfc:label') do
                  @xml.tag!('gco:CharacterString', hDomain[:domainName])
               end
            end

            # definition
            unless hDomain[:domainDescription].nil?
               @xml.tag!('gfc:definition') do
                  @xml.tag!('gco:CharacterString', hDomain[:domainDescription])
               end
            end
            if hDomain[:domainDescription].empty? && @hResponseObj[:writerShowTags]
               @xml.tag!('gfc:definition')
            end

         end
      end
   end

end