diff options
author | Christoph Helma <helma@in-silico.ch> | 2011-03-09 12:31:05 +0100 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2011-03-09 12:31:05 +0100 |
commit | c651fe10fe5e09dbfdf2b3abd420fc2fc0051937 (patch) | |
tree | 30029f9c3246de739aaf7b66a490c01b7b147f04 /lib/ontology_service.rb | |
parent | 5233ab341757557c536ed8cc8eefd79a936b4295 (diff) | |
parent | 66f2ee967317954568562510111b0d832881547d (diff) |
Merge branch 'release/v1.0.0'v1.0.0
Conflicts:
lib/dataset.rb
Diffstat (limited to 'lib/ontology_service.rb')
-rw-r--r-- | lib/ontology_service.rb | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/ontology_service.rb b/lib/ontology_service.rb new file mode 100644 index 0000000..4ff688f --- /dev/null +++ b/lib/ontology_service.rb @@ -0,0 +1,43 @@ +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:<http://www.opentox.org/api/1.1#> + PREFIX ota:<http://www.opentox.org/algorithms.owl#> + PREFIX owl:<http://www.w3.org/2002/07/owl#> + PREFIX dc:<http://purl.org/dc/elements/1.1/> + PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> + PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> + PREFIX otee:<http://www.opentox.org/echaEndpoints.owl#> + PREFIX toxcast:<http://www.opentox.org/toxcast.owl#> + 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 += "<option value='#{title}' id='#{endpointname}' class='level_#{level}'>#{title}</option>\n" + out += make_option_list(endpointname, level + 1) + end + return out + end + + def self.get_endpoint_selectlist(include_blank=true) + out = "<select id='endpoint' name='endpoint'>\n" + out += "<option value='' id='please_select'>Please select</option>\n" if include_blank + out += make_option_list + out += "</select>\n" + return out + end + end + end +end
\ No newline at end of file |