Module: ADIWG::Mdtranslator::Readers::MdJson::ResourceLineage

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

Class Method Summary collapse

Class Method Details

.unpack(hLineage, responseObj) ⇒ Object



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
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
# File 'lib/adiwg/mdtranslator/readers/mdJson/modules/module_lineage.rb', line 25

def self.unpack(hLineage, responseObj)

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

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

   # instance classes needed in script
   intMetadataClass = .new
   intLineage = intMetadataClass.newLineage

   outContext = 'resource lineage'
   haveLineage = false

   # lineage - statement
   if hLineage.has_key?('statement')
      unless hLineage['statement'] == ''
         intLineage[:statement] = hLineage['statement']
         haveLineage = true
      end
   end

   # lineage - resource scope
   if hLineage.has_key?('scope')
      hObject = hLineage['scope']
      unless hObject.empty?
         hReturn = Scope.unpack(hObject, responseObj, outContext)
         unless hReturn.nil?
            intLineage[:resourceScope] = hReturn
         end
      end
   end

   # lineage - citation []
   if hLineage.has_key?('citation')
      aCitation = hLineage['citation']
      aCitation.each do |item|
         hCitation = Citation.unpack(item, responseObj, outContext)
         unless hCitation.nil?
            intLineage[:lineageCitation] << hCitation
         end
      end
   end

   # lineage - sources []
   if hLineage.has_key?('source')
      aSource = hLineage['source']
      aSource.each do |item|
         hSource = Source.unpack(item, responseObj, outContext)
         unless hSource.nil?
            intLineage[:dataSources] << hSource
            haveLineage = true
         end
      end
   end

   # lineage - process steps []
   if hLineage.has_key?('processStep')
      aSteps = hLineage['processStep']
      aSteps.each do |item|
         hSteps = ProcessStep.unpack(item, responseObj, outContext)
         unless hSteps.nil?
            intLineage[:processSteps] << hSteps
            haveLineage = true
         end
      end
   end

   unless haveLineage
      @MessagePath.issueError(501, responseObj)
   end

   return intLineage
end