Diff
Modified: branches/packs/app/controllers/items_controller.rb (3738 => 3739)
--- branches/packs/app/controllers/items_controller.rb 2013-10-01 10:45:10 UTC (rev 3738)
+++ branches/packs/app/controllers/items_controller.rb 2013-10-01 15:02:06 UTC (rev 3739)
@@ -36,25 +36,38 @@
@statements = merge_graphs(@annotations.map { |annotation| annotation[:graph] })
+ @item_uri = @item.uri
+ @view_uri = RDF::URI(params[:view]) if params[:view]
+
# Show a custom view if a view parameter is given
- if params[:view]
- @view_type = @statements.query([RDF::URI(params[:view]), RDF.type, nil]).first_object
+ if @view_uri
+ @view_types = @statements.query(address@hidden, RDF.type, nil]).objects
@resource_uri = polymorphic_path(address@hidden, :items]) + "/" + @item.ore_path
@view_uri = RDF::URI(params[:view])
- render :workflow_run
- return
+ if @view_types.include?(RDF::URI("http://purl.org/wf4ever/wfprov#WorkflowRun"))
+ render :workflow_run
+ return
+ elsif @view_types.include?(RDF::URI("http://purl.org/wf4ever/wfprov#ProcessRun"))
+ render :process_run
+ return
+ else
+ if Rails.env == "development"
+ render :text => "<pre>Types\n\n" + @view_types.map { |t| t.to_s }.join("\n") + "</pre>"
+ return
+ end
+ end
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
- @input_files_for_this_workflow = @statements.query(address@hidden, RDF::URI("http://purl.org/wf4ever/roterms#inputSelected"), nil]).objects
- @requires_hardware = @statements.query(address@hidden, RDF::URI("http://purl.org/wf4ever/roterms#requiresHardware"), nil]).objects
- @requires_software = @statements.query(address@hidden, RDF::URI("http://purl.org/wf4ever/roterms#requiresSoftware"), nil]).objects
- @roles_in_time = @statements.query([nil, RDF::URI("http://purl.org/spar/pro/relatesToEntity"), @item.uri]).subjects
+ @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
+ @input_files_for_this_workflow = @statements.query(address@hidden, RDF::URI("http://purl.org/wf4ever/roterms#inputSelected"), nil]).objects
+ @requires_hardware = @statements.query(address@hidden, RDF::URI("http://purl.org/wf4ever/roterms#requiresHardware"), nil]).objects
+ @requires_software = @statements.query(address@hidden, RDF::URI("http://purl.org/wf4ever/roterms#requiresSoftware"), nil]).objects
+ @roles_in_time = @statements.query([nil, RDF::URI("http://purl.org/spar/pro/relatesToEntity"), @item_uri]).subjects
# Get the top-level workflow runs by selecting only those that were not
# part of other workflow runs.
Modified: branches/packs/app/helpers/research_objects_helper.rb (3738 => 3739)
--- branches/packs/app/helpers/research_objects_helper.rb 2013-10-01 10:45:10 UTC (rev 3738)
+++ branches/packs/app/helpers/research_objects_helper.rb 2013-10-01 15:02:06 UTC (rev 3739)
@@ -345,5 +345,26 @@
folders.reverse
end
+
+ def item_uri(resource)
+ polymorphic_url([resource.research_object.context, :items]) + "/" + resource.ore_path
+ end
+
+ def item_uri_with_view(resource, view)
+ item_uri(resource) + "?" + { :view => view }.to_query
+ end
+
+ def item_label(resource, statements)
+
+ label = statements.query([resource, RDF::RDFS.label, nil]).first_literal
+
+ return label if label
+
+ resource
+ end
+
+ def item_link(resource, view, statements)
+ link_to(h(item_label(view, statements)), item_uri_with_view(resource, view))
+ end
end
Added: branches/packs/app/views/items/_debug.html.erb (0 => 3739)
--- branches/packs/app/views/items/_debug.html.erb (rev 0)
+++ branches/packs/app/views/items/_debug.html.erb 2013-10-01 15:02:06 UTC (rev 3739)
@@ -0,0 +1,65 @@
+<% if Rails.env == "development" %>
+
+<h2>Debug</h2>
+
+ <div id="tabsContainer" class="tabsContainer"></div>
+
+ <div class="tabContainer">
+ <div class="tabTitle">Resource as subject</div>
+ <div class="tabContent">
+ <table class="simple" style="font-size: 80%">
+ <% statements.query([view_uri, nil, nil]).each do |s, p, o| %>
+ <tr>
+ <td><%=h shorten_uri(p.to_s) -%></td>
+ <td>
+ <% if o.resource? %>
+ <%= link_to(o.to_s, item_uri_with_view(item, o.to_s)) -%></td>
+ <% else %>
+ <%=h o.to_s -%></td>
+ <% end %>
+ </td>
+ </tr>
+ <% end %>
+ </table>
+ </div>
+ </div>
+
+ <div class="tabContainer">
+ <div class="tabTitle">Resource as object</div>
+ <div class="tabContent">
+ <table class="simple" style="font-size: 80%">
+ <% statements.query([nil, nil, view_uri]).each do |s, p, o| %>
+ <tr>
+ <td>
+ <% if s.resource? %>
+ <%= link_to(s.to_s, item_uri_with_view(item, s.to_s)) -%></td>
+ <% else %>
+ <%=h s.to_s -%></td>
+ <% end %>
+ <td><%=h shorten_uri(p.to_s) -%></td>
+ </tr>
+ <% end %>
+ </table>
+ </div>
+ </div>
+
+ <div class="tabContainer">
+ <div class="tabTitle">Possible views</div>
+ <div class="tabContent">
+ <table class="simple" style="font-size: 80%">
+ <tr>
+ <th>URI</th>
+ <th>RDF type</th>
+ </tr>
+ <% statements.query([nil, RDF.type, nil]).each do |s, p, o| %>
+ <tr>
+ <td><%= link_to(s.to_s, item_uri_with_view(item, s.to_s)) -%></td>
+ <td><%=h shorten_uri(o.to_s) -%></td>
+ </tr>
+ <% end %>
+ </table>
+ </div>
+ </div>
+
+<% end %>
+
Added: branches/packs/app/views/items/_duration.html.erb (0 => 3739)
--- branches/packs/app/views/items/_duration.html.erb (rev 0)
+++ branches/packs/app/views/items/_duration.html.erb 2013-10-01 15:02:06 UTC (rev 3739)
@@ -0,0 +1,16 @@
+<% start_time = @statements.query([resource_uri, RDF::URI("http://www.w3.org/ns/prov#startedAtTime"), nil]).first_object %>
+<% end_time = @statements.query([resource_uri, RDF::URI("http://www.w3.org/ns/prov#endedAtTime"), nil]).first_object %>
+
+<h3>Duration</h3>
+
+<ul>
+ <% if start_time %>
+ <li>Started at <%= datetime(DateTime.parse(start_time.to_s)) -%>.</li>
+ <% end %>
+ <% if end_time %>
+ <li>Ended at <%= datetime(DateTime.parse(end_time.to_s)) -%>.</li>
+ <% end %>
+ <% if start_time && end_time %>
+ <li>Time elapsed: <%= sprintf("%.2f", (DateTime.parse(end_time.to_s).to_time - DateTime.parse(start_time.to_s).to_time).to_f * 100000) -%> seconds.</li>
+ <% end %>
+</ul>
Added: branches/packs/app/views/items/_inputs.html.erb (0 => 3739)
--- branches/packs/app/views/items/_inputs.html.erb (rev 0)
+++ branches/packs/app/views/items/_inputs.html.erb 2013-10-01 15:02:06 UTC (rev 3739)
@@ -0,0 +1,22 @@
+<% inputs = statements.query([view_uri, RDF::URI("http://purl.org/wf4ever/wfprov#usedInput"), nil]).objects %>
+
+<% if inputs.count > 0 %>
+ <h3>Inputs</h3>
+ <table class="simple">
+ <tr>
+ <th>Label</th>
+ <th>Zip entry</th>
+ </tr>
+ <% inputs.each do |input| %>
+ <% local_path = statements.query([input, RDF::URI("http://ns.taverna.org.uk/2012/tavernaprov/content"), nil]).first_object %>
+ <% sha1 = statements.query([local_path, RDF::URI("http://ns.taverna.org.uk/2012/tavernaprov/sha1"), nil]).first_literal %>
+ <% b1 = statements.query([nil, RDF::URI("http://www.w3.org/ns/prov#entity"), input]).first_subject %>
+ <% role = statements.query([b1, RDF::URI("http://www.w3.org/ns/prov#hadRole"), nil]).first_object %>
+ <% label = statements.query([role, RDF::RDFS.label, nil]).first_literal %>
+ <tr>
+ <td><%=h label -%></td>
+ <td><%=h local_path -%></td>
+ </tr>
+ <% end %>
+ </table>
+<% end %>
Added: branches/packs/app/views/items/_nested_workflow_runs.html.erb (0 => 3739)
--- branches/packs/app/views/items/_nested_workflow_runs.html.erb (rev 0)
+++ branches/packs/app/views/items/_nested_workflow_runs.html.erb 2013-10-01 15:02:06 UTC (rev 3739)
@@ -0,0 +1,18 @@
+<%
+runs = statements.query([view_uri, RDF::URI("http://purl.org/dc/terms/hasPart"), nil]).objects.select do |resource|
+ statements.has_triple?([resource, RDF.type, RDF::URI("http://purl.org/wf4ever/wfprov#WorkflowRun")])
+end
+%>
+
+<% if runs.count > 0 %>
+
+ <h3>Nested Workflow Runs</h3>
+
+ <p>The following workflow runs were performed as a consequence.</p>
+
+ <ul>
+ <% runs.each do |run| %>
+ <li><%= item_link(@item, run, @statements) -%></li>
+ <% end %>
+ </ul>
+<% end %>
Added: branches/packs/app/views/items/_outputs.html.erb (0 => 3739)
--- branches/packs/app/views/items/_outputs.html.erb (rev 0)
+++ branches/packs/app/views/items/_outputs.html.erb 2013-10-01 15:02:06 UTC (rev 3739)
@@ -0,0 +1,22 @@
+<% outputs = statements.query([nil, RDF::URI("http://purl.org/wf4ever/wfprov#wasOutputFrom"), view_uri]).subjects %>
+
+<% if outputs.count > 0 %>
+ <h3>Outputs</h3>
+ <table class="simple">
+ <tr>
+ <th>Label</th>
+ <th>Size</th>
+ </tr>
+ <% outputs.each do |output| %>
+ <% zip_entry = statements.query([output, RDF::URI("http://ns.taverna.org.uk/2012/tavernaprov/content"), nil]).first_object %>
+ <% param = statements.query([output, RDF::URI("http://purl.org/wf4ever/wfprov#describedByParameter"), nil]).first_object %>
+ <% label = statements.query([param, RDF::RDFS.label, nil]).first_literal %>
+ <% sha1 = statements.query([zip_entry, RDF::URI("http://ns.taverna.org.uk/2012/tavernaprov/sha1"), nil]).first_literal %>
+ <% size = statements.query([zip_entry, RDF::URI("http://ns.taverna.org.uk/2012/tavernaprov/byteCount"), nil]).first_literal %>
+ <tr>
+ <td><%=h label -%></td>
+ <td><%=h size -%></td>
+ </tr>
+ <% end %>
+ </table>
+<% end %>
Added: branches/packs/app/views/items/_parent_workflow_run.html.erb (0 => 3739)
--- branches/packs/app/views/items/_parent_workflow_run.html.erb (rev 0)
+++ branches/packs/app/views/items/_parent_workflow_run.html.erb 2013-10-01 15:02:06 UTC (rev 3739)
@@ -0,0 +1,10 @@
+<%
+parent = statements.query([view_uri, RDF::URI("http://purl.org/wf4ever/wfprov#wasPartOfWorkflowRun"), nil]).first_object
+%>
+
+<% if parent %>
+
+ <h3>Part of workflow run</h3>
+
+ <p>This is a part of the workflow run: <%= item_link(@item, parent, statements) -%></p>
+<% end %>
Added: branches/packs/app/views/items/_process_runs.html.erb (0 => 3739)
--- branches/packs/app/views/items/_process_runs.html.erb (rev 0)
+++ branches/packs/app/views/items/_process_runs.html.erb 2013-10-01 15:02:06 UTC (rev 3739)
@@ -0,0 +1,17 @@
+<%
+process_runs = @statements.query([view_uri, RDF::URI("http://purl.org/dc/terms/hasPart"), nil]).objects.select do |part|
+ @statements.has_triple?([part, RDF.type, RDF::URI("http://purl.org/wf4ever/wfprov#ProcessRun")])
+end
+%>
+
+<% if process_runs.count > 0 %>
+
+ <h3>Process Runs</h3>
+
+ <ul>
+ <% process_runs.each do |process_run| %>
+ <li><%= item_link(@item, process_run, statements) -%></li>
+ <% end %>
+ </ul>
+
+<% end %>
Added: branches/packs/app/views/items/process_run.html.erb (0 => 3739)
--- branches/packs/app/views/items/process_run.html.erb (rev 0)
+++ branches/packs/app/views/items/process_run.html.erb 2013-10-01 15:02:06 UTC (rev 3739)
@@ -0,0 +1,9 @@
+<h1>Process Run: <%=h item_label(@view_uri, @statements) -%></h1>
+
+<%= render(:partial => "parent_workflow_run", :locals => { :item => @item, :view_uri => @view_uri, :statements => @statements }) -%>
+
+<%= render(:partial => "inputs", :locals => { :item => @item, :view_uri => @view_uri, :statements => @statements }) -%>
+
+<%= render(:partial => "outputs", :locals => { :item => @item, :view_uri => @view_uri, :statements => @statements }) -%>
+
+<%= render(:partial => "debug", :locals => { :item => @item, :view_uri => @view_uri, :statements => @statements }) -%>
Modified: branches/packs/app/views/items/show.html.erb (3738 => 3739)
--- branches/packs/app/views/items/show.html.erb 2013-10-01 10:45:10 UTC (rev 3738)
+++ branches/packs/app/views/items/show.html.erb 2013-10-01 15:02:06 UTC (rev 3739)
@@ -124,19 +124,12 @@
<h2>Workflow runs</h2>
<ul>
<% @workflow_runs.each do |workflow_run| %>
- <% label = @statements.query([workflow_run, RDF::RDFS.label, nil]).first_literal %>
<% start_time = @statements.query([workflow_run, RDF::URI("http://www.w3.org/ns/prov#startedAtTime"), nil]).first_object %>
<% end_time = @statements.query([workflow_run, RDF::URI("http://www.w3.org/ns/prov#endedAtTime"), nil]).first_object %>
- <h3><%=h label -%></h3>
+ <h3><%= item_link(@item, workflow_run, @statements) -%></h3>
<ul>
- <% if start_time %>
- <li>Started at <%= datetime(DateTime.parse(start_time.to_s)) -%>.</li>
- <% end %>
- <% if end_time %>
- <li>Ended at <%= datetime(DateTime.parse(end_time.to_s)) -%>.</li>
- <% end %>
<% if start_time && end_time %>
<li>Time elapsed: <%= sprintf("%.2f", (DateTime.parse(end_time.to_s).to_time - DateTime.parse(start_time.to_s).to_time).to_f * 100000) -%> seconds.</li>
<% end %>
Modified: branches/packs/app/views/items/workflow_run.html.erb (3738 => 3739)
--- branches/packs/app/views/items/workflow_run.html.erb 2013-10-01 10:45:10 UTC (rev 3738)
+++ branches/packs/app/views/items/workflow_run.html.erb 2013-10-01 15:02:06 UTC (rev 3739)
@@ -1,135 +1,15 @@
-<h1>Workflow Run</h1>
+<h1>Workflow Run: <%=h item_label(@view_uri, @statements) -%></h1>
-<% workflow_run = @view_uri %>
+<%= render(:partial => "duration", :locals => { :resource_uri => @view_uri, :statements => @statements }) -%>
-<p>View URI: <%=h @view_uri.to_s -%></p>
-<p>View type: <%=h @view_type.to_s -%></p>
+<%= render(:partial => "parent_workflow_run", :locals => { :item => @item, :view_uri => @view_uri, :statements => @statements }) -%>
-<% label = @statements.query([workflow_run, RDF::RDFS.label, nil]).first_literal %>
-<% start_time = @statements.query([workflow_run, RDF::URI("http://www.w3.org/ns/prov#startedAtTime"), nil]).first_object %>
-<% end_time = @statements.query([workflow_run, RDF::URI("http://www.w3.org/ns/prov#endedAtTime"), nil]).first_object %>
+<%= render(:partial => "inputs", :locals => { :item => @item, :view_uri => @view_uri, :statements => @statements }) -%>
-<h3><%=h label -%></h3>
+<%= render(:partial => "process_runs", :locals => { :view_uri => @view_uri, :statements => @statements } ) -%>
-<ul>
- <% if start_time %>
- <li>Started at <%= datetime(DateTime.parse(start_time.to_s)) -%>.</li>
- <% end %>
- <% if end_time %>
- <li>Ended at <%= datetime(DateTime.parse(end_time.to_s)) -%>.</li>
- <% end %>
- <% if start_time && end_time %>
- <li>Time elapsed: <%= sprintf("%.2f", (DateTime.parse(end_time.to_s).to_time - DateTime.parse(start_time.to_s).to_time).to_f * 100000) -%> seconds.</li>
- <% end %>
-</ul>
+<%= render(:partial => "nested_workflow_runs", :locals => { :item => @item, :view_uri => @view_uri, :statements => @statements }) -%>
-<% inputs = @statements.query([workflow_run, RDF::URI("http://purl.org/wf4ever/wfprov#usedInput"), nil]).objects %>
+<%= render(:partial => "outputs", :locals => { :item => @item, :view_uri => @view_uri, :statements => @statements }) -%>
-<% if inputs.count > 0 %>
- <h3>Inputs</h3>
- <table class="simple">
- <tr>
- <th>Label</th>
- <th>Zip entry</th>
- </tr>
- <% inputs.each do |input| %>
- <% local_path = @statements.query([input, RDF::URI("http://ns.taverna.org.uk/2012/tavernaprov/content"), nil]).first_object %>
- <% sha1 = @statements.query([local_path, RDF::URI("http://ns.taverna.org.uk/2012/tavernaprov/sha1"), nil]).first_literal %>
- <% b1 = @statements.query([nil, RDF::URI("http://www.w3.org/ns/prov#entity"), input]).first_subject %>
- <% role = @statements.query([b1, RDF::URI("http://www.w3.org/ns/prov#hadRole"), nil]).first_object %>
- <% label = @statements.query([role, RDF::RDFS.label, nil]).first_literal %>
- <tr>
- <td><%=h label -%></td>
- <td><%=h local_path -%></td>
- </tr>
- <% end %>
- </table>
-<% end %>
-
-<% outputs = @statements.query([nil, RDF::URI("http://purl.org/wf4ever/wfprov#wasOutputFrom"), workflow_run]).subjects %>
-
-<% if outputs.count > 0 %>
- <h3>Outputs</h3>
- <table class="simple">
- <tr>
- <th>Label</th>
- <th>Size</th>
- </tr>
- <% outputs.each do |output| %>
- <% zip_entry = @statements.query([output, RDF::URI("http://ns.taverna.org.uk/2012/tavernaprov/content"), nil]).first_object %>
- <% param = @statements.query([output, RDF::URI("http://purl.org/wf4ever/wfprov#describedByParameter"), nil]).first_object %>
- <% label = @statements.query([param, RDF::RDFS.label, nil]).first_literal %>
- <% sha1 = @statements.query([zip_entry, RDF::URI("http://ns.taverna.org.uk/2012/tavernaprov/sha1"), nil]).first_literal %>
- <% size = @statements.query([zip_entry, RDF::URI("http://ns.taverna.org.uk/2012/tavernaprov/byteCount"), nil]).first_literal %>
- <tr>
- <td><%=h label -%></td>
- <td><%=h size -%></td>
- </tr>
- <% end %>
- </table>
-<% end %>
-
-<% if Rails.env == "development" %>
-
-<h2>Debug</h2>
-
- <div id="tabsContainer" class="tabsContainer"></div>
-
- <div class="tabContainer">
- <div class="tabTitle">Resource as subject</div>
- <div class="tabContent">
- <table class="simple" style="font-size: 80%">
- <% @statements.query(address@hidden, nil, nil]).each do |s, p, o| %>
- <tr>
- <td><%=h shorten_uri(p.to_s) -%></td>
- <td>
- <% if o.resource? %>
- <%= link_to(o.to_s, url_with_params(@resource_uri, :view => o.to_s)) -%></td>
- <% else %>
- <%=h o.to_s -%></td>
- <% end %>
- </td>
- </tr>
- <% end %>
- </table>
- </div>
- </div>
-
- <div class="tabContainer">
- <div class="tabTitle">Resource as object</div>
- <div class="tabContent">
- <table class="simple" style="font-size: 80%">
- <% @statements.query([nil, nil, @view_uri]).each do |s, p, o| %>
- <tr>
- <td>
- <% if s.resource? %>
- <%= link_to(s.to_s, url_with_params(@resource_uri, :view => s.to_s)) -%></td>
- <% else %>
- <%=h s.to_s -%></td>
- <% end %>
- <td><%=h shorten_uri(p.to_s) -%></td>
- </tr>
- <% end %>
- </table>
- </div>
- </div>
-
- <div class="tabContainer">
- <div class="tabTitle">Possible views</div>
- <div class="tabContent">
- <table class="simple" style="font-size: 80%">
- <tr>
- <th>URI</th>
- <th>RDF type</th>
- </tr>
- <% @statements.query([nil, RDF.type, nil]).each do |s, p, o| %>
- <tr>
- <td><%= link_to(s.to_s, url_with_params(@resource_uri, :view => s.to_s)) -%></td>
- <td><%=h shorten_uri(o.to_s) -%></td>
- </tr>
- <% end %>
- </table>
- </div>
- </div>
-
-<% end %>
+<%= render(:partial => "debug", :locals => { :item => @item, :view_uri => @view_uri, :statements => @statements }) -%>