diff options
author | Andreas Maunz <andreas@maunz.de> | 2012-10-31 12:24:00 +0100 |
---|---|---|
committer | Andreas Maunz <andreas@maunz.de> | 2012-10-31 12:24:00 +0100 |
commit | dfe5b9523a18dbb86bab433df8136166c9938d12 (patch) | |
tree | b8d7709f6286541d537831d550857d9a6b8bdbe5 /application.rb | |
parent | a1f96efdda366ba19f70222bc2e145b6fe730a54 (diff) |
Added allnde target, correct order for uri-list requests
Diffstat (limited to 'application.rb')
-rw-r--r-- | application.rb | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/application.rb b/application.rb index 65cab40..2d54eb2 100644 --- a/application.rb +++ b/application.rb @@ -453,7 +453,7 @@ module OpenTox get '/dataset/:id/metadata' do case @accept when "application/rdf+xml", "text/turtle", "text/plain" - sparql = "CONSTRUCT {?s ?p ?o.} FROM <#{@uri}> WHERE {<#{@uri}> ?p ?o. }" + sparql = "CONSTRUCT {?s ?p ?o.} FROM <#{@uri}> WHERE { ?s ?p ?o. <#{@uri}> ?p ?o. }" FourStore.query sparql, @accept else bad_request_error "'#{@accept}' is not a supported content type." @@ -462,13 +462,13 @@ module OpenTox # Get a list of all features # @param [Header] Accept one of `application/rdf+xml, text/turtle, text/plain, text/uri-list` (default application/rdf+xml) - # @return [application/rdf+xml, text/turtle, text/plain, text/uri-list] Feature list + # @return [application/rdf+xml, text/turtle, text/plain, text/uri-list] Feature data get '/dataset/:id/features' do case @accept when "application/rdf+xml", "text/turtle", "text/plain" sparql = "CONSTRUCT {?s ?p ?o.} FROM <#{@uri}> WHERE {?s <#{RDF.type}> <#{RDF::OT.Feature}>; ?p ?o. }" when "text/uri-list" - sparql = "SELECT DISTINCT ?s FROM <#{@uri}> WHERE {?s <#{RDF.type}> <#{RDF::OT.Feature}>. }" + sparql = "SELECT DISTINCT ?s FROM <#{@uri}> WHERE {?s <#{RDF.type}> <#{RDF::OT.Feature}>. ?s <#{RDF::OLO.index}> ?idx } ORDER BY ?idx" else bad_request_error "'#{@accept}' is not a supported content type." end @@ -476,18 +476,34 @@ module OpenTox end # Get a list of all compounds - # @return [text/uri-list] Feature list + # @param [Header] Accept one of `application/rdf+xml, text/turtle, text/plain, text/uri-list` (default application/rdf+xml) + # @return [application/rdf+xml, text/turtle, text/plain, text/uri-list] Compound data get '/dataset/:id/compounds' do case @accept when "application/rdf+xml", "text/turtle", "text/plain" sparql = "CONSTRUCT {?s ?p ?o.} FROM <#{@uri}> WHERE {?s <#{RDF.type}> <#{RDF::OT.Compound}>; ?p ?o. }" when "text/uri-list" - sparql = "SELECT DISTINCT ?s FROM <#{@uri}> WHERE {?s <#{RDF.type}> <#{RDF::OT.Compound}>. }" + sparql = "SELECT DISTINCT ?s FROM <#{@uri}> WHERE {?s <#{RDF.type}> <#{RDF::OT.Compound}>. ?s <#{RDF::OLO.index}> ?idx } ORDER BY ?idx" + else + bad_request_error "'#{@accept}' is not a supported content type." + end + FourStore.query sparql, @accept + end + + # Get everything but the data entries + # @param [Header] Accept one of `application/rdf+xml, text/turtle, text/plain, text/uri-list` (default application/rdf+xml) + # @return [application/rdf+xml, text/turtle, text/plain, text/uri-list] The data + get '/dataset/:id/allnde' do + case @accept + when "application/rdf+xml", "text/turtle", "text/plain" + sparql = "CONSTRUCT {?s ?p ?o.} FROM <#{@uri}> WHERE { { ?s ?p ?o. <#{@uri}> ?p ?o. } UNION { ?s ?p ?o. ?s <#{RDF.type}> <#{RDF::OT.Feature}> } UNION { ?s ?p ?o. ?s <#{RDF.type}> <#{RDF::OT.Compound}> } }" else bad_request_error "'#{@accept}' is not a supported content type." end FourStore.query sparql, @accept end + + end end |