myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [3405] branches/wf4ever: added relationships to p


From: noreply
Subject: [myexperiment-hackers] [3405] branches/wf4ever: added relationships to pack page
Date: Thu, 7 Feb 2013 01:46:59 +0000 (UTC)

Revision
3405
Author
dgc
Date
2013-02-07 01:46:58 +0000 (Thu, 07 Feb 2013)

Log Message

added relationships to pack page

Modified Paths

Diff

Modified: branches/wf4ever/app/controllers/packs_controller.rb (3404 => 3405)


--- branches/wf4ever/app/controllers/packs_controller.rb	2013-02-06 17:00:04 UTC (rev 3404)
+++ branches/wf4ever/app/controllers/packs_controller.rb	2013-02-07 01:46:58 UTC (rev 3405)
@@ -73,6 +73,14 @@
 
     @annotations = session.get_annotation_graph(@pack.ro_uri, @pack.ro_uri)
 
+    # Get all the annotations as a merged graph
+
+    @all_annotations = RDF::Graph.new
+
+    session.get_annotation_graphs(@pack.ro_uri).each do |ag|
+      @all_annotations << ag[:body]
+    end
+
     if allow_statistics_logging(@pack)
       @viewing = Viewing.create(:contribution => @pack.contribution, :user => (logged_in? ? current_user : nil), :user_agent => request.env['HTTP_USER_AGENT'], :accessed_from_site => accessed_from_website?())
     end

Modified: branches/wf4ever/app/views/packs/show.rhtml (3404 => 3405)


--- branches/wf4ever/app/views/packs/show.rhtml	2013-02-06 17:00:04 UTC (rev 3404)
+++ branches/wf4ever/app/views/packs/show.rhtml	2013-02-07 01:46:58 UTC (rev 3405)
@@ -122,6 +122,30 @@
 			<%= render :partial => "relationships/relationships", :locals => { :context => @pack, :show_delete => true } -%>
       <% end %>
 
+      <% input_selected = @all_annotations.query([nil, RDF::ROTERMS2.inputSelected, nil]) %>
+
+      <% if input_selected.count == 0 %>
+        <p><i>There are no relationships in this pack.</i></p>
+      <% else %>
+        <!-- FIXME: This is *not* the right way to create labels for resources. -->
+        <ul>
+          <% input_selected.each do |s| %>
+            <li>
+              <%=
+              entry = @pack.contributable_entries.find_by_uri(s.object.to_s)
+              label = entry.ro_local_uri.split("/").last
+              link_to(label, pack_resources_path(@pack) + '/' + entry.ro_local_uri)
+              -%>
+            was selected as input for
+              <%=
+              entry = @pack.contributable_entries.find_by_uri(s.subject.to_s)
+              label = entry.ro_local_uri.split("/").last
+              link_to(label, pack_resources_path(@pack) + '/' + entry.ro_local_uri)
+              -%>
+            </li>
+          <% end %>
+        </ul>
+      <% end %>
 			
       <% if @authorised_to_edit %>
         <% if @pack.items_count < 2 %>
@@ -130,17 +154,19 @@
 
         <% else %>
 
+<div >
           <% form_tag("#{rest_resource_uri(@pack)}/relationships") do -%>
 
-              <% @resource_options = @pack.contributable_entries.map do |e| [URI::decode(e.ro_local_uri), e.ro_local_uri] end %> 
+              <% @resource_options = @pack.contributable_entries.map do |e| [URI::decode(e.ro_local_uri).split("/").last, e.ro_local_uri] end %> 
               <% @relationship_options = Conf.ro_terms %>
-              <div><%= select_tag("subject",   options_for_select(@resource_options)) -%></div>
-              <div><%= select_tag("predicate", options_for_select(@relationship_options)) -%></div>
-              <div><%= select_tag("object",    options_for_select(@resource_options)) -%></div>
+              <div style="margin: 2px;"><%= select_tag("subject",   options_for_select(@resource_options)) -%></div>
+              <div style="margin: 2px;"><%= select_tag("predicate", options_for_select(@relationship_options)) -%></div>
+              <div style="margin: 2px;"><%= select_tag("object",    options_for_select(@resource_options)) -%></div>
 
-            <input type="submit" value="Add relationship"/>
+            <input style="margin-top: 8px" type="submit" value="Add relationship"/>
 
           <% end %>
+</div>
         <% end %>
       <% end %>
 

Modified: branches/wf4ever/config/initializers/rosrs_patch.rb (3404 => 3405)


--- branches/wf4ever/config/initializers/rosrs_patch.rb	2013-02-06 17:00:04 UTC (rev 3404)
+++ branches/wf4ever/config/initializers/rosrs_patch.rb	2013-02-07 01:46:58 UTC (rev 3405)
@@ -3,3 +3,32 @@
   attr_accessor :graph
 end
 
+# resource_uri handling is different in that if it is nil then it will return
+# all annotation statements for the entire RO
+
+class ROSRS::Session
+  def get_annotation_statements(ro_uri, resource_uri=nil)
+    manifesturi, manifest = get_manifest(ro_uri)
+    statements = []
+
+    resource_uri = RDF::URI.parse(ro_uri).join(RDF::URI.parse(resource_uri)) if ro_uri && resource_uri
+
+    manifest.query(:object => resource_uri) do |stmt|
+      if [RDF::AO.annotatesResource,RDF::RO.annotatesAggregatedResource].include?(stmt.predicate)
+        statements << stmt
+      end
+    end
+    statements
+  end
+end
+
+# ROTERMS in the gem has the wrong base URI
+
+module RDF
+  class ROTERMS2 < Vocabulary("http://purl.org/wf4ever/roterms#")
+    property :note
+    property :resource
+    property :defaultBase
+  end
+end
+

reply via email to

[Prev in Thread] Current Thread [Next in Thread]