Diff
Modified: branches/packs/app/controllers/packs_controller.rb (3663 => 3664)
--- branches/packs/app/controllers/packs_controller.rb 2013-09-02 20:42:09 UTC (rev 3663)
+++ branches/packs/app/controllers/packs_controller.rb 2013-09-02 23:29:59 UTC (rev 3664)
@@ -495,12 +495,8 @@
@visible_annotations = @annotations.select { |a| a[:template] != nil }
- @statements = RDF::Graph.new
+ @statements = merge_graphs(@annotations.map { |annotation| annotation[:graph] })
- @annotations.each do |annotation|
- @statements << annotation[:graph]
- end
-
unless @item.is_folder
@title = @statements.query(address@hidden, RDF::DC.title, nil]).first_value || @item.folder_entry.entry_name
@description = @statements.query(address@hidden, RDF::DC.description, nil]).first_value
Modified: branches/packs/app/helpers/research_objects_helper.rb (3663 => 3664)
--- branches/packs/app/helpers/research_objects_helper.rb 2013-09-02 20:42:09 UTC (rev 3663)
+++ branches/packs/app/helpers/research_objects_helper.rb 2013-09-02 23:29:59 UTC (rev 3664)
@@ -137,6 +137,36 @@
candidate
end
+ def merge_graphs_aux(node, bnodes)
+ if node.class == RDF::Node
+ if bnodes[node]
+ bnodes[node]
+ else
+ bnodes[node] = RDF::Node.new
+ end
+ else
+ node
+ end
+ end
+
+ def merge_graphs(graphs)
+
+ result = RDF::Graph.new
+
+ graphs.each do |graph|
+
+ bnodes = {}
+
+ graph.statements.each do |subject, predicate, object|
+ result << [merge_graphs_aux(subject, bnodes),
+ merge_graphs_aux(predicate, bnodes),
+ merge_graphs_aux(object, bnodes)]
+ end
+ end
+
+ result
+ end
+
def parse_links(headers)
links = {}
Modified: branches/packs/app/models/research_object.rb (3663 => 3664)
--- branches/packs/app/models/research_object.rb 2013-09-02 20:42:09 UTC (rev 3663)
+++ branches/packs/app/models/research_object.rb 2013-09-02 23:29:59 UTC (rev 3664)
@@ -485,14 +485,12 @@
def merged_annotation_graphs
- result = RDF::Graph.new
-
- resources.all(:conditions => { :is_annotation => true }).each do |annotation|
+ graphs = resources.all(:conditions => { :is_annotation => true }).map do |annotation|
ao_body = annotation.ao_body
- result << load_graph(ao_body.content_blob.data, :content_type => ao_body.content_type)
+ load_graph(ao_body.content_blob.data, :content_type => ao_body.content_type)
end
- result
+ merge_graphs(graphs)
end
def ore_structure_aux(entry, all_entries) #:nodoc:
Modified: branches/packs/app/views/packs/_annotation.html.erb (3663 => 3664)
--- branches/packs/app/views/packs/_annotation.html.erb 2013-09-02 20:42:09 UTC (rev 3663)
+++ branches/packs/app/views/packs/_annotation.html.erb 2013-09-02 23:29:59 UTC (rev 3664)
@@ -13,10 +13,16 @@
<% if annotation[:template] %>
<table>
<% annotation[:template]["parameters"].each do |parameter| %>
- <tr>
- <td class="label"><%=h parameter["label"] -%></td>
- <td class="value"><%=h annotation[:parameters][parameter["symbol"]].to_s -%></td>
- </tr>
+
+ <% label = parameter["label"] %>
+ <% value = annotation[:parameters][parameter["symbol"]].to_s %>
+
+ <% unless value.empty? %>
+ <tr>
+ <td class="label"><%=h label -%></td>
+ <td class="value"><%=h value -%></td>
+ </tr>
+ <% end %>
<% end %>
</table>
<% end %>
Modified: branches/packs/app/views/packs/item_show.html.erb (3663 => 3664)
--- branches/packs/app/views/packs/item_show.html.erb 2013-09-02 20:42:09 UTC (rev 3663)
+++ branches/packs/app/views/packs/item_show.html.erb 2013-09-02 23:29:59 UTC (rev 3664)
@@ -46,7 +46,14 @@
<h2>Hardware requirements</h2>
<ul>
<% @requires_hardware.each do |hardware| %>
- <li><%=h hardware -%></li>
+ <% desc = @statements.query([hardware, RDF::DC.description, nil]).first_literal %>
+ <% link = @statements.query([hardware, RDF::RDFS.seeAlso, nil]).first_literal %>
+
+ <% if link %>
+ <li><%= link_to(h(desc), link.to_s, :rel => "nofollow") -%></li>
+ <% else %>
+ <li><%=h desc -%></li>
+ <% end %>
<% end %>
</ul>
<% end %>
Modified: branches/packs/config/default_settings.yml (3663 => 3664)
--- branches/packs/config/default_settings.yml 2013-09-02 20:42:09 UTC (rev 3663)
+++ branches/packs/config/default_settings.yml 2013-09-02 23:29:59 UTC (rev 3664)
@@ -1557,19 +1557,32 @@
label: requires hardware
+ bnodes: [:b1]
+
parameters:
- label: Resource
type: resource
symbol: :resource
- - label: Hardware
+ - label: Description
type: string
- symbol: :hardware
+ symbol: :description
+ - label: Link
+ type: string
+ symbol: :link
+ optional: true
+
required_statements:
- - template: [:resource, "<http://purl.org/wf4ever/roterms#requiresHardware>", :hardware]
+ - template: [:resource, "<http://purl.org/wf4ever/roterms#requiresHardware>", :b1]
+
+ - template: [:b1, "<http://purl.org/dc/terms/description>", :description]
+
+ - template: [:b1, "<http://www.w3.org/2000/01/rdf-schema#seeAlso>", :link]
+ depends: [:link]
+
targets:
- :resource