Added: branches/showcase48/app/helpers/research_objects_helper.rb (0 => 3007)
--- branches/showcase48/app/helpers/research_objects_helper.rb (rev 0)
+++ branches/showcase48/app/helpers/research_objects_helper.rb 2012-05-21 13:59:16 UTC (rev 3007)
@@ -0,0 +1,41 @@
+# myExperiment: app/helpers/research_objects_helper.rb
+#
+# Copyright (c) 2012 University of Manchester and the University of Southampton.
+# See license.txt for details.
+
+module ResearchObjectsHelper
+
+ def research_object_summary(ro)
+
+ s_uris = []
+ p_uris = []
+ o_uris = []
+
+ ro.annotations.each do |annotation|
+ s_uris << annotation.subject_text
+ p_uris << annotation.predicate_text
+ o_uris << annotation.objekt_text
+ end
+
+ uris = (s_uris + p_uris + o_uris).uniq!
+
+ uris.map! do |uri|
+ [uri, s_uris.select do |u| u == uri end.length,
+ p_uris.select do |u| u == uri end.length,
+ o_uris.select do |u| u == uri end.length]
+ end
+
+ uris.sort! do |a, b|
+ by_count = (b[1] + b[2] + b[3]) <=> (a[1] + a[2] + a[3])
+
+ if by_count == 0
+ b[0] <=> a[0]
+ else
+ by_count
+ end
+ end
+
+ uris
+ end
+
+end
Modified: branches/showcase48/app/views/research_objects/show.rhtml (3006 => 3007)
--- branches/showcase48/app/views/research_objects/show.rhtml 2012-05-21 12:59:49 UTC (rev 3006)
+++ branches/showcase48/app/views/research_objects/show.rhtml 2012-05-21 13:59:16 UTC (rev 3007)
@@ -36,69 +36,25 @@
<% if @contributable.annotations.length > 0 %>
- <h2>Summary of subjects</h2>
+ <h2>Summary</h2>
<table class="simple">
<tr>
<th>URI</th>
- <th>Count</th>
+ <th>S</th>
+ <th>P</th>
+ <th>O</th>
</tr>
- <% @contributable.annotations.group_by do |a|
- a.subject_text
- end.sort do |a, b|
- b[1].length <=> a[1].length
- end.map do |pair| %>
-
- <tr>
- <td><%=h pair[0] -%></td>
- <td><%= pair[1].length -%></td>
- </tr>
+ <% research_object_summary(@contributable).each do |row| %>
+ <tr>
+ <td><%=h row[0] -%></td>
+ <td><%= row[1] -%></td>
+ <td><%= row[2] -%></td>
+ <td><%= row[3] -%></td>
+ </tr>
+ <% end %>
+ </table>
- <% end %>
- </table>
-
- <h2>Summary of predicates</h2>
-
- <table class="simple">
- <tr>
- <th>URI</th>
- <th>Count</th>
- </tr>
- <% @contributable.annotations.group_by do |a|
- a.predicate_text
- end.sort do |a, b|
- b[1].length <=> a[1].length
- end.map do |pair| %>
-
- <tr>
- <td><%=h pair[0] -%></td>
- <td><%= pair[1].length -%></td>
- </tr>
-
- <% end %>
- </table>
-
- <h2>Summary of objects</h2>
-
- <table class="simple">
- <tr>
- <th>URI</th>
- <th>Count</th>
- </tr>
- <% @contributable.annotations.group_by do |a|
- a.objekt_text
- end.sort do |a, b|
- b[1].length <=> a[1].length
- end.map do |pair| %>
-
- <tr>
- <td><%=h pair[0] -%></td>
- <td><%= pair[1].length -%></td>
- </tr>
-
- <% end %>
- </table>
-
<h2>Complete annotation list</h2>
<div id="annotation_list">