summaryrefslogtreecommitdiff
path: root/lib/dataset.rb
diff options
context:
space:
mode:
authormguetlein <martin.guetlein@gmail.com>2010-05-06 11:32:05 +0200
committermguetlein <martin.guetlein@gmail.com>2010-05-06 11:32:05 +0200
commit9e356d0d94ea4fe210ea7cefce5d4c1179cb63cd (patch)
tree486bd97d9e968c56c755dfa69331a8cabc70895f /lib/dataset.rb
parent8439bb9b337bded4a54018c03500a15082bce6b0 (diff)
major change: using literal datatypes in owl
Diffstat (limited to 'lib/dataset.rb')
-rw-r--r--lib/dataset.rb21
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/dataset.rb b/lib/dataset.rb
index c513463..ff07a6f 100644
--- a/lib/dataset.rb
+++ b/lib/dataset.rb
@@ -12,12 +12,21 @@ module OpenTox
@compounds = []
end
- def self.find(uri)
+ def self.find(uri, accept_header=nil)
- if uri.match(/webservices.in-silico.ch|localhost|ot.dataset.de|opentox.informatik.uni-freiburg.de/) # try to get YAML first
- d = YAML.load RestClientWrapper.get(uri.to_s.strip, :accept => 'application/x-yaml').to_s
+ unless accept_header
+ if uri.match(@@config[:services]["opentox-dataset"])
+ accept_header = 'text/x-yaml'
+ else
+ accept_header = "application/rdf+xml"
+ end
+ end
+
+ case accept_header
+ when "text/x-yaml"
+ d = YAML.load RestClientWrapper.get(uri.to_s.strip, :accept => 'text/x-yaml').to_s
d.uri = uri unless d.uri
- else # get default rdf+xml
+ when "application/rdf+xml"
owl = OpenTox::Owl.from_uri(uri.to_s.strip, "Dataset")
d = Dataset.new
@@ -32,6 +41,8 @@ module OpenTox
d.compounds.uniq!
d.features.uniq!
+ else
+ raise "cannot get datset with accept header: "+accept_header.to_s
end
return d
end
@@ -159,7 +170,7 @@ module OpenTox
@features.uniq!
@compounds.uniq!
- RestClient::Resource.new(@@config[:services]["opentox-dataset"], :user => @@users[:users].keys[0], :password => @@users[:users].values[0]).post(self.to_yaml, :content_type => "application/x-yaml").chomp.to_s
+ OpenTox::RestClientWrapper.post(@@config[:services]["opentox-dataset"],{:content_type => "text/x-yaml"},self.to_yaml).strip
end
=begin