Modified: branches/wf4ever/app/controllers/research_objects_controller.rb (3205 => 3206)
--- branches/wf4ever/app/controllers/research_objects_controller.rb 2012-11-26 14:22:26 UTC (rev 3205)
+++ branches/wf4ever/app/controllers/research_objects_controller.rb 2012-11-26 14:23:08 UTC (rev 3206)
@@ -4,6 +4,7 @@
# See license.txt for details.
require 'curl'
+require 'wf4ever/rosrs_client'
class ResearchObjectsController < ApplicationController
@@ -44,6 +45,9 @@
# GET /research_objects/1
def show
+
+ @manifest = @contributable.manifest
+
respond_to do |format|
format.html # show.rhtml
end
@@ -137,32 +141,52 @@
def destroy
end
- # GET /research_objects/:id/resource/:path
+ # GET /research_objects/:id/resource/:resource_path
def resource_show
- resource_object = Statement.find(:first, :conditions => {
- :research_object_id => @contributable.id,
- :predicate_text => 'http://purl.org/wf4ever/ro#name',
- :objekt_text => params[:path]})
+# resource_object = Statement.find(:first, :conditions => {
+# :research_object_id => @contributable.id,
+# :predicate_text => 'http://purl.org/wf4ever/ro#name',
+# :objekt_text => params[:path]})
- raise ActiveRecord::RecordNotFound if resource_object.nil?
+# raise ActiveRecord::RecordNotFound if resource_object.nil?
- statements = Statement.find(:all, :conditions => {
- :subject_text => resource_object.subject_text
- })
-
- statements.each do |statement|
+# statements = Statement.find(:all, :conditions => {
+# :subject_text => resource_object.subject_text
+# })
- case statement.predicate_text
- when "http://purl.org/wf4ever/ro#name": @name = statement.objekt_text
- when "http://purl.org/dc/terms/created": @created = Date.parse(statement.objekt_text)
- when "http://purl.org/dc/terms/creator": @creator = statement.objekt_text
- when "http://purl.org/wf4ever/ro#checksum" : @md5 = statement.objekt_text
- when "http://purl.org/wf4ever/ro#filesize" : @size = statement.objekt_text.to_i
+ # Get annotations as merged graph. This will be pulled from cache
+ # eventually.
+
+ session = ROSRS::Session.new(@contributable.url, Conf.rodl_bearer_token)
+
+ @resuri = @contributable.resolve_resource_uri(params[:resource_path])
+
+ @annotations = session.get_annotation_graph(@contributable.url, @resuri)
+
+ @contributable.manifest.query(address@hidden, nil, nil]).each do |statement|
+
+ case statement.predicate.to_s
+ when "http://purl.org/wf4ever/ro#name": @manifest_name = statement.object.to_s
+ when "http://purl.org/dc/terms/created": @manifest_created = Date.parse(statement.object.to_s)
+ when "http://purl.org/dc/terms/creator": @manifest_creator = statement.object.to_s
+ when "http://purl.org/wf4ever/ro#checksum" : @manifest_md5 = statement.object.to_s
+ when "http://purl.org/wf4ever/ro#filesize" : @manifest_size = statement.object.to_s.to_i
end
end
+ @annotations.query(address@hidden, nil, nil]).each do |statement|
+
+ case statement.predicate.to_s
+ when "http://purl.org/dc/terms/title": @title = statement.object.to_s
+ when "http://purl.org/dc/terms/description": @description = statement.object.to_s
+ when "http://purl.org/dc/terms/creator": @creator = statement.object.to_s
+ when "http://purl.org/dc/terms/created": @created = Date.parse(statement.object.to_s)
+ end
+
+ end
+
render :resource_show
end
Modified: branches/wf4ever/app/views/research_objects/resource_show.rhtml (3205 => 3206)
--- branches/wf4ever/app/views/research_objects/resource_show.rhtml 2012-11-26 14:22:26 UTC (rev 3205)
+++ branches/wf4ever/app/views/research_objects/resource_show.rhtml 2012-11-26 14:23:08 UTC (rev 3206)
@@ -1,38 +1,81 @@
-<h1>Resource: <%=h @name -%></h1>
+<h1>Resource: <%=h @manifest_name -%></h1>
-<h2>Pack Items</h2>
+<h2>Basic resource information via manifest</h2>
-<%= research_object_resources(@contributable) -%>
-
-<h2>Basic resource information</h2>
-
<table class="simple">
<tr>
<td>Name</td>
- <td><%=h @name -%></td>
+ <td><%=h @manifest_name -%></td>
</tr>
<tr>
<td>Size</td>
- <td><%=h @size -%></td>
+ <td><%=h @manifest_size -%></td>
</tr>
<tr>
<td>Creator</td>
- <td><%=h @creator -%></td>
+ <td><%=h @manifest_creator -%></td>
</tr>
<tr>
<td>Created at</td>
- <td><%=h @created -%></td>
+ <td><%=h @manifest_created -%></td>
</tr>
<tr>
<td>MD5</td>
- <td><%=h @md5 -%></td>
+ <td><%=h @manifest_md5 -%></td>
</tr>
</table>
<h2>Annotations specific to this resource</h2>
+
+<table class="simple">
+
+ <tr>
+ <td>Title</td>
+ <td><%=h @title -%></td>
+ </tr>
+
+ <tr>
+ <td>Description</td>
+ <td><%=h @description -%></td>
+ </tr>
+
+ <tr>
+ <td>Creator</td>
+ <td><%=h @creator -%></td>
+ </tr>
+
+ <tr>
+ <td>Created at</td>
+ <td><%=h @created -%></td>
+ </tr>
+
+</table>
+
+<h2>Debug</h2>
+
+<div class="fold">
+
+ <div class="foldTitle">Merged annotation bodies (<%= @annotations.query([nil, nil, nil]).count -%>)</div>
+ <div class="foldContent" style="display: none;">
+
+ <div id="statement_list">
+ <% @annotations.query([nil, nil, nil]).each do |statement| %>
+ <div>
+ <table>
+ <tr><td><%=h statement.subject -%></td></tr>
+ <tr><td><%=h statement.predicate -%></td></tr>
+ <tr><td><%=h statement.object -%></td></tr>
+ </table>
+ </div>
+ <% end %>
+ </div>
+
+ </div>
+</div>
+
Modified: branches/wf4ever/app/views/research_objects/show.rhtml (3205 => 3206)
--- branches/wf4ever/app/views/research_objects/show.rhtml 2012-11-26 14:22:26 UTC (rev 3205)
+++ branches/wf4ever/app/views/research_objects/show.rhtml 2012-11-26 14:23:08 UTC (rev 3206)
@@ -1,5 +1,7 @@
<h1>Research Object: <%=h @contributable.title -%></h1>
+<h2>Resources from manifest</h2>
+
<table class="simple">
<tr>
@@ -37,6 +39,7 @@
<% resources = @contributable.wf4ever_resources %>
<% annotations = @contributable.annotations %>
+<% if false %>
<% if resources.length > 0 %>
<h2>Pack Items</h2>
@@ -44,6 +47,7 @@
<%= research_object_resources(@contributable) -%>
<% end %>
+<% end %>
<% if annotations.length > 0 %>