summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2013-06-05 19:43:14 +0200
committerChristoph Helma <helma@in-silico.ch>2013-06-05 19:43:14 +0200
commitde79524895b0a0be4bdf2113781d14a8439ea2dc (patch)
tree44446def3b2c4742194f21192f6d96884848b058
parentb3f82247d347429a30881ac7f35677f87f503976 (diff)
list sorting removed. DC.modified inserted.
-rw-r--r--lib/4store.rb22
-rw-r--r--lib/opentox.rb1
2 files changed, 17 insertions, 6 deletions
diff --git a/lib/4store.rb b/lib/4store.rb
index b8aaca9..5fb2020 100644
--- a/lib/4store.rb
+++ b/lib/4store.rb
@@ -8,7 +8,19 @@ module OpenTox
def self.list mime_type
bad_request_error "'#{mime_type}' is not a supported mime type. Please specify one of #{@@accept_formats.join(", ")} in the Accept Header." unless @@accept_formats.include? mime_type
if mime_type =~ /(uri-list|html)/
- sparql = "SELECT DISTINCT ?g WHERE {GRAPH ?g {?s <#{RDF.type}> <#{klass}>; <#{RDF::DC.modified}> ?o.} } ORDER BY ?o"
+ sparql = "SELECT DISTINCT ?g WHERE {GRAPH ?g {?g ?p ?o} }"
+=begin
+ #sparql = "SELECT DISTINCT ?g WHERE {GRAPH ?g {?s <#{RDF.type}> <#{klass}>; <#{RDF::DC.modified}> ?o.} } ORDER BY ?o"
+ # not working for multiple DC.modified
+ sparql = "SELECT DISTINCT ?g WHERE {
+ GRAPH ?g {
+ ?g <#{RDF.type}> <#{klass}>.
+ OPTIONAL {?g <#{RDF::DC.date}> ?date.}
+ OPTIONAL {?g <#{RDF::OT.created_at}> ?date.}
+ OPTIONAL {?g <#{RDF::DC.modified}> ?date.}
+ }
+ } ORDER BY ?date"
+=end
else
sparql = "CONSTRUCT {?s ?p ?o.} WHERE {?s <#{RDF.type}> <#{klass}>; ?p ?o. }"
end
@@ -16,7 +28,7 @@ module OpenTox
end
def self.head uri
- sparql = "SELECT DISTINCT ?g WHERE {GRAPH ?g {<#{uri}> <#{RDF::DC.modified}> ?o.} }"
+ sparql = "SELECT DISTINCT ?g WHERE {GRAPH ?g {<#{uri}> ?p ?o.} }"
rdf = query sparql, 'application/sparql-results+xml'
resource_not_found_error "#{uri} not found." unless rdf.match("#{uri}")
rdf
@@ -34,8 +46,8 @@ module OpenTox
bad_request_error "'#{mime_type}' is not a supported content type. Please use one of #{@@content_type_formats.join(", ")}." unless @@content_type_formats.include? mime_type or mime_type == "multipart/form-data"
bad_request_error "Request body empty." unless rdf
mime_type = "application/x-turtle" if mime_type == "text/plain" # ntriples is turtle in 4store
- RestClient.post File.join(four_store_uri,"data")+"/", :data => rdf.gsub(/\\C/,'C'), :graph => uri, "mime-type" => mime_type # remove backslashes in SMILES (4store interprets them as UTF-8 \C even within single quoates)
- #update "INSERT DATA { GRAPH <#{uri}> { <#{uri}> <#{RDF::DC.modified}> \"#{DateTime.now}\" } }"
+ RestClient.post File.join(four_store_uri,"data")+"/", :data => rdf.gsub(/\\C/,'C'), :graph => uri, "mime-type" => mime_type # remove backslashes in SMILES (4store interprets them as UTF-8 \C even within single quotes)
+ update "INSERT DATA { GRAPH <#{uri}> { <#{uri}> <#{RDF::DC.modified}> \"#{DateTime.now}\" } }"
end
def self.put uri, rdf, mime_type
@@ -44,7 +56,7 @@ module OpenTox
mime_type = "application/x-turtle" if mime_type == "text/plain"
RestClientWrapper.put File.join(four_store_uri,"data",uri), rdf, :content_type => mime_type
# update moved to opentox-client to improve performance
- #update "INSERT DATA { GRAPH <#{uri}> { <#{uri}> <#{RDF::DC.modified}> \"#{DateTime.now}\" } }"
+ update "INSERT DATA { GRAPH <#{uri}> { <#{uri}> <#{RDF::DC.modified}> \"#{DateTime.now}\" } }"
# RestClientWrapper.put File.join(four_store_uri,"data",uri), rdf, :content_type => mime_type
# update "WITH <#{uri}>
# DELETE {<#{uri}> <{RDF::DC.modified}> ?o}
diff --git a/lib/opentox.rb b/lib/opentox.rb
index 0869262..b7b363c 100644
--- a/lib/opentox.rb
+++ b/lib/opentox.rb
@@ -29,7 +29,6 @@ module OpenTox
before do
@uri = uri(request.env['PATH_INFO']) # prevent /algorithm/algorithm in algorithm service
- #@uri = uri(request.env['REQUEST_URI'])
get_subjectid if respond_to? :get_subjectid
# fix IE
request.env['HTTP_ACCEPT'] += ";text/html" if request.env["HTTP_USER_AGENT"]=~/MSIE/