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

- old
+ new

@@ -1,10 +1,10 @@ # unpack metadata information # Reader - ADIwg JSON to internal data structure # History: -# Stan Smith 2018-02-19 refactored error and warning messaging +# Stan Smith 2018-06-21 refactored error and warning messaging # Stan Smith 2018-01-27 add metadataConstraints # Stan Smith 2017-01-31 remove metadataCreationDate # Stan Smith 2016-10-31 original script require_relative 'module_identifier' @@ -23,129 +23,129 @@ module MetadataInfo def self.unpack(hMetaInfo, responseObj) + @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson # return nil object if input is empty if hMetaInfo.empty? - responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: metadata info object is empty' - responseObj[:readerExecutionPass] = false + @MessagePath.issueError(570, responseObj) return nil end # instance classes needed in script intMetadataClass = InternalMetadata.new intMetaInfo = intMetadataClass.newMetadataInfo + outContext = 'metadata-info' + # metadata information - metadata identifier {identifier} if hMetaInfo.has_key?('metadataIdentifier') hObject = hMetaInfo['metadataIdentifier'] unless hObject.empty? - hReturn = Identifier.unpack(hObject, responseObj) + hReturn = Identifier.unpack(hObject, responseObj, outContext) unless hReturn.nil? intMetaInfo[:metadataIdentifier] = hReturn end end end # metadata information - parent metadata {citation} if hMetaInfo.has_key?('parentMetadata') hObject = hMetaInfo['parentMetadata'] unless hObject.empty? - hReturn = Citation.unpack(hObject, responseObj) + hReturn = Citation.unpack(hObject, responseObj, outContext) unless hReturn.nil? intMetaInfo[:parentMetadata] = hReturn end end end # metadata information - default metadata locale {locale} (default to utf-8) if hMetaInfo.has_key?('defaultMetadataLocale') hObject = hMetaInfo['defaultMetadataLocale'] unless hObject.empty? - hReturn = Locale.unpack(hObject, responseObj) + hReturn = Locale.unpack(hObject, responseObj, outContext) unless hReturn.nil? intMetaInfo[:defaultMetadataLocale] = hReturn end end end # metadata information - other metadata locale [] {locale} if hMetaInfo.has_key?('otherMetadataLocale') aItems = hMetaInfo['otherMetadataLocale'] aItems.each do |item| - hReturn = Locale.unpack(item, responseObj) + hReturn = Locale.unpack(item, responseObj, outContext) unless hReturn.nil? intMetaInfo[:otherMetadataLocales] << hReturn end end end # metadata information - metadata contact [] {responsibleParty} (required) if hMetaInfo.has_key?('metadataContact') aItems = hMetaInfo['metadataContact'] aItems.each do |item| - hReturn = ResponsibleParty.unpack(item, responseObj) + hReturn = ResponsibleParty.unpack(item, responseObj, outContext) unless hReturn.nil? intMetaInfo[:metadataContacts] << hReturn end end end if intMetaInfo[:metadataContacts].empty? - responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: metadata info contact is missing' - responseObj[:readerExecutionPass] = false - return nil + @MessagePath.issueError(571, responseObj, outContext) end # metadata information - metadata dates [] {date} if hMetaInfo.has_key?('metadataDate') aItems = hMetaInfo['metadataDate'] aItems.each do |item| - hReturn = Date.unpack(item, responseObj) + hReturn = Date.unpack(item, responseObj, outContext) unless hReturn.nil? intMetaInfo[:metadataDates] << hReturn end end end # metadata information - metadata online resource [] {onlineResource} if hMetaInfo.has_key?('metadataOnlineResource') aItems = hMetaInfo['metadataOnlineResource'] aItems.each do |item| - hReturn = OnlineResource.unpack(item, responseObj) + hReturn = OnlineResource.unpack(item, responseObj, outContext) unless hReturn.nil? intMetaInfo[:metadataLinkages] << hReturn end end end # metadata information - metadata constraint [] {constraint} if hMetaInfo.has_key?('metadataConstraint') hMetaInfo['metadataConstraint'].each do |hItem| - hReturn = Constraint.unpack(hItem, responseObj) + hReturn = Constraint.unpack(hItem, responseObj, outContext) unless hReturn.nil? intMetaInfo[:metadataConstraints] << hReturn end end end # metadata information - metadata maintenance {maintenance} if hMetaInfo.has_key?('metadataMaintenance') hObject = hMetaInfo['metadataMaintenance'] unless hObject.empty? - hReturn = Maintenance.unpack(hObject, responseObj) + hReturn = Maintenance.unpack(hObject, responseObj, outContext) unless hReturn.nil? intMetaInfo[:metadataMaintenance] = hReturn end end end # metadata information - alternative metadata reference [] {citation} if hMetaInfo.has_key?('alternateMetadataReference') aItems = hMetaInfo['alternateMetadataReference'] aItems.each do |item| - hReturn = Citation.unpack(item, responseObj) + hReturn = Citation.unpack(item, responseObj, outContext) unless hReturn.nil? intMetaInfo[:alternateMetadataReferences] << hReturn end end end