class T2Server::Server

An interface for directly communicating with one or more Taverna 2 Server instances.

Attributes

version[R]

The version of the remote Taverna Server instance.

Public Class Methods

new(uri, connection_parameters = nil) → Server click to toggle source
new(uri, connection_parameters = nil) {|self| ...}

Create a new Server instance that represents the real server at uri. If connection_parameters are supplied they will be used to set up the network connection to the server.

It will yield itself if a block is given.

# File lib/t2-server/server.rb, line 73
def initialize(uri, params = nil)
  # we want to use URIs here but strings can be passed in
  unless uri.is_a? URI
    uri = URI.parse(Util.strip_path_slashes(uri))
  end

  # strip username and password from the URI if present
  if uri.user != nil
    uri = URI::HTTP.new(uri.scheme, nil, uri.host, uri.port, nil,
    uri.path, nil, nil, nil);
  end

  # setup connection
  @connection = ConnectionFactory.connect(uri, params)

  # add a slash to the end of this address to work around this bug:
  # http://www.mygrid.org.uk/dev/issues/browse/TAVSERV-113
  server_description = xml_document(get_attribute("#{uri.path}/rest/",
    "application/xml"))
  @version = get_version(server_description)
  @links = get_description(server_description)
  @links[:admin] = "#{uri.path}/admin"

  # initialize run object cache
  @runs = {}

  yield(self) if block_given?
end

Public Instance Methods

administrator(credentials = nil) → Administrator click to toggle source
administrator(credentials = nil) {|admin| ...}

Return an instance of the Taverna Server administrator interface. This method will yield the newly created administrator if a block is given.

# File lib/t2-server/server.rb, line 116
def administrator(credentials = nil)
  admin = Administrator.new(self, credentials)

  yield(admin) if block_given?
  admin
end
create_run(workflow, credentials = nil) → run click to toggle source
create_run(workflow, credentials = nil) {|run| ...}

Create a run on this server using the specified workflow. This method will yield the newly created Run if a block is given.

# File lib/t2-server/server.rb, line 129
def create_run(workflow, credentials = nil)
  id = initialize_run(workflow, credentials)
  run = Run.create(self, "", credentials, id)

  # cache newly created run object - this must be done per user
  user = credentials.nil? ? :all : credentials.username
  @runs[user] = {} unless @runs[user]
  @runs[user][id] = run

  yield(run) if block_given?
  run
end
delete_all_runs(credentials = nil) click to toggle source

Delete all runs on this server, discarding all of their state.

# File lib/t2-server/server.rb, line 213
def delete_all_runs(credentials = nil)
  # first refresh run list
  runs(credentials).each {|run| run.delete}
end
delete_run(run, credentials = nil) → bool click to toggle source

Delete the specified run from the server, discarding all of its state. run can be either a Run instance or a identifier.

# File lib/t2-server/server.rb, line 195
def delete_run(run, credentials = nil)
  # get the identifier from the run if that is what is passed in
  if run.instance_of? Run
    run = run.identifier
  end

  if delete_attribute("#{@links[:runs]}/#{run}", credentials)
    # delete cached run object - this must be done per user
    user = credentials.nil? ? :all : credentials.username
    @runs[user].delete(run) if @runs[user]
    true
  end
end
initialize_run(workflow, credentials = nil) → string click to toggle source

Create a run on this server using the specified workflow but do not return it as a Run instance. Return its identifier instead.

# File lib/t2-server/server.rb, line 147
def initialize_run(workflow, credentials = nil)
  # set up the run object cache - this must be done per user
  user = credentials.nil? ? :all : credentials.username
  @runs[user] = {} unless @runs[user]

  @connection.POST_run("#{@links[:runs]}",
    XML::Fragments::WORKFLOW % workflow, credentials)
end
run(identifier, credentials = nil) → run click to toggle source

Return the specified run.

# File lib/t2-server/server.rb, line 186
def run(identifier, credentials = nil)
  get_runs(credentials)[identifier]
end
run_limit(credentials = nil) → num click to toggle source

The maximum number of runs that this server will allow at any one time. Runs in any state (Initialized, Running and Finished) are counted against this maximum.

# File lib/t2-server/server.rb, line 170
def run_limit(credentials = nil)
  get_attribute(@links[:runlimit], "text/plain", credentials).to_i
end
runs(credentials = nil) → [runs] click to toggle source

Return the set of runs on this server.

# File lib/t2-server/server.rb, line 178
def runs(credentials = nil)
  get_runs(credentials).values
end
uri → URI click to toggle source

The URI of the connection to the remote Taverna Server.

# File lib/t2-server/server.rb, line 160
def uri
  @connection.uri
end