myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [3695] branches/packs: added workflow run type an


From: noreply
Subject: [myexperiment-hackers] [3695] branches/packs: added workflow run type annotation using a temporary method
Date: Tue, 10 Sep 2013 10:29:00 +0000 (UTC)

Revision
3695
Author
dgc
Date
2013-09-10 10:28:59 +0000 (Tue, 10 Sep 2013)

Log Message

added workflow run type annotation using a temporary method

Modified Paths

Added Paths

Diff

Added: branches/packs/app/helpers/annotations_helper.rb (0 => 3695)


--- branches/packs/app/helpers/annotations_helper.rb	                        (rev 0)
+++ branches/packs/app/helpers/annotations_helper.rb	2013-09-10 10:28:59 UTC (rev 3695)
@@ -0,0 +1,18 @@
+# myExperiment: app/helpers/annotations_helper.rb
+#
+# Copyright (c) 2007-2013 The University of Manchester, the University of
+# Oxford, and the University of Southampton.  See license.txt for details.
+
+module AnnotationsHelper
+
+  def wfprov_workflow_run(research_object)
+    graph = research_object.merged_annotation_graphs
+
+    workflows = graph.query([nil, RDF.type, RDF::URI("http://purl.org/wf4ever/wfprov#WorkflowRun")]).subjects
+
+    select_options = workflows.map do |workflow|
+      [graph.query([workflow, RDF::RDFS.label, nil]).first_literal.to_s, workflow.to_s]
+    end
+  end
+
+end

Modified: branches/packs/app/models/research_object.rb (3694 => 3695)


--- branches/packs/app/models/research_object.rb	2013-09-09 15:48:58 UTC (rev 3694)
+++ branches/packs/app/models/research_object.rb	2013-09-10 10:28:59 UTC (rev 3695)
@@ -13,6 +13,7 @@
   MANIFEST_PATH = ".ro/manifest.rdf"
 
   include ResearchObjectsHelper
+  include AnnotationsHelper # FIXME temporary due to wfprov_workflow_run
 
   after_create :create_manifest
 
@@ -697,8 +698,14 @@
 
     # Verify that the node value is valid.
 
-    return false unless parameter["options"].find { |o| o[1] == node.to_s }
+    if parameter["options"]
+      options = parameter["options"]
+    elsif parameter["special"] == "wfprov_workflow_run"
+      options = wfprov_workflow_run(self)
+    end
 
+    return false unless options.find { |o| o[1] == node.to_s }
+
     # A valid select match as it passed the tests.
 
     return true

Modified: branches/packs/app/views/annotations/_annotation.html.erb (3694 => 3695)


--- branches/packs/app/views/annotations/_annotation.html.erb	2013-09-09 15:48:58 UTC (rev 3694)
+++ branches/packs/app/views/annotations/_annotation.html.erb	2013-09-10 10:28:59 UTC (rev 3695)
@@ -18,7 +18,13 @@
         <% value = annotation[:parameters][parameter["symbol"]].to_s %>
 
         <% if parameter["type"] == "select" %>
-          <% value_match = parameter["options"].find { |option| value == option[1] } %>
+          <% if parameter["options"]
+               options = parameter["options"]
+             elsif parameter["special"] == "wfprov_workflow_run"
+               options = wfprov_workflow_run(context.research_object)
+             end
+          %>
+          <% value_match = options.find { |option| value == option[1] } %>
           <% value = value_match[0] if value_match %>
         <% end %>
 

Modified: branches/packs/app/views/annotations/_form.html.erb (3694 => 3695)


--- branches/packs/app/views/annotations/_form.html.erb	2013-09-09 15:48:58 UTC (rev 3694)
+++ branches/packs/app/views/annotations/_form.html.erb	2013-09-10 10:28:59 UTC (rev 3695)
@@ -29,7 +29,11 @@
           <% case parameter["type"] ; when "string" %>
             <%= text_field_tag(parameter["symbol"], values[parameter["symbol"]], :placeholder => parameter["placeholder"]) -%>
           <% when "select" %>
-            <%= select_tag(parameter["symbol"], options_for_select(parameter["options"])) -%>
+            <% if parameter["special"] == "wfprov_workflow_run" %>
+              <%= select_tag(parameter["symbol"], options_for_select(wfprov_workflow_run(@context.research_object))) -%>
+            <% else %>
+              <%= select_tag(parameter["symbol"], options_for_select(parameter["options"])) -%>
+            <% end %>
           <% when "textarea" %>
             <%= text_area_tag(parameter["symbol"], values[parameter["symbol"]]) -%>
           <% when "resource" %>

Modified: branches/packs/config/default_settings.yml (3694 => 3695)


--- branches/packs/config/default_settings.yml	2013-09-09 15:48:58 UTC (rev 3694)
+++ branches/packs/config/default_settings.yml	2013-09-10 10:28:59 UTC (rev 3695)
@@ -1523,6 +1523,40 @@
     - :workflow
     - :input
 
+  workflow_run_type:
+
+    label: Workflow Run Type
+
+    parameters:
+
+    - label:     Workflow Run
+      type:      select
+      symbol:    :workflow_run
+      node_type: resource
+      special:   wfprov_workflow_run
+
+    - label:     Type
+      type:      select
+      symbol:    :type
+      node_type: resource
+      options:
+      
+      - - "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"
+
+    required_statements:
+    - template: [:workflow_run, "<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>", :type]
+
+    targets:
+    - :workflow
+    - :input
+
   title:
 
     label: title

reply via email to

[Prev in Thread] Current Thread [Next in Thread]