module ADIWG::Mdtranslator::Readers::MdJson::Scope

Public Class Methods

unpack(hScope, responseObj, inContext = nil) click to toggle source
# File lib/adiwg/mdtranslator/readers/mdJson/modules/module_scope.rb, line 19
def self.unpack(hScope, responseObj, inContext = nil)

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

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

   # instance classes needed in script
   intMetadataClass = InternalMetadata.new
   intScope = intMetadataClass.newScope

   outContext = 'scope'
   outContext = inContext + ' > ' + outContext unless inContext.nil?

   # scope - scope code (required)
   if hScope.has_key?('scopeCode')
      intScope[:scopeCode] = hScope['scopeCode']
   end
   if intScope[:scopeCode].nil? || intScope[:scopeCode] == ''
      @MessagePath.issueError(731, responseObj, inContext)
   end

   # scope - scope description [] {MD_ScopeDescription}
   if hScope.has_key?('scopeDescription')
      aScopeDes = hScope['scopeDescription']
      aScopeDes.each do |item|
         hScopeDes = ScopeDescription.unpack(item, responseObj, outContext)
         unless hScopeDes.nil?
            intScope[:scopeDescriptions] << hScopeDes
         end
      end
   end

   # scope - extent [] {EX_Extent}
   if hScope.has_key?('scopeExtent')
      aExtents = hScope['scopeExtent']
      aExtents.each do |item|
         hExtent = Extent.unpack(item, responseObj, outContext)
         unless hExtent.nil?
            intScope[:extents] << hExtent
         end
      end
   end

   return intScope

end