Diff
Modified: branches/wf4ever/app/controllers/relationships_controller.rb (3348 => 3349)
--- branches/wf4ever/app/controllers/relationships_controller.rb 2013-01-25 09:44:56 UTC (rev 3348)
+++ branches/wf4ever/app/controllers/relationships_controller.rb 2013-01-25 09:46:22 UTC (rev 3349)
@@ -29,25 +29,42 @@
# POST /:context_type/:context_id/relationships
def create
- subject = @context.find_pack_item(params[:subject])
- objekt = @context.find_pack_item(params[:objekt])
+ subject_name = URI::decode(params[:subject])
+ object_name = URI::decode(params[:object])
- prefix, title = params[:predicate].split(":")
+ subject = @context.contributable_entries.find_by_name(subject_name)
+ object = @context.contributable_entries.find_by_name(object_name)
- predicate = Predicate.find(:first, :conditions =>
- [' AND title = ?',
- Ontology.find_by_prefix(prefix).id, title])
+ match = params[:predicate].match("(.*[#/])([^#/]+)")
- raise("Invalid form data") if subject.nil? || objekt.nil? || predicate.nil?
+ ns1 = match[1]
+ prop = match[2]
- @relationship = Relationship.new(:context => @context, :predicate => predicate, :user => current_user)
+ session = ROSRS::Session.new(@context.ro_uri, Conf.rodl_bearer_token)
- @relationship.subject = subject
- @relationship.objekt = objekt
+ subject_uri = "address@hidden::encode(subject.name)}"
+ object_uri = "address@hidden::encode(object.name)}"
- @relationship.save
+ ao_body = <<RDF
+<rdf:RDF
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:ns1="#{ns1}" >
+ <rdf:Description rdf:about="#{subject_uri}">
+ <ns1:#{prop} rdf:resource="#{object_uri}"/>
+ </rdf:Description>
+</rdf:RDF>
+RDF
- redirect_to(:action ="" :edit_relationships)
+ agraph = ROSRS::RDFGraph.new(:data ="" ao_body, :format => :xml)
+
+ begin
+ code, reason, stub_uri, body_uri = session.create_internal_annotation(@context.ro_uri, subject_uri, agraph)
+ code, reason, stub_uri, body_uri = session.create_internal_annotation(@context.ro_uri, object_uri, agraph)
+ rescue ROSRS::Exception => e
+ errors.add(params[:template], 'Error from remote server')
+ end
+
+ redirect_to pack_path(@context.id)
end
# DELETE /:context_type/:context_id/relationships/:id
@@ -66,6 +83,9 @@
def find_resource
@context = extract_resource_context(params)
+
+ return nil if @context.ro_uri
+
@relationship = Relationship.find_by_id(params[:id])
return error if @relationship.nil? || @context.nil? || @relationship.context != @context
Modified: branches/wf4ever/app/models/pack.rb (3348 => 3349)
--- branches/wf4ever/app/models/pack.rb 2013-01-25 09:44:56 UTC (rev 3348)
+++ branches/wf4ever/app/models/pack.rb 2013-01-25 09:46:22 UTC (rev 3349)
@@ -76,6 +76,8 @@
ce.checksum = @manifest.graph.first_object([resource.object, RDF::RO.checksum, nil])
ce.size = @manifest.graph.first_value([resource.object, RDF::RO.filesize, nil])
+ next unless ce.name
+
@entries << ce
end
end
@@ -95,6 +97,19 @@
end
end
+ def map(&blk)
+ if @pack.ro_uri
+ @entries.map(&blk)
+ end
+ end
+
+ def find_by_name(name)
+ @entries.each do |entry|
+ return entry if entry.name == name
+ end
+
+ nil
+ end
end
class Pack < ActiveRecord::Base
Modified: branches/wf4ever/app/views/packs/resource_show.rhtml (3348 => 3349)
--- branches/wf4ever/app/views/packs/resource_show.rhtml 2013-01-25 09:44:56 UTC (rev 3348)
+++ branches/wf4ever/app/views/packs/resource_show.rhtml 2013-01-25 09:46:22 UTC (rev 3349)
@@ -74,10 +74,20 @@
</tr>
<% end %>
-
</table>
<% end %>
+<% input_selected = @annotations.query(address@hidden, RDF::URI.parse("http://purl.org/wf4ever/roterms#inputSelected"), nil]) %>
+
+<% if input_selected.count > 0 %>
+ <h2>Workflow Inputs</h2>
+ <ul>
+ <% input_selected.statements.each do |statement| %>
+ <li><%=h statement.object -%></li>
+ <% end %>
+ </ul>
+<% end %>
+
<div class="download">
<h3>
<%= info_icon_with_tooltip("This section provides links to the download(s) for this File") %>
Modified: branches/wf4ever/app/views/packs/show.rhtml (3348 => 3349)
--- branches/wf4ever/app/views/packs/show.rhtml 2013-01-25 09:44:56 UTC (rev 3348)
+++ branches/wf4ever/app/views/packs/show.rhtml 2013-01-25 09:46:22 UTC (rev 3349)
@@ -113,10 +113,24 @@
<%= render :partial => "relationships/relationships", :locals => { :context => @pack, :show_delete => true } -%>
<% if @authorised_to_edit %>
- <br />
- <ul class="sectionIcons">
- <li><%= icon('manage', edit_relationships_pack_relationships_path(@pack), nil, nil, 'Edit Relationships') -%></li>
- </ul>
+ <% if @pack.items_count < 2 %>
+
+ <p><i>There must be at least two entries before you can add relationships.</i></p>
+
+ <% else %>
+
+ <% 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 %>
+ <% @relationship_options = [["Input selected", "http://purl.org/wf4ever/roterms#inputSelected"]] %>
+ <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>
+
+ <input type="submit" value="Add relationship"/>
+
+ <% end %>
+ <% end %>
<% end %>
<br/><br/>
@@ -235,3 +249,23 @@
<%= render :partial => "contributions/alternative_formats" %>
+<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/config/default_settings.yml (3348 => 3349)
--- branches/wf4ever/config/default_settings.yml 2013-01-25 09:44:56 UTC (rev 3348)
+++ branches/wf4ever/config/default_settings.yml 2013-01-25 09:46:22 UTC (rev 3349)
@@ -709,4 +709,7 @@
- "Results"
- "http://purl.org/wf4ever/roterms#Results"
-
\ No newline at end of file
+ro_terms:
+
+ - ["Input selected", "http://purl.org/wf4ever/roterms#inputSelected"]
+