diff options
author | gebele <gebele@in-silico.ch> | 2014-11-05 14:06:33 +0100 |
---|---|---|
committer | gebele <gebele@in-silico.ch> | 2014-11-05 14:06:33 +0100 |
commit | 9fc686c9f1dbf6155a95d6a9c884bc9eb531c797 (patch) | |
tree | 9dfd6082506384262833874b00a97cdaaa7e8ba2 | |
parent | ed06e45d0b21987f53875615b055fcd0a1829bd6 (diff) |
fixed metadata call for find_or_create, flatten arrays in object; ensure right quotation for string objects
-rw-r--r-- | lib/opentox.rb | 8 |
1 files changed, 6 insertions, 2 deletions
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 |