class ADIWG::Mdtranslator::Writers::Iso19110::FC_Constraint

Public Class Methods

new(xml, responseObj) click to toggle source
# File lib/adiwg/mdtranslator/writers/iso19110/classes/class_featureConstraint.rb, line 23
def initialize(xml, responseObj)
   @xml = xml
   @hResponseObj = responseObj
end

Public Instance Methods

writeXML(conType, hConstraint) click to toggle source
# 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