Module: ADIWG::Mdtranslator::Readers::MdJson::LegalConstraint

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

Class Method Summary collapse

Class Method Details

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



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
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/adiwg/mdtranslator/readers/mdJson/modules/module_legalConstraint.rb', line 21

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

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

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

   # instance classes needed in script
   intMetadataClass = .new
   intLegalCon = intMetadataClass.newLegalConstraint

   haveLegal = false

   # legal constraint - use constraint []
   if hLegalCon.has_key?('useConstraint')
      hLegalCon['useConstraint'].each do |item|
         unless item == ''
            intLegalCon[:useCodes] << item
            haveLegal = true
         end
      end
   end

   # legal constraint - access constraint []
   if hLegalCon.has_key?('accessConstraint')
      hLegalCon['accessConstraint'].each do |item|
         unless item == ''
            intLegalCon[:accessCodes] << item
            haveLegal = true
         end
      end
   end

   # legal constraint - other constraint []
   if hLegalCon.has_key?('otherConstraint')
      hLegalCon['otherConstraint'].each do |item|
         unless item == ''
            intLegalCon[:otherCons] << item
            haveLegal = true
         end
      end
   end

   # error messages
   unless haveLegal
      @MessagePath.issueError(491, responseObj, inContext)
   end

   return intLegalCon

end