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

- old
+ new

@@ -1,55 +1,55 @@ # unpack vector object # Reader - ADIwg JSON to internal data structure # History: +# Stan Smith 2018-02-19 refactored error and warning messaging # Stan Smith 2016-10-19 original script module ADIWG - module Mdtranslator - module Readers - module MdJson + module Mdtranslator + module Readers + module MdJson - module VectorObject + module VectorObject - def self.unpack(hVecObj, responseObj) + def self.unpack(hVecObj, responseObj) - # return nil object if input is empty - if hVecObj.empty? - responseObj[:readerExecutionMessages] << 'Vector Object object is empty' - responseObj[:readerExecutionPass] = false - return nil - end + # return nil object if input is empty + if hVecObj.empty? + responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: vector object is empty' + return nil + end - # instance classes needed in script - intMetadataClass = InternalMetadata.new - intVecObj = intMetadataClass.newVectorObject + # instance classes needed in script + intMetadataClass = InternalMetadata.new + intVecObj = intMetadataClass.newVectorObject - # vector object - object type (required) - if hVecObj.has_key?('objectType') - if hVecObj['objectType'] != '' - intVecObj[:objectType] = hVecObj['objectType'] - end - end - if intVecObj[:objectType].nil? - responseObj[:readerExecutionMessages] << 'Vector Object attribute objectType is missing' - responseObj[:readerExecutionPass] = false - return nil - end + # vector object - object type (required) + if hVecObj.has_key?('objectType') + unless hVecObj['objectType'] == '' + intVecObj[:objectType] = hVecObj['objectType'] + end + end + if intVecObj[:objectType].nil? + responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: vector object type is missing' + responseObj[:readerExecutionPass] = false + return nil + end - # vector object - object count - if hVecObj.has_key?('objectCount') - if hVecObj['objectCount'] != '' - intVecObj[:objectCount] = hVecObj['objectCount'] - end - end + # vector object - object count + if hVecObj.has_key?('objectCount') + unless hVecObj['objectCount'] == '' + intVecObj[:objectCount] = hVecObj['objectCount'] + end + end - return intVecObj + return intVecObj - end + end - end - end - end - end + + end + end + end end