From d262dbc79c9f5d8e2d74647df52a9c44e1af511d Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 6 May 2010 17:42:03 +0200 Subject: martins modifications merged and adjusted --- lib/dataset.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/dataset.rb') diff --git a/lib/dataset.rb b/lib/dataset.rb index c513463..3cfe639 100644 --- a/lib/dataset.rb +++ b/lib/dataset.rb @@ -14,9 +14,10 @@ module OpenTox def self.find(uri) - if uri.match(/webservices.in-silico.ch|localhost|ot.dataset.de|opentox.informatik.uni-freiburg.de/) # try to get YAML first + #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 d.uri = uri unless d.uri +=begin else # get default rdf+xml owl = OpenTox::Owl.from_uri(uri.to_s.strip, "Dataset") @@ -33,6 +34,7 @@ module OpenTox d.compounds.uniq! d.features.uniq! end +=end return d end -- cgit v1.2.3 From 0cf1fbcfae7f618f188f8b44051e5fc0724f8728 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Mon, 10 May 2010 18:45:22 +0200 Subject: Validation service integrated --- lib/dataset.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/dataset.rb') diff --git a/lib/dataset.rb b/lib/dataset.rb index 9304eec..e21ccce 100644 --- a/lib/dataset.rb +++ b/lib/dataset.rb @@ -15,7 +15,7 @@ module OpenTox def self.find(uri, accept_header=nil) unless accept_header - if uri.match(@@config[:services]["opentox-dataset"]) || uri=~ /188.40.32.88/ + if uri.match(@@config[:services]["opentox-dataset"]) || uri=~ /188.40.32.88/ || uri =~ /informatik/ accept_header = 'text/x-yaml' else accept_header = "application/rdf+xml" -- cgit v1.2.3 From 1d0c46a9711050e116147437fbb334bd800324f3 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Wed, 12 May 2010 12:31:39 +0200 Subject: Modification for new RestClient: body instead of to_s --- lib/dataset.rb | 124 +++------------------------------------------------------ 1 file changed, 6 insertions(+), 118 deletions(-) (limited to 'lib/dataset.rb') diff --git a/lib/dataset.rb b/lib/dataset.rb index e21ccce..17f0997 100644 --- a/lib/dataset.rb +++ b/lib/dataset.rb @@ -15,16 +15,17 @@ module OpenTox def self.find(uri, accept_header=nil) unless accept_header - if uri.match(@@config[:services]["opentox-dataset"]) || uri=~ /188.40.32.88/ || uri =~ /informatik/ - accept_header = 'text/x-yaml' + #if uri.match(@@config[:services]["opentox-dataset"]) || uri=~ /188.40.32.88/ || uri =~ /informatik/ + if !@@config[:accept_headers]["opentox-dataset"].grep(/yaml/).empty? + accept_header = 'application/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 + when "application/x-yaml" + d = YAML.load RestClientWrapper.get(uri.to_s.strip, :accept => 'application/x-yaml').to_s d.uri = uri unless d.uri when "application/rdf+xml" owl = OpenTox::Owl.from_uri(uri.to_s.strip, "Dataset") @@ -172,122 +173,9 @@ module OpenTox @features.uniq! @compounds.uniq! - OpenTox::RestClientWrapper.post(@@config[:services]["opentox-dataset"],{:content_type => "text/x-yaml"},self.to_yaml).strip + OpenTox::RestClientWrapper.post(@@config[:services]["opentox-dataset"],{:content_type => "application/x-yaml"},self.to_yaml).strip end -=begin - # create/add to entry from uris or Redland::Resources - def add(compound,feature,value) - compound = self.find_or_create_compound compound unless compound.class == Redland::Resource - feature = self.find_or_create_feature feature unless feature.class == Redland::Resource - data_entry = @model.subject OT['compound'], compound - if data_entry.nil? - data_entry = @model.create_resource - dataset = @model.subject(RDF['type'],OT[self.owl_class]) - @model.add dataset, OT['dataEntry'], data_entry - @model.add data_entry, RDF['type'], OT["DataEntry"] - @model.add data_entry, OT['compound'], compound - end - values = @model.create_resource - @model.add data_entry, OT['values'], values - @model.add values, RDF['type'], OT['FeatureValue'] - @model.add values, OT['feature'], feature - @model.add values, OT['value'], value.to_s - end - - def add_tuple(compound,tuple) - compound = self.find_or_create_compound compound unless compound.class == Redland::Resource - data_entry = @model.subject OT['compound'], compound - if data_entry.nil? - data_entry = @model.create_resource - dataset = @model.subject(RDF['type'],OT[self.owl_class]) - @model.add dataset, OT['dataEntry'], data_entry - @model.add data_entry, RDF['type'], OT["DataEntry"] - @model.add data_entry, OT['compound'], compound - end - @model.add data_entry, OT['values'], tuple - end - - def create_tuple(feature,t) - feature = self.find_or_create_feature feature unless feature.class == Redland::Resource - tuple = @model.create_resource - @model.add tuple, RDF['type'], OT["Tuple"] - @model.add tuple, OT['feature'], feature - t.each do |name,value| - f = self.find_or_create_feature name unless name.class == Redland::Resource - complex_value = @model.create_resource - feature = self.find_or_create_feature(name) - @model.add tuple, OT['complexValue'], complex_value - @model.add complex_value, RDF['type'], OT["FeatureValue"] - @model.add complex_value, OT['feature'], f - @model.add complex_value, OT['value'], value.to_s - end - - tuple - end - - # find or create a new compound and return the resource - def find_or_create_compound(uri) - compound = @model.subject(DC["identifier"], uri) - if compound.nil? - compound = @model.create_resource(uri) - @model.add compound, RDF['type'], OT["Compound"] - @model.add compound, DC["identifier"], uri - end - compound - end - - # find or create a new feature and return the resource - def find_or_create_feature(uri) - feature = @model.subject(DC["identifier"], uri) - if feature.nil? - feature = @model.create_resource(uri) - @model.add feature, RDF['type'], OT["Feature"] - @model.add feature, DC["identifier"], uri - @model.add feature, DC["title"], File.basename(uri).split(/#/)[1] - @model.add feature, DC['source'], uri - end - feature - end - - def self.create(data, content_type = 'application/rdf+xml') - resource = RestClient::Resource.new(@@config[:services]["opentox-dataset"], :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) - uri = resource.post data, :content_type => content_type - dataset = Dataset.new - dataset.read uri.chomp.to_s - dataset - end - - def features - features = [] - @model.subjects(RDF['type'], OT["Feature"]).each do |feature_node| - features << @model.object(feature_node, DC["identifier"])# - end - features - end - - def compounds - compounds = [] - @model.subjects(RDF['type'], OT["Compound"]).each do |compound_node| - compounds << @model.object(compound_node, DC["identifier"]).to_s - end - compounds - end - - # Delete a dataset - def delete - resource = RestClient::Resource.new(@uri, :user => @@users[:users].keys[0], :password => @@users[:users].values[0]) - resource.delete - end - - def to_owl - end - - def from_owl - end - -=end - def init_dirty_features(owl) @dirty_features = @features @owl = owl -- cgit v1.2.3