Module: OpenTox::Ontology::Model
- Defined in:
- lib/ontology.rb
Overview
Model Class for OpenTox::Ontology to register/deregister and check models in the ontology service
Class Method Summary collapse
-
.delete(uri, subjectid = nil) ⇒ Object
Deregister an OpenTox resource into ontology service.
-
.exists?(uri, subjectid = nil) ⇒ Boolean
Find an OpenTox resource in the ontology service.
-
.register(uri, subjectid = nil) ⇒ Object
Register an OpenTox resource into ontology service.
Class Method Details
.delete(uri, subjectid = nil) ⇒ Object
Deregister an OpenTox resource into ontology service
84 85 86 87 88 89 90 91 |
# File 'lib/ontology.rb', line 84 def self.delete(uri, subjectid=nil) begin RestClientWrapper.delete("#{ONTOLOGY_SERVER}?uri=#{CGI.escape(uri)}", {:subjectid => CGI.escape(subjectid)}) rescue LOGGER.warn "OpenTox::Ontology::Model.exists ontology service is not reachable. Failed to delete URI: #{uri} with subjectid: #{subjectid}" false end end |
.exists?(uri, subjectid = nil) ⇒ Boolean
Find an OpenTox resource in the ontology service
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/ontology.rb', line 96 def self.exists?(uri, subjectid=nil) begin out = RestClientWrapper.get("#{ONTOLOGY_SERVER}?query=#{querystring(uri)}",:accept => "text/csv").collect{|l| l.gsub("\r\n", "") if l.match(/^http/)}.uniq.compact return true if out.size > 0 false rescue LOGGER.warn "OpenTox::Ontology::Model.exists ontology service is not reachable. Failed to check for URI: #{uri} with subjectid: #{subjectid}" false end end |
.register(uri, subjectid = nil) ⇒ Object
Register an OpenTox resource into ontology service
72 73 74 75 76 77 78 79 |
# File 'lib/ontology.rb', line 72 def self.register(uri, subjectid=nil) begin RestClientWrapper.post(ONTOLOGY_SERVER, {:uri => uri}, {:subjectid => CGI.escape(subjectid)}) rescue LOGGER.warn "OpenTox::Ontology::Model.register ontology service is not reachable. Failed to register URI: #{uri} with subjectid: #{subjectid}" false end end |