class T2Server::Server

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

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 74
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)

  # The following four fields hold cached data about the server that is
  # only downloaded the first time it is requested.
  @server_doc = nil
  @version = nil
  @version_components = nil
  @links = nil

  # 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. Note that only those runs that the provided credentials have permission to delete will be deleted.

# File lib/t2-server/server.rb, line 242
def delete_all_runs(credentials = nil)
  # first refresh run list
  runs(credentials).each {|run| run.delete}
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(links[:runs], workflow,
    "application/vnd.taverna.t2flow+xml", credentials)
end
run(identifier, credentials = nil) → run click to toggle source

Return the specified run.

# File lib/t2-server/server.rb, line 212
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 196
def run_limit(credentials = nil)
  read(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 204
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 186
def uri
  @connection.uri
end
version → String click to toggle source

The version string of the remote Taverna Server.

# File lib/t2-server/server.rb, line 160
def version
  if @version.nil?
    @version = _get_version
  end

  @version
end
version_components → Array click to toggle source

An array of the major, minor and patch version components of the remote Taverna Server.

# File lib/t2-server/server.rb, line 173
def version_components
  if @version_components.nil?
    comps = version.split(".")
    @version_components = comps.map { |v| v.to_i }
  end

  @version_components
end