taverna-player 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/.gitignore +18 -0
  2. data/Gemfile +18 -0
  3. data/LICENCE.rdoc +29 -0
  4. data/README.rdoc +663 -0
  5. data/Rakefile +65 -0
  6. data/app/assets/javascripts/taverna_player/application.js +14 -0
  7. data/app/assets/javascripts/taverna_player/runs.js +42 -0
  8. data/app/assets/stylesheets/scaffold.css +56 -0
  9. data/app/assets/stylesheets/taverna_player/application.css +13 -0
  10. data/app/assets/stylesheets/taverna_player/coderay.css +120 -0
  11. data/app/controllers/taverna_player/application_controller.rb +16 -0
  12. data/app/controllers/taverna_player/runs_controller.rb +18 -0
  13. data/app/controllers/taverna_player/service_credentials_controller.rb +18 -0
  14. data/app/helpers/taverna_player/application_helper.rb +55 -0
  15. data/app/helpers/taverna_player/runs_helper.rb +84 -0
  16. data/app/models/taverna_player/interaction.rb +25 -0
  17. data/app/models/taverna_player/run.rb +117 -0
  18. data/app/models/taverna_player/run_port.rb +148 -0
  19. data/app/models/taverna_player/service_credential.rb +56 -0
  20. data/app/views/layouts/taverna_player/embedded.html.erb +27 -0
  21. data/app/views/taverna_player/runs/_button.html.erb +19 -0
  22. data/app/views/taverna_player/runs/_info.html.erb +56 -0
  23. data/app/views/taverna_player/runs/_info.json.jbuilder +2 -0
  24. data/app/views/taverna_player/runs/_inputs.html.erb +34 -0
  25. data/app/views/taverna_player/runs/_inputs.json.jbuilder +8 -0
  26. data/app/views/taverna_player/runs/_interaction.html.erb +68 -0
  27. data/app/views/taverna_player/runs/_outputs.html.erb +41 -0
  28. data/app/views/taverna_player/runs/_poll.html.erb +27 -0
  29. data/app/views/taverna_player/runs/create.json.jbuilder +3 -0
  30. data/app/views/taverna_player/runs/embedded/_button.html.erb +19 -0
  31. data/app/views/taverna_player/runs/embedded/_info.html.erb +25 -0
  32. data/app/views/taverna_player/runs/embedded/_inputs.html.erb +32 -0
  33. data/app/views/taverna_player/runs/embedded/_outputs.html.erb +32 -0
  34. data/app/views/taverna_player/runs/embedded/new.html.erb +58 -0
  35. data/app/views/taverna_player/runs/embedded/show.html.erb +39 -0
  36. data/app/views/taverna_player/runs/embedded/show.js.erb +35 -0
  37. data/app/views/taverna_player/runs/index.html.erb +40 -0
  38. data/app/views/taverna_player/runs/index.json.jbuilder +1 -0
  39. data/app/views/taverna_player/runs/new.html.erb +56 -0
  40. data/app/views/taverna_player/runs/new.json.jbuilder +1 -0
  41. data/app/views/taverna_player/runs/show.html.erb +29 -0
  42. data/app/views/taverna_player/runs/show.js.erb +25 -0
  43. data/app/views/taverna_player/runs/show.json.jbuilder +25 -0
  44. data/app/views/taverna_player/service_credentials/_form.html.erb +53 -0
  45. data/app/views/taverna_player/service_credentials/edit.html.erb +18 -0
  46. data/app/views/taverna_player/service_credentials/index.html.erb +41 -0
  47. data/app/views/taverna_player/service_credentials/new.html.erb +17 -0
  48. data/app/views/taverna_player/service_credentials/show.html.erb +36 -0
  49. data/config/routes.rb +34 -0
  50. data/db/migrate/20130313105546_create_taverna_player_runs.rb +16 -0
  51. data/db/migrate/20130315163019_create_taverna_player_run_ports.rb +15 -0
  52. data/db/migrate/20130318170744_add_attachment_file_to_taverna_player_run_ports.rb +6 -0
  53. data/db/migrate/20130319183634_create_delayed_jobs.rb +22 -0
  54. data/db/migrate/20130320102600_add_status_message_to_taverna_player_runs.rb +5 -0
  55. data/db/migrate/20130321100110_add_depth_and_metadata_to_taverna_player_run_ports.rb +6 -0
  56. data/db/migrate/20130704095504_add_attachment_results_to_taverna_player_runs.rb +5 -0
  57. data/db/migrate/20130705142704_add_embedded_to_taverna_player_runs.rb +5 -0
  58. data/db/migrate/20130714140911_create_taverna_player_interactions.rb +13 -0
  59. data/db/migrate/20130717083653_add_proxy_to_taverna_player_runs.rb +6 -0
  60. data/db/migrate/20130717155415_add_stop_to_taverna_player_runs.rb +5 -0
  61. data/db/migrate/20130811152840_add_attachment_log_to_taverna_player_runs.rb +5 -0
  62. data/db/migrate/20130811211725_change_taverna_player_runs_state_column.rb +5 -0
  63. data/db/migrate/20130812155839_add_name_to_taverna_player_runs.rb +5 -0
  64. data/db/migrate/20130918135348_create_taverna_player_service_credentials.rb +15 -0
  65. data/db/migrate/20130919154200_add_displayed_to_taverna_player_interactions.rb +5 -0
  66. data/db/migrate/20131007153209_add_job_ref_to_taverna_player_runs.rb +13 -0
  67. data/db/migrate/20131010094537_add_reply_caching_to_taverna_player_interactions.rb +19 -0
  68. data/db/migrate/20131017141514_add_failure_message_to_taverna_player_run.rb +5 -0
  69. data/db/migrate/20131018152940_add_serial_number_to_taverna_player_interactions.rb +5 -0
  70. data/db/migrate/20131018160715_add_parent_run_id_to_taverna_player_runs.rb +5 -0
  71. data/db/migrate/20131102113933_add_page_uri_to_taverna_player_interaction.rb +5 -0
  72. data/db/migrate/20131105115218_remove_proxy_from_taverna_player_runs.rb +11 -0
  73. data/db/migrate/20131105141934_change_taverna_player_interactions_output_value_column_name.rb +5 -0
  74. data/db/migrate/20131112165520_add_user_to_taverna_player_run.rb +5 -0
  75. data/lib/generators/taverna_player/callbacks_generator.rb +25 -0
  76. data/lib/generators/taverna_player/controllers_generator.rb +30 -0
  77. data/lib/generators/taverna_player/install_generator.rb +30 -0
  78. data/lib/generators/taverna_player/job_generator.rb +26 -0
  79. data/lib/generators/taverna_player/models_generator.rb +27 -0
  80. data/lib/generators/taverna_player/renderers_generator.rb +26 -0
  81. data/lib/generators/taverna_player/views_generator.rb +27 -0
  82. data/lib/generators/templates/ReadMe.txt +118 -0
  83. data/lib/generators/templates/callbacks/render_callbacks.rb +56 -0
  84. data/lib/generators/templates/callbacks/worker_callbacks.rb +31 -0
  85. data/lib/generators/templates/controllers/runs_controller.rb +20 -0
  86. data/lib/generators/templates/controllers/service_credentials_controller.rb +20 -0
  87. data/lib/generators/templates/initializer.rb +154 -0
  88. data/lib/generators/templates/models/run.rb +20 -0
  89. data/lib/tasks/delete-cancelled-runs.rake +26 -0
  90. data/lib/tasks/delete-old-embedded-runs.rake +26 -0
  91. data/lib/taverna-player.rb +139 -0
  92. data/lib/taverna_player/concerns/controllers/runs_controller.rb +281 -0
  93. data/lib/taverna_player/concerns/controllers/service_credentials_controller.rb +89 -0
  94. data/lib/taverna_player/concerns/models/run.rb +205 -0
  95. data/lib/taverna_player/engine.rb +23 -0
  96. data/lib/taverna_player/model_proxy.rb +51 -0
  97. data/lib/taverna_player/output_renderer.rb +96 -0
  98. data/lib/taverna_player/render_callbacks.rb +41 -0
  99. data/lib/taverna_player/version.rb +15 -0
  100. data/lib/taverna_player/worker.rb +325 -0
  101. data/script/delayed_job +5 -0
  102. data/script/rails +8 -0
  103. data/taverna_player.gemspec +46 -0
  104. data/test/dummy/Rakefile +7 -0
  105. data/test/dummy/app/assets/javascripts/application.js +16 -0
  106. data/test/dummy/app/assets/stylesheets/application.css +14 -0
  107. data/test/dummy/app/controllers/application_controller.rb +15 -0
  108. data/test/dummy/app/controllers/home_controller.rb +16 -0
  109. data/test/dummy/app/controllers/taverna_player/runs_controller.rb +25 -0
  110. data/test/dummy/app/controllers/taverna_player/service_credentials_controller.rb +25 -0
  111. data/test/dummy/app/controllers/workflows_controller.rb +17 -0
  112. data/test/dummy/app/models/user.rb +15 -0
  113. data/test/dummy/app/models/workflow.rb +32 -0
  114. data/test/dummy/app/views/home/index.html.erb +18 -0
  115. data/test/dummy/app/views/layouts/application.html.erb +43 -0
  116. data/test/dummy/app/views/workflows/index.html.erb +35 -0
  117. data/test/dummy/config.ru +4 -0
  118. data/test/dummy/config/application.rb +58 -0
  119. data/test/dummy/config/boot.rb +10 -0
  120. data/test/dummy/config/database.yml +25 -0
  121. data/test/dummy/config/environment.rb +5 -0
  122. data/test/dummy/config/environments/development.rb +37 -0
  123. data/test/dummy/config/environments/production.rb +67 -0
  124. data/test/dummy/config/environments/test.rb +37 -0
  125. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  126. data/test/dummy/config/initializers/inflections.rb +15 -0
  127. data/test/dummy/config/initializers/mime_types.rb +5 -0
  128. data/test/dummy/config/initializers/secret_token.rb +7 -0
  129. data/test/dummy/config/initializers/session_store.rb +8 -0
  130. data/test/dummy/config/initializers/taverna_player.example.rb +40 -0
  131. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  132. data/test/dummy/config/locales/en.yml +5 -0
  133. data/test/dummy/config/routes.rb +22 -0
  134. data/test/dummy/db/migrate/20130314103555_create_workflows.rb +12 -0
  135. data/test/dummy/db/migrate/20130318141557_create_taverna_player_runs.taverna_player.rb +17 -0
  136. data/test/dummy/db/migrate/20130318141558_create_taverna_player_run_ports.taverna_player.rb +16 -0
  137. data/test/dummy/db/migrate/20130318173013_add_attachment_file_to_taverna_player_run_ports.taverna_player.rb +7 -0
  138. data/test/dummy/db/migrate/20130319183816_create_delayed_jobs.taverna_player.rb +23 -0
  139. data/test/dummy/db/migrate/20130320102635_add_status_message_to_taverna_player_runs.taverna_player.rb +6 -0
  140. data/test/dummy/db/migrate/20130321161859_add_depth_and_metadata_to_taverna_player_run_ports.taverna_player.rb +7 -0
  141. data/test/dummy/db/migrate/20130704100146_add_attachment_results_to_taverna_player_runs.taverna_player.rb +6 -0
  142. data/test/dummy/db/migrate/20130705142816_add_embedded_to_taverna_player_runs.taverna_player.rb +6 -0
  143. data/test/dummy/db/migrate/20130714142144_create_taverna_player_interactions.taverna_player.rb +14 -0
  144. data/test/dummy/db/migrate/20130717084809_add_proxy_to_taverna_player_runs.taverna_player.rb +7 -0
  145. data/test/dummy/db/migrate/20130718102707_add_stop_to_taverna_player_runs.taverna_player.rb +6 -0
  146. data/test/dummy/db/migrate/20130811204449_add_attachment_log_to_taverna_player_runs.taverna_player.rb +6 -0
  147. data/test/dummy/db/migrate/20130811212709_change_taverna_player_runs_state_column.taverna_player.rb +6 -0
  148. data/test/dummy/db/migrate/20130812161152_add_name_to_taverna_player_runs.taverna_player.rb +6 -0
  149. data/test/dummy/db/migrate/20130918155525_create_taverna_player_service_credentials.taverna_player.rb +16 -0
  150. data/test/dummy/db/migrate/20130919155202_add_displayed_to_taverna_player_interactions.taverna_player.rb +6 -0
  151. data/test/dummy/db/migrate/20131007153659_add_job_ref_to_taverna_player_runs.taverna_player.rb +14 -0
  152. data/test/dummy/db/migrate/20131016123941_add_reply_caching_to_taverna_player_interactions.taverna_player.rb +20 -0
  153. data/test/dummy/db/migrate/20131017141614_add_failure_message_to_taverna_player_run.taverna_player.rb +6 -0
  154. data/test/dummy/db/migrate/20131018153316_add_serial_number_to_taverna_player_interactions.taverna_player.rb +6 -0
  155. data/test/dummy/db/migrate/20131018164614_add_parent_run_id_to_taverna_player_runs.taverna_player.rb +6 -0
  156. data/test/dummy/db/migrate/20131102114343_add_page_uri_to_taverna_player_interaction.taverna_player.rb +6 -0
  157. data/test/dummy/db/migrate/20131105115724_remove_proxy_from_taverna_player_runs.taverna_player.rb +12 -0
  158. data/test/dummy/db/migrate/20131105142417_change_taverna_player_interactions_output_value_column_name.taverna_player.rb +6 -0
  159. data/test/dummy/db/migrate/20131112165815_add_user_to_taverna_player_run.taverna_player.rb +6 -0
  160. data/test/dummy/db/migrate/20131114130937_create_users.rb +10 -0
  161. data/test/dummy/db/schema.rb +123 -0
  162. data/test/dummy/lib/callbacks.rb +35 -0
  163. data/test/dummy/log/.gitkeep +0 -0
  164. data/test/dummy/public/404.html +26 -0
  165. data/test/dummy/public/422.html +26 -0
  166. data/test/dummy/public/500.html +25 -0
  167. data/test/dummy/public/favicon.ico +0 -0
  168. data/test/dummy/script/delayed_job +5 -0
  169. data/test/dummy/script/rails +6 -0
  170. data/test/dummy/test/functional/home_controller_test.rb +28 -0
  171. data/test/dummy/test/functional/workflows_controller_test.rb +21 -0
  172. data/test/fixtures/files/crassostrea_gigas.csv +737 -0
  173. data/test/fixtures/taverna_player/interactions.yml +32 -0
  174. data/test/fixtures/taverna_player/run_ports.yml +54 -0
  175. data/test/fixtures/taverna_player/runs.yml +69 -0
  176. data/test/fixtures/taverna_player/service_credentials.yml +25 -0
  177. data/test/fixtures/users.yml +16 -0
  178. data/test/fixtures/workflows.yml +32 -0
  179. data/test/functional/taverna_player/runs_controller_test.rb +316 -0
  180. data/test/functional/taverna_player/service_credentials_controller_test.rb +99 -0
  181. data/test/taverna_player_test.rb +25 -0
  182. data/test/test_helper.rb +33 -0
  183. data/test/unit/helpers/taverna_player/application_helper_test.rb +70 -0
  184. data/test/unit/helpers/taverna_player/runs_helper_test.rb +45 -0
  185. data/test/unit/taverna_player/interaction_test.rb +47 -0
  186. data/test/unit/taverna_player/run_port_test.rb +309 -0
  187. data/test/unit/taverna_player/run_test.rb +196 -0
  188. data/test/unit/taverna_player/service_credential_test.rb +64 -0
  189. data/test/workflows/hello.t2flow +164 -0
  190. data/test/workflows/list_with_errors.t2flow +107 -0
  191. data/test/workflows/pass_through.t2flow +12 -0
  192. metadata +539 -0
