myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [3015] branches/showcase48/app/models/research_ob


From: noreply
Subject: [myexperiment-hackers] [3015] branches/showcase48/app/models/research_object.rb: modified import to use ttl instead of zip
Date: Wed, 6 Jun 2012 08:37:52 +0000 (UTC)

Revision
3015
Author
dgc
Date
2012-06-06 08:37:51 +0000 (Wed, 06 Jun 2012)

Log Message

modified import to use ttl instead of zip

Modified Paths

Diff

Modified: branches/showcase48/app/models/research_object.rb (3014 => 3015)


--- branches/showcase48/app/models/research_object.rb	2012-06-06 06:45:29 UTC (rev 3014)
+++ branches/showcase48/app/models/research_object.rb	2012-06-06 08:37:51 UTC (rev 3015)
@@ -26,7 +26,7 @@
 
   format_attribute :description
 
-  def load_graph
+  def load_graph_from_zip
 
     begin
 
@@ -71,6 +71,33 @@
     end
   end
 
+  def load_graph
+
+    # create RDF graph
+
+    manifest_name = "tmp/graph.#{Process.pid}.ttl"
+
+    File.open(manifest_name, "w") do |f|
+      f.write(content_blob.data)
+    end
+
+    graph = RDF::Graph.load(manifest_name)
+
+    FileUtils.rm_rf(manifest_name)
+
+    # create triples
+
+    graph.query([nil, nil, nil]).each do |s, p, o|
+
+      annotations.create(
+          :subject_text =>   s.to_s,
+          :predicate_text => p.to_s,
+          :objekt_text =>    o.to_s)
+    end
+
+    graph
+  end
+
   def wf4ever_resources
 
     resources = annotations.find(:all, :conditions =>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]