Module: ADIWG::Mdtranslator::Readers::MdJson::ResourceUsage

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

Class Method Summary collapse

Class Method Details

.unpack(hUsage, responseObj) ⇒ 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/adiwg/mdtranslator/readers/mdJson/modules/module_resourceUsage.rb', line 26

def self.unpack(hUsage, responseObj)

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

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

   # instance classes needed in script
   intMetadataClass = InternalMetadata.new
   intUsage = intMetadataClass.newResourceUsage

   # resource usage - specific usage (required)
   if hUsage.has_key?('specificUsage')
      intUsage[:specificUsage] = hUsage['specificUsage']
   end
   if intUsage[:specificUsage].nil? || intUsage[:specificUsage] == ''
      @MessagePath.issueError(701, responseObj)
   end

   # resource usage - temporal extent []
   if hUsage.has_key?('temporalExtent')
      aItems = hUsage['temporalExtent']
      aItems.each do |hItem|
         hReturn = TemporalExtent.unpack(hItem, responseObj)
         unless hReturn.nil?
            intUsage[:temporalExtents] << hReturn
         end
      end
   end

   # resource usage - user determined limitations
   if hUsage.has_key?('userDeterminedLimitation')
      unless hUsage['userDeterminedLimitation'] == ''
         intUsage[:userLimitation] = hUsage['userDeterminedLimitation']
      end
   end

   # resource usage - repository - limitation response []
   if hUsage.has_key?('limitationResponse')
      hUsage['limitationResponse'].each do |item|
         unless item == ''
            intUsage[:limitationResponses] << item
         end
      end
   end

   # resource usage - repository - documented issue
   if hUsage.has_key?('documentedIssue')
      hCitation = hUsage['documentedIssue']
      unless hCitation.empty?
         hReturn = Citation.unpack(hCitation, responseObj)
         unless hReturn.nil?
            intUsage[:identifiedIssue] = hReturn
         end
      end
   end

   # resource usage - repository - additional documentation []
   if hUsage.has_key?('additionalDocumentation')
      aItems = hUsage['additionalDocumentation']
      aItems.each do |hItem|
         hReturn = Citation.unpack(hItem, responseObj)
         unless hReturn.nil?
            intUsage[:additionalDocumentation] << hReturn
         end
      end
   end

   # resource usage - repository - responsible party []
   if hUsage.has_key?('userContactInfo')
      aContacts = hUsage['userContactInfo']
      aContacts.each do |item|
         hReturn = ResponsibleParty.unpack(item, responseObj)
         unless hReturn.nil?
            intUsage[:userContacts] << hReturn
         end
      end
   end

   return intUsage

end