diff options
author | gebele <gebele@in-silico.ch> | 2013-05-27 16:51:36 +0200 |
---|---|---|
committer | gebele <gebele@in-silico.ch> | 2013-05-27 16:51:36 +0200 |
commit | e904ce55da3d59744a5345f9c0b56f9c35971844 (patch) | |
tree | b39b72bec83e3d996776b805aad7cd193513b7e1 | |
parent | 48df3bf1b0c8f0dc68a3f91e93448d55a0cf5c0e (diff) |
changed method to avoid dublicates in modified date
-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 |