diff options
author | Christoph Helma <helma@in-silico.ch> | 2010-09-13 18:38:16 +0200 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2010-09-13 18:38:16 +0200 |
commit | 992dace31947a934788e3de11fd7fafb46685168 (patch) | |
tree | 22b86b488e604cb653116e1453d869e45bb03bf1 | |
parent | 28b78aca88f9776ee32c98bc3b8960fd92fe04a1 (diff) | |
parent | 971155a2f06266ffb5fa1234d4901a174dac5a3a (diff) |
Merge commit 'mguetlein/test' into test
Conflicts:
application.rb
-rwxr-xr-x | application.rb | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/application.rb b/application.rb index a2cd182..f6dc140 100755 --- a/application.rb +++ b/application.rb @@ -35,7 +35,11 @@ get '/?' do Dataset.all(params).collect{|d| d.uri}.join("\n") + "\n" end -get '/:id' do +# provides dataset in various formats +# +# only_metadata=true => compounds and features are removed +# +def get_dataset( params, request, response, only_metadata=false ) accept = request.env['HTTP_ACCEPT'] accept = 'application/rdf+xml' if accept == '*/*' or accept == '' or accept.nil? # workaround for browser links @@ -58,14 +62,27 @@ get '/:id' do halt 404, "Dataset #{params[:id]} not found." end halt 404, "Dataset #{params[:id]} not found." if dataset.nil? # not sure how an empty cataset can be returned, but if this happens stale processes keep runing at 100% cpu + + if only_metadata # remove compounds and feature data from yaml + d = YAML.load(dataset.yaml) + def d.to_yaml_properties + super - [ "@compounds", "@features", "@data"] + end + dataset.yaml = d.to_yaml + end + case accept when /rdf/ # redland sends text/rdf instead of application/rdf+xml response['Content-Type'] = 'application/rdf+xml' - unless dataset.owl # lazy owl creation - dataset.owl = dataset.to_owl - dataset.save + if only_metadata + dataset.to_owl + else + unless dataset.owl # lazy owl creation + dataset.owl = dataset.to_owl + dataset.save + end + dataset.owl end - dataset.owl when /yaml/ response['Content-Type'] = 'application/x-yaml' dataset.yaml @@ -103,6 +120,14 @@ get '/:id' do end end +get '/:id' do + get_dataset(params, request, response) +end + +get '/:id/metadata/?' do + get_dataset(params, request, response, true) +end + get '/:id/features/:feature_id/?' do OpenTox::Dataset.find(url_for("/#{params[:id]}", :full)).feature(params[:feature_id]) end |