From 03d8866d13857a8b18ecbb932c8dbb4f35b662f4 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Fri, 6 Jul 2012 16:48:59 +0200 Subject: feature and task tests pass --- application.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/application.rb b/application.rb index f523775..77426d3 100644 --- a/application.rb +++ b/application.rb @@ -2,9 +2,10 @@ module OpenTox class Application < Service helpers do + def status_code uri sparql = "SELECT ?o WHERE { GRAPH <#{uri}> { <#{uri}> <#{RDF::OT.hasStatus}> ?o. } }" - status = Backend::FourStore.query(sparql,nil).last.gsub(/"|'/,'').gsub(/\^\^.*$/,'') + status = Backend::FourStore.query(sparql,"text/uri-list") case status when "Completed" 200 @@ -14,7 +15,7 @@ module OpenTox 503 when "Error" sparql = "SELECT ?code WHERE { GRAPH <#{uri}> { <#{uri}> <#{RDF::OT.error}> ?error. ?error <#{RDF::OT.statusCode}> ?code } }" - code = Backend::FourStore.query(sparql,nil).last.to_i + code = Backend::FourStore.query(sparql,"text/uri-list").to_i code ? code : 500 end end @@ -24,10 +25,11 @@ module OpenTox get '/task/:id/?' do uri = uri("/task/#{params[:id]}") code = status_code(uri) - if request.env['HTTP_ACCEPT'] == "text/uri-list" # return resultURI + #code = 200 + if @accept == "text/uri-list" # return resultURI halt code, uri unless code == 200 sparql = "SELECT ?o WHERE { GRAPH <#{uri}> { <#{uri}> <#{RDF::OT.resultURI}> ?o. } }" - result_uri = Backend::FourStore.query(sparql,nil).last.gsub(/"|'/,'').gsub(/\^\^.*$/,'') + result_uri = Backend::FourStore.query(sparql,"text/uri-list").gsub(/"|'/,'').gsub(/\^\^.*$/,'') halt code, result_uri else rdf = FourStore.get(uri, request.env['HTTP_ACCEPT']) -- cgit v1.2.3