@@ -0,0 +1,56 @@
1
+ #------------------------------------------------------------------------------
2
+ # Copyright (c) 2013 The University of Manchester, UK.
3
+ #
4
+ # BSD Licenced. See LICENCE.rdoc for details.
5
+ #
6
+ # Taverna Player was developed in the BioVeL project, funded by the European
7
+ # Commission 7th Framework Programme (FP7), through grant agreement
8
+ # number 283359.
9
+ #
10
+ # Author: Robert Haines
11
+ #------------------------------------------------------------------------------
12
+
13
+ # These methods are the default renderer callbacks that Taverna Player uses.
14
+ # If you customize (or add to) the methods in this file you must register them
15
+ # in the Taverna Player initializer. These methods will not override the
16
+ # defaults automatically.
17
+ #
18
+ # Each method MUST accept two parameters:
19
+ # * The first (content) is what will be rendered. In the case of a text/*
20
+ # type output this will be the actual text. In the case of anything else
21
+ # this will be a path to the object to be linked to.
22
+ # * The second (type) is the MIME type of the output as a string. This allows
23
+ # a single method to handle multiple types or sub-types if needed.
24
+ #
25
+ # Note that you can use most of the ActiveView Helpers here as global methods
26
+ # but the image_tag() method does not work as explained below.
27
+
28
+ def format_text(content, type)
29
+ # Use CodeRay to format text so that newlines are respected.
30
+ content = CodeRay.scan(content, :text).div(:css => :class)
31
+
32
+ # Use auto_link to turn URI-like text into links.
33
+ auto_link(content, :html => { :target => '_blank' }, :sanitize => false)
34
+ end
35
+
36
+ def format_xml(content, type)
37
+ # Make sure XML is indented consistently.
38
+ out = String.new
39
+ REXML::Document.new(content).write(out, 1)
40
+ CodeRay.scan(out, :xml).div(:css => :class, :line_numbers => :table)
41
+ end
42
+
43
+ def show_image(content, type)
44
+ # Can't use image_tag() here because the image doesn't really exist (it's in
45
+ # a zip file, really) and this confuses the Rails asset pipeline.
46
+ tag("img", :src => content)
47
+ end
48
+
49
+ def workflow_error(content, type)
50
+ link_to("This output is a workflow error.", content)
51
+ end
52
+
53
+ def cannot_inline(content, type)
54
+ "Sorry but we cannot show this type of content in the browser. Please " +
55
+ link_to("download it", content) + " to view it on your local machine."
56
+ end
@@ -0,0 +1,31 @@
1
+ #------------------------------------------------------------------------------
2
+ # Copyright (c) 2013 The University of Manchester, UK.
3
+ #
4
+ # BSD Licenced. See LICENCE.rdoc for details.
5
+ #
6
+ # Taverna Player was developed in the BioVeL project, funded by the European
7
+ # Commission 7th Framework Programme (FP7), through grant agreement
8
+ # number 283359.
9
+ #
10
+ # Author: Robert Haines
11
+ #------------------------------------------------------------------------------
12
+
13
+ def player_pre_run_callback(run)
14
+ w = Workflow.find(run.workflow_id)
15
+ puts "Pre-run callback called for run '#{run.name}' of workflow '#{w.id}'"
16
+ end
17
+
18
+ def player_post_run_callback(run)
19
+ w = Workflow.find(run.workflow_id)
20
+ puts "Post-run callback called for run '#{run.name}' of workflow '#{w.id}'"
21
+ end
22
+
23
+ def player_run_cancelled_callback(run)
24
+ w = Workflow.find(run.workflow_id)
25
+ puts "Run-cancelled callback called for run '#{run.name}' of workflow '#{w.id}'"
26
+ end
27
+
28
+ def player_run_failed_callback(run)
29
+ w = Workflow.find(run.workflow_id)
30
+ puts "Run-failed callback called for run '#{run.name}' of workflow '#{w.id}'"
31
+ end
@@ -0,0 +1,20 @@
1
+ #------------------------------------------------------------------------------
2
+ # Copyright (c) 2013 The University of Manchester, UK.
3
+ #
4
+ # BSD Licenced. See LICENCE.rdoc for details.
5
+ #
6
+ # Taverna Player was developed in the BioVeL project, funded by the European
7
+ # Commission 7th Framework Programme (FP7), through grant agreement
8
+ # number 283359.
9
+ #
10
+ # Author: Robert Haines
11
+ #------------------------------------------------------------------------------
12
+
13
+ module TavernaPlayer
14
+ class RunsController < TavernaPlayer::ApplicationController
15
+ # Do not remove the next line.
16
+ include TavernaPlayer::Concerns::Controllers::RunsController
17
+
18
+ # Extend the RunsController here.
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ #------------------------------------------------------------------------------
2
+ # Copyright (c) 2013 The University of Manchester, UK.
3
+ #
4
+ # BSD Licenced. See LICENCE.rdoc for details.
5
+ #
6
+ # Taverna Player was developed in the BioVeL project, funded by the European
7
+ # Commission 7th Framework Programme (FP7), through grant agreement
8
+ # number 283359.
9
+ #
10
+ # Author: Robert Haines
11
+ #------------------------------------------------------------------------------
12
+
13
+ module TavernaPlayer
14
+ class ServiceCredentialsController < TavernaPlayer::ApplicationController
15
+ # Do not remove the next line.
16
+ include TavernaPlayer::Concerns::Controllers::ServiceCredentialsController
17
+
18
+ # Extend the ServiceCredentialsController here.
19
+ end
20
+ end
@@ -0,0 +1,154 @@
1
+ # Taverna Player configuration
2
+
3
+ TavernaPlayer.setup do |config|
4
+
5
+ # This should be set to the name of the workflow model class in the main
6
+ # application and the listed methods should also be mapped if necessary.
7
+ config.workflow_model_proxy("Workflow")
8
+ #config.workflow_model_proxy("Workflow") do |proxy|
9
+ # This is the method that returns the name of the workflow file. Your
10
+ # model MUST provide this otherwise a workflow cannot be run.
11
+ #proxy.file_method_name = :file
12
+
13
+ # This is the method that returns the title of the workflow. This can be
14
+ # left unset if your model does not have this field but if you want to
15
+ # set a run name at the time of run creation then you will need to
16
+ # provide one or override the new run view.
17
+ #proxy.title_method_name = :title
18
+
19
+ # This is a method that returns a list of descriptions of the workflow
20
+ # inputs. Each description should be of the form:
21
+ # {
22
+ # :name => "<input_name>",
23
+ # :description => "<input_description>",
24
+ # :example => "<input_example_value>"
25
+ # }
26
+ #
27
+ # If you don't provide this method you will have to override the new run
28
+ # view to create and initialize the inputs to a workflow.
29
+ #proxy.inputs_method_name = :inputs
30
+ #end
31
+
32
+ # This should be set to the name of the user model class in the main
33
+ # application if you have one. This defaults to nil and should be left as
34
+ # such if your main application does not have users.
35
+ #config.user_model_proxy = "User"
36
+
37
+ # This should be set to the name of the method used to get the current user
38
+ # in the main app. For Devise this would be :current_user. Defaults to nil.
39
+ #config.current_user_callback = nil
40
+
41
+ # Taverna Server configuration information. The poll interval is in seconds
42
+ # and sets how often the server will be polled for updates by each worker.
43
+ # The retry interval is also in seconds and sets how long a worker will wait
44
+ # before trying to start a run if the server is initially busy.
45
+ config.server_address = "http://localhost:8080/taverna"
46
+ config.server_username = "taverna"
47
+ config.server_password = "taverna"
48
+ config.server_poll_interval = 5
49
+ config.server_retry_interval = 10
50
+
51
+ # Taverna Server connection configuration.
52
+ #config.server_connection[:verify_peer] = true
53
+ #config.server_connection[:ca_file] = "/etc/certs/my-cert.crt"
54
+ #config.server_connection[:ca_path] = "/etc/certs/"
55
+ #config.server_connection[:client_certificate] = "client-cert.crt"
56
+ #config.server_connection[:client_password] = "P@5$w0Rd!"
57
+ #config.server_connection[:ssl_version] = :TLSv1
58
+ #config.server_connection[:open_timeout] = 10
59
+ #config.server_connection[:read_timeout] = 10
60
+
61
+ # Where to store files created by workflow runs. Should be fully qualified
62
+ # or use :rails_root for the root directory of your application.
63
+ #config.file_store = ":rails_root/public/system"
64
+
65
+ # Callbacks to be run at various points during a workflow run. These can be
66
+ # defined as Proc objects or as methods and referenced by name.
67
+ #
68
+ # Be careful! If a callback fails then the worker running the job will fail!
69
+ #
70
+ # Add callbacks in this initializer or define them elsewhere and require the
71
+ # file as usual (if they are not pulled in by some other code). You can
72
+ # create example stub callbacks using:
73
+ # "rails generate taverna_player:callbacks"
74
+ # which will put them in "lib/taverna_player_callbacks.rb".
75
+ #require "taverna_player_callbacks"
76
+
77
+ # The pre-run callback is called before the run has started (before Taverna
78
+ # Server is contacted, in fact).
79
+ # It takes the run model object as its parameter.
80
+ #config.pre_run_callback = Proc.new { |run| puts "Starting: #{run.name}" }
81
+ #config.pre_run_callback = "player_pre_run_callback"
82
+ #config.pre_run_callback = :player_pre_run_callback
83
+
84
+ # The post-run callback is called after the run has completed normally.
85
+ # It takes the run model object as its parameter.
86
+ #config.post_run_callback = Proc.new { |run| puts "Finished: #{run.name}" }
87
+ #config.post_run_callback = "player_post_run_callback"
88
+ #config.post_run_callback = :player_post_run_callback
89
+
90
+ # The run-cancelled callback is called if the run is cancelled by the user.
91
+ # It takes the run model object as its parameter.
92
+ #config.run_cancelled_callback = Proc.new { |run| puts "Cancelled: #{run.name}" }
93
+ #config.run_cancelled_callback = "player_run_cancelled_callback"
94
+ #config.run_cancelled_callback = :player_run_cancelled_callback
95
+
96
+ # The run-failed callback is called if the run fails for any reason.
97
+ # It takes the run model object as its parameter.
98
+ #config.run_failed_callback = Proc.new { |run| puts "Failed: #{run.name}" }
99
+ #config.run_failed_callback = "player_run_failed_callback"
100
+ #config.run_failed_callback = :player_run_failed_callback
101
+
102
+ # Callbacks to be run to render various types of workflow output. These can
103
+ # be defined as Proc objects or as methods and referenced by name.
104
+ #
105
+ # Be careful! If a callback fails then users will see an Internal Server
106
+ # Error (HTTP status code 500) instead of their run outputs!
107
+ #
108
+ # Add callbacks in this initializer or define them elsewhere and require the
109
+ # file as usual (if they are not pulled in by some other code). You can
110
+ # create example stub callbacks using:
111
+ # "rails generate taverna_player:renderers"
112
+ # which will put them in "lib/taverna_player_renderers.rb".
113
+ #require "taverna_player_renderers"
114
+
115
+ # Renderers for each type of output (referenced by MIME type) must then be
116
+ # registered. All the renderers shown below are supplied as defaults.
117
+ #config.output_renderers do |renderers|
118
+ # Set a default renderer for if there is a workflow type that browsers
119
+ # can't otherwise handle.
120
+ #renderers.default(:cannot_inline)
121
+
122
+ # You can set a renderer to also be a default for the whole media-type. In
123
+ # this case the below renderer is to be used for ALL text/* types that
124
+ # aren't otherwise registered.
125
+ #renderers.add("text/plain", :format_text, true)
126
+
127
+ # This renderer overrides the default text/* renderer for text/xml outputs.
128
+ #renderers.add("text/xml", :format_xml)
129
+
130
+ # Browsers can't show all image types so just register very common ones.
131
+ #renderers.add("image/jpeg", :show_image)
132
+ #renderers.add("image/png", :show_image)
133
+ #renderers.add("image/gif", :show_image)
134
+ #renderers.add("image/bmp", :show_image)
135
+
136
+ # This is the workflow error type and you should have a special renderer
137
+ # for it.
138
+ #renderers.add("application/x-error", :workflow_error)
139
+ #end
140
+ end
141
+
142
+ # Example workflow run callbacks defined in the initializer.
143
+
144
+ #def player_pre_run_callback(run)
145
+ # puts "Starting: #{run.name}"
146
+ #end
147
+
148
+ #def player_post_run_callback(run)
149
+ # puts "Finished: #{run.name}"
150
+ #end
151
+
152
+ #def player_run_cancelled_callback(run)
153
+ # puts "Cancelled: #{run.name}"
154
+ #end
@@ -0,0 +1,20 @@
1
+ #------------------------------------------------------------------------------
2
+ # Copyright (c) 2013 The University of Manchester, UK.
3
+ #
4
+ # BSD Licenced. See LICENCE.rdoc for details.
5
+ #
6
+ # Taverna Player was developed in the BioVeL project, funded by the European
7
+ # Commission 7th Framework Programme (FP7), through grant agreement
8
+ # number 283359.
9
+ #
10
+ # Author: Robert Haines
11
+ #------------------------------------------------------------------------------
12
+
13
+ module TavernaPlayer
14
+ class Run < ActiveRecord::Base
15
+ # Do not remove the next line.
16
+ include TavernaPlayer::Concerns::Models::Run
17
+
18
+ # Extend the Run model here.
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ #------------------------------------------------------------------------------
2
+ # Copyright (c) 2013 The University of Manchester, UK.
3
+ #
4
+ # BSD Licenced. See LICENCE.rdoc for details.
5
+ #
6
+ # Taverna Player was developed in the BioVeL project, funded by the European
7
+ # Commission 7th Framework Programme (FP7), through grant agreement
8
+ # number 283359.
9
+ #
10
+ # Author: Robert Haines
11
+ #------------------------------------------------------------------------------
12
+
13
+ namespace :taverna_player do
14
+ desc "Delete all cancelled workflow runs."
15
+ task :delete_cancelled_runs => :environment do
16
+
17
+ gone = 0
18
+ TavernaPlayer::Run.all.each do |run|
19
+ if run.cancelled?
20
+ gone += 1 #if run.destroy
21
+ end
22
+ end
23
+
24
+ puts "#{gone} cancelled runs were deleted."
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ #------------------------------------------------------------------------------
2
+ # Copyright (c) 2013 The University of Manchester, UK.
3
+ #
4
+ # BSD Licenced. See LICENCE.rdoc for details.
5
+ #
6
+ # Taverna Player was developed in the BioVeL project, funded by the European
7
+ # Commission 7th Framework Programme (FP7), through grant agreement
8
+ # number 283359.
9
+ #
10
+ # Author: Robert Haines
11
+ #------------------------------------------------------------------------------
12
+
13
+ namespace :taverna_player do
14
+ desc "Delete all completed embedded workflow runs."
15
+ task :delete_completed_embedded_runs => :environment do
16
+
17
+ gone = 0
18
+ TavernaPlayer::Run.find_all_by_embedded(true).each do |run|
19
+ if run.complete?
20
+ gone += 1 if run.destroy
21
+ end
22
+ end
23
+
24
+ puts "#{gone} complete embedded runs were deleted."
25
+ end
26
+ end
@@ -0,0 +1,139 @@
1
+ #------------------------------------------------------------------------------
2
+ # Copyright (c) 2013 The University of Manchester, UK.
3
+ #
4
+ # BSD Licenced. See LICENCE.rdoc for details.
5
+ #
6
+ # Taverna Player was developed in the BioVeL project, funded by the European
7
+ # Commission 7th Framework Programme (FP7), through grant agreement
8
+ # number 283359.
9
+ #
10
+ # Author: Robert Haines
11
+ #------------------------------------------------------------------------------
12
+
13
+ require "require_all"
14
+ require "coderay"
15
+ require "delayed_job_active_record"
16
+ require "jbuilder"
17
+ require 'mime/types'
18
+ require "paperclip"
19
+ require "pmrpc-rails"
20
+ require "rails_autolink"
21
+ require "t2-server"
22
+ require "taverna-t2flow"
23
+ require "tmpdir"
24
+ require "zip/zip"
25
+
26
+ # Grab everything in the taverna_player directory using the require_all gem.
27
+ require_rel "taverna_player"
28
+
29
+ # This module serves as the configuration point of Taverna Player. Examples of
30
+ # all configuration options can be found in the taverna_player initializer.
31
+ module TavernaPlayer
32
+ # Configuration without defaults
33
+ mattr_accessor :server_address, :server_password, :server_username
34
+
35
+ # This should be set to the name of the workflow model class in the main
36
+ # application via the workflow_model_proxy method below.
37
+ mattr_reader :workflow_proxy
38
+
39
+ # :call-seq:
40
+ # workflow_model_proxy(workflow_class) {|proxy| ...}
41
+ #
42
+ # Set up a proxy to the main application's workflow model. The class name
43
+ # should be supplied as a string, e.g. "Workflow".
44
+ #
45
+ # See the taverna_player initializer for more information.
46
+ def self.workflow_model_proxy(workflow_class)
47
+ @@workflow_proxy = ModelProxy.new(workflow_class, [:file, :title, :inputs])
48
+ yield @@workflow_proxy if block_given?
49
+ end
50
+
51
+ # This should be set to the name of the user model class in the main
52
+ # application via the user_model_proxy method below. Defaults to nil.
53
+ mattr_reader :user_proxy
54
+ @@user_proxy = nil
55
+
56
+ # :call-seq:
57
+ # user_model_proxy = user_class
58
+ #
59
+ # Set up a proxy to the main application's user model if it has one. The
60
+ # class name should be supplied as a string, e.g. "User".
61
+ #
62
+ # See the taverna_player initializer for more information.
63
+ def self.user_model_proxy=(user_class)
64
+ @@user_proxy = ModelProxy.new(user_class)
65
+ end
66
+
67
+ # This should be set to the name of the method used to get the current user
68
+ # in the main app. For Devise this would be :current_user. Defaults to nil.
69
+ mattr_accessor :current_user_callback
70
+ @@current_user_callback = nil
71
+
72
+ # Setup default output render callbacks.
73
+ mattr_reader :output_renderer
74
+ @@output_renderer = OutputRenderer.new
75
+ @@output_renderer.default(:cannot_inline_tp_default)
76
+ @@output_renderer.add("text/plain", :format_text_tp_default, true)
77
+ @@output_renderer.add("text/xml", :format_xml_tp_default)
78
+ @@output_renderer.add("image/jpeg", :show_image_tp_default)
79
+ @@output_renderer.add("image/png", :show_image_tp_default)
80
+ @@output_renderer.add("image/gif", :show_image_tp_default)
81
+ @@output_renderer.add("image/bmp", :show_image_tp_default)
82
+ @@output_renderer.add("application/x-error", :workflow_error_tp_default)
83
+ @@output_renderer.add("application/x-empty", :empty_tp_default)
84
+ @@output_renderer.add("inode/x-empty", :empty_tp_default)
85
+
86
+ # :call-seq:
87
+ # output_renderers {|renderer| ...}
88
+ #
89
+ # Set up the renderers for each MIME type that you want to be able to show
90
+ # in the browser. In most cases the supplied defaults will be sufficient.
91
+ #
92
+ # See the taverna_player initializer for more information.
93
+ def self.output_renderers
94
+ yield @@output_renderer if block_given?
95
+ end
96
+
97
+ # Path to place where files should be stored.
98
+ mattr_accessor :file_store
99
+ @@file_store = ":rails_root/public/system"
100
+
101
+ # Taverna server polling interval (in seconds)
102
+ mattr_accessor :server_poll_interval
103
+ @@server_poll_interval = 5
104
+
105
+ # Taverna server retry interval (in seconds)
106
+ mattr_accessor :server_retry_interval
107
+ @@server_retry_interval = 10
108
+
109
+ # Taverna Server connection parameters
110
+ mattr_accessor :server_connection
111
+ @@server_connection = T2Server::DefaultConnectionParameters.new
112
+
113
+ # Pre run callback
114
+ mattr_accessor :pre_run_callback
115
+ @@pre_run_callback = nil
116
+
117
+ # Post run callback
118
+ mattr_accessor :post_run_callback
119
+ @@post_run_callback = nil
120
+
121
+ # Run cancelled callback
122
+ mattr_accessor :run_cancelled_callback
123
+ @@run_cancelled_callback = nil
124
+
125
+ # Run failed callback
126
+ mattr_accessor :run_failed_callback
127
+ @@run_failed_callback = nil
128
+
129
+ # :call-seq:
130
+ # setup {|config| ...}
131
+ #
132
+ # Yield this configuration class so that Taverna Player can be set up.
133
+ #
134
+ # See the taverna_player initializer for more information.
135
+ def self.setup
136
+ yield self
137
+ end
138
+
139
+ end