Module: ADIWG::Mdtranslator::Readers::MdJson::EntityIndex

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

Class Method Summary collapse

Class Method Details

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



20
21
22
23
24
25
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
# File 'lib/adiwg/mdtranslator/readers/mdJson/modules/module_entityIndex.rb', line 20

def self.unpack(hIndex, responseObj, inContext = nil)

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

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

   # instance classes needed in script
   intMetadataClass = .new
   intIndex = intMetadataClass.newEntityIndex

   # entity index - code name (required)
   # return nil if no entity index is provided
   if hIndex.has_key?('codeName')
      intIndex[:indexCode] = hIndex['codeName']
   end
   if intIndex[:indexCode].nil? || intIndex[:indexCode] == ''
      @MessagePath.issueError(261, responseObj, inContext)
   end

   # entity index - allow duplicates (required)
   if hIndex.has_key?('allowDuplicates')
      if hIndex['allowDuplicates'] === true
         intIndex[:duplicate] = true
      end
   end

   # entity index - attribute list [] (required)
   # return nil if no attribute list is provided
   if hIndex.has_key?('attributeCodeName')
      intIndex[:attributeNames] = hIndex['attributeCodeName']
   end
   if intIndex[:attributeNames].empty?
      @MessagePath.issueError(262, responseObj, inContext)
   end

   return intIndex

end