From ad4d8d455bddbf4b54fd168b795623c6b9d12ea9 Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Mon, 23 May 2011 13:54:09 +0200 Subject: Hotfix: forgot to update version --- application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application.rb b/application.rb index 7e8e9bc..4008a74 100644 --- a/application.rb +++ b/application.rb @@ -1,5 +1,5 @@ require 'rubygems' -gem "opentox-ruby", "~> 1" +gem "opentox-ruby", "~> 2" require 'opentox-ruby' set :lock, true -- cgit v1.2.3 From dcb32e4271cb1cab70f3669985e8e34c87e3bf23 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 6 Jun 2011 16:54:56 +0000 Subject: halts (partially) substituted by OpenTox errors --- application.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/application.rb b/application.rb index 4008a74..749dbcc 100644 --- a/application.rb +++ b/application.rb @@ -93,7 +93,7 @@ before do @uri = uri @id @yaml_file = "public/#{@id}.yaml" - halt 404, "Dataset #{@id} not found." unless File.exists? @yaml_file + raise OpenTox::NotFoundError.new "Dataset #{@id} not found." unless File.exists? @yaml_file extension = File.extname(request.path_info) unless extension.empty? @@ -109,7 +109,7 @@ before do when ".xls" @accept = 'application/ms-excel' else - halt 404, "File format #{extension} not supported." + raise OpenTox::NotFoundError.new "File format #{extension} not supported." end end end @@ -162,7 +162,7 @@ get '/:id' do File.open(file).read else - halt 404, "Content-type #{@accept} not supported." + raise OpenTox::NotFoundError.new "Content-type #{@accept} not supported." end end @@ -270,7 +270,7 @@ post '/?' do OpenTox::Authorization.check_policy(@uri, @subjectid) if File.exists? @yaml_file @uri end - halt 503,task.uri+"\n" if task.status == "Cancelled" + raise OpenTox::ServiceUnavailableError.newtask.uri+"\n" if task.status == "Cancelled" halt 202,task.uri+"\n" end end @@ -294,7 +294,7 @@ post '/:id' do load_dataset @id, params, request.content_type, request.env["rack.input"].read @uri end - halt 503,task.uri+"\n" if task.status == "Cancelled" + raise OpenTox::ServiceUnavailableError.newtask.uri+"\n" if task.status == "Cancelled" halt 202,task.uri.to_s+"\n" end @@ -315,7 +315,7 @@ delete '/:id' do response['Content-Type'] = 'text/plain' "Dataset #{@id} deleted." rescue - halt 404, "Dataset #{@id} does not exist." + raise OpenTox::NotFoundError.new "Dataset #{@id} does not exist." end end -- cgit v1.2.3 From 3bc3b9b907acbb396463188e34cb04e99da1fb57 Mon Sep 17 00:00:00 2001 From: mguetlein Date: Wed, 29 Jun 2011 11:36:45 +0200 Subject: add html support for dataset listing --- application.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/application.rb b/application.rb index 749dbcc..a77d5d3 100644 --- a/application.rb +++ b/application.rb @@ -123,8 +123,15 @@ end # Get a list of available datasets # @return [text/uri-list] List of available datasets get '/?' do - response['Content-Type'] = 'text/uri-list' - Dir["./public/*yaml"].collect{|f| File.basename(f.sub(/.yaml/,'')).to_i}.sort.collect{|n| uri n}.join("\n") + "\n" + uri_list = Dir["./public/*yaml"].collect{|f| File.basename(f.sub(/.yaml/,'')).to_i}.sort.collect{|n| uri n}.join("\n") + "\n" + case @accept + when /html/ + response['Content-Type'] = 'text/html' + OpenTox.text_to_html uri_list + else + response['Content-Type'] = 'text/uri-list' + uri_list + end end # Get a dataset representation -- cgit v1.2.3 From 4f98fc6c5733e4f2760f73c93f437b062d6a8695 Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Thu, 21 Jul 2011 14:01:40 +0200 Subject: Support for SDF in GET --- application.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/application.rb b/application.rb index a77d5d3..c64d5ce 100644 --- a/application.rb +++ b/application.rb @@ -168,6 +168,10 @@ get '/:id' do response['Content-Type'] = 'application/ms-excel' File.open(file).read + when /chemical\/x-mdl-sdfile/ + response['Content-Type'] = 'chemical/x-mdl-sdfile' + YAML.load_file(@yaml_file).to_sdf + else raise OpenTox::NotFoundError.new "Content-type #{@accept} not supported." end -- cgit v1.2.3 From acd586185ace0cf7bfc477951fb06fce4c88f385 Mon Sep 17 00:00:00 2001 From: Andreas Maunz Date: Thu, 28 Jul 2011 11:18:28 +0200 Subject: Added support for uri-list and sdf --- application.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/application.rb b/application.rb index c64d5ce..cdbaef2 100644 --- a/application.rb +++ b/application.rb @@ -168,10 +168,14 @@ get '/:id' do response['Content-Type'] = 'application/ms-excel' File.open(file).read - when /chemical\/x-mdl-sdfile/ + when /sdfile/ response['Content-Type'] = 'chemical/x-mdl-sdfile' YAML.load_file(@yaml_file).to_sdf + when /uri-list/ + response['Content-Type'] = 'text/uri-list' + YAML.load_file(@yaml_file).to_urilist + else raise OpenTox::NotFoundError.new "Content-type #{@accept} not supported." end -- cgit v1.2.3 From 0067f6f05b28709e5c34ab064fc4002b4eaaa552 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 28 Jul 2011 12:23:14 +0000 Subject: sdf upload enabled --- application.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/application.rb b/application.rb index c64d5ce..8c52ecb 100644 --- a/application.rb +++ b/application.rb @@ -22,6 +22,7 @@ helpers do raise "store subject-id in dataset-object, not in params" if params.has_key?(:subjectid) and @subjectid==nil content_type = "application/rdf+xml" if content_type.nil? + #dataset = OpenTox::Dataset.new(@uri, @subjectid) dataset = OpenTox::Dataset.new(nil, @subjectid) case content_type @@ -31,11 +32,17 @@ helpers do when /application\/rdf\+xml/ dataset.load_rdfxml(input_data) + + when "chemical/x-mdl-sdfile" + dataset.load_sdf(input_data) when /multipart\/form-data/ , "application/x-www-form-urlencoded" # file uploads case params[:file][:type] + when "chemical/x-mdl-sdfile" + dataset.load_sdf(input_data) + when /yaml/ dataset.load_yaml(params[:file][:tempfile].read) @@ -43,7 +50,7 @@ helpers do dataset.load_rdfxml_file(params[:file][:tempfile]) when "text/csv" - dataset = OpenTox::Dataset.new @uri + #dataset = OpenTox::Dataset.new @uri dataset.load_csv(params[:file][:tempfile].read) dataset.add_metadata({ DC.title => File.basename(params[:file][:filename],".csv"), -- cgit v1.2.3 From 97e7f0e0ffa690d5744886e9e0d8431d1c505e11 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Fri, 29 Jul 2011 12:10:58 +0000 Subject: SDF export with data items --- application.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/application.rb b/application.rb index 223a207..2f231f7 100644 --- a/application.rb +++ b/application.rb @@ -115,6 +115,8 @@ before do @accept = 'application/rdf+xml' when ".xls" @accept = 'application/ms-excel' + when ".sdf" + @accept = 'chemical/x-mdl-sdfile' else raise OpenTox::NotFoundError.new "File format #{extension} not supported." end -- cgit v1.2.3