From 3dd413a79d8ef32c8bf0426228e34d87bdcd5a6b Mon Sep 17 00:00:00 2001 From: mr Date: Thu, 9 Dec 2010 10:47:28 +0100 Subject: Ontology Service with Endpoint-option-list from http://apps.ideaconsult.net:8080/ontology --- lib/ontology_service.rb | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 lib/ontology_service.rb (limited to 'lib/ontology_service.rb') 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: + 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 -- cgit v1.2.3