summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormguetlein <martin.guetlein@gmail.com>2011-02-08 08:57:31 +0100
committermguetlein <martin.guetlein@gmail.com>2011-02-08 08:57:31 +0100
commitc37cc91893457cb91ddb2a32b9ac76090bd6c521 (patch)
tree529f6465f8f431c42e03140b2f6ccfe2ac5c149d /lib
parent281a0bade2ca1d1bb040c54704650b69f6da24a5 (diff)
not using rapper directly, use rest client and tmp-file
Diffstat (limited to 'lib')
-rw-r--r--lib/model.rb4
-rw-r--r--lib/parser.rb12
-rw-r--r--lib/task.rb2
3 files changed, 13 insertions, 5 deletions
diff --git a/lib/model.rb b/lib/model.rb
index ae793e8..64d178f 100644
--- a/lib/model.rb
+++ b/lib/model.rb
@@ -31,7 +31,7 @@ module OpenTox
return nil unless uri
model = Generic.new(uri)
model.load_metadata(subjectid)
- raise "could not load model metadata" if model.metadata==nil or model.metadata.size==0
+ raise "could not load model metadata '"+uri.to_s+"'" if model.metadata==nil or model.metadata.size==0
model
end
@@ -134,7 +134,7 @@ module OpenTox
OT.parameters => [{DC.title => "dataset_uri", OT.paramValue => dataset_uri}]
})
d = Dataset.new(dataset_uri,subjectid)
- d.load_compounds
+ d.load_compounds(subjectid)
count = 0
d.compounds.each do |compound_uri|
begin
diff --git a/lib/parser.rb b/lib/parser.rb
index e055eec..27dfeee 100644
--- a/lib/parser.rb
+++ b/lib/parser.rb
@@ -35,10 +35,18 @@ module OpenTox
else
uri = @uri
end
- uri += "?subjectid=#{CGI.escape(subjectid)}" if subjectid
+ # avoid using rapper directly because of 2 reasons:
+ # * http errors wont be noticed
+ # * subjectid cannot be sent as header
+ ##uri += "?subjectid=#{CGI.escape(subjectid)}" if subjectid
+ ## `rapper -i rdfxml -o ntriples #{uri} 2>/dev/null`.each_line do |line|
+ file = Tempfile.new("ot-rdfxml")
+ file.puts OpenTox::RestClientWrapper.get @uri,{:subjectid => subjectid,:accept => "application/rdf+xml"}
+ file.close
+ file = "file://"+file.path
statements = []
parameter_ids = []
- `rapper -i rdfxml -o ntriples #{uri} 2>/dev/null`.each_line do |line|
+ `rapper -i rdfxml -o ntriples #{file} 2>/dev/null`.each_line do |line|
triple = line.to_triple
@metadata[triple[1]] = triple[2].split('^^').first if triple[0] == @uri and triple[1] != RDF['type']
statements << triple
diff --git a/lib/task.rb b/lib/task.rb
index 73d880e..ca18d7b 100644
--- a/lib/task.rb
+++ b/lib/task.rb
@@ -303,7 +303,7 @@ module OpenTox
class SubTask
def initialize(task, min, max)
- raise "not a task or subtask" unless task.is_a?(Task) or task.is_a?(SubTask)
+ raise "not a task or subtask" if task!=nil and !(task.is_a?(Task) or task.is_a?(SubTask))
raise "invalid max ("+max.to_s+"), min ("+min.to_s+") params" unless
min.is_a?(Numeric) and max.is_a?(Numeric) and min >= 0 and max <= 100 and max > min
@task = task