module ADIWG::Mdtranslator::Readers::MdJson::Domain

Public Class Methods

unpack(hDomain, responseObj) click to toggle source
# File lib/adiwg/mdtranslator/readers/mdJson/modules/module_domain.rb, line 24
def self.unpack(hDomain, responseObj)

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

   # return nil object if input is empty
   if hDomain.empty?
      @MessagePath.issueWarning(200, responseObj)
      return nil
   end

   # instance classes needed in script
   intMetadataClass = InternalMetadata.new
   intDomain = intMetadataClass.newDictionaryDomain

   outContext = nil

   # data dictionary domain - id (required)
   if hDomain.has_key?('domainId')
      intDomain[:domainId] = hDomain['domainId']
   end
   if intDomain[:domainId].nil? || intDomain[:domainId] == ''
      @MessagePath.issueError(201, responseObj)
   else
      outContext = 'domain ID ' + hDomain['domainId']
   end

   # data dictionary domain - name
   if hDomain.has_key?('commonName')
      if hDomain['commonName'] != ''
         intDomain[:domainName] = hDomain['commonName']
      end
   end

   # data dictionary domain - code (required)
   if hDomain.has_key?('codeName')
      intDomain[:domainCode] = hDomain['codeName']
   end
   if intDomain[:domainCode].nil? || intDomain[:domainCode] == ''
      @MessagePath.issueError(202, responseObj, outContext)
   end

   # data dictionary domain - description (required)
   if hDomain.has_key?('description')
      intDomain[:domainDescription] = hDomain['description']
   end
   if intDomain[:domainDescription].nil? || intDomain[:domainDescription] == ''
      @MessagePath.issueError(203, responseObj, outContext)
   end

   # data dictionary domain - domain reference {citation}
   if hDomain.has_key?('domainReference')
      hCitation = hDomain['domainReference']
      unless hCitation.empty?
         hReturn = Citation.unpack(hCitation, responseObj)
         unless hReturn.nil?
            intDomain[:domainReference] = hReturn
         end
      end
   end

   # data dictionary domain - items []
   if hDomain.has_key?('domainItem')
      hDomain['domainItem'].each do |item|
         hDom = DomainItem.unpack(item, responseObj, outContext)
         unless hDom.nil?
            intDomain[:domainItems] << hDom
         end
      end
   end

   return intDomain

end