lib/adiwg/mdtranslator/readers/mdJson/modules/module_distributor.rb in adiwg-mdtranslator-2.13.0 vs lib/adiwg/mdtranslator/readers/mdJson/modules/module_distributor.rb in adiwg-mdtranslator-2.13.1
- old
+ new
@@ -1,10 +1,10 @@
# unpack distributor
# Reader - ADIwg JSON to internal data structure
# History:
-# Stan Smith 2018-02-18 refactored error and warning messaging
+# Stan Smith 2018-06-18 refactored error and warning messaging
# Stan Smith 2016-10-21 original script
require_relative 'module_responsibleParty'
require_relative 'module_orderProcess'
require_relative 'module_transferOption'
@@ -16,51 +16,60 @@
module Distributor
def self.unpack(hDistrib, responseObj)
+ @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson
+
# return nil object if input is empty
if hDistrib.empty?
- responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: distributor object is empty'
+ @MessagePath.issueWarning(190, responseObj)
return nil
end
# instance classes needed in script
intMetadataClass = InternalMetadata.new
intDistrib = intMetadataClass.newDistributor
+ outContext = 'distributor'
+
# distributor - contact {responsibleParty} (required)
if hDistrib.has_key?('contact')
hObject = hDistrib['contact']
unless hObject.empty?
- hReturn = ResponsibleParty.unpack(hObject, responseObj)
+ hReturn = ResponsibleParty.unpack(hObject, responseObj, outContext)
unless hReturn.nil?
intDistrib[:contact] = hReturn
+ contactId = hReturn[:parties][0][:contactId]
+ unless contactId.nil?
+ contactName = @MessagePath.findContact(contactId)[2]
+ unless contactName.nil?
+ outContext = outContext + ' > ' + contactName
+ end
+ end
end
end
end
if intDistrib[:contact].empty?
- responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: distributor contact is missing'
- responseObj[:readerExecutionPass] = false
- return nil
+ @MessagePath.issueError(191, responseObj)
end
# distributor - order process [orderProcess]
if hDistrib.has_key?('orderProcess')
aItems = hDistrib['orderProcess']
aItems.each do |item|
- hReturn = OrderProcess.unpack(item, responseObj)
+ hReturn = OrderProcess.unpack(item, responseObj, outContext)
unless hReturn.nil?
intDistrib[:orderProcess] << hReturn
end
end
end
# distributor - transfer options [transferOption]
if hDistrib.has_key?('transferOption')
aItemss = hDistrib['transferOption']
aItemss.each do |item|
- hReturn = TransferOption.unpack(item, responseObj)
+ hReturn = TransferOption.unpack(item, responseObj, outContext)
unless hReturn.nil?
intDistrib[:transferOptions] << hReturn
end
end
end