lib/adiwg/mdtranslator/readers/mdJson/modules/module_dataDictionary.rb in adiwg-mdtranslator-2.9.2 vs lib/adiwg/mdtranslator/readers/mdJson/modules/module_dataDictionary.rb in adiwg-mdtranslator-2.10.0

- old
+ new

@@ -1,9 +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-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) @@ -25,12 +26,11 @@ def self.unpack(hDictionary, responseObj) # return nil object if input is empty if hDictionary.empty? - responseObj[:readerExecutionMessages] << 'Data Dictionary object is empty' - responseObj[:readerExecutionPass] = false + responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: data dictionary object is empty' return nil end # instance classes needed in script intMetadataClass = InternalMetadata.new @@ -53,35 +53,35 @@ intDictionary[:citation] = hReturn end end end if intDictionary[:citation].empty? - responseObj[:readerExecutionMessages] << 'Data Dictionary citation is empty' + responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: data dictionary citation is missing' responseObj[:readerExecutionPass] = false return nil end # dictionary - subject [] (required) if hDictionary.has_key?('subject') aSubjects = hDictionary['subject'] aSubjects.each do |item| - if item != '' + unless item == '' intDictionary[:subjects] << item end end end if intDictionary[:subjects].empty? - responseObj[:readerExecutionMessages] << 'Data Dictionary subject is missing' + responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: data dictionary subject is missing' responseObj[:readerExecutionPass] = false return nil end # dictionary - recommended use [] if hDictionary.has_key?('recommendedUse') aUses = hDictionary['recommendedUse'] aUses.each do |item| - if item != '' + unless item == '' intDictionary[:recommendedUses] << item end end end @@ -105,11 +105,11 @@ intDictionary[:responsibleParty] = hReturn end end end if intDictionary[:responsibleParty].empty? - responseObj[:readerExecutionMessages] << 'Data Dictionary responsible party is empty' + responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: data dictionary responsible party is missing' responseObj[:readerExecutionPass] = false return nil end # dictionary - dictionary format @@ -117,9 +117,11 @@ 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' end unless s.nil? || s == '' intDictionary[:dictionaryFunctionalLanguage] = s end \ No newline at end of file