Diff
Modified: branches/packs/app/controllers/annotations_controller.rb (3664 => 3665)
--- branches/packs/app/controllers/annotations_controller.rb 2013-09-02 23:29:59 UTC (rev 3664)
+++ branches/packs/app/controllers/annotations_controller.rb 2013-09-03 14:37:24 UTC (rev 3665)
@@ -49,16 +49,20 @@
when "string", "textarea"
RDF::Literal(params[parameter["symbol"]])
+ when "select"
+ case parameter["node_type"]
+ when "literal"
+ RDF::Literal(params[parameter["symbol"]])
+ when "resource"
+ RDF::URI(params[parameter["symbol"]])
+ end
when "resource"
pack.research_object.find_using_path(params[parameter["symbol"]]).uri
end
end
-puts "template = #{template.inspect}"
-puts "parameters = #{parameters.inspect}"
targets = template["targets"].map { |t| parameters[t] }
-puts "targets = #{targets.inspect}"
graph = Pack.first.research_object.create_graph_using_ro_template(parameters, template)
pack.research_object.create_annotation(
Modified: branches/packs/app/controllers/packs_controller.rb (3664 => 3665)
--- branches/packs/app/controllers/packs_controller.rb 2013-09-02 23:29:59 UTC (rev 3664)
+++ branches/packs/app/controllers/packs_controller.rb 2013-09-03 14:37:24 UTC (rev 3665)
@@ -98,8 +98,8 @@
:object => RDF::URI("http://purl.org/wf4ever/roterms#ResearchQuestion")).first_subject
@hypothesis = @graph.query(:predicate => RDF.type,
:object => RDF::URI("http://purl.org/wf4ever/roterms#Hypothesis")).first_subject
- @conclusions = @graph.query(:predicate => RDF.type,
- :object => RDF::URI("http://purl.org/wf4ever/roterms#Conclusions")).first_subject
+ @conclusion = @graph.query(:predicate => RDF.type,
+ :object => RDF::URI("http://purl.org/wf4ever/roterms#Conclusion")).first_subject
@maintainers = Authorization.authorized_for_object(:edit, @pack)
Modified: branches/packs/app/models/research_object.rb (3664 => 3665)
--- branches/packs/app/models/research_object.rb 2013-09-02 23:29:59 UTC (rev 3664)
+++ branches/packs/app/models/research_object.rb 2013-09-03 14:37:24 UTC (rev 3665)
@@ -642,6 +642,39 @@
update_manifest!
end
+ def verify_select_value(symbol, node, template)
+
+ # We are only interested in parameterized nodes.
+
+ return true unless symbol.kind_of?(Symbol)
+
+ # Find parameter.
+
+ parameter = template["parameters"].find { |p| p["symbol"] == symbol }
+
+ # No problem if the parameter type isn't a select.
+ return true unless parameter["type"] == "select"
+
+ # Verify that the node type is correct.
+
+ case parameter["node_type"]
+ when "literal"
+ return false unless node.kind_of?(RDF::Literal)
+ when "resource"
+ return false unless node.kind_of?(RDF::URI)
+ else
+ throw "Unknown node_type (#{parameter["node_type"]})"
+ end
+
+ # Verify that the node value is valid.
+
+ return false unless parameter["options"].find { |o| o[1] == node.to_s }
+
+ # A valid select match as it passed the tests.
+
+ return true
+ end
+
def match_ro_template(graph, template)
parameters = {}
@@ -670,6 +703,12 @@
match = graph_copy.query(target).first
+ if match
+ return nil unless verify_select_value(node_template[0], match.subject, template)
+ return nil unless verify_select_value(node_template[1], match.predicate, template)
+ return nil unless verify_select_value(node_template[2], match.object, template)
+ end
+
if depends
if match
found += depends
Modified: branches/packs/app/views/annotations/_form.html.erb (3664 => 3665)
--- branches/packs/app/views/annotations/_form.html.erb 2013-09-02 23:29:59 UTC (rev 3664)
+++ branches/packs/app/views/annotations/_form.html.erb 2013-09-03 14:37:24 UTC (rev 3665)
@@ -24,23 +24,26 @@
<td>
<% case parameter["type"] ; when "string" %>
<%= text_field_tag(parameter["symbol"], values[parameter["symbol"]]) -%>
+ <% when "select" %>
+ <%= select_tag(parameter["symbol"], options_for_select(parameter["options"])) -%>
<% when "textarea" %>
<%= text_area_tag(parameter["symbol"], values[parameter["symbol"]]) -%>
<% when "resource" %>
<%= select_tag(parameter["symbol"], options_for_select(research_object.ore_resources.map { |r| [r[:name], r[:ore_path]] })) -%>
<% end %>
- <% unless parameter["optional"] == true %>
+ </td>
+ <% unless parameter["optional"] == true %>
+ <td>
<span class="required-parameter">*</span>
<% required_parameters = true %>
- <% end %>
- </td>
+ </td>
+ <% end %>
<% end %>
</tr>
<% end %>
<% if required_parameters %>
<tr>
- <td></td>
- <td class="required-parameter">* Required</td>
+ <td colspan="3"><div class="required-parameter">* Required</div></td>
</tr>
<% end %>
</table>
Modified: branches/packs/app/views/packs/_annotation.html.erb (3664 => 3665)
--- branches/packs/app/views/packs/_annotation.html.erb 2013-09-02 23:29:59 UTC (rev 3664)
+++ branches/packs/app/views/packs/_annotation.html.erb 2013-09-03 14:37:24 UTC (rev 3665)
@@ -17,6 +17,11 @@
<% label = parameter["label"] %>
<% value = annotation[:parameters][parameter["symbol"]].to_s %>
+ <% if parameter["type"] == "select" %>
+ <% value_match = parameter["options"].find { |option| value == option[1] } %>
+ <% value = value_match[0] if value_match %>
+ <% end %>
+
<% unless value.empty? %>
<tr>
<td class="label"><%=h label -%></td>
Modified: branches/packs/app/views/packs/item_show.html.erb (3664 => 3665)
--- branches/packs/app/views/packs/item_show.html.erb 2013-09-02 23:29:59 UTC (rev 3664)
+++ branches/packs/app/views/packs/item_show.html.erb 2013-09-03 14:37:24 UTC (rev 3665)
@@ -5,16 +5,21 @@
<table class="metadata">
<tr>
<td>Title</td>
- <td>
- <%=h @title -%>
- [<%= link_to('Add title', new_pack_annotation_path(@pack, { :template => 'title', :resource => @item.ore_path })) -%>]
- </td>
+ <td><%=h @title -%></td>
</tr>
<tr>
+ <td>Aggregator</td>
+ <td><%= user_link(@item.creator_uri) -%></td>
+ </tr>
+ <tr>
<td>File name</td>
<td><%=h @item.folder_entry.entry_name -%></td>
</tr>
<tr>
+ <td>Aggregated at<td>
+ <td><%= datetime(@item.created_at) -%></td>
+ </tr>
+ <tr>
<td>File size</td>
<td><%=h @item.size.to_s -%></td>
</tr>
@@ -78,10 +83,12 @@
<h2>Actions</h2>
<ul>
- <li>[<%= link_to('Add description', new_pack_annotation_path(@pack, { :template => 'description', :resource => @item.ore_path })) -%>]</li>
- <li>[<%= link_to("Select an input file", new_pack_annotation_path(@pack, { :template => 'input_selection_relationship', :workflow => @item.ore_path })) -%>]</li>
- <li>[<%= link_to("Add new hardware requirement", new_pack_annotation_path(@pack, { :template => 'requires_hardware', :resource => @item.ore_path })) -%>]</li>
- <li>[<%= link_to("Add new software requirement", new_pack_annotation_path(@pack, { :template => 'requires_software', :resource => @item.ore_path })) -%>]</li>
+ <li><%= link_to('Add title', new_pack_annotation_path(@pack, { :template => 'title', :resource => @item.ore_path })) -%></li>
+ <li><%= link_to('Add resource type', new_pack_annotation_path(@pack, { :template => 'resource_type', :resource => @item.ore_path })) -%></li>
+ <li><%= link_to('Add description', new_pack_annotation_path(@pack, { :template => 'description', :resource => @item.ore_path })) -%></li>
+ <li><%= link_to("Select an input file", new_pack_annotation_path(@pack, { :template => 'input_selection_relationship', :workflow => @item.ore_path })) -%></li>
+ <li><%= link_to("Add new hardware requirement", new_pack_annotation_path(@pack, { :template => 'requires_hardware', :resource => @item.ore_path })) -%></li>
+ <li><%= link_to("Add new software requirement", new_pack_annotation_path(@pack, { :template => 'requires_software', :resource => @item.ore_path })) -%></li>
</ul>
<% end %>
Modified: branches/packs/app/views/packs/show.rhtml (3664 => 3665)
--- branches/packs/app/views/packs/show.rhtml 2013-09-02 23:29:59 UTC (rev 3664)
+++ branches/packs/app/views/packs/show.rhtml 2013-09-03 14:37:24 UTC (rev 3665)
@@ -103,65 +103,11 @@
<p><%= link_to(h(@hypothesis.to_s), @hypothesis.to_s) -%></p>
<% end %>
- <% if @conclusions %>
- <h2>Conclusions</h2>
- <p><%= link_to(h(@conclusions.to_s), @conclusions.to_s) -%></p>
+ <% if @conclusion %>
+ <h2>Conclusion</h2>
+ <p><%= link_to(h(@conclusion.to_s), @conclusion.to_s) -%></p>
<% end %>
- <div class="contribution_version_box" style="background-color: #EEEEEE;">
- <div class="contribution_version_inner_box">
- <h4>
- <%= feed_icon_tag "RSS feed for items in this pack", items_pack_path(@pack, :format => :rss), "float: right;" %>
- <% if @authorised_to_download %>
- <%= download_icon_tag "Download all items in the pack as a single .zip archive", download_pack_path(@pack), "float: right; margin-right: 0.5em;" -%>
- <% end %>
-
- <%= info_icon_with_tooltip("This section shows all the items that are pointed to in this pack. This can be a combination of internal and external items.") -%>
- Items <span class="count_text">(<%= items_count -%>)</span>
- </h4>
-
- <%= render :partial => "items", :locals => { :pack => @pack, :contributable_entries => contributable_entries, :remote_entries => remote_entries, :authorised_to_edit => @authorised_to_edit } -%>
-
- <% if false %>
- <br/><br/>
- <h4>
- <%= info_icon_with_tooltip("This section shows all the relationships between the items in this pack.") -%>
- Relationships <span class="count_text">(<%= @pack.relationships.length -%>)</span>
- </h4>
-
- <%= 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>
- <% end %>
- <% end %>
-
- <br/><br/>
-
- <h3>
- <%= info_icon_with_tooltip("This section provides the ability to add relationships between items in this pack") %>
- Relationships
- </h3>
-
- <div>
- <% if @authorised_to_edit %>
- <% if @ore_resources.count > 1 %>
- <% 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["template"]] }) ) -%>
- <%= select_tag(:object, options_for_select(@ore_resources.map { |r| [r[:name], r[:ore_path]] }) ) -%>
- <%= submit_tag("Add") -%>
- <% end %>
- <% end %>
- <% end %>
- </div>
-
- </div>
- </div>
-
<% if @authorised_to_edit -%>
<h2>
<%= info_icon_with_tooltip("This section provides various ways of adding items to this pack") %>
@@ -239,6 +185,7 @@
<div class="contribution_section_box">
<p style="font-size: 108%;">
<b><%= pluralize items_count, "item" %> in this pack</b>
+ <%= feed_icon_tag "RSS feed for items in this pack", items_pack_path(@pack, :format => :rss) %>
</p>
</div>
Modified: branches/packs/config/default_settings.yml (3664 => 3665)
--- branches/packs/config/default_settings.yml 2013-09-02 23:29:59 UTC (rev 3664)
+++ branches/packs/config/default_settings.yml 2013-09-03 14:37:24 UTC (rev 3665)
@@ -1619,6 +1619,69 @@
targets:
- :resource
+ resource_type:
+
+ label: resource type
+
+ parameters:
+
+ - label: Resource
+ type: resource
+ symbol: :resource
+
+ - label: Type
+ type: select
+ symbol: :type
+ node_type: resource
+ options:
+
+ - - "Workflow"
+ - "http://purl.org/wf4ever/wfdesc#WorkflowDefinition"
+
+ - - "Resource"
+ - "http://purl.org/wf4ever/ro#Resource"
+
+ - - "Sketch"
+ - "http://purl.org/wf4ever/roterms#Sketch"
+
+ - - "Hypothesis"
+ - "http://purl.org/wf4ever/roterms#Hypothesis"
+
+ - - "Research Question"
+ - "http://purl.org/wf4ever/roterms#ResearchQuestion"
+
+ - - "Conclusion"
+ - "http://purl.org/wf4ever/roterms#Conclusion"
+
+ - - "Result"
+ - "http://purl.org/wf4ever/roterms#Result"
+
+ - - "Example inputs"
+ - "http://purl.org/wf4ever/roterms#ExampleInputs"
+
+ - - "Example outputs"
+ - "http://purl.org/wf4ever/roterms#ExampleOutputs"
+
+ - - "Example Workflow Run"
+ - "http://purl.org/wf4ever/roterms#ExampleRun"
+
+ - - "Prospective Workflow Run"
+ - "http://purl.org/wf4ever/roterms#ProspectiveRun"
+
+ - - "Results Generating Workflow Run"
+ - "http://purl.org/wf4ever/roterms#ResultGenerationRun"
+
+ - - "Paper"
+ - "http://purl.org/wf4ever/roterms#Paper"
+
+ required_statements:
+
+ - template: [:resource, "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>", :type]
+
+ targets:
+
+ - :resource
+
wf_ro_service_uri: "http://www.example.com/wf-ro/jobs"
wf_ro_service_bearer_token: "bearer-token"
Modified: branches/packs/public/stylesheets/styles.css (3664 => 3665)
--- branches/packs/public/stylesheets/styles.css 2013-09-02 23:29:59 UTC (rev 3664)
+++ branches/packs/public/stylesheets/styles.css 2013-09-03 14:37:24 UTC (rev 3665)
@@ -2683,5 +2683,6 @@
}
.required-parameter {
+ text-align: right;
color: red;
}