From 0d8bc5916106cea30433aad18573cf68cd977059 Mon Sep 17 00:00:00 2001 From: gebele Date: Mon, 10 Jun 2013 16:59:26 +0200 Subject: return unordered uri-list --- lib/4store.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/4store.rb b/lib/4store.rb index 1377643..00414c0 100644 --- a/lib/4store.rb +++ b/lib/4store.rb @@ -8,8 +8,8 @@ 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.date}> ?o.} } ORDER BY ?o" - else + sparql = "SELECT DISTINCT ?g WHERE {GRAPH ?g {?s <#{RDF.type}> <#{klass}>} }" + else sparql = "CONSTRUCT {?s ?p ?o.} WHERE {?s <#{RDF.type}> <#{klass}>; ?p ?o. }" end query sparql, mime_type -- cgit v1.2.3 From b92b9702d8c8f8d864d2069e36d05203eb31aa37 Mon Sep 17 00:00:00 2001 From: gebele Date: Mon, 10 Jun 2013 17:01:34 +0200 Subject: new route for internal purposes; last modified uris --- lib/opentox.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/opentox.rb b/lib/opentox.rb index e5305fd..80339b4 100644 --- a/lib/opentox.rb +++ b/lib/opentox.rb @@ -131,6 +131,17 @@ module OpenTox end end + # internal route not in API + # example: /SERVICE/last/0 returns last 10 modified uris (default) + # example: /SERVICE/last/5 returns last 5 modified uris + get "/#{SERVICE}/last/:limit/?" do + limit = params[:limit].to_i > 0 ? params[:limit].to_i : 10 + FourStore.query("SELECT DISTINCT ?g WHERE + {GRAPH ?g + {?s <#{RDF::DC.modified}> ?o.} + } ORDER BY ?o LIMIT #{limit}", @accept) + end + # Create a new resource post "/#{SERVICE}/?" do @uri = uri("/#{SERVICE}/#{SecureRandom.uuid}") -- cgit v1.2.3 From c934e64879a30f640fc2b9fcaa28daacd874cd59 Mon Sep 17 00:00:00 2001 From: gebele Date: Tue, 11 Jun 2013 12:45:30 +0200 Subject: added missing accept format for uri-list --- lib/4store.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/4store.rb b/lib/4store.rb index 00414c0..24200ae 100644 --- a/lib/4store.rb +++ b/lib/4store.rb @@ -7,10 +7,10 @@ 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)/ + if mime_type =~ /(uri-list|html|sparql-results)/ sparql = "SELECT DISTINCT ?g WHERE {GRAPH ?g {?s <#{RDF.type}> <#{klass}>} }" else - sparql = "CONSTRUCT {?s ?p ?o.} WHERE {?s <#{RDF.type}> <#{klass}>; ?p ?o. }" + sparql = "CONSTRUCT {?s <#{RDF.type}> <#{klass}>.} WHERE { GRAPH ?g {?s <#{RDF.type}> <#{klass}>.} }" end query sparql, mime_type end -- cgit v1.2.3 From 93b90b0800f8c339eb1a495c23634921abce321f Mon Sep 17 00:00:00 2001 From: gebele Date: Wed, 12 Jun 2013 19:10:50 +0200 Subject: changed sparql string to return subgraph subject --- lib/4store.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/4store.rb b/lib/4store.rb index 24200ae..0c78580 100644 --- a/lib/4store.rb +++ b/lib/4store.rb @@ -8,7 +8,7 @@ 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-results)/ - sparql = "SELECT DISTINCT ?g WHERE {GRAPH ?g {?s <#{RDF.type}> <#{klass}>} }" + sparql = "SELECT DISTINCT ?s WHERE {GRAPH ?g {?s <#{RDF.type}> <#{klass}>.} }" else sparql = "CONSTRUCT {?s <#{RDF.type}> <#{klass}>.} WHERE { GRAPH ?g {?s <#{RDF.type}> <#{klass}>.} }" end -- cgit v1.2.3 From 1313f579dd1ca8bad2c8a0d717ad24ecb7939400 Mon Sep 17 00:00:00 2001 From: gebele Date: Wed, 12 Jun 2013 19:13:00 +0200 Subject: removed sparql LIMIT; changed internal route /last/:limit to /ordered --- lib/opentox.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/opentox.rb b/lib/opentox.rb index 80339b4..3adca81 100644 --- a/lib/opentox.rb +++ b/lib/opentox.rb @@ -134,12 +134,11 @@ module OpenTox # internal route not in API # example: /SERVICE/last/0 returns last 10 modified uris (default) # example: /SERVICE/last/5 returns last 5 modified uris - get "/#{SERVICE}/last/:limit/?" do - limit = params[:limit].to_i > 0 ? params[:limit].to_i : 10 - FourStore.query("SELECT DISTINCT ?g WHERE + get "/#{SERVICE}/ordered/?" do + FourStore.query("SELECT DISTINCT ?s WHERE {GRAPH ?g - {?s <#{RDF::DC.modified}> ?o.} - } ORDER BY ?o LIMIT #{limit}", @accept) + {?s <#{RDF.type}> <#{RDF::OT}#{SERVICE.capitalize}>; <#{RDF::DC.date}> ?o. } + } ORDER BY ?o ", @accept) end # Create a new resource -- cgit v1.2.3 From df1d9c779eed10affa4f8bdcccd5a77eaa57ec9a Mon Sep 17 00:00:00 2001 From: gebele Date: Thu, 13 Jun 2013 11:29:10 +0200 Subject: changed route --- lib/opentox.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/opentox.rb b/lib/opentox.rb index 3adca81..e3f1910 100644 --- a/lib/opentox.rb +++ b/lib/opentox.rb @@ -132,9 +132,7 @@ module OpenTox end # internal route not in API - # example: /SERVICE/last/0 returns last 10 modified uris (default) - # example: /SERVICE/last/5 returns last 5 modified uris - get "/#{SERVICE}/ordered/?" do + get "/#{SERVICE}/last/ordered/?" do FourStore.query("SELECT DISTINCT ?s WHERE {GRAPH ?g {?s <#{RDF.type}> <#{RDF::OT}#{SERVICE.capitalize}>; <#{RDF::DC.date}> ?o. } -- cgit v1.2.3