myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [3013] branches/showcase48/app: added wf4ever res


From: noreply
Subject: [myexperiment-hackers] [3013] branches/showcase48/app: added wf4ever resource summary on RO page
Date: Tue, 5 Jun 2012 17:41:37 +0000 (UTC)

Revision
3013
Author
dgc
Date
2012-06-05 17:41:36 +0000 (Tue, 05 Jun 2012)

Log Message

added wf4ever resource summary on RO page

Modified Paths

Diff

Modified: branches/showcase48/app/models/research_object.rb (3012 => 3013)


--- branches/showcase48/app/models/research_object.rb	2012-06-05 10:17:13 UTC (rev 3012)
+++ branches/showcase48/app/models/research_object.rb	2012-06-05 17:41:36 UTC (rev 3013)
@@ -71,6 +71,38 @@
     end
   end
 
+  def wf4ever_resources
+
+    resources = annotations.find(:all, :conditions =>
+      ['predicate_text = ? AND objekt_text = ?',
+        'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',
+        'http://purl.org/wf4ever/ro#Resource']).map do
+      |a| a.subject_text
+    end
+
+    resources.map do |resource|
+
+      metadata = {}
+
+      annotations.find(:all, :conditions =>
+        ['subject_text = ?', resource]).each do |annotation|
+
+        case annotation.predicate_text
+        when "http://purl.org/wf4ever/ro#name":      metadata[:name]    = annotation.objekt_text
+        when "http://purl.org/dc/terms/created":     metadata[:created] = Date.parse(annotation.objekt_text)
+        when "http://purl.org/dc/terms/creator":     metadata[:creator] = annotation.objekt_text
+        when "http://purl.org/wf4ever/ro#checksum" : metadata[:md5]     = annotation.objekt_text
+        when "http://purl.org/wf4ever/ro#filesize" : metadata[:size]    = annotation.objekt_text.to_i
+        end
+
+      end
+
+      metadata
+
+    end
+
+  end
+
   def self.related_research_objects_to_t2(uuid)
 
     self.related_research_objects("

Modified: branches/showcase48/app/views/research_objects/show.rhtml (3012 => 3013)


--- branches/showcase48/app/views/research_objects/show.rhtml	2012-06-05 10:17:13 UTC (rev 3012)
+++ branches/showcase48/app/views/research_objects/show.rhtml	2012-06-05 17:41:36 UTC (rev 3013)
@@ -34,6 +34,31 @@
 
 </table>
 
+<% resources = @contributable.wf4ever_resources %>
+
+<% if resources.length > 0 %>
+
+  <h2>wf4ever resource summary</h2>
+
+  <table class="simple">
+    <tr>
+      <th>Name</th>
+      <th>Size</th>
+      <th>Created</th>
+      <th>Creator</th>
+    </tr>
+    <% resources.each do |resource| %>
+      <tr>
+        <td><%=h resource[:name] -%></td>
+        <td><%=h resource[:size] -%></td>
+        <td><%=h resource[:created] -%></td>
+        <td><%=h resource[:creator] -%></td>
+      </tr>
+    <% end %>
+  </table>
+
+<% end %>
+
 <% if @contributable.annotations.length > 0 %>
 
   <h2>Summary</h2>

reply via email to

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