summaryrefslogtreecommitdiff
path: root/lib/task.rb
diff options
context:
space:
mode:
authormguetlein <martin.guetlein@gmail.com>2011-01-28 12:20:08 +0100
committermguetlein <martin.guetlein@gmail.com>2011-01-28 12:20:08 +0100
commite1a067953dd9139b01aaebe42ff158a944240540 (patch)
treef81e2027b2fd36660f6d12427500c7b1b7fa6d9f /lib/task.rb
parent171ab814d15b9504ef9892ba5f194de8bc019f46 (diff)
extend whitelisting, get feature_type from algorithm
Diffstat (limited to 'lib/task.rb')
-rw-r--r--lib/task.rb20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/task.rb b/lib/task.rb
index 3c6aba5..74940de 100644
--- a/lib/task.rb
+++ b/lib/task.rb
@@ -78,6 +78,7 @@ module OpenTox
# @param [String] uri Task URI
# @return [OpenTox::Task] Task object
def self.find(uri)
+ return nil unless uri
task = Task.new(uri)
task.load_metadata
task
@@ -94,10 +95,23 @@ module OpenTox
@metadata = YAML.load(yaml)
end
+
def self.from_rdfxml(rdfxml)
- file = Tempfile.open("ot-rdfxml"){|f| f.write(rdfxml)}.path
+ file = Tempfile.new("ot-rdfxml")
+ file.puts rdfxml
+ file.close
+ file = "file://"+file.path
+
+ # PENDING
+ raise "Parse from file not working: what is the base-object-uri??? (omitted in triples)"
+
parser = Parser::Owl::Generic.new file
- @metadata = parser.load_metadata
+ metadata = parser.load_metadata
+ puts metadata.inspect
+
+ task = Task.new(uri)
+ task.add_metadata(metadata)
+ task
end
def to_rdfxml
@@ -232,7 +246,7 @@ module OpenTox
sleep dur
load_metadata
# if another (sub)task is waiting for self, set progress accordingly
- waiting_task.progress(@metadata[OT.percentageCompleted]) if waiting_task
+ waiting_task.progress(@metadata[OT.percentageCompleted].to_f) if waiting_task
check_state
if (Time.new > due_to_time)
raise "max wait time exceeded ("+DEFAULT_TASK_MAX_DURATION.to_s+"sec), task: '"+@uri.to_s+"'"