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

- old
+ new

@@ -1,10 +1,10 @@ # unpack a data dictionary # 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 2018-01-25 rename dictionaryFormat to dictionaryFunctionalLanguage # Stan Smith 2017-11-09 add dictionary description # Stan Smith 2017-01-20 refactored for mdJson/mdTranslator 2.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) @@ -24,13 +24,15 @@ module DataDictionary def self.unpack(hDictionary, responseObj) + @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson + # return nil object if input is empty if hDictionary.empty? - responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: data dictionary object is empty' + @MessagePath.issueWarning(140, responseObj) return nil end # instance classes needed in script intMetadataClass = InternalMetadata.new @@ -53,13 +55,11 @@ intDictionary[:citation] = hReturn end end end if intDictionary[:citation].empty? - responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: data dictionary citation is missing' - responseObj[:readerExecutionPass] = false - return nil + @MessagePath.issueError(141, responseObj) end # dictionary - subject [] (required) if hDictionary.has_key?('subject') aSubjects = hDictionary['subject'] @@ -68,13 +68,11 @@ intDictionary[:subjects] << item end end end if intDictionary[:subjects].empty? - responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: data dictionary subject is missing' - responseObj[:readerExecutionPass] = false - return nil + @MessagePath.issueError(142, responseObj) end # dictionary - recommended use [] if hDictionary.has_key?('recommendedUse') aUses = hDictionary['recommendedUse'] @@ -105,23 +103,20 @@ intDictionary[:responsibleParty] = hReturn end end end if intDictionary[:responsibleParty].empty? - responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: data dictionary responsible party is missing' - responseObj[:readerExecutionPass] = false - return nil + @MessagePath.issueError(143, responseObj) end # dictionary - dictionary format # deprecate dictionaryFormat in favor of dictionaryFunctionalLanguage s = nil if hDictionary.has_key?('dictionaryFunctionalLanguage') s = hDictionary['dictionaryFunctionalLanguage'] elsif hDictionary.has_key?('dictionaryFormat') s = hDictionary['dictionaryFormat'] - responseObj[:readerExecutionMessages] << - 'WARNING: mdJson reader: data dictionary dictionaryFormat is deprecated, use dictionaryFunctionalLanguage' + @MessagePath.issueWarning(144, responseObj) end unless s.nil? || s == '' intDictionary[:dictionaryFunctionalLanguage] = s end \ No newline at end of file