module ADIWG::Mdtranslator::Readers::MdJson::Graphic

Public Class Methods

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

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

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

   # instance classes needed in script
   intMetadataClass = InternalMetadata.new
   intGraphic = intMetadataClass.newGraphic

   # graphic - file name (required)
   if hGraphic.has_key?('fileName')
      intGraphic[:graphicName] = hGraphic['fileName']
   end
   if intGraphic[:graphicName].nil? || intGraphic[:graphicName] == ''
      @MessagePath.issueError(431, responseObj, inContext)
   end

   # graphic - file description
   if hGraphic.has_key?('fileDescription')
      unless hGraphic['fileDescription'] == ''
         intGraphic[:graphicDescription] = hGraphic['fileDescription']
      end
   end

   # graphic - file  type
   if hGraphic.has_key?('fileType')
      unless hGraphic['fileType'] == ''
         intGraphic[:graphicType] = hGraphic['fileType']
      end
   end

   # graphic - file  constraint []
   if hGraphic.has_key?('fileConstraint')
      aItems = hGraphic['fileConstraint']
      aItems.each do |hItem|
         unless hItem.empty?
            hReturn = Constraint.unpack(hItem, responseObj)
            unless hReturn.nil?
               intGraphic[:graphicConstraints] << hReturn
            end
         end
      end
   end

   # graphic - online resource []
   if hGraphic.has_key?('fileUri')
      hGraphic['fileUri'].each do |item|
         unless item.empty?
            uri = OnlineResource.unpack(item, responseObj)
            unless uri.nil?
               intGraphic[:graphicURI] << uri
            end
         end
      end
   end

   return intGraphic

end