module TavernaPlayer::Concerns::Controllers::RunsController

Public Instance Methods

cancel() click to toggle source

PUT /runs/1/cancel

# 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.embedded?
        redirect_to view_context.new_embedded_run_path(@run)
      else
        redirect_to :back
      end
    end
  end
end
create() click to toggle source

POST /runs

# 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() click to toggle source

DELETE /runs/1

# 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() click to toggle source

GET /runs/1/download/input/:port

# File lib/taverna_player/concerns/controllers/runs_controller.rb, line 191
def download_input
  download_port
end
download_log() click to toggle source

GET /runs/1/download/log

# 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() click to toggle source

GET /runs/1/download/output/:port

# File lib/taverna_player/concerns/controllers/runs_controller.rb, line 196
def download_output
  download_port
end
download_port() click to toggle source

Download an input or output port as an “attachment” (i.e. not “inline”).

# File lib/taverna_player/concerns/controllers/runs_controller.rb, line 80
def download_port
  # If there is no such port then return a 404.
  raise ActionController::RoutingError.new('Not Found') if @port.nil?

  type = @port.depth == 0 ? @port.value_type : "application/zip"
  send_data @port.value, :type => type, :filename => @port.filename
end
download_results() click to toggle source

GET /runs/1/download/results

# 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
filter_update_parameters() click to toggle source
# File lib/taverna_player/concerns/controllers/runs_controller.rb, line 69
def filter_update_parameters
  name = params[:run][:name]
  @update_parameters = { :name => name } unless name.blank?
end
find_interaction() click to toggle source
# File lib/taverna_player/concerns/controllers/runs_controller.rb, line 74
def find_interaction
  @interaction = Interaction.find_by_run_id_and_serial(@run.id, params[:serial])
end
find_port() click to toggle source
# File lib/taverna_player/concerns/controllers/runs_controller.rb, line 51
def find_port
  @port = RunPort.find_by_run_id_and_name(@run.id, params[:port])
end
find_run() click to toggle source
# File lib/taverna_player/concerns/controllers/runs_controller.rb, line 43
def find_run
  @run = Run.find(params[:id])
end
find_runs() click to toggle source
# File lib/taverna_player/concerns/controllers/runs_controller.rb, line 37
def find_runs
  select = { :embedded => false }
  select[:workflow_id] = params[:workflow_id] if params[:workflow_id]
  @runs = Run.where(select).all
end
find_workflow() click to toggle source
# File lib/taverna_player/concerns/controllers/runs_controller.rb, line 47
def find_workflow
  @workflow = TavernaPlayer.workflow_proxy.class_const.find(params[:workflow_id])
end
index() click to toggle source

GET /runs

# File lib/taverna_player/concerns/controllers/runs_controller.rb, line 91
def index

end
input() click to toggle source

GET /runs/1/input/*

# 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() click to toggle source

GET /runs/new

# 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.embedded
    end
  end
end
output() click to toggle source

GET /runs/1/output/*

# 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() click to toggle source

GET /runs/1/interaction/:int_id

# File lib/taverna_player/concerns/controllers/runs_controller.rb, line 230
def read_interaction
  send_data @interaction.page, :type => "text/html",
    :disposition => "inline"
end
set_run_user() click to toggle source
# File lib/taverna_player/concerns/controllers/runs_controller.rb, line 60
def set_run_user
  return if params[:run][:embedded] == "true" || TavernaPlayer.user_proxy.nil?

  unless TavernaPlayer.current_user_callback.blank?
    user = callback(TavernaPlayer.current_user_callback)
    params[:run][:user_id] = user.id unless user.nil?
  end
end
setup_new_run() click to toggle source
# File lib/taverna_player/concerns/controllers/runs_controller.rb, line 55
def setup_new_run
  @run = Run.new(:workflow_id => @workflow.id)
  @run.embedded = true if params[:embedded] == "true"
end
show() click to toggle source

GET /runs/1

# 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.embedded
    end
  end
end
update() click to toggle source

PUT /runs/1

# File lib/taverna_player/concerns/controllers/runs_controller.rb, line 144
def update
  @run.update_attributes(@update_parameters)

  respond_with(@run)
end
write_interaction() click to toggle source

POST /runs/1/interaction/:int_id

# 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