lib/adiwg/mdtranslator/readers/mdJson/modules/module_voucher.rb in adiwg-mdtranslator-2.13.0 vs lib/adiwg/mdtranslator/readers/mdJson/modules/module_voucher.rb in adiwg-mdtranslator-2.13.1
- old
+ new
@@ -1,11 +1,11 @@
# unpack voucher
# Reader - ADIwg JSON to internal data structure
# History:
-# Stan Smith 2018-02-19 refactored error and warning messaging
-# Stan Smith 2016-10-21 original script
+# Stan Smith 2018-06-27 refactored error and warning messaging
+# Stan Smith 2016-10-21 original script
require_relative 'module_responsibleParty'
module ADIWG
module Mdtranslator
@@ -14,43 +14,43 @@
module Voucher
def self.unpack(hVoucher, responseObj)
+ @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson
+
# return nil object if input is empty
if hVoucher.empty?
- responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: voucher object is empty'
+ @MessagePath.issueWarning(940, responseObj)
return nil
end
# instance classes needed in script
intMetadataClass = InternalMetadata.new
intVoucher = intMetadataClass.newTaxonVoucher
+ outContext = 'taxon voucher'
+
# voucher - specimen (required)
if hVoucher.has_key?('specimen')
intVoucher[:specimen] = hVoucher['specimen']
end
if intVoucher[:specimen].nil? || intVoucher[:specimen] == ''
- responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: voucher specimen is missing'
- responseObj[:readerExecutionPass] = false
- return nil
+ @MessagePath.issueError(941, responseObj)
end
# voucher - repository (required)
if hVoucher.has_key?('repository')
hObject = hVoucher['repository']
unless hObject.empty?
- hReturn = ResponsibleParty.unpack(hObject, responseObj)
+ hReturn = ResponsibleParty.unpack(hObject, responseObj, outContext)
unless hReturn.nil?
intVoucher[:repository] = hReturn
end
end
end
if intVoucher[:repository].empty?
- responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: voucher repository is missing'
- responseObj[:readerExecutionPass] = false
- return nil
+ @MessagePath.issueError(942, responseObj)
end
return intVoucher
end