lib/adiwg/mdtranslator/readers/mdJson/modules/module_distributor.rb in adiwg-mdtranslator-2.9.2 vs lib/adiwg/mdtranslator/readers/mdJson/modules/module_distributor.rb in adiwg-mdtranslator-2.10.0
- old
+ new
@@ -1,78 +1,78 @@
# unpack distributor
# Reader - ADIwg JSON to internal data structure
# History:
-# Stan Smith 2016-10-21 original script
+# Stan Smith 2018-02-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'
module ADIWG
- module Mdtranslator
- module Readers
- module MdJson
+ module Mdtranslator
+ module Readers
+ module MdJson
- module Distributor
+ module Distributor
- def self.unpack(hDistrib, responseObj)
+ def self.unpack(hDistrib, responseObj)
- # return nil object if input is empty
- if hDistrib.empty?
- responseObj[:readerExecutionMessages] << 'Distributor object is empty'
- responseObj[:readerExecutionPass] = false
- return nil
- end
+ # return nil object if input is empty
+ if hDistrib.empty?
+ responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: distributor object is empty'
+ return nil
+ end
- # instance classes needed in script
- intMetadataClass = InternalMetadata.new
- intDistrib = intMetadataClass.newDistributor
+ # instance classes needed in script
+ intMetadataClass = InternalMetadata.new
+ intDistrib = intMetadataClass.newDistributor
- # distributor - contact {responsibleParty} (required)
- if hDistrib.has_key?('contact')
- hObject = hDistrib['contact']
- unless hObject.empty?
- hReturn = ResponsibleParty.unpack(hObject, responseObj)
- unless hReturn.nil?
- intDistrib[:contact] = hReturn
- end
- end
+ # distributor - contact {responsibleParty} (required)
+ if hDistrib.has_key?('contact')
+ hObject = hDistrib['contact']
+ unless hObject.empty?
+ hReturn = ResponsibleParty.unpack(hObject, responseObj)
+ unless hReturn.nil?
+ intDistrib[:contact] = hReturn
end
- if intDistrib[:contact].empty?
- responseObj[:readerExecutionMessages] << 'Distributor object is missing contact'
- responseObj[:readerExecutionPass] = false
- return nil
- end
+ end
+ end
+ if intDistrib[:contact].empty?
+ responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: distributor contact is missing'
+ responseObj[:readerExecutionPass] = false
+ return nil
+ end
- # distributor - order process [orderProcess]
- if hDistrib.has_key?('orderProcess')
- aItems = hDistrib['orderProcess']
- aItems.each do |item|
- hReturn = OrderProcess.unpack(item, responseObj)
- unless hReturn.nil?
- intDistrib[:orderProcess] << hReturn
- end
- end
+ # distributor - order process [orderProcess]
+ if hDistrib.has_key?('orderProcess')
+ aItems = hDistrib['orderProcess']
+ aItems.each do |item|
+ hReturn = OrderProcess.unpack(item, responseObj)
+ 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)
- unless hReturn.nil?
- intDistrib[:transferOptions] << hReturn
- end
- end
+ # distributor - transfer options [transferOption]
+ if hDistrib.has_key?('transferOption')
+ aItemss = hDistrib['transferOption']
+ aItemss.each do |item|
+ hReturn = TransferOption.unpack(item, responseObj)
+ unless hReturn.nil?
+ intDistrib[:transferOptions] << hReturn
end
+ end
+ end
- return intDistrib
+ return intDistrib
- end
+ end
- end
-
end
- end
- end
+
+ end
+ end
+ end
end