Diff
Modified: branches/wf4ever/app/controllers/packs_controller.rb (3374 => 3375)
--- branches/wf4ever/app/controllers/packs_controller.rb 2013-01-29 18:41:16 UTC (rev 3374)
+++ branches/wf4ever/app/controllers/packs_controller.rb 2013-01-29 18:41:31 UTC (rev 3375)
@@ -96,43 +96,24 @@
end
end
+
def edit_annotations
-
- session = ROSRS::Session.new(@pack.ro_uri, Conf.rodl_bearer_token)
-
- @annotations = session.get_annotation_graphs(@pack.ro_uri, @pack.ro_uri)
+ @annotations = get_annotations @pack.ro_uri, @pack.ro_uri
end
def update_annotations
-
resource_uri = @pack.ro_uri
-
update_annotations_aux(@pack, @pack.ro_uri, resource_uri)
-
redirect_to edit_annotations_pack_path(@pack)
-
end
- def resource_types(resuri)
- @annotations.query([resuri, RDF::type, nil]).map do |s,p,type|
- type.to_s
- end
- end
- def textual_type(typeuri)
- type = Conf.ro_resource_types.rassoc(typeuri)
- type.first if type
- end
-
# GET /packs/:id/resources/:resource_path
def resource_show
# Get annotations as merged graph. This will be pulled from cache
# eventually.
-
- session = ROSRS::Session.new(@pack.ro_uri, Conf.rodl_bearer_token)
- @annotations = session.get_annotation_graph(@pack.ro_uri, @resuri)
+ @annotations = get_annotations @pack.ro_uri, @resuri
@annotations.query(address@hidden, nil, nil]).each do |statement|
- puts 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
@@ -141,9 +122,9 @@
end
end
- @types = resource_types(@resuri).map do |typeuri|
- textual_type(typeuri) or typeuri
- end
+ puts "XXXXXXXXXXXXXXXZZZ"
+ puts @resuri
+ @types = resource_types_as_labels @annotations, @resuri
render :resource_show
end
@@ -213,12 +194,9 @@
end
def edit_resource_annotations
-
@resource_uri = @pack.resolve_resource_uri(params[:resource_path])
-
- session = ROSRS::Session.new(@pack.ro_uri, Conf.rodl_bearer_token)
-
- @annotations = session.get_annotation_graphs(@pack.ro_uri, @resource_uri)
+ # FIXME: @annotations is really @annotations_graphs ()
+ @annotations = get_annotation_graphs(@pack.ro_uri, @pack.ro_uri)
end
def update_resource_annotations
Modified: branches/wf4ever/app/helpers/research_objects_helper.rb (3374 => 3375)
--- branches/wf4ever/app/helpers/research_objects_helper.rb 2013-01-29 18:41:16 UTC (rev 3374)
+++ branches/wf4ever/app/helpers/research_objects_helper.rb 2013-01-29 18:41:31 UTC (rev 3375)
@@ -38,6 +38,34 @@
uris
end
+
+ def get_annotations(ro_uri, resource_uri)
+ session = ROSRS::Session.new(ro_uri, Conf.rodl_bearer_token)
+ session.get_annotation_graph(ro_uri, resource_uri)
+ end
+
+ def get_annotation_graphs(ro_uri, resource_uri)
+ session = ROSRS::Session.new(ro_uri, Conf.rodl_bearer_token)
+ session.get_annotation_graphs(ro_uri, resource_uri)
+ end
+
+ def resource_types(annotations, resource_uri)
+ annotations.graph.query([RDF::URI(resource_uri), RDF::type, nil]).map do |s,p,type|
+ type.to_s
+ end
+ end
+
+ def resource_types_as_labels(annotations, resource_uri)
+ resource_types(annotations, resource_uri).map do |type_uri|
+ textual_type(type_uri) or type_uri
+ end
+ end
+
+ def textual_type(typeuri)
+ type = Conf.ro_resource_types.rassoc(typeuri)
+ type.first if type
+ end
+
def research_object_statements(contributable)
return [] unless contributable.respond_to?(:content_blob)
Modified: branches/wf4ever/app/views/packs/_items.rhtml (3374 => 3375)
--- branches/wf4ever/app/views/packs/_items.rhtml 2013-01-29 18:41:16 UTC (rev 3374)
+++ branches/wf4ever/app/views/packs/_items.rhtml 2013-01-29 18:41:31 UTC (rev 3375)
@@ -98,7 +98,16 @@
</li>
<% else %>
<% if e && e.name %>
- <li><%= link_to(e.ro_local_uri, pack_resources_path(pack) + '/' + e.ro_local_uri) -%></li>
+ <%
+ label = e.ro_local_uri
+ annotations = get_annotations(pack.ro_uri, e.uri)
+ types = resource_types_as_labels(annotations, e.uri)
+ %>
+ <li><%= link_to(label, pack_resources_path(pack) + '/' + e.ro_local_uri) -%>
+ <% if not types.empty? %>
+ (<%= types -%>)
+ <% end %>
+ </li>
<% end %>
<% end %>
<% end -%>