From c0bef2dc83d2ce1fea6434ca73586d49865bb810 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Thu, 31 Mar 2011 13:44:02 +0200 Subject: ohm-contrib added --- Rakefile | 3 +-- lib/environment.rb | 2 +- lib/ontology.rb | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/ontology_service.rb | 43 -------------------------------------- lib/opentox-ruby.rb | 2 +- 5 files changed, 58 insertions(+), 47 deletions(-) create mode 100644 lib/ontology.rb delete mode 100644 lib/ontology_service.rb diff --git a/Rakefile b/Rakefile index b496cc2..215aeb2 100644 --- a/Rakefile +++ b/Rakefile @@ -28,6 +28,7 @@ begin "tmail", "rinruby", "ohm", + "ohm-contrib", "SystemTimer", "rjb" ].each { |dep| gem.add_dependency dep } @@ -44,8 +45,6 @@ begin gem.add_dependency "haml", ">=3" ['jeweler'].each { |dep| gem.add_development_dependency dep } gem.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*", 'lib/jeweler/templates/.gitignore'] - #gem.files.include %w(lib/environment.rb, lib/algorithm.rb, lib/compound.rb, lib/dataset.rb, lib/model.rb, lib/validation.rb, lib/templates/*) - # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings end Jeweler::GemcutterTasks.new rescue LoadError diff --git a/lib/environment.rb b/lib/environment.rb index 59578c1..57ae014 100644 --- a/lib/environment.rb +++ b/lib/environment.rb @@ -74,7 +74,7 @@ CONFIG[:authorization][:authenticate_request] = [""] unless CONFIG[:authorizatio CONFIG[:authorization][:authorize_request] = [""] unless CONFIG[:authorization][:authorize_request] CONFIG[:authorization][:free_request] = [""] unless CONFIG[:authorization][:free_request] -RDF = OwlNamespace.new 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' +#RDF = OwlNamespace.new 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' OWL = OwlNamespace.new 'http://www.w3.org/2002/07/owl#' DC = OwlNamespace.new 'http://purl.org/dc/elements/1.1/' OT = OwlNamespace.new 'http://www.opentox.org/api/1.1#' diff --git a/lib/ontology.rb b/lib/ontology.rb new file mode 100644 index 0000000..c3952c3 --- /dev/null +++ b/lib/ontology.rb @@ -0,0 +1,55 @@ +module OpenTox + module Ontology + module Echa + require 'sparql/client' + @sparql = SPARQL::Client.new("http://apps.ideaconsult.net:8080/ontology") + def self.qs(classname="Endpoints") + return "PREFIX ot: + PREFIX ota: + PREFIX owl: + PREFIX dc: + PREFIX rdfs: + PREFIX rdf: + PREFIX otee: + PREFIX toxcast: + select * + where { + ?endpoint rdfs:subClassOf otee:#{classname}. + ?endpoint dc:title ?title. + }" + end + + def self.make_option_list(endpoint="Endpoints", level=1) + out = "" + results = @sparql.query(qs(endpoint)) rescue results = [] + results.each do |result| + endpointname = result.Endpoints.to_s.split('#').last + title = result.bound?(:title) ? result.title : endpointname + out += "\n" + out += make_option_list(endpointname, level + 1) + end + return out + end + + def self.get_endpoint_selectlist(include_blank=true) + out = "\n" + return out + end + + def self.endpoints#(endpoint="Endpoints") + endpoint_datasets = {} + RestClientWrapper.get("http://apps.ideaconsult.net:8080/ambit2/query/ndatasets_endpoint",:accept => "text/csv").each do |line| + if line.match(/^http/) + e = line.split(',') + endpoint_datasets["#{e.first} (#{e[1]})"] = RestClientWrapper.get(e.last, :accept => "text/uri-list").split("\n")#[0..e[1].to_i-1] # hack to get only the first count entries + end + end + endpoint_datasets + end + end + + end +end diff --git a/lib/ontology_service.rb b/lib/ontology_service.rb deleted file mode 100644 index 4ff688f..0000000 --- a/lib/ontology_service.rb +++ /dev/null @@ -1,43 +0,0 @@ -module OpenTox - module OntologyService - module Endpoints - require 'sparql/client' - @sparql = SPARQL::Client.new("http://apps.ideaconsult.net:8080/ontology") - def self.qs(classname="Endpoints") - return "PREFIX ot: - PREFIX ota: - PREFIX owl: - PREFIX dc: - PREFIX rdfs: - PREFIX rdf: - PREFIX otee: - PREFIX toxcast: - select ?Endpoints ?title ?id - where {?Endpoints rdfs:subClassOf otee:#{classname}. - OPTIONAL {?Endpoints dc:title ?title}. - OPTIONAL {?Endpoints dc:identifier ?id}.} - ORDER BY ?title" - end - - def self.make_option_list(endpoint="Endpoints", level=1) - out = "" - results = @sparql.query(qs(endpoint)) rescue results = [] - results.each do |result| - endpointname = result.Endpoints.to_s.split('#').last - title = result.bound?(:title) ? result.title : endpointname - out += "\n" - out += make_option_list(endpointname, level + 1) - end - return out - end - - def self.get_endpoint_selectlist(include_blank=true) - out = "\n" - return out - end - end - end -end \ No newline at end of file diff --git a/lib/opentox-ruby.rb b/lib/opentox-ruby.rb index ab8d824..ae05cb2 100644 --- a/lib/opentox-ruby.rb +++ b/lib/opentox-ruby.rb @@ -9,6 +9,6 @@ rescue LoadError end ['opentox', 'compound','dataset', 'parser','serializer', 'algorithm','model','task','validation','feature', - 'rest_client_wrapper', 'authorization', 'policy', 'helper', 'to-html' ].each do |lib| + 'rest_client_wrapper', 'authorization', 'policy', 'helper', 'to-html', 'ontology' ].each do |lib| require lib end -- cgit v1.2.3