From e904ce55da3d59744a5345f9c0b56f9c35971844 Mon Sep 17 00:00:00 2001 From: gebele Date: Mon, 27 May 2013 16:51:36 +0200 Subject: changed method to avoid dublicates in modified date --- lib/4store.rb | 10 ++++------ 1 file 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\>").to_s.gsub(/\|<\/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 -- cgit v1.2.3