From 9fc686c9f1dbf6155a95d6a9c884bc9eb531c797 Mon Sep 17 00:00:00 2001 From: gebele Date: Wed, 5 Nov 2014 14:06:33 +0100 Subject: fixed metadata call for find_or_create, flatten arrays in object; ensure right quotation for string objects --- lib/opentox.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/opentox.rb') diff --git a/lib/opentox.rb b/lib/opentox.rb index 16cecca..9564e9c 100644 --- a/lib/opentox.rb +++ b/lib/opentox.rb @@ -244,14 +244,18 @@ module OpenTox def self.find_or_create metadata t = Time.now sparql = "SELECT DISTINCT ?s WHERE { " + # flatten 3.level arrays in objects + metadata.each{|p,o| o.flatten! if o.is_a? Array} metadata.each do |predicate,objects| unless [RDF::DC.date,RDF::DC.modified,RDF::DC.description].include? predicate # remove dates and description (strange characters in description may lead to SPARQL errors) if objects.is_a? String - URI.valid?(objects) ? o = "<#{objects}>" : o = "'''#{objects}'''" + #URI.valid?(objects) ? o = "<#{objects}>" : o = "'''#{objects}'''" #DG: do not understand this quotation + URI.valid?(objects) ? o = "<#{objects}>" : o = "\"#{objects}\"" sparql << "?s <#{predicate}> #{o}. " elsif objects.is_a? Array objects.each do |object| - URI.valid?(object) ? o = "<#{object}>" : o = "'#{object}'" + #URI.valid?(object) ? o = "<#{object}>" : o = "'#{object}'" #DG: do not understand this quotation + URI.valid?(object) ? o = "<#{object}>" : o = "\"#{object}\"" sparql << "?s <#{predicate}> #{o}. " end end -- cgit v1.2.3