summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/algorithm.rb19
-rw-r--r--lib/model.rb5
-rw-r--r--lib/owl.rb4
3 files changed, 23 insertions, 5 deletions
diff --git a/lib/algorithm.rb b/lib/algorithm.rb
index cc06032..30a41e0 100644
--- a/lib/algorithm.rb
+++ b/lib/algorithm.rb
@@ -2,6 +2,25 @@ LOGGER.progname = File.expand_path(__FILE__)
module OpenTox
module Algorithm
+
+
+ class Generic
+
+ attr_accessor :uri, :title, :date
+
+ def self.find(uri)
+ owl = OpenTox::Owl.from_uri(uri, "Algorithm")
+ return self.new(owl)
+ end
+
+ protected
+ def initialize(owl)
+ @title = owl.get("title")
+ @date = owl.get("date")
+ @uri = owl.uri
+ end
+
+ end
class Fminer
diff --git a/lib/model.rb b/lib/model.rb
index b6cef46..25266e3 100644
--- a/lib/model.rb
+++ b/lib/model.rb
@@ -21,9 +21,8 @@ module OpenTox
protected
def initialize(owl)
- [:date, :creator, :title, :format, :algorithm, :dependentVariables,
- :independentVariables, :predictedVariables, :trainingDataset].each do |a|
- self.send("#{a.to_s}=".to_sym, owl.get(a.to_s))
+ MODEL_ATTRIBS.each do |a|
+ self.send("#{a.to_s}=".to_sym, owl.get(a.to_s)) unless a==:uri
end
@uri = owl.uri
if ENV['RACK_ENV'] =~ /test|debug/
diff --git a/lib/owl.rb b/lib/owl.rb
index 7447ce6..245dcc7 100644
--- a/lib/owl.rb
+++ b/lib/owl.rb
@@ -233,7 +233,7 @@ module OpenTox
unless owl.root_node
types = []
owl.model.find(nil, RDF_TYPE, nil){ |s,p,o| types << o.to_s }
- raise "root node for class '"+ot_class+"' not found (available type nodes: "+types.inspect+")"
+ raise "root node for class '"+owl.node(ot_class).to_s+"' not found (available type nodes: "+types.inspect+")"
end
raise "no uri in rdf: '"+owl.uri+"'" unless owl.uri and Utils.is_uri?(owl.uri)
owl.ot_class = ot_class
@@ -244,7 +244,7 @@ module OpenTox
end
def self.from_uri(uri, ot_class)
- return from_data(RestClientWrapper.get(uri,:accept => "application/rdf+xml").to_s, uri, ot_class)
+ return from_data(RestClientWrapper.get(uri,:accept => "application/rdf+xml").to_s, uri, ot_class)
end
def rdf