lib/adiwg/mdtranslator/readers/mdJson/modules/module_phone.rb in adiwg-mdtranslator-2.13.0 vs lib/adiwg/mdtranslator/readers/mdJson/modules/module_phone.rb in adiwg-mdtranslator-2.13.1

- old
+ new

@@ -1,10 +1,10 @@ # unpack phone # Reader - ADIwg JSON to internal data structure # History: -# Stan Smith 2018-02-19 refactored error and warning messaging +# Stan Smith 2018-06-22 refactored error and warning messaging # Stan Smith 2016-10-02 phone service is now an array rather than creating individual phone records per service # Stan Smith 2016-10-02 refactored for mdJson 2.0.0 # Stan Smith 2015-07-14 refactored to remove global namespace constants # Stan Smith 2015-06-22 replace global ($response) with passed in object (responseObj) # Stan Smith 2014-12-15 refactored to handle namespacing readers and writers @@ -17,30 +17,30 @@ module Readers module MdJson module Phone - def self.unpack(hPhone, responseObj) + def self.unpack(hPhone, responseObj, inContext = nil) + @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson + # instance classes needed in script intMetadataClass = InternalMetadata.new intPhone = intMetadataClass.newPhone if hPhone.empty? - responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: phone object is empty' + @MessagePath.issueWarning(630, responseObj, inContext) return nil end # phone - phoneNumber (required) # return nil if no phone number is provided if hPhone.has_key?('phoneNumber') intPhone[:phoneNumber] = hPhone['phoneNumber'] end if hPhone['phoneNumber'].nil? || hPhone['phoneNumber'] == '' - responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: phone number is missing' - responseObj[:readerExecutionPass] = false - return nil + @MessagePath.issueError(631, responseObj, inContext) end # phone - phoneName if hPhone.has_key?('phoneName') unless hPhone['phoneName'] == '' @@ -51,10 +51,10 @@ # phone - service (recommended) if hPhone.has_key?('service') intPhone[:phoneServiceTypes] = hPhone['service'] end if intPhone[:phoneServiceTypes].empty? - responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: phone service type is missing' + @MessagePath.issueWarning(632, responseObj, inContext) end return intPhone end end