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

- old
+ new

@@ -1,72 +1,72 @@ # unpack scope # Reader - ADIwg JSON to internal data structure # History: +# Stan Smith 2018-02-19 refactored error and warning messaging # Stan Smith 2016-10-14 original script require_relative 'module_scopeDescription' require_relative 'module_timePeriod' require_relative 'module_extent' module ADIWG - module Mdtranslator - module Readers - module MdJson + module Mdtranslator + module Readers + module MdJson - module Scope + module Scope - def self.unpack(hScope, responseObj) + def self.unpack(hScope, responseObj) - # return nil object if input is empty - if hScope.empty? - responseObj[:readerExecutionMessages] << 'Scope object is empty' - responseObj[:readerExecutionPass] = false - return nil - end + # return nil object if input is empty + if hScope.empty? + responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: mdJson scope object is empty' + return nil + end - # instance classes needed in script - intMetadataClass = InternalMetadata.new - intScope = intMetadataClass.newScope + # instance classes needed in script + intMetadataClass = InternalMetadata.new + intScope = intMetadataClass.newScope - # scope - scope code (required) - if hScope.has_key?('scopeCode') - intScope[:scopeCode] = hScope['scopeCode'] - end - if intScope[:scopeCode].nil? || intScope[:scopeCode] == '' - responseObj[:readerExecutionMessages] << 'Scope attribute scopeCode is missing' - responseObj[:readerExecutionPass] = false - return nil - end + # scope - scope code (required) + if hScope.has_key?('scopeCode') + intScope[:scopeCode] = hScope['scopeCode'] + end + if intScope[:scopeCode].nil? || intScope[:scopeCode] == '' + responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: scope scopeCode is missing' + responseObj[:readerExecutionPass] = false + return nil + end - # scope - scope description [] {MD_ScopeDescription} - if hScope.has_key?('scopeDescription') - aScopeDes = hScope['scopeDescription'] - aScopeDes.each do |item| - hScopeDes = ScopeDescription.unpack(item, responseObj) - unless hScopeDes.nil? - intScope[:scopeDescriptions] << hScopeDes - end - end + # scope - scope description [] {MD_ScopeDescription} + if hScope.has_key?('scopeDescription') + aScopeDes = hScope['scopeDescription'] + aScopeDes.each do |item| + hScopeDes = ScopeDescription.unpack(item, responseObj) + unless hScopeDes.nil? + intScope[:scopeDescriptions] << hScopeDes end + end + end - # scope - extent [] {EX_Extent} - if hScope.has_key?('scopeExtent') - aExtents = hScope['scopeExtent'] - aExtents.each do |item| - hExtent = Extent.unpack(item, responseObj) - unless hExtent.nil? - intScope[:extents] << hExtent - end - end + # scope - extent [] {EX_Extent} + if hScope.has_key?('scopeExtent') + aExtents = hScope['scopeExtent'] + aExtents.each do |item| + hExtent = Extent.unpack(item, responseObj) + unless hExtent.nil? + intScope[:extents] << hExtent end + end + end - return intScope + return intScope - end + end - end - end - end - end + + end + end + end end