Diff
Modified: branches/wf4ever/app/controllers/application_controller.rb (3294 => 3295)
--- branches/wf4ever/app/controllers/application_controller.rb 2013-01-10 11:23:15 UTC (rev 3294)
+++ branches/wf4ever/app/controllers/application_controller.rb 2013-01-15 11:24:07 UTC (rev 3295)
@@ -6,6 +6,9 @@
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
+require 'rdf'
+require 'wf4ever/rosrs_client'
+
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details
@@ -1054,4 +1057,77 @@
format.html { redirect_to target, (referrer.blank? ? nil : params) }
end
end
+
+ def create_annotation_body(ro_uri, resource_uri, body, namespaces)
+
+ namespaces["rdf"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+
+ doc = LibXML::XML::Document.new
+ doc.root = LibXML::XML::Node.new("rdf:RDF")
+ doc.root["xml:base"] = ro_uri
+
+ namespaces.each do |name, uri|
+ doc.root["xmlns:#{name}"] = uri
+ end
+
+ description = LibXML::XML::Node.new("rdf:Description")
+ description["rdf:about"] = resource_uri.to_s
+ description << body
+ doc.root << description
+
+ doc
+ end
+
+ def update_annotations_aux(contributable, ro_uri, resource_uri)
+
+ session = ROSRS::Session.new(ro_uri, Conf.rodl_bearer_token)
+
+ if params[:commit] == 'Add' || params[:commit] == 'Edit'
+
+ case params[:template]
+ when "Title"
+ ao_body = create_annotation_body(ro_uri, resource_uri,
+ LibXML::XML::Node.new('dct:title', params[:value]),
+ { "dct" => "http://purl.org/dc/terms/" })
+ when "Creator"
+ ao_body = create_annotation_body(ro_uri, resource_uri,
+ LibXML::XML::Node.new('dct:creator', params[:value]),
+ { "dct" => "http://purl.org/dc/terms/" })
+ when "Contributor"
+ ao_body = create_annotation_body(ro_uri, resource_uri,
+ LibXML::XML::Node.new('dct:contributor', params[:value]),
+ { "dct" => "http://purl.org/dc/terms/" })
+ when "Description"
+ ao_body = create_annotation_body(ro_uri, resource_uri,
+ LibXML::XML::Node.new('dct:description', params[:value]),
+ { "dct" => "http://purl.org/dc/terms/" })
+ end
+ end
+
+ if params[:commit] == 'Add'
+ if ao_body
+ agraph = ROSRS::RDFGraph.new(:data ="" ao_body.to_s, :format => :xml)
+
+ begin
+ code, reason, stub_uri, body_uri = session.create_internal_annotation(ro_uri, resource_uri, agraph)
+ rescue ROSRS::Exception => e
+ contributable.errors.add(params[:template], 'Error from remote server')
+ end
+ end
+ end
+
+ if params[:commit] == 'Edit'
+ if ao_body
+ agraph = ROSRS::RDFGraph.new(:data ="" ao_body.to_s, :format => :xml)
+
+ c, r, body_uri = session.update_internal_annotation(ro_uri, params[:stub_uri], resource_uri, agraph)
+ end
+ end
+
+ if params[:commit] == 'Delete'
+ c, r, h, d = session.do_request("DELETE", params[:stub_uri], {} )
+ c, r, h, d = session.do_request("DELETE", params[:body_uri], {} )
+ end
+
+ end
end
Modified: branches/wf4ever/app/controllers/packs_controller.rb (3294 => 3295)
--- branches/wf4ever/app/controllers/packs_controller.rb 2013-01-10 11:23:15 UTC (rev 3294)
+++ branches/wf4ever/app/controllers/packs_controller.rb 2013-01-15 11:24:07 UTC (rev 3295)
@@ -13,6 +13,8 @@
before_filter :find_pack_auth, :except => [:index, :new, :create, :search]
before_filter :set_sharing_mode_variables, : [:show, :new, :create, :edit, :update]
+
+ before_filter :get_manifest_metadata, : [:resource_show, :edit_resource_annotations]
# declare sweepers and which actions should invoke them
cache_sweeper :pack_sweeper, : [ :create, :update, :destroy ]
@@ -82,41 +84,33 @@
end
end
- # GET /packs/:id/resources/:resource_path
- def resource_show
+ def edit_annotations
-# resource_object = Statement.find(:first, :conditions => {
-# :research_object_id => @contributable.id,
-# :predicate_text => 'http://purl.org/wf4ever/ro#name',
-# :objekt_text => params[:path]})
+ session = ROSRS::Session.new(@pack.ro_uri, Conf.rodl_bearer_token)
-# raise ActiveRecord::RecordNotFound if resource_object.nil?
+ @annotations = session.get_annotation_graphs(@pack.ro_uri, @pack.ro_uri)
+ end
-# statements = Statement.find(:all, :conditions => {
-# :subject_text => resource_object.subject_text
-# })
+ 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
+
+ # 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)
- @resuri = @pack.resolve_resource_uri(params[:resource_path])
-
@annotations = session.get_annotation_graph(@pack.ro_uri, @resuri)
- @pack.contributable_entries.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
@@ -165,6 +159,26 @@
}
end
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)
+ end
+
+ def update_resource_annotations
+
+ resource_uri = @pack.resolve_resource_uri(params[:resource_path])
+puts " [params[:resource_path], resource_uri] = #{ [params[:resource_path], resource_uri].inspect}"
+
+ update_annotations_aux(@pack, @pack.ro_uri, resource_uri)
+
+ redirect_to(pack_resource_edit_path(@pack, params[:resource_path]))
+ end
+
# GET /packs/1;download
def download
@@ -244,6 +258,31 @@
respond_to do |format|
if @pack.update_attributes(params[:pack])
+
+ # Check that the RO exists and if not, create it.
+
+ unless params[:pack][:ro_uri].empty?
+
+ rodl_uri = URI.parse(@pack.ro_uri)
+
+ path_bits = rodl_uri.path.sub(/\/$/, "").split("/")
+
+ slug = path_bits.pop
+
+ rodl_uri.path = "#{path_bits.join("/")}/"
+
+ session = ROSRS::Session.new(rodl_uri.to_s, Conf.rodl_bearer_token)
+
+ if session.check_research_object(slug) == false
+ c, r, u, m = session.create_research_object(slug)
+
+ if c != 201
+ flash.now[:error] = "Unable to create research object: #{r}"
+ end
+ end
+
+ end
+
@pack.refresh_tags(convert_tags_to_gem_format(params[:pack][:tag_list]), current_user) if params[:pack][:tag_list]
policy_err_msg = update_policy(@pack, params)
update_layout(@pack, params[:layout])
@@ -504,29 +543,33 @@
def find_pack_auth
action_permissions = {
- "create" => "create",
- "create_item" => "edit",
- "create_resource" => "edit",
- "destroy" => "destroy",
- "destroy_item" => "destroy",
- "download" => "download",
- "edit" => "edit",
- "edit_item" => "edit",
- "favourite" => "view",
- "favourite_delete" => "view",
- "index" => "view",
- "items" => "view",
- "new" => "create",
- "new_item" => "edit",
- "quick_add" => "edit",
- "resolve_link" => "edit",
- "search" => "view",
- "show" => "view",
- "resource_show" => "view",
- "statistics" => "view",
- "tag" => "view",
- "update" => "edit",
- "update_item" => "edit"
+ "create" => "create",
+ "create_item" => "edit",
+ "create_resource" => "edit",
+ "destroy" => "destroy",
+ "destroy_item" => "destroy",
+ "download" => "download",
+ "edit" => "edit",
+ "edit_item" => "edit",
+ "edit_annotations" => "edit",
+ "update_annotations" => "edit",
+ "edit_resource_annotations" => "edit",
+ "update_resource_annotations" => "edit",
+ "favourite" => "view",
+ "favourite_delete" => "view",
+ "index" => "view",
+ "items" => "view",
+ "new" => "create",
+ "new_item" => "edit",
+ "quick_add" => "edit",
+ "resolve_link" => "edit",
+ "search" => "view",
+ "show" => "view",
+ "resource_show" => "view",
+ "statistics" => "view",
+ "tag" => "view",
+ "update" => "edit",
+ "update_item" => "edit"
}
begin
@@ -594,4 +637,24 @@
final_errs.add_to_base(msg)
end
end
+
+ def get_manifest_metadata
+
+ session = ROSRS::Session.new(@pack.ro_uri, Conf.rodl_bearer_token)
+
+ @resuri = @pack.resolve_resource_uri(params[:resource_path])
+
+ @pack.contributable_entries.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
+
+ end
end
Modified: branches/wf4ever/app/controllers/workflows_controller.rb (3294 => 3295)
--- branches/wf4ever/app/controllers/workflows_controller.rb 2013-01-10 11:23:15 UTC (rev 3294)
+++ branches/wf4ever/app/controllers/workflows_controller.rb 2013-01-15 11:24:07 UTC (rev 3295)
@@ -717,59 +717,13 @@
end
def update_annotations
-
- session = ROSRS::Session.new(@workflow.ro_uri, Conf.rodl_bearer_token)
resource_uri = workflow_url(@workflow)
- if params[:commit] == 'Add' || params[:commit] == 'Edit'
+ update_annotations_aux(@workflow, @workflow.ro_uri, resource_uri)
- case params[:template]
- when "Title"
- ao_body = @workflow.create_annotation_body(resource_uri,
- LibXML::XML::Node.new('dct:title', params[:value]),
- { "dct" => "http://purl.org/dc/terms/" })
- when "Creator"
- ao_body = @workflow.create_annotation_body(resource_uri,
- LibXML::XML::Node.new('dct:creator', params[:value]),
- { "dct" => "http://purl.org/dc/terms/" })
- when "Contributor"
- ao_body = @workflow.create_annotation_body(resource_uri,
- LibXML::XML::Node.new('dct:contributor', params[:value]),
- { "dct" => "http://purl.org/dc/terms/" })
- when "Description"
- ao_body = @workflow.create_annotation_body(resource_uri,
- LibXML::XML::Node.new('dct:description', params[:value]),
- { "dct" => "http://purl.org/dc/terms/" })
- end
- end
-
- if params[:commit] == 'Add'
- if ao_body
- agraph = ROSRS::RDFGraph.new(:data ="" ao_body.to_s, :format => :xml)
-
- begin
- code, reason, stub_uri, body_uri = session.create_internal_annotation(@workflow.ro_uri, resource_uri, agraph)
- rescue ROSRS::Exception => e
- @workflow.errors.add(params[:template], 'Error from remote server')
- end
- end
- end
-
- if params[:commit] == 'Edit'
- if ao_body
- agraph = ROSRS::RDFGraph.new(:data ="" ao_body.to_s, :format => :xml)
-
- c, r, body_uri = session.update_internal_annotation(@workflow.ro_uri, params[:stub_uri], resource_uri, agraph)
- end
- end
-
- if params[:commit] == 'Delete'
- c, r, h, d = session.do_request("DELETE", params[:stub_uri], {} )
- c, r, h, d = session.do_request("DELETE", params[:body_uri], {} )
- end
-
redirect_to edit_annotations_workflow_path(@workflow)
+
end
protected
Modified: branches/wf4ever/app/helpers/application_helper.rb (3294 => 3295)
--- branches/wf4ever/app/helpers/application_helper.rb 2013-01-10 11:23:15 UTC (rev 3294)
+++ branches/wf4ever/app/helpers/application_helper.rb 2013-01-15 11:24:07 UTC (rev 3295)
@@ -1621,4 +1621,10 @@
@layout = layout || {"layout" => Conf.page_template, "stylesheets" => [Conf.stylesheet]}
end
+ def get_simple_annotations(annotations, predicate)
+ annotations.select do |annotation|
+ annotation[:body].count == 1 && annotation[:body].query(:predicate => predicate).count == 1
+ end
+ end
+
end
Modified: branches/wf4ever/app/models/workflow.rb (3294 => 3295)
--- branches/wf4ever/app/models/workflow.rb 2013-01-10 11:23:15 UTC (rev 3294)
+++ branches/wf4ever/app/models/workflow.rb 2013-01-15 11:24:07 UTC (rev 3295)
@@ -374,74 +374,4 @@
WsdlDeprecation.find_all_by_wsdl(workflow_processors.map {|wp| wp.wsdl}).group_by {|wd| wd.deprecation_event}
end
- def create_annotation_body(resource_uri, body, namespaces)
-
- namespaces["rdf"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-
- doc = LibXML::XML::Document.new
- doc.root = LibXML::XML::Node.new("rdf:RDF")
- doc.root["xml:base"] = ro_uri
-
- namespaces.each do |name, uri|
- doc.root["xmlns:#{name}"] = uri
- end
-
- description = LibXML::XML::Node.new("rdf:Description")
- description["rdf:about"] = resource_uri
- description << body
- doc.root << description
-
- doc
- end
-
- def set_simple_annotation(resource_uri, predicate, namespaces, term, new_value)
-
- session = ROSRS::Session.new(ro_uri, Conf.rodl_bearer_token)
-
- # Remove existing annotations of the same structure
-
- annotations = session.get_annotation_graphs(ro_uri, resource_uri)
-
- annotations.each do |annotation|
-
- next unless annotation[:body].count == 1
- next unless annotation[:body].query(:predicate => predicate).count == 1
-
- c, r, h, d = session.do_request("DELETE", annotation[:stub], {} )
- c, r, h, d = session.do_request("DELETE", annotation[:body_uri], {} )
- end
-
- # Create the new annotation
-
- annotation_body = create_annotation_body(resource_uri,
- LibXML::XML::Node.new(term, new_value),
- namespaces)
-
- agraph = ROSRS::RDFGraph.new(:data ="" annotation_body.to_s, :format => :xml)
-
- code, reason, stub_uri, body_uri = session.create_internal_annotation(ro_uri, resource_uri, agraph)
- end
-
- def get_simple_annotations(annotations, predicate)
- annotations.select do |annotation|
- annotation[:body].count == 1 && annotation[:body].query(:predicate => predicate).count == 1
- end
- end
-
- def set_dc_title(resource_uri, value)
- set_simple_annotation(resource_uri,
- RDF::DC.title,
- { "dct" => "http://purl.org/dc/terms/" },
- "dct:title",
- value)
- end
-
- def set_dc_description(resource_uri, value)
- set_simple_annotation(resource_uri,
- RDF::DC.description,
- { "dct" => "http://purl.org/dc/terms/" },
- "dct:description",
- value)
- end
-
end
Added: branches/wf4ever/app/views/contributions/_edit_annotations.rhtml (0 => 3295)
--- branches/wf4ever/app/views/contributions/_edit_annotations.rhtml (rev 0)
+++ branches/wf4ever/app/views/contributions/_edit_annotations.rhtml 2013-01-15 11:24:07 UTC (rev 3295)
@@ -0,0 +1,57 @@
+<%
+templates = [
+ {
+ :label => 'Title',
+ :predicate => RDF::DC.title,
+ :add_text => 'New title'
+ },
+ {
+ :label => 'Creator',
+ :predicate => RDF::DC.creator,
+ :add_text => 'New creator'
+ },
+ {
+ :label => 'Contributor',
+ :predicate => RDF::DC.contributor,
+ :add_text => 'New contributor'
+ },
+ {
+ :label => 'Description',
+ :predicate => RDF::DC.description,
+ :add_text => 'New description'
+ }
+]
+%>
+
+<% templates.each do |template| %>
+
+ <h2><%= template[:label] -%></h2>
+
+ <ul>
+
+ <% get_simple_annotations(annotations, template[:predicate]).each do |annotation| %>
+ <% value = ""; annotation[:body].query([RDF::URI.parse(resource_uri), template[:predicate], nil]).each do |statement| value = statement.object.to_s end %>
+ <li>
+ <% form_tag(update_path) do %>
+ <%= text_field_tag("value", value) -%>
+ <%= hidden_field_tag("template", template[:label]) -%>
+ <%= hidden_field_tag("stub_uri", annotation[:stub].to_s) -%>
+ <%= hidden_field_tag("body_uri", annotation[:body_uri].to_s) -%>
+ <%= submit_tag("Edit") -%>
+ <%= submit_tag("Delete") -%>
+ <% end %>
+ </li>
+ <% end %>
+
+ <% form_tag(update_path) do %>
+ <li>
+ <%= text_field_tag('value', '', :placeholder => template[:add_text]) -%>
+ <%= hidden_field_tag("template", template[:label]) -%>
+ <%= submit_tag("Add") -%>
+ </li>
+ <% end %>
+
+ </ul>
+
+<% end %>
+
Modified: branches/wf4ever/app/views/packs/_breadcrumbs.rhtml (3294 => 3295)
--- branches/wf4ever/app/views/packs/_breadcrumbs.rhtml 2013-01-10 11:23:15 UTC (rev 3294)
+++ branches/wf4ever/app/views/packs/_breadcrumbs.rhtml 2013-01-15 11:24:07 UTC (rev 3295)
@@ -1,24 +1,30 @@
<li><%= link_to 'Packs', packs_path %></li>
-<% if ["show", "new", "edit", "all", "new_item", "edit_item", "search"].include? controller.action_name.to_s %>
- <% case controller.action_name.to_s; when "show" %>
- <li><%= h(@pack.title) %></li>
- <% when "new" %>
- <li>New Pack</li>
- <% when "edit" %>
- <li><%= link_to "#{h(@pack.title)}", pack_path(@pack) %></li>
- <li>Manage</li>
- <% when "new_item" %>
- <li><%= link_to "#{h(@pack.title)}", pack_path(@pack) %></li>
- <li>Add New Item</li>
- <% when "edit_item" %>
- <li><%= link_to "#{h(@pack.title)}", pack_path(@pack) %></li>
- <li>Edit Item Entry</li>
- <% when "all" %>
- <li>All Packs</li>
- <% when "search" %>
- <li>Search Results</li>
- <% else %>
- <!-- no breadcrumb -->
- <% end %>
+<% case controller.action_name.to_s; when "show" %>
+ <li><%= h(@pack.title) %></li>
+<% when "new" %>
+ <li>New Pack</li>
+<% when "edit" %>
+ <li><%= link_to "#{h(@pack.title)}", pack_path(@pack) %></li>
+ <li>Manage</li>
+<% when "new_item" %>
+ <li><%= link_to "#{h(@pack.title)}", pack_path(@pack) %></li>
+ <li>Add New Item</li>
+<% when "edit_item" %>
+ <li><%= link_to "#{h(@pack.title)}", pack_path(@pack) %></li>
+ <li>Edit Item Entry</li>
+<% when "all" %>
+ <li>All Packs</li>
+<% when "search" %>
+ <li>Search Results</li>
+<% when "edit_annotations" %>
+ <li><%= link_to "#{h(@pack.title)}", pack_path(@pack) %></li>
+ <li>Edit</li>
+<% when "resource_show" %>
+ <li><%= link_to "#{h(@pack.title)}", pack_path(@pack) %></li>
+ <li><%=h @manifest_name -%></li>
+<% when "edit_resource_annotations" %>
+ <li><%= link_to "#{h(@pack.title)}", pack_path(@pack) %></li>
+ <li><%= link_to h(@manifest_name), pack_resource_path(@pack, params[:resource_path]) -%></li>
+ <li>Edit</li>
<% end %>
Added: branches/wf4ever/app/views/packs/edit_annotations.rhtml (0 => 3295)
--- branches/wf4ever/app/views/packs/edit_annotations.rhtml (rev 0)
+++ branches/wf4ever/app/views/packs/edit_annotations.rhtml 2013-01-15 11:24:07 UTC (rev 3295)
@@ -0,0 +1,12 @@
+<h1>Edit annotations for <%= h(@pack.title) -%></h1>
+
+<%= error_messages_for :pack -%>
+
+<%= render(:partial => 'contributions/edit_annotations', :locals => { :update_path => update_annotations_pack_path(@pack), :resource_uri => @pack.ro_uri, :annotations => @annotations }) -%>
+
+<p style="text-align: center; margin: 1em">
+ <% form_tag( { :action ="" "show" }, :method => :get) do %>
+ <%= submit_tag("Return to pack") -%>
+ <% end %>
+</p>
+
Added: branches/wf4ever/app/views/packs/edit_resource_annotations.rhtml (0 => 3295)
--- branches/wf4ever/app/views/packs/edit_resource_annotations.rhtml (rev 0)
+++ branches/wf4ever/app/views/packs/edit_resource_annotations.rhtml 2013-01-15 11:24:07 UTC (rev 3295)
@@ -0,0 +1,14 @@
+<% if false %>
+<h1>Edit annotations for <%= h(@manifest_name) -%></h1>
+
+<%= error_messages_for :pack -%>
+<% end %>
+
+<%= render(:partial => 'contributions/edit_annotations', :locals => { :update_path => pack_resource_update_path(@pack, params[:resource_path]), :resource_uri => @resource_uri, :annotations => @annotations }) -%>
+
+<p style="text-align: center; margin: 1em">
+ <% form_tag( { :action ="" "show" }, :method => :get) do %>
+ <%= submit_tag("Return to pack") -%>
+ <% end %>
+</p>
+
Modified: branches/wf4ever/app/views/packs/resource_show.rhtml (3294 => 3295)
--- branches/wf4ever/app/views/packs/resource_show.rhtml 2013-01-10 11:23:15 UTC (rev 3294)
+++ branches/wf4ever/app/views/packs/resource_show.rhtml 2013-01-15 11:24:07 UTC (rev 3295)
@@ -1,5 +1,15 @@
<h1>Resource: <%=h @manifest_name -%></h1>
+<div style="margin-top: 1em;">
+ <ul class="sectionIcons" style="margin-top: 0.7em; margin-bottom: 0.6em;">
+ <% if Authorization.check("edit", @pack, current_user) %>
+ <% if @pack.ro_uri %>
+ <li style="margin-left: 0;"><%= icon('edit', pack_resource_edit_path(@pack, params[:resource_path]), nil, nil, "Edit Annotations") %></li>
+ <% end %>
+ <% end %>
+ </ul>
+</div>
+
<h2>Basic resource information via manifest</h2>
<table class="simple">
@@ -57,6 +67,28 @@
</table>
+<% if false %>
+
+<h2>Workflow inputs (via WF-DESC)</h2>
+
+<ul>
+ <% @annotations.query([nil, RDF::URI.parse("http://purl.org/wf4ever/wfdesc#hasInput"), nil]).each do |statement| %>
+ <% input_labels = @annotations.query([statement.object, RDF::URI.parse("http://www.w3.org/2000/01/rdf-schema#label"), nil]) %>
+ <li>Input: <%= input_labels.first.object -%></li>
+ <% end %>
+</ul>
+
+<h2>Workflow outputs (via WF-DESC)</h2>
+
+<ul>
+ <% @annotations.query([nil, RDF::URI.parse("http://purl.org/wf4ever/wfdesc#hasOutput"), nil]).each do |statement| %>
+ <% input_labels = @annotations.query([statement.object, RDF::URI.parse("http://www.w3.org/2000/01/rdf-schema#label"), nil]) %>
+ <li>Output: <%= input_labels.first.object -%></li>
+ <% end %>
+</ul>
+
+<% end %>
+
<h2>Debug</h2>
<div class="fold">
Modified: branches/wf4ever/app/views/workflows/edit_annotations.rhtml (3294 => 3295)
--- branches/wf4ever/app/views/workflows/edit_annotations.rhtml 2013-01-10 11:23:15 UTC (rev 3294)
+++ branches/wf4ever/app/views/workflows/edit_annotations.rhtml 2013-01-15 11:24:07 UTC (rev 3295)
@@ -2,63 +2,8 @@
<%= error_messages_for :workflow -%>
-<%
-templates = [
- {
- :label => 'Title',
- :predicate => RDF::DC.title,
- :add_text => 'New title'
- },
- {
- :label => 'Creator',
- :predicate => RDF::DC.creator,
- :add_text => 'New creator'
- },
- {
- :label => 'Contributor',
- :predicate => RDF::DC.contributor,
- :add_text => 'New contributor'
- },
- {
- :label => 'Description',
- :predicate => RDF::DC.description,
- :add_text => 'New description'
- }
-]
-%>
+<%= render(:partial => 'contributions/edit_annotations', :locals => { :update_path => update_annotations_workflow_path(@workflow), :resource_uri => workflow_url(@workflow), :annotations => @annotations }) -%>
-<% templates.each do |template| %>
-
- <h2><%= template[:label] -%></h2>
-
- <ul>
-
- <% @workflow.get_simple_annotations(@annotations, template[:predicate]).each do |annotation| %>
- <% value = ""; annotation[:body].query([RDF::URI.parse(workflow_url(@workflow)), template[:predicate], nil]).each do |statement| value = statement.object.to_s end %>
- <li>
- <% form_tag(update_annotations_workflow_path(@workflow)) do %>
- <%= text_field_tag("value", value) -%>
- <%= hidden_field_tag("template", template[:label]) -%>
- <%= hidden_field_tag("stub_uri", annotation[:stub].to_s) -%>
- <%= hidden_field_tag("body_uri", annotation[:body_uri].to_s) -%>
- <%= submit_tag("Edit") -%>
- <%= submit_tag("Delete") -%>
- <% end %>
- </li>
- <% end %>
-
- <% form_tag(update_annotations_workflow_path(@workflow)) do %>
- <li>
- <%= text_field_tag('value', '', :placeholder => template[:add_text]) -%>
- <%= hidden_field_tag("template", template[:label]) -%>
- <%= submit_tag("Add") -%>
- </li>
- <% end %>
-
- </ul>
-
-<% end %>
-
<p style="text-align: center; margin: 1em">
<% form_tag( { :action ="" "show" }, :method => :get) do %>
<%= submit_tag("Return to workflow") -%>
Modified: branches/wf4ever/config/routes.rb (3294 => 3295)
--- branches/wf4ever/config/routes.rb 2013-01-10 11:23:15 UTC (rev 3294)
+++ branches/wf4ever/config/routes.rb 2013-01-15 11:24:07 UTC (rev 3295)
@@ -99,16 +99,21 @@
:download => :get,
:quick_add => :post,
:resolve_link => :post,
+ :edit_annotations => :get,
+ :update_annotations => :post,
:create_resource => :post,
:destroy_resource => :delete,
:items => :get } do |pack|
pack.resources :comments, :collection => { :timeline => :get }
pack.resources :relationships, :collection => { :edit_relationships => :get }
end
-
+
map.pack_resources '/packs/:id/resources', :controller => 'packs', :action ="" 'resource_index', :conditions => { :method => :get }
- map.pack_resource '/packs/:id/resources/:resource_path', :controller => 'packs', :action ="" 'resource_show', :conditions => { :method => :get }, :requirements => { :resource_path => /.*/ }
+ map.pack_resource '/packs/:id/resources/:resource_path', :controller => 'packs', :action ="" 'resource_show', :conditions => { :method => :get }, :requirements => { :resource_path => /[^;]+/ }
+ map.pack_resource_edit '/packs/:id/resources/:resource_path;edit', :controller => 'packs', :action ="" 'edit_resource_annotations', :conditions => { :method => :get }, :requirements => { :resource_path => /[^;]+/ }
+ map.pack_resource_update '/packs/:id/resources/:resource_path;update', :controller => 'packs', :action ="" 'update_resource_annotations', :conditions => { :method => :post }, :requirements => { :resource_path => /[^;]+/ }
+
# workflows (downloadable)
map.resources :workflows,
:collection => { :search => :get },
Modified: branches/wf4ever/public/stylesheets/styles.css (3294 => 3295)
--- branches/wf4ever/public/stylesheets/styles.css 2013-01-10 11:23:15 UTC (rev 3294)
+++ branches/wf4ever/public/stylesheets/styles.css 2013-01-15 11:24:07 UTC (rev 3295)
@@ -2403,6 +2403,7 @@
#statement_list TD {
border: 1px solid gray;
+ background: white;
text-align: left;
}