Module: ADIWG::Mdtranslator::Readers::MdJson::Graphic

Defined in:
lib/adiwg/mdtranslator/readers/mdJson/modules/module_graphic.rb

Class Method Summary collapse

Class Method Details

.unpack(hGraphic, responseObj, inContext = nil) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# 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