myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [2999] branches/showcase48/app: added an annotati


From: noreply
Subject: [myexperiment-hackers] [2999] branches/showcase48/app: added an annotations table for storing triples
Date: Fri, 18 May 2012 09:07:16 +0000 (UTC)

Revision
2999
Author
dgc
Date
2012-05-18 09:07:15 +0000 (Fri, 18 May 2012)

Log Message

added an annotations table for storing triples

Modified Paths

Diff

Modified: branches/showcase48/app/controllers/research_objects_controller.rb (2998 => 2999)


--- branches/showcase48/app/controllers/research_objects_controller.rb	2012-05-17 18:34:36 UTC (rev 2998)
+++ branches/showcase48/app/controllers/research_objects_controller.rb	2012-05-18 09:07:15 UTC (rev 2999)
@@ -101,6 +101,8 @@
         :description  => ro_params[:description],
         :content_blob => ContentBlob.new(:data ="" research_object))
 
+    @research_object.load_graph if @research_object.valid?
+
     respond_to do |format|
       format.html {
         if @research_object.new_record?

Modified: branches/showcase48/app/models/research_object.rb (2998 => 2999)


--- branches/showcase48/app/models/research_object.rb	2012-05-17 18:34:36 UTC (rev 2998)
+++ branches/showcase48/app/models/research_object.rb	2012-05-18 09:07:15 UTC (rev 2999)
@@ -17,6 +17,8 @@
   acts_as_site_entity
   acts_as_contributable
 
+  has_many :annotations, :dependent => :destroy
+
   belongs_to :content_blob, :dependent => :destroy
 
   validates_presence_of :title
@@ -55,6 +57,16 @@
 
       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
   end

Modified: branches/showcase48/app/views/research_objects/show.rhtml (2998 => 2999)


--- branches/showcase48/app/views/research_objects/show.rhtml	2012-05-17 18:34:36 UTC (rev 2998)
+++ branches/showcase48/app/views/research_objects/show.rhtml	2012-05-18 09:07:15 UTC (rev 2999)
@@ -25,14 +25,14 @@
 </table>
 
 <h2>Triples</h2>
-  
+
 <div id="annotation_list">
-  <% @contributable.load_graph.query([nil, nil, nil]).each do |s, p, o| %>
+  <% @contributable.annotations.each do |annotation| %>
     <div>
       <table>
-        <tr><td><%=h s.to_s -%></td></tr>
-        <tr><td><%=h p.to_s -%></td></tr>
-        <tr><td><%=h o.to_s -%></td></tr>
+        <tr><td><%=h annotation.subject_text   -%></td></tr>
+        <tr><td><%=h annotation.predicate_text -%></td></tr>
+        <tr><td><%=h annotation.objekt_text    -%></td></tr>
       </table>
     </div>
   <% end %>

reply via email to

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