Module: ADIWG::Mdtranslator::Readers::MdJson::ResponsibleParty

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

Class Method Summary collapse

Class Method Details

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



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

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

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

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

   # instance classes needed in script
   # CI_Responsibility replaces CI_ResponsibleParty in 19115-3
   # Responsibility object is translated to ResponsibleParty by 19115-2 writer
   intMetadataClass = InternalMetadata.new
   intResParty = intMetadataClass.newResponsibility

   outContext = 'responsible party'
   outContext = inContext + ' > ' + outContext unless inContext.nil?

   # responsible party - role - (required)
   if hRParty.has_key?('role')
      intResParty[:roleName] = hRParty['role']
   end
   if intResParty[:roleName].nil? || intResParty[:roleName] == ''
      @MessagePath.issueError(711, responseObj, inContext)
   end

   # responsible party - role extent
   if hRParty.has_key?('roleExtent')
      aExtent = hRParty['roleExtent']
      aExtent.each do |hItem|
         unless hItem.empty?
            hTimeExtent = Extent.unpack(hItem, responseObj, outContext)
            unless hTimeExtent.nil?
               intResParty[:roleExtents] << hTimeExtent
            end
         end
      end
   end

   # responsible party - party [] (minimum 1)
   if hRParty.has_key?('party')
      hRParty['party'].each do |hParty|
         unless hParty.empty?
            party = Party.unpack(hParty, responseObj, outContext)
            unless party.nil?
               intResParty[:parties] << party
            end
         end
      end
   end
   if intResParty[:parties].empty?
      @MessagePath.issueError(712, responseObj, inContext)
   end

   return intResParty

end