Diff
Modified: branches/packs/app/controllers/packs_controller.rb (3626 => 3627)
--- branches/packs/app/controllers/packs_controller.rb 2013-08-23 13:40:34 UTC (rev 3626)
+++ branches/packs/app/controllers/packs_controller.rb 2013-08-23 13:41:41 UTC (rev 3627)
@@ -14,7 +14,7 @@
RO_RESOURCE = "http://purl.org/wf4ever/ro#Resource"
WORKFLOW_RUN = "http://purl.org/wf4ever/roterms#WorkflowRunBundle"
- before_filter :login_required, :except => [:index, :show, :search, :items, :download, :statistics]
+ before_filter :login_required, :except => [:index, :show, :search, :items, :download, :statistics, :item_show]
before_filter :find_pack_auth, :except => [:index, :new, :create, :search]
@@ -473,6 +473,14 @@
@visible_annotations = @annotations.select { |a| a[:template] != nil }
+ @statements = RDF::Graph.new
+
+ @annotations.each do |annotation|
+ @statements << annotation[:graph]
+ end
+
+ @title = @statements.query(address@hidden, RDF::DC.title, nil]).first_value || @item.folder_entry.entry_name
+
unless @item
render_404("Pack item not found.")
return
Modified: branches/packs/app/models/research_object.rb (3626 => 3627)
--- branches/packs/app/models/research_object.rb 2013-08-23 13:40:34 UTC (rev 3626)
+++ branches/packs/app/models/research_object.rb 2013-08-23 13:41:41 UTC (rev 3627)
@@ -21,6 +21,8 @@
has_many :annotation_resources
+ has_one :pack
+
validates_presence_of :slug
def uri
@@ -555,16 +557,16 @@
ore_directories_aux('', ore_structure).sort
end
- def ore_resources_aux(structure)
+ def ore_resources_aux(structure, prefix)
results = []
structure.each do |entry|
case entry[:type]
when :file
- results << entry
+ results << { :name => entry[:name], :type => entry[:type], :ore_path => "#{prefix}#{entry[:path]}" }
when :folder
- results += ore_resources_aux(entry[:entries])
+ results += ore_resources_aux(entry[:entries], "#{prefix}#{entry[:name]}/")
end
end
@@ -572,7 +574,7 @@
end
def ore_resources
- ore_resources_aux(ore_structure)
+ ore_resources_aux(ore_structure, '')
end
def find_template_from_graph(graph, templates)
Modified: branches/packs/app/views/packs/_add_item.rhtml (3626 => 3627)
--- branches/packs/app/views/packs/_add_item.rhtml 2013-08-23 13:40:34 UTC (rev 3626)
+++ branches/packs/app/views/packs/_add_item.rhtml 2013-08-23 13:41:41 UTC (rev 3627)
@@ -127,10 +127,10 @@
</div>
<% if @ore_resources.count > 1 %>
- <% form_tag("#{rest_resource_uri(@pack)}/relationships") do -%>
- <%= select_tag(:subject, options_for_select(@ore_resources.map { |r| [r[:name], r[:path]] }) ) -%>
- <%= select_tag(:predicate, options_for_select(@ro_relationships.map { |r| [r["label"], r["uri"]] }) ) -%>
- <%= select_tag(:object, options_for_select(@ore_resources.map { |r| [r[:name], r[:path]] }) ) -%>
+ <% form_tag(pack_annotations_path(@pack)) do -%>
+ <%= select_tag(:subject, options_for_select(@ore_resources.map { |r| [r[:name], r[:ore_path]] }) ) -%>
+ <%= select_tag(:annotation_type, options_for_select(@ro_relationships.map { |r| [r["label"], r["label"]] }) ) -%>
+ <%= select_tag(:object, options_for_select(@ore_resources.map { |r| [r[:name], r[:ore_path]] }) ) -%>
<%= submit_tag("Add") -%>
<% end %>
<% end %>
Added: branches/packs/app/views/packs/_annotation.html.erb (0 => 3627)
--- branches/packs/app/views/packs/_annotation.html.erb (rev 0)
+++ branches/packs/app/views/packs/_annotation.html.erb 2013-08-23 13:41:41 UTC (rev 3627)
@@ -0,0 +1,9 @@
+<div class="annotation">
+ <p>Annotation type: <%=h annotation[:template]["label"] -%></p>
+ <% case annotation[:template]["label"]; when "Title" %>
+ <p>
+ <span class="label">Title</span>
+ <span class="value"><%=h annotation[:parameters][:title].to_s -%></span>
+ </p>
+ <% end %>
+</div>
Modified: branches/packs/config/default_settings.yml (3626 => 3627)
--- branches/packs/config/default_settings.yml 2013-08-23 13:40:34 UTC (rev 3626)
+++ branches/packs/config/default_settings.yml 2013-08-23 13:41:41 UTC (rev 3627)
@@ -1484,16 +1484,24 @@
input_selection_relationship:
- label: Input selection relationship
+ label: Input selected
types:
- resource1: user
- resource2: user
+ :subject: workflow
+ :object: contributable
required_statements:
- - [:resource1, "<http://purl.org/wf4ever/roterms#inputSelected>", :resource2]
+ - [:subject, "<http://purl.org/wf4ever/roterms#inputSelected>", :object]
+ title:
+
+ label: Title
+
+ required_statements:
+ - [:resource, "<http://purl.org/dc/terms/title>", :title]
+
+
wf_ro_service_uri: "http://www.example.com/wf-ro/jobs"
wf_ro_service_bearer_token: "bearer-token"
Modified: branches/packs/config/routes.rb (3626 => 3627)
--- branches/packs/config/routes.rb 2013-08-23 13:40:34 UTC (rev 3626)
+++ branches/packs/config/routes.rb 2013-08-23 13:41:41 UTC (rev 3627)
@@ -67,6 +67,7 @@
:items => :get } do |pack|
pack.resources :comments, :collection => { :timeline => :get }
pack.resources :relationships, :collection => { :edit_relationships => :get }
+ pack.resources :annotations
end
# Pack entries. These are not creating using the normal RESTful routes as
Modified: branches/packs/lib/authorization.rb (3626 => 3627)
--- branches/packs/lib/authorization.rb 2013-08-23 13:40:34 UTC (rev 3626)
+++ branches/packs/lib/authorization.rb 2013-08-23 13:41:41 UTC (rev 3627)
@@ -345,6 +345,29 @@
end
+ when "Resource"
+
+ case action
+
+ when "view"
+
+ # You can only view a pack resource if you can view the pack
+ return false unless Authorization.check('view', object.research_object.pack, user)
+
+ # In addition to the above, you must be able to view the
+ # contributable if it is local to myExperiment
+
+ if object.pack_contributable_entry
+ return false unless Authorization.check('view', object.pack_contributable_entry, user)
+ end
+
+ when "create"
+
+ # Only users that can edit the pack can create RO resources
+ return Authorization.check('edit', context, user)
+
+ end
+
when "Message"
case action
when "view"