lib/adiwg/mdtranslator/readers/mdJson/modules/module_extent.rb in adiwg-mdtranslator-2.13.0 vs lib/adiwg/mdtranslator/readers/mdJson/modules/module_extent.rb in adiwg-mdtranslator-2.13.1
- old
+ new
@@ -1,10 +1,10 @@
# unpack a extent
# Reader - mdJson 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 2016-10-30 original script
require_relative 'module_geographicExtent'
require_relative 'module_temporalExtent'
require_relative 'module_verticalExtent'
@@ -14,22 +14,27 @@
module Readers
module MdJson
module Extent
- def self.unpack(hExtent, responseObj)
+ def self.unpack(hExtent, responseObj, inContext = nil)
+ @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson
+
# return nil object if input is empty
if hExtent.empty?
- responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: extent object is empty'
+ @MessagePath.issueWarning(270, responseObj, inContext)
return nil
end
# instance classes needed in script
intMetadataClass = InternalMetadata.new
intExtent = intMetadataClass.newExtent
+ outContext = 'extent'
+ outContext = inContext + ' > ' + outContext unless inContext.nil?
+
haveExtent = false
# extent - description
if hExtent.has_key?('description')
unless hExtent['description'] == ''
@@ -40,11 +45,11 @@
# extent - geographicExtent
if hExtent.has_key?('geographicExtent')
hExtent['geographicExtent'].each do |item|
unless item.empty?
- hReturn = GeographicExtent.unpack(item, responseObj)
+ hReturn = GeographicExtent.unpack(item, responseObj, outContext)
unless hReturn.nil?
intExtent[:geographicExtents] << hReturn
haveExtent = true
end
end
@@ -53,11 +58,11 @@
# extent - temporalExtent
if hExtent.has_key?('temporalExtent')
hExtent['temporalExtent'].each do |item|
unless item.empty?
- hReturn = TemporalExtent.unpack(item, responseObj)
+ hReturn = TemporalExtent.unpack(item, responseObj, outContext)
unless hReturn.nil?
intExtent[:temporalExtents] << hReturn
haveExtent = true
end
end
@@ -66,24 +71,21 @@
# extent - verticalExtent
if hExtent.has_key?('verticalExtent')
hExtent['verticalExtent'].each do |item|
unless item.empty?
- hReturn = VerticalExtent.unpack(item, responseObj)
+ hReturn = VerticalExtent.unpack(item, responseObj, outContext)
unless hReturn.nil?
intExtent[:verticalExtents] << hReturn
haveExtent = true
end
end
end
end
# error messages
unless haveExtent
- responseObj[:readerExecutionMessages] <<
- 'ERROR: mdJson reader: extent must have description or at least one geographic, temporal, or vertical extent'
- responseObj[:readerExecutionPass] = false
- return nil
+ @MessagePath.issueError(271, responseObj, inContext)
end
return intExtent
end