class T2Server::Server
An interface for directly communicating with one or more Taverna 2 Server
instances.
Public Class Methods
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 76 def initialize(uri, params = nil) 77 # Convert strings to URIs and strip any credentials that have been given 78 # in the URI. We do not want to store credentials in this class. 79 uri, creds = Util.strip_uri_credentials(uri) 80 81 # setup connection 82 @connection = ConnectionFactory.connect(uri, params) 83 84 # The following four fields hold cached data about the server that is 85 # only downloaded the first time it is requested. 86 @server_doc = nil 87 @version = nil 88 @version_components = nil 89 @links = nil 90 91 # Initialize the run object cache. 92 @run_cache = RunCache.new(self) 93 94 yield(self) if block_given? 95 end
Public Instance Methods
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 103 def administrator(credentials = nil) 104 admin = Administrator.new(self, credentials) 105 106 yield(admin) if block_given? 107 admin 108 end
Create a run on this server using the specified workflow. This method will yield the newly created Run
if a block is given.
The workflow parameter may be the workflow itself, a file name or a File or IO object.
# File lib/t2-server/server.rb 119 def create_run(workflow, credentials = nil) 120 uri = initialize_run(workflow, credentials) 121 run = Run.create(self, "", credentials, uri) 122 123 # Add the newly created run object to the user's run cache 124 @run_cache.add_run(run, credentials) 125 126 yield(run) if block_given? 127 run 128 end
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 218 def delete_all_runs(credentials = nil) 219 # Refresh run list, delete everything, clear the user's run cache. 220 runs(credentials).each {|run| run.delete} 221 @run_cache.clear!(credentials) 222 end
Return the specified run.
# File lib/t2-server/server.rb 208 def run(identifier, credentials = nil) 209 get_runs(credentials)[identifier] 210 end
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 192 def run_limit(credentials = nil) 193 read(links[:runlimit], "text/plain", credentials).to_i 194 end
Return the set of runs on this server.
# File lib/t2-server/server.rb 200 def runs(credentials = nil) 201 get_runs(credentials).values 202 end
The URI of the connection to the remote Taverna Server
.
# File lib/t2-server/server.rb 182 def uri 183 @connection.uri 184 end
An object representing the version of the remote Taverna Server
.
# File lib/t2-server/server.rb 164 def version 165 @version ||= _get_version 166 end
Private Instance Methods
# File lib/t2-server/server.rb 338 def _get_server_description 339 if @server_doc.nil? 340 rest_uri = Util.append_to_uri_path(uri, REST_ENDPOINT) 341 @server_doc = xml_document(read(rest_uri, "application/xml")) 342 end 343 344 @server_doc 345 end
# File lib/t2-server/server.rb 359 def _get_server_links 360 doc = _get_server_description 361 links = get_uris_from_doc(doc, [:runs, :policy]) 362 363 doc = xml_document(read(links[:policy], "application/xml")) 364 links.merge get_uris_from_doc(doc, 365 [:permlisteners, :notifications, :runlimit, :permworkflows]) 366 end
# File lib/t2-server/server.rb 347 def _get_version 348 doc = _get_server_description 349 version = xpath_attr(doc, @@xpaths[:server], "serverVersion") 350 351 if version.nil? 352 raise RuntimeError.new("Taverna Servers prior to version 2.3 " + 353 "are no longer supported.") 354 end 355 356 Version.new(version) 357 end
# File lib/t2-server/server.rb 368 def get_runs(credentials = nil) 369 run_list = read(links[:runs], "application/xml", credentials) 370 371 doc = xml_document(run_list) 372 373 # get list of run identifiers 374 run_list = {} 375 xpath_find(doc, @@xpaths[:run]).each do |run| 376 uri = URI.parse(xml_node_attribute(run, "href")) 377 id = xml_node_content(run) 378 run_list[id] = uri 379 end 380 381 # Refresh the user's cache and return the runs in it. 382 @run_cache.refresh_all!(run_list, credentials) 383 end
# File lib/t2-server/server.rb 334 def links 335 @links ||= _get_server_links 336 end