diff options
-rw-r--r-- | lib/4store.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/4store.rb b/lib/4store.rb index f3ab026..77fa045 100644 --- a/lib/4store.rb +++ b/lib/4store.rb @@ -43,12 +43,10 @@ module OpenTox bad_request_error "Reqest body empty." unless rdf mime_type = "application/x-turtle" if mime_type == "text/plain" RestClientWrapper.put File.join(four_store_uri,"data",uri), rdf, :content_type => mime_type - # prevent 4store from dublicates - # sparql for modified time (DELETE WHERE is not supported)-> delete -> insert new time - date = query "SELECT ?date WHERE { <#{uri}> <#{RDF::DC.modified}> ?date }", "application/sparql-results+xml" - date = date.match("\<literal\>.*\<\/literal\>").to_s.gsub(/\<literal\>|<\/literal\>/, "") - update "DELETE DATA { GRAPH <#{uri}> { <#{uri}> <#{RDF::DC.modified}> \"#{date}\" } }" if date.size >0 - update "INSERT DATA { GRAPH <#{uri}> { <#{uri}> <#{RDF::DC.modified}> \"#{DateTime.now}\" } }" + update "WITH <#{uri}> + DELETE {<#{uri}> <{RDF::DC.modified}> ?o} + WHERE {<#{uri}> <{RDF::DC.modified}> ?o}; + INSERT DATA { GRAPH <#{uri}> { <#{uri}> <#{RDF::DC.modified}> \"#{DateTime.now}\" } }" end def self.delete uri |