lib/adiwg/mdtranslator/readers/mdJson/modules/module_source.rb in adiwg-mdtranslator-2.12.0 vs lib/adiwg/mdtranslator/readers/mdJson/modules/module_source.rb in adiwg-mdtranslator-2.13.0
- old
+ new
@@ -33,26 +33,26 @@
# instance classes needed in script
intMetadataClass = InternalMetadata.new
intSource = intMetadataClass.newDataSource
+ haveRequired = false
+
# source - source ID
if hSource.has_key?('sourceId')
unless hSource['sourceId'] == ''
intSource[:sourceId] = hSource['sourceId']
end
end
- # source - description (required)
+ # source - description (required if)
if hSource.has_key?('description')
- intSource[:description] = hSource['description']
+ unless hSource['description'] == ''
+ intSource[:description] = hSource['description']
+ haveRequired = true
+ end
end
- if intSource[:description].nil? || intSource[:description] == ''
- responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: source description is missing'
- responseObj[:readerExecutionPass] = false
- return nil
- end
# source - source citation
if hSource.has_key?('sourceCitation')
hObject = hSource['sourceCitation']
unless hObject.empty?
@@ -112,11 +112,19 @@
hObject = hSource['scope']
unless hObject.empty?
hReturn = Scope.unpack(hObject, responseObj)
unless hReturn.nil?
intSource[:scope] = hReturn
+ haveRequired = true
end
end
+ end
+
+ unless haveRequired
+ responseObj[:readerExecutionMessages] <<
+ 'ERROR: mdJson reader: source requires a description or scope'
+ responseObj[:readerExecutionPass] = false
+ return nil
end
return intSource
end