Class: ADIWG::Mdtranslator::Writers::Iso19110::FC_Constraint

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

Instance Method Summary collapse

Constructor Details

#initialize(xml, responseObj) ⇒ FC_Constraint

Returns a new instance of FC_Constraint.



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

def initialize(xml, responseObj)
   @xml = xml
   @hResponseObj = responseObj
end

Instance Method Details

#writeXML(conType, hConstraint) ⇒ 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
# File 'lib/adiwg/mdtranslator/writers/iso19110/classes/class_featureConstraint.rb', line 28

def writeXML(conType, hConstraint)

   @xml.tag!('gfc:FC_Constraint') do
      @xml.tag!('gfc:description') do

         # find type of constraint (primary key or index)
         case conType

            # primary keys
            when 'pk'
               s = 'PRIMARY KEY ' + hConstraint.to_s

            # indexes
            when 'index'
               if hConstraint[:duplicate]
                  indexType = 'DUPLICATE'
               else
                  indexType = 'UNIQUE'
               end
               s = indexType + ' INDEX ' + hConstraint[:indexCode]
               s += ' ON ' + hConstraint[:attributeNames].to_s

            # foreign keys
            when 'fk'
               s = 'FK'
               hConstraint[:fkLocalAttributes].each do |attribute|
                  s += '_' + attribute
               end
               s += ' FOREIGN KEY '
               s += hConstraint[:fkLocalAttributes].to_s
               s += ' REFERENCES ' + hConstraint[:fkReferencedEntity]
               s += hConstraint[:fkReferencedAttributes].to_s

         end

         @xml.tag!('gco:CharacterString', s)

      end
   end # gfc:FC_Constraint tag
end