module ADIWG::Mdtranslator::Readers::MdJson::AttributeGroup

Public Class Methods

unpack(hAttGroup, responseObj) click to toggle source
# File lib/adiwg/mdtranslator/readers/mdJson/modules/module_attributeGroup.rb, line 17
def self.unpack(hAttGroup, responseObj)

   @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson

   inContext = 'coverage description'

   # return nil object if input is empty
   if hAttGroup.empty?
      @MessagePath.issueWarning(50, responseObj, inContext)
      return nil
   end

   # instance classes needed in script
   intMetadataClass = InternalMetadata.new
   intAttGroup = intMetadataClass.newAttributeGroup

   outContext = inContext + ' attribute group'

   # attribute group - attribute content type [] (required)
   if hAttGroup.has_key?('attributeContentType')
      hAttGroup['attributeContentType'].each do |item|
         unless item == ''
            intAttGroup[:attributeContentTypes] << item
         end
      end
   end
   if intAttGroup[:attributeContentTypes].empty?
      @MessagePath.issueError(51, responseObj, inContext)
   end

   # attribute group - attribute []
   if hAttGroup.has_key?('attribute')
      aItems = hAttGroup['attribute']
      aItems.each do |item|
         hReturn = Attribute.unpack(item, responseObj, outContext)
         unless hReturn.nil?
            intAttGroup[:attributes] << hReturn
         end
      end
   end

   return intAttGroup

end