Diff
Modified: branches/packs/app/models/research_object.rb (3661 => 3662)
--- branches/packs/app/models/research_object.rb 2013-09-02 15:27:06 UTC (rev 3661)
+++ branches/packs/app/models/research_object.rb 2013-09-02 20:41:27 UTC (rev 3662)
@@ -593,9 +593,23 @@
template["required_statements"].each do |statement|
- graph << [prepare_ro_template_value(statement[0], parameters),
- prepare_ro_template_value(statement[1], parameters),
- prepare_ro_template_value(statement[2], parameters)]
+ node_template = statement["template"]
+ depends = statement["depends"]
+
+ if depends
+
+ all_present = true
+
+ depends.each do |dependent|
+ all_present = false if parameters[dependent].to_s.empty?
+ end
+
+ next unless all_present
+ end
+
+ graph << [prepare_ro_template_value(node_template[0], parameters),
+ prepare_ro_template_value(node_template[1], parameters),
+ prepare_ro_template_value(node_template[2], parameters)]
end
graph
@@ -642,25 +656,44 @@
graph_copy << statement
end
+ found = []
+ missing = []
+
template["required_statements"].each do |statement|
+ node_template = statement["template"]
+ depends = statement["depends"]
+
# Find a statement that matches the current statement in the template.
- target = [prepare_ro_template_value(statement[0], parameters),
- prepare_ro_template_value(statement[1], parameters),
- prepare_ro_template_value(statement[2], parameters)]
+ target = [prepare_ro_template_value(node_template[0], parameters),
+ prepare_ro_template_value(node_template[1], parameters),
+ prepare_ro_template_value(node_template[2], parameters)]
match = graph_copy.query(target).first
+ if depends
+ if match
+ found += depends
+ else
+ missing += depends
+ end
+ end
- return nil if match.nil?
+ if match.nil?
+ if depends
+ next
+ else
+ return nil
+ end
+ end
# Verify that there are no mismatches between existing parameters and found
# parameters; Then fill in newly defined parameters.
- return nil unless process_ro_template_parameter(statement[0], match[0], parameters)
- return nil unless process_ro_template_parameter(statement[1], match[1], parameters)
- return nil unless process_ro_template_parameter(statement[2], match[2], parameters)
+ return nil unless process_ro_template_parameter(node_template[0], match[0], parameters)
+ return nil unless process_ro_template_parameter(node_template[1], match[1], parameters)
+ return nil unless process_ro_template_parameter(node_template[2], match[2], parameters)
# Remove the current statement from the graph copy
@@ -671,6 +704,11 @@
return nil unless graph_copy.empty?
+ # Verify that no dependencies were missing in some optional statements and
+ # present in other optional statements.
+
+ return nil unless (found & missing).empty?
+
parameters
end
Modified: branches/packs/app/views/annotations/_form.html.erb (3661 => 3662)
--- branches/packs/app/views/annotations/_form.html.erb 2013-09-02 15:27:06 UTC (rev 3661)
+++ branches/packs/app/views/annotations/_form.html.erb 2013-09-02 20:41:27 UTC (rev 3662)
@@ -4,7 +4,14 @@
<%= hidden_field_tag(:annotation_id, id) %>
<% end %>
+<% required_parameters = false %>
+
<table class="annotation">
+ <tr>
+ <td colspan="2">
+ <span class="type"><%=h annotation_template["label"].capitalize -%></span>
+ </td>
+ </tr>
<% annotation_template["parameters"].each do |parameter| %>
<tr>
<td><%= parameter["label"] -%></td>
@@ -14,14 +21,26 @@
<%= hidden_field_tag(parameter["symbol"], values[parameter["symbol"]]) -%>
</td>
<% else %>
- <% case parameter["type"] ; when "string" %>
- <td><%= text_field_tag(parameter["symbol"], values[parameter["symbol"]]) -%></td>
- <% when "textarea" %>
- <td><%= text_area_tag(parameter["symbol"], values[parameter["symbol"]]) -%></td>
- <% when "resource" %>
- <td><%= select_tag(parameter["symbol"], options_for_select(research_object.ore_resources.map { |r| [r[:name], r[:ore_path]] })) -%></td>
- <% end %>
+ <td>
+ <% case parameter["type"] ; when "string" %>
+ <%= text_field_tag(parameter["symbol"], values[parameter["symbol"]]) -%>
+ <% 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 %>
+ <span class="required-parameter">*</span>
+ <% required_parameters = true %>
+ <% end %>
+ </td>
<% end %>
</tr>
+ <% end %>
+ <% if required_parameters %>
+ <tr>
+ <td></td>
+ <td class="required-parameter">* Required</td>
+ </tr>
<% end %>
</table>
Modified: branches/packs/app/views/annotations/new.html.erb (3661 => 3662)
--- branches/packs/app/views/annotations/new.html.erb 2013-09-02 15:27:06 UTC (rev 3661)
+++ branches/packs/app/views/annotations/new.html.erb 2013-09-02 20:41:27 UTC (rev 3662)
@@ -1,4 +1,4 @@
-<h1>New <%=h @annotation_template["label"] -%> annotation</h1>
+<h1>New annotation</h1>
<% form_tag(pack_annotations_path(@pack)) do |f| -%>
<%= render(:partial => "form", :locals => {
Modified: branches/packs/config/default_settings.yml (3661 => 3662)
--- branches/packs/config/default_settings.yml 2013-09-02 15:27:06 UTC (rev 3661)
+++ branches/packs/config/default_settings.yml 2013-09-02 20:41:27 UTC (rev 3662)
@@ -1480,17 +1480,17 @@
bnodes: [:b1]
required_statements:
- - [:resource, "<http://purl.org/dc/terms/creator>", :b1]
- - [:b1, "<http://xmlns.com/foaf/0.1/Agent>", :person]
- - [:b1, "<http://purl.org/dc/terms/date>", :date]
- - [:b1, "<http://xmlns.com/foaf/0.1/name>", :name]
+ - template: [:resource, "<http://purl.org/dc/terms/creator>", :b1]
+ - template: [:b1, "<http://xmlns.com/foaf/0.1/Agent>", :person]
+ - template: [:b1, "<http://purl.org/dc/terms/date>", :date]
+ - template: [:b1, "<http://xmlns.com/foaf/0.1/name>", :name]
creator_simple:
label: Creator (simple)
required_statements:
- - [:resource, "<http://purl.org/dc/terms/creator>", :agent]
+ - template: [:resource, "<http://purl.org/dc/terms/creator>", :agent]
input_selection_relationship:
@@ -1507,7 +1507,7 @@
symbol: :input
required_statements:
- - [:workflow, "<http://purl.org/wf4ever/roterms#inputSelected>", :input]
+ - template: [:workflow, "<http://purl.org/wf4ever/roterms#inputSelected>", :input]
targets:
- :workflow
@@ -1528,7 +1528,7 @@
symbol: :title
required_statements:
- - [:resource, "<http://purl.org/dc/terms/title>", :title]
+ - template: [:resource, "<http://purl.org/dc/terms/title>", :title]
targets:
- :resource
@@ -1548,7 +1548,7 @@
symbol: :description
required_statements:
- - [:resource, "<http://purl.org/dc/terms/description>", :description]
+ - template: [:resource, "<http://purl.org/dc/terms/description>", :description]
targets:
- :resource
@@ -1568,7 +1568,7 @@
symbol: :hardware
required_statements:
- - [:resource, "<http://purl.org/wf4ever/roterms#requiresHardware>", :hardware]
+ - template: [:resource, "<http://purl.org/wf4ever/roterms#requiresHardware>", :hardware]
targets:
- :resource
@@ -1577,19 +1577,32 @@
label: requires software
+ bnodes: [:b1]
+
parameters:
- label: Resource
type: resource
symbol: :resource
- - label: Software
+ - label: Description
type: string
- symbol: :software
+ symbol: :description
+ - label: Link
+ type: string
+ symbol: :link
+ optional: true
+
required_statements:
- - [:resource, "<http://purl.org/wf4ever/roterms#requiresSoftware>", :software]
+ - template: [:resource, "<http://purl.org/wf4ever/roterms#requiresSoftware>", :b1]
+
+ - template: [:b1, "<http://purl.org/dc/terms/description>", :description]
+
+ - template: [:b1, "<http://www.w3.org/2000/01/rdf-schema#seeAlso>", :link]
+ depends: [:link]
+
targets:
- :resource
Modified: branches/packs/public/stylesheets/styles.css (3661 => 3662)
--- branches/packs/public/stylesheets/styles.css 2013-09-02 15:27:06 UTC (rev 3661)
+++ branches/packs/public/stylesheets/styles.css 2013-09-02 20:41:27 UTC (rev 3662)
@@ -2681,3 +2681,7 @@
text-align: right;
font-size: 10px;
}
+
+.required-parameter {
+ color: red;
+}