Module: TavernaPlayer::Concerns::Controllers::RunsController
- Extended by:
- ActiveSupport::Concern
- Includes:
- TavernaPlayer::Concerns::Callback, Utils
- Included in:
- RunsController
- Defined in:
- lib/taverna_player/concerns/controllers/runs_controller.rb
Instance Method Summary collapse
-
#cancel ⇒ Object
PUT /runs/1/cancel.
-
#create ⇒ Object
POST /runs.
-
#destroy ⇒ Object
DELETE /runs/1.
-
#download_input ⇒ Object
GET /runs/1/download/input/:port.
-
#download_log ⇒ Object
GET /runs/1/download/log.
-
#download_output ⇒ Object
GET /runs/1/download/output/:port.
-
#download_results ⇒ Object
GET /runs/1/download/results.
-
#index ⇒ Object
GET /runs.
-
#input ⇒ Object
GET /runs/1/input/*.
-
#new ⇒ Object
GET /runs/new.
-
#output ⇒ Object
GET /runs/1/output/*.
-
#read_interaction ⇒ Object
GET /runs/1/interaction/:int_id.
-
#show ⇒ Object
GET /runs/1.
-
#update ⇒ Object
PUT /runs/1.
-
#write_interaction ⇒ Object
POST /runs/1/interaction/:int_id.
Methods included from Utils
#list_depth, #recurse_into_lists
Methods included from TavernaPlayer::Concerns::Callback
Instance Method Details
#cancel ⇒ Object
PUT /runs/1/cancel
164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/taverna_player/concerns/controllers/runs_controller.rb', line 164 def cancel @run.cancel unless @run.complete? respond_with(@run, :action => :show) do |format| format.html do if @run. redirect_to view_context.(@run) else redirect_to :back end end end end |
#create ⇒ Object
POST /runs
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/taverna_player/concerns/controllers/runs_controller.rb', line 127 def create @run = Run.new(params[:run]) # Set workflow, just in case the create fails and needs to redirect # back to the form @workflow = @run.workflow if @run.save flash[:notice] = "Run was successfully created." respond_with(@run, :status => :created, :location => @run) else flash[:alert] = "Run was not successfully created." respond_with(@run) end end |
#destroy ⇒ Object
DELETE /runs/1
151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/taverna_player/concerns/controllers/runs_controller.rb', line 151 def destroy if @run.destroy flash[:notice] = "Run was deleted." respond_with(@run) else flash[:alert] = "Run must be cancelled before deletion." respond_with(@run, :nothing => true, :status => :forbidden) do |format| format.html { redirect_to :back } end end end |
#download_input ⇒ Object
GET /runs/1/download/input/:port
191 192 193 |
# File 'lib/taverna_player/concerns/controllers/runs_controller.rb', line 191 def download_input download_port end |
#download_log ⇒ Object
GET /runs/1/download/log
179 180 181 182 |
# File 'lib/taverna_player/concerns/controllers/runs_controller.rb', line 179 def download_log send_file @run.log.path, :type => "text/plain", :filename => "#{@run.name}-log.txt" end |
#download_output ⇒ Object
GET /runs/1/download/output/:port
196 197 198 |
# File 'lib/taverna_player/concerns/controllers/runs_controller.rb', line 196 def download_output download_port end |
#download_results ⇒ Object
GET /runs/1/download/results
185 186 187 188 |
# File 'lib/taverna_player/concerns/controllers/runs_controller.rb', line 185 def download_results send_file @run.results.path, :type => "application/zip", :filename => "#{@run.name}-all-results.zip" end |
#index ⇒ Object
GET /runs
91 92 93 |
# File 'lib/taverna_player/concerns/controllers/runs_controller.rb', line 91 def index end |
#input ⇒ Object
GET /runs/1/input/*
201 202 203 204 205 206 207 |
# File 'lib/taverna_player/concerns/controllers/runs_controller.rb', line 201 def input # If there is no such input port then return a 404. raise ActionController::RoutingError.new('Not Found') if @port.nil? send_data @port.value, :type => @port.value_type, :disposition => "inline" end |
#new ⇒ Object
GET /runs/new
117 118 119 120 121 122 123 124 |
# File 'lib/taverna_player/concerns/controllers/runs_controller.rb', line 117 def new respond_with(@run) do |format| # Render new.html.erb unless the run is embedded. format.html do render "taverna_player/runs/embedded/new", :layout => "taverna_player/embedded" if @run. end end end |
#output ⇒ Object
GET /runs/1/output/*
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/taverna_player/concerns/controllers/runs_controller.rb', line 210 def output # We need to parse out the path into a list of numbers here so we have # a list of indices into the file structure. path = [] unless params[:path].nil? path = params[:path].split("/").map { |p| p.to_i } end # If there is no such output port or the path is the wrong depth then # return a 404. if @port.nil? || path.length != @port.depth raise ActionController::RoutingError.new('Not Found') end # Just need to mangle the MIME type when sending error messages. type = @port.value_is_error?(path) ? "text/plain" : @port.value_type(path) send_data @port.value(path), :type => type, :disposition => "inline" end |
#read_interaction ⇒ Object
GET /runs/1/interaction/:int_id
230 231 232 233 |
# File 'lib/taverna_player/concerns/controllers/runs_controller.rb', line 230 def read_interaction send_data @interaction.page, :type => "text/html", :disposition => "inline" end |
#show ⇒ Object
GET /runs/1
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/taverna_player/concerns/controllers/runs_controller.rb', line 96 def show if @run.running? @interaction = Interaction.find_by_run_id_and_replied(@run.id, false) unless @interaction.nil? unless @interaction.displayed @new_interaction = true @interaction.displayed = true @interaction.save end end end respond_with(@run) do |format| # Render show.{html|js}.erb unless the run is embedded. format.any(:html, :js) do render "taverna_player/runs/embedded/show", :layout => "taverna_player/embedded" if @run. end end end |
#update ⇒ Object
PUT /runs/1
144 145 146 147 148 |
# File 'lib/taverna_player/concerns/controllers/runs_controller.rb', line 144 def update @run.update_attributes(@update_parameters) respond_with(@run) end |
#write_interaction ⇒ Object
POST /runs/1/interaction/:int_id
236 237 238 239 240 241 242 |
# File 'lib/taverna_player/concerns/controllers/runs_controller.rb', line 236 def write_interaction @interaction.data = request.body.read @interaction.feed_reply = request.headers["X-Taverna-Interaction-Reply"] @interaction.save render :nothing => true, :status => 201 end |