myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [2347] trunk/vendor/plugins: frozen mannie's gems


From: noreply
Subject: [myexperiment-hackers] [2347] trunk/vendor/plugins: frozen mannie's gems
Date: Fri, 26 Mar 2010 12:20:10 -0400 (EDT)

Revision
2347
Author
dgc
Date
2010-03-26 12:20:10 -0400 (Fri, 26 Mar 2010)

Log Message

frozen mannie's gems

Added Paths

Diff

Added: trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/LICENCE (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/LICENCE	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/LICENCE	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,165 @@
+		   GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+  This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+  0. Additional Definitions. 
+
+  As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+  "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+  An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+  A "Combined Work" is a work produced by combining or linking an
+Application with the Library.  The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+  The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+  The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+  1. Exception to Section 3 of the GNU GPL.
+
+  You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+  2. Conveying Modified Versions.
+
+  If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+   a) under this License, provided that you make a good faith effort to
+   ensure that, in the event an Application does not supply the
+   function or data, the facility still operates, and performs
+   whatever part of its purpose remains meaningful, or
+
+   b) under the GNU GPL, with none of the additional permissions of
+   this License applicable to that copy.
+
+  3. Object Code Incorporating Material from Library Header Files.
+
+  The object code form of an Application may incorporate material from
+a header file that is part of the Library.  You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+   a) Give prominent notice with each copy of the object code that the
+   Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the object code with a copy of the GNU GPL and this license
+   document.
+
+  4. Combined Works.
+
+  You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+   a) Give prominent notice with each copy of the Combined Work that
+   the Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the Combined Work with a copy of the GNU GPL and this license
+   document.
+
+   c) For a Combined Work that displays copyright notices during
+   execution, include the copyright notice for the Library among
+   these notices, as well as a reference directing the user to the
+   copies of the GNU GPL and this license document.
+
+   d) Do one of the following:
+
+       0) Convey the Minimal Corresponding Source under the terms of this
+       License, and the Corresponding Application Code in a form
+       suitable for, and under terms that permit, the user to
+       recombine or relink the Application with a modified version of
+       the Linked Version to produce a modified Combined Work, in the
+       manner specified by section 6 of the GNU GPL for conveying
+       Corresponding Source.
+
+       1) Use a suitable shared library mechanism for linking with the
+       Library.  A suitable mechanism is one that (a) uses at run time
+       a copy of the Library already present on the user's computer
+       system, and (b) will operate properly with a modified version
+       of the Library that is interface-compatible with the Linked
+       Version. 
+
+   e) Provide Installation Information, but only if you would otherwise
+   be required to provide such information under section 6 of the
+   GNU GPL, and only to the extent that such information is
+   necessary to install and execute a modified version of the
+   Combined Work produced by recombining or relinking the
+   Application with a modified version of the Linked Version. (If
+   you use option 4d0, the Installation Information must accompany
+   the Minimal Corresponding Source and Corresponding Application
+   Code. If you use option 4d1, you must provide the Installation
+   Information in the manner specified by section 6 of the GNU GPL
+   for conveying Corresponding Source.)
+
+  5. Combined Libraries.
+
+  You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+   a) Accompany the combined library with a copy of the same work based
+   on the Library, uncombined with any other library facilities,
+   conveyed under the terms of this License.
+
+   b) Give prominent notice with the combined library that part of it
+   is a work based on the Library, and explaining where to find the
+   accompanying uncombined form of the same work.
+
+  6. Revised Versions of the GNU Lesser General Public License.
+
+  The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+  Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+  If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.

Added: trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/README.rdoc (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/README.rdoc	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/README.rdoc	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,133 @@
+= Taverna[http://taverna.sourceforge.net] 1 Interaction Gem
+
+Authors::       Stian Soiland, David Withers, Emmanuel Tagarira
+Version::       0.7.1
+Contact::       address@hidden
+URL::           http://taverna.sourceforge.net/
+Licence::       LGPL 3 (See LICENCE or http://www.gnu.org/licenses/lgpl.html)
+Copyright::     (c)2006-2008 University of Manchester, UK
+
+
+
+== Synopsis
+
+This is a Ruby library to support the interaction with Taverna[http://taverna.sourceforge.net] version 1 workflows (Scufls).  This relies on the functionality provided by a graph visualization package called GraphViz[http://www.graphviz.org/Download.php].
+
+
+
+== Installation
+To install the gems required by the Taverna 1 gem library, type into your command prompt:
+  [sudo] gem install libxml-ruby
+  [sudo] gem install rdoc
+  [sudo] gem install darkfish-rdoc
+
+When you have the required gems on your system, you may install this gem using the following commands:
+  gem sources -a http://gems.github.com
+  [sudo] gem install mannie-taverna-scufl
+
+
+
+== Usage
+
+To be able to generate at least a Scufl model using the gem, you can use the code following code:
+  require "scufl/model.rb"
+  require "scufl/parser.rb"
+  
+  foo = File.new("path/to/workflow/file", "r")
+  bar = Scufl::Parser.new.parse(foo)
+
+Alternatively:
+  foo = File.new("path/to/workflow/file", "r").read
+  bar = Scufl::Parser.new.parse(foo)
+
+You will then be able to use your Scufl model to retrieve information about the workflow by invoking the different methods and attributes.
+  bar.INVOKED
+... where INVOKED is the method or attribute required.
+
+You can also interact with remote workflows.
+  require "open-uri"
+  
+  foo = Uri.parse("xxxx://uri_to_workflow").read
+  bar = Scufl::Parser.new.parse(foo)
+
+To be enable you to draw images of the Scufl, you need to include:
+  require "scufl/dot.rb"
+
+To be able to use any functionality included in "scufl/dot.rb", you need to have GraphViz[http://www.graphviz.org/Download.php] installed on your system.  Once this package has been installed, you may use the gem to draw an image showing the structure of the Scufl as follows.
+  out_file = File.new("path/to/file/you/want/the/dot/script/to/be/written", "w+")
+  Scufl::Dot.new.write_dot(out_file, bar)
+  `dot -Tpng -o"path/to/the/output/image" #{out_file.path}`
+The last line draws a PNG image using +out_file+.  To learn more about dot, try typing into your command prompt:
+  % man dot
+or
+  % dot -h
+
+
+
+== Taverna Remote Execution Service Client
+
+The library also includes support for submitting Taverna[http://taverna.sourceforge.net] workflows to the Taverna
+Remote Execution service[2]. This requires the Remote Execution service that
+has already been installed and configured, and with a client username and
+password already registered by the administrator of the service. We 
+recommend first testing the service using the Remote Execution service
+from the Taverna workbench[3].
+
+
+
+== Usage
+
+Here's the simplest usecase. Given a Taverna workflow in "workflow.xml" (that produces
+a value at the port "myOutput") and a Taverna Remote Execution service [2] running 
+at http://localhost:8080/tavernaservice/v1/ you can try:
+
+	SERVICE = "http://localhost:8080/tavernaservice/v1/"
+	workflow = IO.read("workflow.xml")
+	require 'rubygems'
+	require 'enactor/client'
+	enactor = Enactor::Client(SERVICE, "johndoe", "s3cret")
+	results = enactor.execute_sync(workflow)
+	print results["myOutput"]
+
+
+Note that the call to execute_sync() will block until the workflow has been executed
+on the server. If you want to do this asynchronously, try:
+	
+	workflow_url = enactor.upload_workflow(workflow)
+	job_url = enactor.submit_job(workflow_url)
+	sleep 1 while not enactor.finished?(job_url)
+	if enactor.get_job_status(job_url) == Enactor::Status.COMPLETE
+	  results = enactor.get_job_outputs(job_url)
+	  print results["myOutput"]
+	end
+
+
+You can also supply inputs as a hash:
+
+	inputs = {}
+	inputs['gene'] = ["MY_GENE", "HIS_GENE"]
+	inputs['database'] = "kegg"
+	results = enactor.execute_sync(workflow, inputs)
+
+or
+
+	inputs_url = enactor.upload_data(inputs)
+	job_url = enactor.submitJob(workflow_url, inputsURL)
+
+
+See the rdoc documentation of Enactor::Client for more information, try:
+
+	help Enactor::Client
+
+Included are also lower level modules Baclava for parsing 
+and creating Baclava data documents, and Scufl for extracting basic 
+information about a workflow, such as which input and output ports it defines.
+
+
+
+== References
+
+[1] http://taverna.sourceforge.net
+[2] http://www.mygrid.org.uk/usermanual1.7/remote_execution_server.html
+[3] http://www.mygrid.org.uk/usermanual1.7/remote_execution.html
+

Added: trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/Release_Notes.rdoc (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/Release_Notes.rdoc	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/Release_Notes.rdoc	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,8 @@
+= Version 0.7.1
+Released:: Wednesday, September 16, 2009
+
+== Added Functionality
+- Retrieval of Taverna local workers.
+
+=== New instance method in T2Flow::Model
+      local_workers

Added: trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/baclava/reader.rb (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/baclava/reader.rb	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/baclava/reader.rb	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,61 @@
+require "rexml/document"
+require "document/data"
+
+module Baclava
+  
+  class Reader
+    
+    #Reads a baclava document amd returns a hash of Document::Data objects
+    def self.read(xml)
+      if xml.kind_of?(REXML::Document)
+      	document = xml
+      else
+        document = REXML::Document.new(xml)
+      end
+      root = document.root
+      raise "'#{root.name}' doesn't appear to be a data thing!" if root.name != "dataThingMap"
+      
+      create_data_map(root)
+    end
+    
+    def self.create_data_map(element)
+      data_map = {}
+      
+      element.each_element('b:dataThing') { |datathing|
+        key = datathing.attribute('key').value
+        data = ""
+        data_map[key] = data
+        datathing.each_element('b:myGridDataDocument')  { |dataDocument|
+          dataDocument.each_element('s:metadata')  { |metadata| data.annotation = get_metadata(metadata) }
+          dataDocument.each_element('b:partialOrder') { |partialOrder| data.value = get_list(partialOrder) }
+          dataDocument.each_element('b:dataElement')  { |dataElement| data.value = get_element(dataElement) }
+        }
+      }
+      
+      data_map   
+    end
+    
+    def self.get_list(element)
+      list = []
+      element.each_element('b:itemList') { |itemList|  
+        itemList.each_element('b:dataElement')  { |dataElement| list << get_element(dataElement) }
+        itemList.each_element('b:partialOrder') { |partialOrder| list << get_list(partialOrder) }
+      }
+      list
+    end
+    
+    def self.get_metadata(element)
+      list = []
+      element.each_element('s:mimeTypes') { |mimeTypes|
+        mimeTypes.each_element('s:mimeType')  { |mimeType| list << mimeType.text }
+      }
+      list
+    end
+    
+    def self.get_element(element)
+      element.each_element('b:dataElementData') { |data| return Base64.decode64(data.text) }
+    end
+    
+  end
+  
+end

Added: trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/baclava/writer.rb (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/baclava/writer.rb	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/baclava/writer.rb	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,82 @@
+require 'base64'
+require 'rubygems'
+require 'builder'
+
+module Baclava # :nodoc:
+  
+  class Writer
+    
+	def self.write_doc(data_map)
+		REXML::Document.new(write(data_map))
+	end  	
+
+    def self.write(data_map)
+      xml = Builder::XmlMarkup.new :indent => 2
+      xml.instruct!
+      xml.b :dataThingMap, 'xmlns:b' => 'http://org.embl.ebi.escience/baclava/0.1alpha' do
+        for key in data_map.keys do
+          data = ""
+          xml.b :dataThing, 'key' => key do
+            xml.b :myGridDataDocument, 'lsid' => '', 'syntactictype' => '' do
+              #write_metadata xml, data.annotation
+              write_data xml, data.value
+            end
+          end
+        end
+      end
+    end
+    
+    #def self.write_metadata(xml, metadata)
+    #  xml.s :metadata, 'xmlns:s' => 'http://org.embl.ebi.escience/xscufl/0.1alpha' do
+    #    xml.s :mimeTypes do
+    #      for mimetype in metadata do
+    #        xml.s :mimetype, mimetype
+    #      end
+    #    end
+    #  end    
+    #end
+    
+    def self.write_data(xml, data, index = nil)
+      if data.is_a? Array
+        write_list xml, data, index
+      else
+        if index
+          xml.b :dataElement, 'lsid' => '', 'index' => index do
+            xml.b :dataElementData, Base64.encode64(data)
+          end
+        else
+          xml.b :dataElement, 'lsid' => '' do
+            xml.b :dataElementData, Base64.encode64(data)
+          end
+        end
+      end
+      
+    end
+    
+    def self.write_list(xml, list, index)
+      if index
+        xml.b :partialOrder, 'lsid' => '', 'type' => 'list', 'index' => index do
+          write_item_list xml, list
+        end
+      else
+        xml.b :partialOrder, 'lsid' => '', 'type' => 'list' do
+          write_item_list xml, list
+        end
+      end
+    end
+    
+    def self.write_item_list(xml, list)
+      xml.b :relationList
+      for i in 0..list.length - 1 do
+        xml.b :relation, 'parent' => i, 'child' => i + 1
+      end
+      xml.b :itemList do
+        for i in 0..list.length - 1 do
+          write_data xml, list[i], i
+        end
+      end
+    end
+    
+  end
+  
+end
\ No newline at end of file

Added: trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/document/data.rb (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/document/data.rb	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/document/data.rb	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,24 @@
+module Document # :nodoc:
+	
+	#Input or output data
+	#
+	#value - the data value or a (possibly nested) list of data values
+	class Data
+		attr_accessor :value, :annotation
+		
+		def initialize(value=nil, annotation=nil)
+			@value = value
+			@annotation = annotation
+		end
+				
+		def eql?(other)
+			@value.eql?(other.value) and @annotation.eql?(other.annotation)
+		end
+		
+		def ==(other)
+			@value == other.value and @annotation == other.annotation
+		end
+		
+	end
+	
+end
\ No newline at end of file

Added: trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/document/report.rb (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/document/report.rb	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/document/report.rb	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,91 @@
+module Document
+  
+	class Report
+  
+		attr_reader :processors
+		attr_accessor :id, :status
+		
+		def initialize
+		  	@processors = Array.new
+		end
+		
+		def self.from_xml(xml)
+			Reader.read(xml)  
+		end
+	  
+		def self.from_document(document)
+			Reader.read(document)  
+		end
+	  
+	end
+	
+	class Processor
+		attr_accessor :name, :status, :time, :total, :number 
+	end
+    
+	class Reader
+
+		def self.read(report)
+			if report.kind_of?(REXML::Document)
+				document = report
+			else
+				document = REXML::Document.new(report)
+			end
+			root = document.root
+					  
+			return nil if not root
+								  
+			raise root.name + "Doesn't appear to be a workflow report!" if root.name != "workflowReport"
+								  
+			create_report(root)
+		end
+	  
+		def self.create_report(element)
+			report = Report.new
+			
+			id = element.attribute('workflowId')
+			report.id = id.value if id
+			
+			status = element.attribute('workflowStatus')
+			report.status = status.value if status
+			
+			element.elements['processorList'].each_element('processor') { |processor|
+			  add_processor(processor, report)
+			}
+			
+			report
+		end
+	  
+		def self.add_processor(element, report)
+			processor = Processor.new
+			
+			name = element.attribute('name')
+			processor.name = name.value if name
+				
+			if element.has_elements?
+			  	firstElement = element.elements[1]
+				case firstElement.name
+				when 'ProcessComplete'
+			   		processor.status = 'COMPLETE'
+					processor.time = firstElement.attribute('TimeStamp')
+				when 'ProcessScheduled'
+			   		processor.status = 'SCHEDULED'
+					processor.time = firstElement.attribute('TimeStamp')
+				when 'InvokingWithIteration'
+					processor.status = 'ITERATING'
+					processor.time = firstElement.attribute('TimeStamp')
+					processor.number = firstElement.attribute('IterationNumber')
+					processor.total = firstElement.attribute('IterationTotal')			 
+				when 'ServiceFailure'
+					processor.status = 'FAILED'
+					processor.time = firstElement.attribute('TimeStamp')
+				else
+					processor.status = 'UNKNOWN'
+				end
+			end
+			report.processors.push processor		
+		end
+	  	
+	end
+	
+end

Added: trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/enactor/client.rb (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/enactor/client.rb	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/enactor/client.rb	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,673 @@
+require 'rubygems'
+require 'builder'
+require "uri"
+require 'rexml/document'
+require 'net/http'
+require 'baclava/reader'
+require 'baclava/writer'
+require 'document/report'
+require 'document/data'
+
+module Enactor # :nodoc:
+
+	#Base class for Taverna service errors.
+	class TavernaServiceError < StandardError
+	end
+
+	#Job did not complete. 
+    #Thrown by execute_sync()
+	class NotCompleteError < TavernaServiceError
+		def initialize(job_url, status)
+			super("Job #{job_url} not complete, status: #{status}")
+    	end
+	end
+
+	#Could not create resource.
+	class CouldNotCreateError < TavernaServiceError
+    	def initialize(url)
+        	super("Expected 201 Created when uploading #url")
+    	end
+	end
+	
+	
+    #Status messages that can be returned from TavernaService.get_job_status().
+    #
+    #If finished?(status) is true, this means the job is finished, 
+    #either successfully (COMPLETE), unsuccessfully (CANCELLED, FAILED), or 
+    #that the job is no longer in the database (DESTROYED).
+    #
+    #When a job has just been created it will be in status NEW, after that 
+    #it will immediately be on a queue and in the state QUEUED. Once the 
+    #job has been picked up by a worker it will be in INITIALISING, this 
+    #state might include the startup time of the worker and while downloading 
+    #the workflow and input data to the worker. The state PAUSED is not 
+    #currently used. The FAILING state can occur if the workflow engine
+    #crashed, after clean-up or if the workflow itself failed, the state 
+    #will be FAILED.
+    #
+    #The job might at any time be set to the state CANCELLING by the user, 
+    #which will stop execution of the workflow, leading to the state 
+    #CANCELLED.
+    #
+    #If the workflow execution completed the state will be set to COMPLETE, 
+    #after which the workflow result data should be available by using
+    #get_job_outputs_doc().
+    #
+    #If data about the job has been lost (probably because it's too old 
+    #or has been deleted by the user), the state will be DESTROYED.
+	class Status
+    	NEW = "NEW"
+        QUEUED = "QUEUED"
+        INITIALISING = "INITIALISING"
+        PAUSED = "PAUSED"
+        FAILING = "FAILING"
+        CANCELLING = "CANCELLING"
+        CANCELLED = "CANCELLED"
+        COMPLETE = "COMPLETE"
+        FAILED = "FAILED"
+        DESTROYED = "DESTROYED"
+        FINISHED = [COMPLETE, CANCELLED, DESTROYED, FAILED]
+        ALL = [NEW, QUEUED, INITIALISING, FAILING, 
+                   CANCELLING, CANCELLED, COMPLETE, FAILED, DESTROYED]
+    
+        #Return True if the status is a finished status.
+        #
+        #This would normally include COMPLETE, CANCELLED, DESTROYED and FAILED.
+        def Status.finished?(status)
+            return FINISHED.include?(status)
+        end
+        
+        #Check if a string is a valid status.
+        def Status.valid?(status)
+            ALL.include?(status)
+        end
+	end
+        
+    #Client library for accessing a Taverna Remote execution service.
+    #
+    #Since the service is a rest interface, this library reflects that to 
+    #a certain degree and many of the methods return URLs to be used by 
+    #other methods.
+    # 
+    # The main methods of interest are - in order of a normal execution:
+    # 
+    #    execute_sync() -- Given a scufl document or the URL for a previously 
+    #        uploaded workflow, and data as a hash or URL for previously
+    #        uploaded data, submit job for execution, wait for completion 
+    #        (or a timeout) and retrieve results. This is a blocking 
+    #        convenience method that can be used instead of the methods below.
+    # 
+    #    upload_workflow() -- Given a scufl document as a string, upload the
+    #        workflow to the server for later execution. Return the URL for the
+    #        created workflow resource that can be used with submit_job()
+    #        
+    #    upload_data()-- Given a hash of input values to a
+    #        workflow run, upload the data to the user's collection.
+    #        Return the URL for the created data resource that can be used with 
+    #        submit_job()
+    #    
+    #    submit_job() -- Given the URL for a workflow resource and optionally
+    #        the URL for a input data resource, submit the a to the server 
+    #        to be executed. Return the URL to the created job resource.
+    #    
+    #    get_job_status() -- Get the status of the job. Return one of the values from
+    #        Status.
+    #        
+    #    finished?() -- Return True if the job is in a finished state. Note 
+    #        that this also includes failed states.
+    #
+    #    wait_for_job() -- Wait until job has finished execution, or a maximum
+    #        timeout is exceeded.
+    #                   
+    #    get_job_outputs() -- Get the outputs produced by job.  Return a  
+    #        hash which values are strings, lists of strings, 
+    #        or deeper lists.
+    #        
+    #Most or all of these methods might in addition to stated exceptions also raise
+    #Net::HTTPError or InvalidResponseError if anything goes wrong in communicating with the service.
+	class Client
+    
+    	#Name spaces used by various XML documents.
+  	    NAMESPACES = {
+			  :xscufl => 'http://org.embl.ebi.escience/xscufl/0.1alpha',
+			  :baclava => 'http://org.embl.ebi.escience/baclava/0.1alpha',
+			  :service => 'http://taverna.sf.net/service',
+			  :xlink => 'http://www.w3.org/1999/xlink',
+			  :dcterms => 'http://purl.org/dc/terms/'
+		}
+
+		#Mime types used by the rest protocol.
+		#
+		# See net.sf.taverna.service.interfaces.TavernaConstants.java
+		MIME_TYPES = {
+			:rest => 'application/vnd.taverna.rest+xml', # For most of the rest documents
+			:scufl => 'application/vnd.taverna.scufl+xml', # For Taverna workflows
+			:baclava => 'application/vnd.taverna.baclava+xml', # For Taverna's Baclava data documents
+			:report => 'application/vnd.taverna.report+xml', # For Taverna's internal progress reports
+			:console => 'text/plain' # For Taverna's console
+		}
+
+
+		DEFAULT_TIMEOUT = 5 * 60 # in seconds
+		DEFAULT_REFRESH = 0.5 # in seconds
+	
+		#Construct a Taverna remote execution service client accessing the service
+		#at the given base URL.  
+		#
+		#Note that this constructor will not attempt to verify the URL or the 
+		#credentials. To verify, call get_user_url() which requires authentication.
+		#
+		#url -- The base URL for the service, normally ending in /v1/, for example:
+		#    "http://myserver.com:8080/tavernaService/v1/"
+		#
+		#username -- The username of a user that has been previously created or 
+		#    registered in the web interface of the service.
+		#    
+		#password -- The password of the user. Note that the password will be sent
+		#   over the wire using unencrypted HTTP Basic Auth, unless the URL starts
+		#	with "https".
+		def initialize(url, username, password)
+			@url = ""
+			@username = username
+			@password = password
+		end
+        
+		#private
+		
+		#Get the capabilities document as a REXML::Document 
+		#
+		#This document contains the links to the main collections of the service.
+		def get_capabilities_doc
+			url = ""
+			request = Net::HTTP::Get.new(url.path)
+			request['Accept'] = MIME_TYPES[:rest]
+			request.basic_auth @username, @password
+			response = Net::HTTP.start(url.host, url.port) {|http|
+			  http.request(request)
+			}
+			response.value
+			REXML::Document.new(response.body)
+		end
+        
+		#Get the URL for the current user's home on the server.
+		def get_user_url
+			capabilities_doc = get_capabilities_doc()
+			#currentUser = capabilities_doc.root.elements["{#{NAMESPACES[:service]}}currentUser"]
+			current_user = capabilities_doc.root.elements['currentUser']
+			current_user_url = current_user.attributes.get_attribute_ns(NAMESPACES[:xlink], 'href').value
+			
+			url = ""
+			request = Net::HTTP::Get.new(url.path)
+			request['Accept'] = MIME_TYPES[:rest]
+			request.basic_auth @username, @password
+			response = Net::HTTP.start(url.host, url.port) {|http|
+				http.request(request)
+			}
+			response.error! unless response.kind_of?(Net::HTTPSuccess) or response.kind_of?(Net::HTTPRedirection)
+			response.header['Location']
+		end
+ 
+		#Get the user document as an REXML::Document object. 
+		#
+		#This document contains the links to the user owned collections, 
+		#such as where to upload workflows and jobs.
+		def get_user_doc
+			url = ""
+			request = Net::HTTP::Get.new(url.path)
+			request['Accept'] = MIME_TYPES[:rest]
+			request.basic_auth @username, @password
+			response = Net::HTTP.start(url.host, url.port) {|http|
+				http.request(request)
+			}
+			response.value
+			REXML::Document.new(response.body)
+		end
+		
+		#Get the URL to a user-owned collection. 
+		#
+		#collectionType -- The collection, either "workflows" or "datas"
+		def get_user_collection_url(collection)
+			user_doc = get_user_doc()
+
+			#collections = user_doc.root.elements["{#{NAMESPACES[:service]}}#{collection}"]
+			collections = user_doc.root.elements[collection]
+			return collections.attributes.get_attribute_ns(NAMESPACES[:xlink], 'href').value
+		end
+		
+		#Get the URL to the output document for a job.
+		#
+		#It generally only makes sense to call this function if
+		#get_job_status() == Status::COMPLETED, but no check is enforced here.
+		#
+		#Return the URL to a data document produced by the job, or None if the
+		#job has not (yet) produced any output.
+		#
+		#job_url -- The URL to a job resource previously created using
+		#	submit_job().
+		def get_job_outputs_url(job_url)
+			job_document = get_xml_doc(job_url)
+			#outputs_element = job_document.root.elements["{#{NAMESPACES[:service]}}outputs"]
+			outputs_element = job_document.root.elements['outputs']
+			return nil if not outputs_element
+			outputs_element.attributes.get_attribute_ns(NAMESPACES[:xlink], 'href').value 
+		end
+		
+		#Get the output document for a job.
+		#
+		#Return the output document as an REXML::Document object, or None
+		#if the job didn't have an output document (yet). This document can be
+		#parsed using parse_data_doc().
+		#
+		#job_url -- The URL to a job resource previously created using
+		#	submit_job().
+		def get_job_outputs_doc(job_url)
+			outputs_url = get_job_outputs_url(job_url)
+			return nil if not outputs_url
+			get_xml_doc(outputs_url, MIME_TYPES[:baclava])
+		end   
+		
+		#Retrieve an XML document from the given URL.
+		#
+		#Return the retrieved document as a REXML::Document.
+		#
+		#url -- The URL to a resource retrievable as an XML document
+		#
+		#mimeType -- The mime-type to request using the Accept header, by default
+		#	MIME_TYPES[:rest]
+		def get_xml_doc(doc_url, mimeType=MIME_TYPES[:rest])
+			url = ""			
+			request = Net::HTTP::Get.new(url.path)
+			request['Accept'] = mimeType
+			request.basic_auth @username, @password
+			response = Net::HTTP.start(url.host, url.port) {|http|
+			  http.request(request)
+			}
+			response.value
+			REXML::Document.new(response.body)
+		end
+			
+		#Return the size of an XML document from the given URL without
+		#fetching the document.
+		#
+		#Return the size of a XML document .
+		#
+		#url -- The URL to a resource find the size of
+		#
+		#mimeType -- The mime-type to request using the Accept header, by default
+		#	MIME_TYPES[:rest]
+		def get_xml_doc_size(doc_url, mimeType=MIME_TYPES[:rest])
+			url = ""			
+			request = Net::HTTP::Head.new(url.path)
+			request['Accept'] = mimeType
+			request.basic_auth @username, @password
+			response = Net::HTTP.start(url.host, url.port) {|http|
+			  http.request(request)
+			}
+			response.content_length
+		end
+   
+		#Parse a data document as returned from get_job_outputs_doc().
+		#
+		#Return a hash where the keys are strings, matching the names of 
+		#	ports of the workflow. The values are Document::Data objects. 
+		#	
+		#xml -- A data document as a REXML::Document. This data document can be created
+		#	using create_data_doc()
+		def parse_data_doc(xml_document)
+			Baclava::Reader.read(xml_document)
+		end
+		
+		#Upload a data document to the current user's collection.
+		#
+		#Return the URL of the created data resource.
+		#
+		#xml -- A data document as a REXML::Document. This data document can be created
+		#	using create_data_doc()
+		#
+		#Raises:
+		#	CouldNotCreateError -- If the service returned 200 OK instead of
+		#		creating the resource
+		def upload_data_doc(xml_document)
+			datas_url = get_user_collection_url("datas")
+			upload_to_collection(datas_url, xml_document.to_s, MIME_TYPES[:baclava])
+		end
+		
+		#Tests if the url is valid for this server
+		def url_valid?(url)
+		  url = ""
+		  req = Net::HTTP::Head.new(url.path)
+		  req.basic_auth @username, @password
+		  Net::HTTP.start(url.host, url.port) {|http|
+			http.request(req)
+		  }.kind_of?(Net::HTTPSuccess)
+		end
+					
+		#Upload data by POST-ing to given URL. 
+		#
+		#Return the URL of the created resource if the request succeeded with
+		#201 Created.
+		#
+		#Raises:
+		#	CouldNotCreateError -- If the service returned 200 OK instead of
+		#		creating the resource
+		#	Net::HTTPError -- If any other HTTP result code (including errors) 
+		#		was returned
+		#
+		#url -- The URL of the collection of where to POST, 
+		#	normally retrieved using get_user_collection_url().
+		#
+		#data -- The data to upload as a string
+		#
+		#content_type -- The MIME type of the data to upload. Typically the value
+		#	of one of the MimeTypes constants. For data uploaded to the "datas" user 
+		#	collection this would be MIME_TYPES[:baclava], and for workflow to the "
+		#	workflows" collection, MIME_TYPES[:scufl]. Any other XML documents from 
+		#	the NAMESPACES[:service] namespace has the mime type MIME_TYPES[:rest]
+		def upload_to_collection(url, data, content_type)
+			url = ""    	
+			request = Net::HTTP::Post.new(url.path)
+			request.body = data
+			request['Accept'] = MIME_TYPES[:rest]
+			request['Content-Type'] = content_type
+			request.basic_auth @username, @password
+			response = Net::HTTP.start(url.host, url.port) {|http|
+			  http.request(request)
+			}
+			response.value			
+			raise CouldNotCreateError(url, response) unless response.kind_of?(Net::HTTPCreated)
+			response.header['Location']
+		end
+	
+		#Create a data document to be uploaded with upload_data_doc(). 
+		#
+		#Return the data document a REXML::Document. This data document can be parsed using
+		#parse_data_doc()
+		#
+		#hash -- A hash where the keys are strings, matching the names of input
+		#	ports of the workflow to run. The values are Document::Data objects. 
+		#
+		def create_data_doc(hash)
+			Baclava::Writer.write_doc(hash)
+		end
+		
+		#Create a job document for submission with submit_job().
+		#
+		#Return the job document as XML.
+		#
+		#workflow_url -- The URL of a workflow previously uploaded using
+		#	upload_workflow()
+		#
+		#inputs_url -- The (optional) URL of a input document previously
+		#	uploaded using upload_data_doc()
+		def create_job_doc(workflow_url, inputs_url=nil)
+			xml = Builder::XmlMarkup.new
+			xml.instruct!
+			REXML::Document.new(xml.job('xmlns' => NAMESPACES[:service], 'xmlns:xlink' => NAMESPACES[:xlink]) {
+				xml.inputs('xlink:href' => inputs_url) if inputs_url
+				xml.workflow('xlink:href' => workflow_url)
+			})
+		end
+
+		#Submit a job to be queued for execution on the server.
+		#
+		#Return the URL to the job resource.
+		#
+		#job_document -- A job document created with create_job_doc() specifying
+		#	the workflow to run with which inputs.
+		#	
+		#Raises:
+		#	CouldNotCreateError -- If the service returned 200 OK instead of
+		#		creating the resource
+		def submit_job_doc(job_document)
+			jobsURL = get_user_collection_url("jobs")
+			upload_to_collection(jobsURL, job_document.to_s, MIME_TYPES[:rest])    
+		end
+		
+		public
+		
+		#Get the status of a previously submitted job.
+		#
+		#Return the status as a string, one of the values from Status.
+		#
+		#job_url -- The URL to a job resource previously created using
+		#	submit_job().
+		def get_job_status(job_url)
+			job_document = get_xml_doc(job_url)
+			#status = job_document.elements["{#{NAMESPACES[:service]}}status"]
+			status = job_document.root.elements['status']
+			# TODO: For future checks, use: 
+			#status_url = status.attributes.get_attribute_ns(NAMESPACES[:xlink], 'href').value
+			status.text
+		end
+		
+		#Get the date a previously submitted job was created.
+		#
+		#Return the date as a Datetime object.
+		#
+		#job_url -- The URL to a job resource previously created using
+		#	submit_job().
+		def get_job_created_date(job_url)
+			job_document = get_xml_doc(job_url)
+			#created = job_document.elements["{#{NAMESPACES[:dcterms]}}created"]
+			created = job_document.root.elements['dcterms:created'].text
+			DateTime.parse(created)
+		end
+		
+		#Get the date a previously submitted job was last modified.
+		#
+		#Return the date as a Datetime object.
+		#
+		#job_url -- The URL to a job resource previously created using
+		#	submit_job().
+		def get_job_modified_date(job_url)
+			job_document = get_xml_doc(job_url)
+			#modified = job_document.elements["{#{NAMESPACES[:dcterms]}}modified"]
+			modified = job_document.root.elements['dcterms:modified'].text
+			DateTime.parse(modified)
+		end
+		
+		#Get the job's internal progress report. This might be available
+		#while the job is running.
+		#
+		#Return the internal progress report as a Document::Report object.
+		#
+		#job_url -- The URL to a job resource previously created using submit_job().
+		def get_job_report(job_url)
+			job_document = get_xml_doc(job_url)
+			#report_element = job_document.elements["{#{NAMESPACES[:service]}}report"]
+			report_element = job_document.root.elements['report']
+			report_url = report_element.attributes.get_attribute_ns(NAMESPACES[:xlink], 'href').value
+			# TODO: Cache report_url per job
+			job_report_document = get_xml_doc(report_url, MIME_TYPES[:report])
+			Document::Report.from_document(job_report_document)
+		end
+			
+		#Get the outputs of a job.
+		#
+		#Return the job outputs as a hash where the keys are strings, 
+		#matching the names of output ports of the workflow. The values are
+		#Document::Data objects. If no outputs exists, nil is returned instead.
+		#
+		#job_url -- The URL to a job resource previously created using
+		#	submit_job().
+		def get_job_outputs(job_url)
+			job_outputs = get_job_outputs_doc(job_url)
+			return nil unless job_outputs
+			parse_data_doc(job_outputs)
+		end
+	
+		#Get the size of the outputs of a job.
+		#
+		#Return the size of the outputs of a job in kilobytes.
+		#If no outputs exists, nil is returned instead.
+		#
+		#job_url -- The URL to a job resource previously created using
+		#	submit_job().
+		def get_job_outputs_size(job_url)
+			outputs_url = get_job_outputs_url(job_url)
+			return nil if not outputs_url
+			get_xml_doc_size(outputs_url, MIME_TYPES[:baclava])
+		end
+	
+		#Check if a job has finished in one way or another. 
+		#
+		#Note that the job might have finished unsuccessfully. To check 
+		#if a job is actually complete, check::
+		#
+		#    get_job_status(job_url) == Status::COMPLETE.
+		#
+		#Return True if the job is in a finished state, that is that the
+		#Status.finished?(get_job_status()) is True.
+		#
+		#job_url -- The URL to a job resource previously created using
+		#    #submit_job().
+		#
+		def finished?(job_url)
+			status = get_job_status(job_url)
+			Status.finished?(status)
+		end
+		
+		#Submit a job to be queued for execution on the server.
+		#
+		#Return the URL to the created job resource.
+		# 
+		#workflow_url -- The URL of a workflow previously uploaded using
+		#    upload_workflow()
+		# 
+		#inputs_url -- The (optional) URL of a input resource previously
+		#    uploaded using upload_data()
+		#    
+		#Raises:
+		#    CouldNotCreateError -- If the service returned 200 OK instead of
+		#        creating the resource    
+		#
+		def submit_job(workflow_url, inputs_url=nil)
+			job_document = create_job_doc(workflow_url, inputs_url)
+			submit_job_doc(job_document)
+		end
+		
+		#Upload data to be used with submit_job().
+		#
+		#Return the URL to the created data resource.
+		#
+		#hash -- A hash where the keys are strings, matching the names of input
+		#	ports of the workflow to run. The values can be strings, lists of strings, or deeper
+		#	lists.
+		#	
+		#Raises:
+		#	CouldNotCreateError -- If the service returned 200 OK instead of
+		#		creating the resource    
+		def upload_data(hash)
+			inputs = create_data_doc(hash)
+			upload_data_doc(inputs)
+		end
+		
+		#Checks if the workflow exists on the server
+		#			
+		#workflow_url -- The URL to a workflow previously uploaded using 
+		#	upload_workflow().
+		def workflow_exists?(workflow_url)
+			url_valid?(workflow_url)
+		end
+		
+		#Checks if the username and password is valid for the service
+		def service_valid?
+			begin
+				get_user_url
+				true
+			rescue
+				false
+			end
+		end
+		
+		#Upload a workflow XML document to the current users' collection.
+		#
+		#Return the URL of the created workflow resource.
+		#
+		#workflow_xml -- The Taverna scufl workflow as a string
+		#
+		#Raises:
+		#	CouldNotCreateError -- If the service returned 200 OK instead of
+		#		creating the resource
+		def upload_workflow(workflow_xml)
+			workflows_url = get_user_collection_url("workflows")
+			upload_to_collection(workflows_url, workflow_xml, MIME_TYPES[:scufl])
+		end
+		
+		#Wait (blocking) for a job to finish, or until a maximum timeout 
+		#has been reached.
+		#
+		#Return the status of the job. If the 
+		#
+		#job_url -- The URL to a job resource previously created using
+		#	submit_job().
+		#
+		#timeout -- The maximum number of seconds (as a float) to wait for job.
+		#	The default value is DEFAULT_TIMEOUT.
+		#
+		#refresh -- In seconds (as a float), how often to check the job's 
+		#	status while waiting. The default value is DEFAULT_REFRESH.
+		def wait_for_job(job_url, timeout=DEFAULT_TIMEOUT, refresh=DEFAULT_REFRESH)
+			now = Time.now
+			_until = now + timeout
+			while _until > Time.now and not finished?(job_url)
+				now = Time.now # finished?() might have taken a while
+				sleep [[refresh, _until-now].min, 0].max
+				now = Time.now # after the sleep
+			end         
+			get_job_status(job_url)
+		end
+		
+		#Execute a workflow and wait until it's finished. 
+		#
+		#This will block until the workflow has been executed by the server, and
+		#return the result of the workflow run.
+		#
+		#Return the parsed output document as a hash where the keys are 
+		#strings, matching the names of output ports of the workflow. The 
+		#values are Document::Data objects. If the workflow
+		#did not produce any output, nil might be returned instead.
+		#
+		#workflow_xml -- The workflow as a Taverna scufl XML string. This *or* the 
+		#	workflow_url parameter is required.
+		#
+		#workflow_url -- The URL to a workflow previously uploaded using 
+		#	upload_workflow(). This *or* the workflow_xml parameter is required.
+		#	
+		#inputs -- The (optional) inputs to the workflow, either as a Baclava 
+		#	XML document (string), or as a hash where the keys are 
+		#	strings, matching the names of input ports of the workflow. The 
+		#	values can be strings, lists of strings, or deeper lists. 
+		#
+		#timeout -- The maximum number of seconds (as a float) to wait for job.
+		#	The default value is DEFAULT_TIMEOUT.
+		#
+		#refresh -- In seconds (as a float), how often to check the job's 
+		#	status while waiting. The default value is DEFAULT_REFRESH.
+		#
+		#Raises:
+		#	NotCompleteError -- If the job did not complete, for instance because
+		#		the timeout was reached before completion.
+		#	
+		#	urllib2.HTTPError -- If any step in submitting or requesting the status and
+		#		result of the job failed.
+		def execute_sync(workflow_xml=nil, workflow_url=nil, inputs=nil, 
+						timeout=DEFAULT_TIMEOUT, refresh=DEFAULT_REFRESH)
+			raise TypeError.new("workflow_xml or worklowURL must be given") unless workflow_xml or workflow_url 
+			raise TypeError.new("Only one of workflow_xml and workflow_url can be given") if workflow_xml and workflow_url
+	 
+			workflow_url = upload_workflow(workflow_xml) if workflow_xml
+			inputs_url = upload_data(inputs) if inputs
+			
+			job_url = submit_job(workflow_url, inputs_url)
+			status = wait_for_job(job_url, timeout, refresh)
+
+			raise NotCompleteError.new(job_url, status) if status != Status::COMPLETE
+	
+			get_job_outputs(job_url)
+		end
+		
+	end
+	
+end
+

Added: trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/scufl/dot.rb (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/scufl/dot.rb	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/scufl/dot.rb	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,248 @@
+module Scufl
+  
+  # This class enables you to write the script will will be used by dot
+  # (which is part of GraphViz[http://www.graphviz.org/Download.php])
+  # to generate the image showing the structure of a given model.
+  # To get started quickly, you could try:
+  #   out_file = File.new("path/to/file/you/want/the/dot/script/to/be/written", "w+")
+  #   workflow = File.new("path/to/workflow/file", "r").read
+  #   model = Scufl::Parser.new.parse(workflow)
+  #   Scufl::Dot.new.write_dot(out_file, model)
+  #   `dot -Tpng -o"path/to/the/output/image" #{out_file.path}`
+  class Dot
+
+    @@processor_colours = {
+      'apiconsumer' => 'palegreen',
+      'beanshell' => 'burlywood2',
+      'biomart' => 'lightcyan2',                      
+      'local' => 'mediumorchid2',
+      'biomobywsdl' => 'darkgoldenrod1',
+      'biomobyobject' => 'gold',
+      'biomobyparser' => 'white',
+      'inferno' => 'violetred1',
+      'notification' => 'mediumorchid2',
+      'rdfgenerator' => 'purple',
+      'rserv' => 'lightgoldenrodyellow',
+      'seqhound' => '#836fff',
+      'soaplabwsdl' => 'lightgoldenrodyellow',
+      'stringconstant' => 'lightsteelblue',
+      'talisman' => 'plum2',
+      'bsf' => 'burlywood2',
+      'abstractprocessor' => 'lightgoldenrodyellow',
+      'rshell' => 'lightgoldenrodyellow',
+      'arbitrarywsdl' => 'darkolivegreen3',
+      'workflow' => 'crimson'}
+    
+    @@fill_colours = %w{white aliceblue antiquewhite beige}
+    
+    @@ranksep = '0.22'
+    @@nodesep = '0.05'
+    
+    # Creates a new dot object for interaction.
+    def initialize
+      # @port_style IS CURRENTLY UNUSED. IGNORE!!!
+      @port_style = 'none' # 'all', 'bound' or 'none'
+    end
+    
+    # Writes to the given stream (File, StringIO, etc) the script to generate
+    # the image showing the internals of the given workflow model.  
+    # === Usage
+    #   stream = File.new("path/to/file/you/want/the/dot/script/to/be/written", "w+")
+    #   workflow = .......
+    #   model = Scufl::Parser.new.parse(workflow)
+    #   Scufl::Dot.new.write_dot(stream, model)
+    def write_dot(stream, model)
+      stream.puts 'digraph scufl_graph {'
+      stream.puts ' graph ['
+      stream.puts '  style=""'
+      stream.puts '  labeljust="left"'
+      stream.puts '  clusterrank="local"'
+      stream.puts "  ranksep=\"#@@ranksep\""
+      stream.puts "  nodesep=\"#@@nodesep\""
+      stream.puts ' ]'
+      stream.puts
+      stream.puts ' node ['
+      stream.puts '  fontname="Helvetica",'
+      stream.puts '  fontsize="10",'
+      stream.puts '  fontcolor="black", '
+      stream.puts '  shape="box",'
+      stream.puts '  height="0",'
+      stream.puts '  width="0",'
+      stream.puts '  color="black",'
+      stream.puts '  fillcolor="lightgoldenrodyellow",'
+      stream.puts '  style="filled"'
+      stream.puts ' ];'
+      stream.puts
+      stream.puts ' edge ['
+      stream.puts '  fontname="Helvetica",'
+      stream.puts '  fontsize="8",'
+      stream.puts '  fontcolor="black",'
+      stream.puts '  color="black"'
+      stream.puts ' ];'
+      write_workflow(stream, model)
+      stream.puts '}'
+      
+      stream.flush
+    end
+    
+    def write_workflow(stream, model, prefix="", name="", depth=0) # :nodoc:
+      if name != ""
+        stream.puts "subgraph cluster_#{prefix}#{name} {"
+        stream.puts " label=\"#{name}\""
+        stream.puts ' fontname="Helvetica"'
+        stream.puts ' fontsize="10"'
+        stream.puts ' fontcolor="black"'
+        stream.puts ' clusterrank="local"'
+        stream.puts " fillcolor=\"#{@@fill_colours[depth % @@fill_colours.length]}\""
+        stream.puts ' style="filled"'
+      end
+      model.processors.each {|processor| write_processor(stream, processor, prefix, depth)}
+      write_source_cluster(stream, model.sources, prefix)
+      write_sink_cluster(stream, model.sinks, prefix)
+      model.links.each {|link| write_link(stream, link, model, prefix)}
+      model.coordinations.each {|coordination| write_coordination(stream, coordination, model, prefix)}
+      if name != ""
+        stream.puts '}'
+      end
+    end
+    
+    def write_processor(stream, processor, prefix, depth) # :nodoc:
+      # nested workflows
+      if processor.model
+        write_workflow(stream, processor.model, prefix + processor.name, processor.name, depth.next)
+      else
+        stream.puts " \"#{prefix}#{processor.name}\" ["
+        stream.puts "  fillcolor=\"#{get_colour processor.type}\","
+        stream.puts '  shape="box",'
+        stream.puts '  style="filled",'
+        stream.puts '  height="0",'
+        stream.puts '  width="0",'
+        stream.puts "  label=\"#{processor.name}\""
+        stream.puts ' ];'
+      end
+    end
+    
+    def write_source_cluster(stream, sources, prefix) # :nodoc:
+      if sources.length > 0
+        stream.puts " subgraph cluster_#{prefix}sources {"
+        stream.puts '  style="dotted"'
+        stream.puts '  label="Workflow Inputs"'
+        stream.puts '  fontname="Helvetica"'
+        stream.puts '  fontsize="10"'
+        stream.puts '  fontcolor="black"'
+        stream.puts '  rank="same"'
+        stream.puts " \"#{prefix}WORKFLOWINTERNALSOURCECONTROL\" ["
+        stream.puts '  shape="triangle",'
+        stream.puts '  width="0.2",'
+        stream.puts '  height="0.2",'
+        stream.puts '  fillcolor="brown1"'
+        stream.puts '  label=""'
+        stream.puts ' ]'
+        sources.each {|source| write_source(stream, source, prefix)}
+        stream.puts ' }'
+      end
+    end
+    
+    def write_source(stream, source, prefix) # :nodoc:
+      stream.puts " \"#{prefix}WORKFLOWINTERNALSOURCE_#{source.name}\" ["
+      stream.puts '   shape="box",'
+      stream.puts "   label=\"#{source.name}\""
+      stream.puts '   width="0",'
+      stream.puts '   height="0",'
+      stream.puts '   fillcolor="skyblue"'
+      stream.puts ' ]' 
+    end
+    
+    def write_sink_cluster(stream, sinks, prefix) # :nodoc:
+      if sinks.length > 0
+        stream.puts " subgraph cluster_#{prefix}sinks {"
+        stream.puts '  style="dotted"'
+        stream.puts '  label="Workflow Outputs"'
+        stream.puts '  fontname="Helvetica"'
+        stream.puts '  fontsize="10"'
+        stream.puts '  fontcolor="black"'
+        stream.puts '  rank="same"'
+        stream.puts " \"#{prefix}WORKFLOWINTERNALSINKCONTROL\" ["
+        stream.puts '  shape="invtriangle",'
+        stream.puts '  width="0.2",'
+        stream.puts '  height="0.2",'
+        stream.puts '  fillcolor="chartreuse3"'
+        stream.puts '  label=""'
+        stream.puts ' ]'
+        sinks.each {|sink| write_sink(stream, sink, prefix)}
+        stream.puts ' }'
+      end
+    end
+    
+    def write_sink(stream, sink, prefix) # :nodoc:
+      stream.puts " \"#{prefix}WORKFLOWINTERNALSINK_#{sink.name}\" ["
+      stream.puts '   shape="box",'
+      stream.puts "   label=\"#{sink.name}\""
+      stream.puts '   width="0",'
+      stream.puts '   height="0",'
+      stream.puts '   fillcolor="lightsteelblue2"'
+      stream.puts ' ]'     
+    end
+    
+    def write_link(stream, link, model, prefix) # :nodoc:
+      if model.sources.select{|s| s.name == link.source} != []
+        stream.write " \"#{prefix}WORKFLOWINTERNALSOURCE_#{link.source}\""
+      else 
+        processor = model.processors.select{|p| p.name == link.source.split(':')[0]}[0]
+        if processor.model
+          stream.write " \"#{prefix}#{processor.name}WORKFLOWINTERNALSINK_#{link.source.split(':')[1]}\""
+        else
+          stream.write " \"#{prefix}#{processor.name}\""
+        end
+      end
+      stream.write '->'
+      if model.sinks.select{|s| s.name == link.sink} != []
+        stream.write "\"#{prefix}WORKFLOWINTERNALSINK_#{link.sink}\""
+      else 
+        processor = model.processors.select{|p| p.name == link.sink.split(':')[0]}[0]
+        if processor.model
+          stream.write "\"#{prefix}#{processor.name}WORKFLOWINTERNALSOURCE_#{link.sink.split(':')[1]}\""
+        else
+          stream.write "\"#{prefix}#{processor.name}\""
+        end
+      end
+      stream.puts ' ['
+      stream.puts ' ];'
+    end
+    
+    def write_coordination(stream, coordination, model, prefix) # :nodoc:
+      stream.write " \"#{prefix}#{coordination.controller}"
+      processor = model.processors.select{|p| p.name == coordination.controller}[0]
+      if processor.model
+        stream.write 'WORKFLOWINTERNALSINKCONTROL'
+      end
+      stream.write '"->"'
+      stream.write "#{prefix}#{coordination.target}\""
+      processor = model.processors.select{|p| p.name == coordination.target}[0]
+      if processor.model
+        stream.write 'WORKFLOWINTERNALSOURCECONTROL'
+      end
+      stream.puts ' ['
+      stream.puts '  color="gray",'
+      stream.puts '  arrowhead="odot",'
+      stream.puts '  arrowtail="none"'
+      stream.puts ' ];'
+    end
+    
+    def get_colour(processor_name) # :nodoc:
+      colour = @@processor_colours[processor_name]
+      if colour
+        colour
+      else 
+        'white'
+      end  
+    end
+    
+    # Returns true if the given name is a processor; false otherwise
+    def Dot.is_processor?(processor_name)
+      true if @@processor_colours[processor_name]
+    end
+    
+  end
+  
+end

Added: trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/scufl/model.rb (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/scufl/model.rb	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/scufl/model.rb	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,313 @@
+# This is the module containing the Scufl model implementation i.e. the model structure/definition and all its internals.
+
+module Scufl # :nodoc:
+  
+  # The model for a given Taverna 1 workflow.
+  class Model
+    # This returns a WorkflowDescription object.
+    attr_reader :description
+    
+    # Retrieve the list of processors specific to the workflow.
+    # Does not include those from nested workflows.
+    attr_reader :processors
+    
+    # Retrieve the list of datalinks specific to the workflow.
+    # Does not include those from nested workflows.
+    attr_reader :links
+    
+    # Retrieve the list of sources specific to the workflow.
+    # Does not include those from nested workflows.
+    attr_reader :sources
+    
+    # Retrieve the list of sinks specific to the workflow.
+    # Does not include those from nested workflows.
+    attr_reader :sinks
+    
+    # Retrieve the list of coordinations specific to the workflow.
+    # Does not include those from nested workflows.
+    attr_reader :coordinations
+    
+    # The list of any dependencies that have been found inside the workflow.
+    # Does not include those from nested workflows.
+    attr_accessor :dependencies
+    
+    # Creates an empty model for a Taverna 1 workflow.
+    def initialize
+      @description = WorkflowDescription.new
+      @processors = Array.new
+      @links = Array.new
+      @sources = Array.new
+      @sinks = Array.new
+      @coordinations = Array.new
+    end
+    
+    # Retrieve ALL the beanshell processors WITHIN the given workflow model.
+    def beanshells
+      self.all_processors.select { |x| x.type == "beanshell" }
+    end
+    
+    # Retrieve ALL processors of that are webservices WITHIN the model.
+    def web_services
+      self.all_processors.select { |x| x.type =~ /wsdl|soaplab|biomoby/i }
+    end
+    
+    # Retrieve ALL local workers WITHIN the workflow
+    def local_workers
+      self.all_processors.select { |x| x.type =~ /local/i }
+    end
+    
+    # Retrieve ALL processor objects WITHIN the given workflow model.
+    def all_processors
+      return get_processors(self, [])
+    end
+    
+    
+    # Retrieve ALL the links WITHIN the given workflow model.
+    def all_links
+      return get_links(self, [])
+    end
+    
+    # Retrieve ALL the sinks(outputs) WITHIN the given workflow model.
+    def all_sinks
+      return get_sinks(self, [])
+    end
+    
+    # Retrieve ALL the sources(inputs) WITHIN the given workflow model.    
+    def all_sources
+      return get_sources(self, [])
+    end
+    
+    # For the given dataflow, return the beanshells and/or services which 
+    # have direct links to or from the given processor.
+    # == Usage
+    #   my_processor = model.processor[0]
+    #   linked_processors = model.get_processors_linked_to(my_processor)
+    #   processors_feeding_into_my_processor = linked_processors.sources
+    #   processors_feeding_from_my_processor = linked_processors.sinks    
+    def get_processor_links(processor)
+      return nil unless processor
+      proc_links = ProcessorLinks.new
+      
+      # SOURCES
+      sources = self.all_links.select { |x| x.sink =~ /#{processor.name}:.+/ }
+      proc_links.sources = []
+
+      # SINKS
+      sinks = self.all_links.select { |x| x.source =~ /#{processor.name}:.+/ }
+      proc_links.sinks = []
+      temp_sinks = []
+      sinks.each { |x| temp_sinks << x.sink }
+      
+      # Match links by port into format
+      # my_port:name_of_link_im_linked_to:its_port
+      sources.each do |connection|
+        link = connection.sink
+        connected_proc_name = link.split(":")[0]
+        my_connection_port = link.split(":")[1]
+        
+        if my_connection_port
+          source = my_connection_port << ":" << connection.source
+          proc_links.sources << source if source.split(":").size == 3
+        end
+      end
+      
+      sinks.each do |connection|
+        link = connection.source
+        connected_proc_name = link.split(":")[0]
+        my_connection_port = link.split(":")[1]
+        
+        if my_connection_port
+          sink = my_connection_port << ":" << connection.sink
+          proc_links.sinks << sink if sink.split(":").size == 3
+        end
+      end
+      
+      return proc_links
+    end
+  
+    private
+    
+    def get_beanshells(given_model, beans_collected) # :nodoc:
+      wf_procs = given_model.processors.select { |x| x.type == "workflow" }
+      wf_procs.each { |x| get_beanshells(x.model, beans_collected) if x.model }
+      
+      bean_procs = given_model.processors.select { |b| b.type == "beanshell" }
+      bean_procs.each { |a| beans_collected << a }
+      
+      return beans_collected
+    end
+    
+    def get_processors(given_model, procs_collected) # :nodoc:
+      wf_procs = given_model.processors.select { |x| x.type == "workflow" }
+      wf_procs.each { |x| get_processors(x.model, procs_collected) if x.model }
+      
+      procs = given_model.processors
+      procs.each { |a| procs_collected << a }
+      
+      return procs_collected
+    end
+    
+    def get_links(given_model, links_collected) # :nodoc:
+      wf_procs = given_model.processors.select { |x| x.type == "workflow" }
+      wf_procs.each { |x| get_links(x.model, links_collected) if x.model }
+      
+      links = given_model.links
+      links.each { |a| links_collected << a }
+      
+      return links_collected
+    end
+    
+    def get_sinks(given_model, sinks_collected) # :nodoc:
+      wf_procs = given_model.processors.select { |x| x.type == "workflow" }
+      wf_procs.each { |x| get_sinks(x.model, sinks_collected) if x.model }
+      
+      sinks = given_model.sinks
+      sinks.each { |a| sinks_collected << a }
+      
+      return sinks_collected
+    end
+    
+    def get_sources(given_model, sources_collected) # :nodoc:
+      wf_procs = given_model.processors.select { |x| x.type == "workflow" }
+      wf_procs.each { |x| get_sources(x.model, sources_collected) if x.model }
+      
+      sources = given_model.sources
+      sources.each { |a| sources_collected << a }
+      
+      return sources_collected
+    end
+  end
+  
+  
+  
+  # This is the (shim) object within the workflow.  This can be a beanshell,
+  # a webservice, a workflow, etc...
+  class Processor
+    # A string containing name of the processor.
+    attr_accessor :name 
+    
+    # A string containing the description of the processor if available.  
+    # Returns nil otherwise.
+    attr_accessor :description
+    
+    # A string for the type of processor, e.g. beanshell, workflow, webservice, etc...
+    attr_accessor :type 
+    
+    # For processors that have type == "workflow", model is the the workflow 
+    # definition.  For all other processor types, model is nil.
+    attr_accessor :model
+    
+    # This only has a value in beanshell processors.  This is the actual script
+    # embedded with the processor which does all the "work"
+    attr_accessor :script
+    
+    # This is a list of inputs that the processor can take in.
+    attr_accessor :inputs
+    
+    # This is a list of outputs that the processor can produce.
+    attr_accessor :outputs
+    
+    # For processors of type "arbitrarywsdl", this is the URI to the location
+    # of the wsdl file.
+    attr_accessor :wsdl
+    
+    # For processors of type "arbitrarywsdl", this is the operation invoked.
+    attr_accessor :wsdl_operation
+    
+    # For soaplab and biomoby services, this is the endpoint URI.
+    attr_accessor :endpoint
+    
+    # Authority name for the biomoby service.
+    attr_accessor :biomoby_authority_name
+
+    # Service name for the biomoby service. This is not necessarily the same 
+    # as the processors name.
+    attr_accessor :biomoby_service_name
+    
+    # Category for the biomoby service.
+    attr_accessor :biomoby_category
+
+    # Value of a string constant
+    attr_accessor :value
+  end
+
+
+
+  # This object is returned after invoking model.get_processor_links(processor)
+  # .  The object contains two lists of processors.  Each element consists of: 
+  # the input or output port the processor uses as a link, the name of the
+  # processor being linked, and the port of the processor used for the linking,
+  # all seperated by a colon (:) i.e. 
+  #   my_port:name_of_processor:processor_port
+  class ProcessorLinks
+    # The processors whose output is fed as input into the processor used in
+    # model.get_processors_linked_to(processor).
+    attr_accessor :sources
+    
+    # A list of processors that are fed the output from the processor (used in
+    # model.get_processors_linked_to(processor) ) as input.
+    attr_accessor :sinks
+  end
+  
+
+  
+  # This contains basic descriptive information about the workflow model.
+  class WorkflowDescription
+    # The author of the workflow.
+    attr_accessor :author
+    
+    # The name/title of the workflow.
+    attr_accessor :title
+    
+    # A small piece of descriptive text for the workflow.
+    attr_accessor :description
+  end
+
+  
+  
+  # This represents a connection between any of the following pair of entities:
+  # {processor -> processor}, {workflow -> workflow}, {workflow -> processor}, 
+  # and {processor -> workflow}.
+  class Link
+    # The name of the source (the starting point of the connection).
+    attr_accessor :source
+    
+    # The name of the sink (the endpoint of the connection).
+    attr_accessor :sink
+  end
+
+
+
+  # This is a representation of the 'Run after...' function in Taverna
+  # where the selected processor or workflow is set to run after another.
+  class Coordination
+    # The name of the processor/workflow which is to run first.
+    attr_accessor :controller
+    
+    # The name of the processor/workflow which is to run after the controller.
+    attr_accessor :target
+  end
+
+  
+  
+  # This is the start node of a Link.  Each source has a name and a port
+  # which is seperated by a colon; ":".
+  # This is represented as "source of a processor:port_name".
+  # A string that does not contain a colon can often be returned, signifiying
+  # a workflow source as opposed to that of a processor.
+  class Source
+  	attr_accessor :name, :description
+  end
+  
+  
+  
+  # This is the start node of a Link.  Each sink has a name and a port
+  # which is seperated by a colon; ":".
+  # This is represented as "sink of a processor:port_name".
+  # A string that does not contain a colon can often be returned, signifiying
+  # a workflow sink as opposed to that of a processor.
+  class Sink
+	  attr_accessor :name, :description
+  end  	
+  
+end

Added: trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/scufl/parser.rb (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/scufl/parser.rb	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/lib/scufl/parser.rb	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,188 @@
+require "rexml/document"
+
+module Scufl
+  
+  class Parser
+    # Returns the model for the given t2flow_file.
+    # The method accepts objects of classes File and String only.
+    # ===Usage
+    #   foo = ... # stuff to initialize foo here
+    #   bar = Scufl::Parser.new.parse(foo)
+    def parse(scufl)
+      document = REXML::Document.new(scufl)
+      
+      root = document.root
+      raise "Doesn't appear to be a workflow!" if root.name != "scufl"
+      version = root.attribute('version').value
+      
+      create_model(root, version)
+    end
+    
+    def create_model(element, version) # :nodoc:
+      model = Model.new
+      
+      element.each_element('s:workflowdescription') { |description|  set_description(model, description, version)}
+      element.each_element('s:processor')           { |processor|    add_processor(model, processor, version)}
+      element.each_element('s:link')                { |link|         add_link(model, link, version)}
+      element.each_element('s:source')              { |source|       add_source(model, source, version)}
+      element.each_element('s:sink')                { |sink|         add_sink(model, sink, version)}
+      element.each_element('s:coordination')        { |coordination| add_coordination(model, coordination, version)}
+      
+      return model   
+    end
+    
+    def add_coordination(model, element, version) # :nodoc:
+      coordination = Coordination.new
+      
+      element.each_element('s:condition') do |condition|
+        condition.each_element('s:target') {|target| coordination.controller = target.text}
+      end
+      element.each_element('s:action') do |action|
+        action.each_element('s:target') {|target| coordination.target = target.text}
+      end
+      
+      model.coordinations.push coordination
+    end
+    
+    def add_link(model, element, version) # :nodoc:
+      link = Link.new
+      
+      if version == '0.1'
+        element.each_element('s:input') { |input| link.sink = input.text}
+        element.each_element('s:output') { |output| link.source = output.text}
+      else
+        source = element.attribute('source') 
+        link.source = source.value if source
+        
+        sink = element.attribute('sink')
+        link.sink = sink.value if sink
+      end
+      
+      model.links.push link
+    end
+    
+    def add_source(model, element, version) # :nodoc:
+      source = Source.new
+      
+      if version == '0.1'
+        name = element.text
+        source.name = name.value if name
+      else
+        name = element.attribute('name')
+        source.name = name.value if name
+        element.each_element('s:metadata') { |metadata|
+          metadata.each_element('s:description') {|description| source.description = description.text}			
+        }
+      end
+      
+      model.sources.push source
+    end
+    
+    def add_sink(model, element, version) # :nodoc:
+      sink = Sink.new
+      
+      if version == '0.1'
+        name = element.text
+        sink.name = name.value if name
+      else
+        name = element.attribute('name')
+        sink.name = name.value if name
+        element.each_element('s:metadata') { |metadata|
+          metadata.each_element('s:description') {|description| sink.description = description.text}			
+        }
+      end
+      
+      model.sinks.push sink
+    end
+    
+    def add_processor(model, element, version) # :nodoc:
+      processor = Processor.new
+      
+      name = element.attribute('name')
+      processor.name = name.value if name
+      
+      element.each_element() do |e|
+        case e.name
+          when 'description'
+            processor.description = e.text
+          when 'arbitrarywsdl'
+            processor.type = e.name
+            e.each_element do |wsdl|
+              processor.wsdl = wsdl.text if wsdl.name == 'wsdl'
+              processor.wsdl_operation = wsdl.text if wsdl.name == 'operation'
+            end
+          when 'soaplabwsdl'
+            processor.type = e.name
+            processor.endpoint = e.text
+          when 'biomobywsdl'
+            processor.type = e.name
+            e.each_element do |wsdl|
+              case wsdl.name
+                when /endpoint/i
+                  processor.endpoint = wsdl.text
+                when /servicename/i
+                  processor.biomoby_service_name = wsdl.text
+                when /authorityname/i
+                  processor.biomoby_authority_name = wsdl.text
+                when "category"
+                  processor.biomoby_category = wsdl.text
+              end
+            end
+          when'beanshell'
+            processor.type = e.name
+            e.each_element do |bean|
+              case bean.name
+                when "scriptvalue"
+                  processor.script = bean.text
+                when "beanshellinputlist"
+                  bean.each_element do |input|
+                    if input.name == "beanshellinput"
+                      processor.inputs = [] if processor.inputs.nil?
+                      processor.inputs << input.text
+                    end # if
+                  end # bean.each_element
+                when "beanshelloutputlist"
+                  bean.each_element do |output|
+                    if output.name == "beanshelloutput"
+                      processor.outputs = [] if processor.outputs.nil?
+                      processor.outputs << output.text
+                    end # if
+                  end # bean.each_element
+                when "dependencies"
+                  bean.each_element do |dep|
+                    model.dependencies = [] if model.dependencies.nil?
+                    model.dependencies << dep.text unless dep.text =~ /^\s*$/
+                  end # bean.each_element
+                end # case bean.name
+              end # e.each_element
+            when 'mergemode'
+            when 'defaults'
+            when 'iterationstrategy'
+            when 'stringconstant'
+              processor.type = e.name
+              processor.value = e.text
+            else
+            if Dot.is_processor? e.name
+              processor.type = e.name
+              if processor.type == 'workflow'
+                e.each_element('s:scufl') {|e| processor.model = create_model(e, version)}
+              end
+            end
+          end
+        end
+      
+      model.processors.push processor
+      end
+    
+    def set_description(model, element, version) # :nodoc:
+      author = element.attribute('author')
+      title = element.attribute('title')
+      
+      model.description.author = author.value if author
+      model.description.title = title.value if title
+      model.description.description = element.text
+    end
+    
+  end
+  
+end

Added: trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/test/fixtures/animal.xml (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/test/fixtures/animal.xml	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/test/fixtures/animal.xml	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<s:scufl xmlns:s="http://org.embl.ebi.escience/xscufl/0.1alpha" version="0.2" log="0">
+  <s:workflowdescription lsid="urn:lsid:net.sf.taverna:wfDefinition:6ebc9ec6-1045-459d-a26c-74e4efe2d6f8" author="" title="animal" />
+  <s:processor name="AnimalFactory" boring="true">
+    <s:stringconstant>frog</s:stringconstant>
+  </s:processor>
+  <s:link source="AnimalFactory:value" sink="animal" />
+  <s:sink name="animal" />
+</s:scufl>
+

Added: trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/test/fixtures/colouranimal.xml (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/test/fixtures/colouranimal.xml	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/test/fixtures/colouranimal.xml	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<s:scufl xmlns:s="http://org.embl.ebi.escience/xscufl/0.1alpha" version="0.2" log="0">
+  <s:workflowdescription lsid="urn:lsid:net.sf.taverna:wfDefinition:a378c99c-b85e-46cd-91be-47ac93cde18c" author="" title="animal" />
+  <s:processor name="colour_the_animal">
+    <s:local>org.embl.ebi.escience.scuflworkers.java.StringConcat</s:local>
+  </s:processor>
+  <s:link source="animal" sink="colour_the_animal:string2" />
+  <s:link source="colour" sink="colour_the_animal:string1" />
+  <s:link source="colour_the_animal:output" sink="coulouredAnimal" />
+  <s:source name="animal" />
+  <s:source name="colour" />
+  <s:sink name="coulouredAnimal" />
+</s:scufl>
+

Added: trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/test/tc_client.rb (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/test/tc_client.rb	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/test/tc_client.rb	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,191 @@
+$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
+
+require 'test/unit'
+require 'enactor/client'
+require 'document/data'
+
+class TcClient < Test::Unit::TestCase
+
+	FIXTURES = File.join(File.dirname(__FILE__), "fixtures")
+	
+	TEST_SERVER="http://rpc269.cs.man.ac.uk:8180/remotetaverna/v1/"
+	TEST_USER="snake"
+	TEST_PW=IO.read("#{FIXTURES}/password.txt").strip
+	
+	# Test workflows
+	ANIMAL_WF=IO.read("#{FIXTURES}/animal.xml")
+	COLOUR_ANIMAL_WF=IO.read("#{FIXTURES}/colouranimal.xml")
+		
+    def setup
+    	@service = Enactor::Client.new(TEST_SERVER, TEST_USER, TEST_PW)
+    end
+	
+	def test_connect
+		capabilities_doc = @service.get_capabilities_doc()
+        #users = capabilities.elements["{http://taverna.sf.net/service}users"]
+        users = capabilities_doc.root.elements["users"]
+        users_url = users.attributes.get_attribute_ns('http://www.w3.org/1999/xlink', 'href').value
+        assert_equal(TEST_SERVER  + "users", users_url)
+	end
+    
+    def test_get_user_url
+        user_url = @service.get_user_url()
+        assert_equal(TEST_SERVER + "users/" + TEST_USER, user_url)
+    end
+    
+    def test_get_user_collection_url
+        workflow_url = @service.get_user_collection_url("workflows")
+        assert_equal(TEST_SERVER + "users/" + TEST_USER + "/workflows", workflow_url)
+        job_url = @service.get_user_collection_url("jobs")
+        assert_equal(TEST_SERVER + "users/" + TEST_USER + "/jobs", job_url)
+        data_url = @service.get_user_collection_url("datas")
+        assert_equal(TEST_SERVER + "users/" + TEST_USER + "/data", data_url)
+    end
+    
+    def test_upload_workflow
+        workflow_url = @service.upload_workflow(ANIMAL_WF)
+        prefix = TEST_SERVER + "workflows/"
+        assert(workflow_url.index(prefix) == 0)
+    end
+        
+	def test_workflow_exists
+        workflow_url = @service.upload_workflow(ANIMAL_WF)
+		assert(@service.workflow_exists?(workflow_url))
+		assert(address@hidden(workflow_url.chop))
+	end
+	
+	def test_service_valid
+		assert(@service.service_valid?)
+		assert(!Enactor::Client.new(TEST_SERVER, TEST_USER, TEST_PW.chop).service_valid?)
+	end
+	
+    def test_create_job
+        workflow_url = @service.upload_workflow(ANIMAL_WF)
+        job_doc = @service.create_job_doc(workflow_url)
+        #workflow_element = job_doc.elements["{http://taverna.sf.net/service}workflow"]
+        workflow_element = job_doc.root.elements['workflow']
+        assert_equal(workflow_url, workflow_element.attributes.get_attribute_ns('http://www.w3.org/1999/xlink', 'href').value)
+    end
+    
+    def test_submit_job
+        workflow_url = @service.upload_workflow(ANIMAL_WF)
+        job_url = @service.submit_job(workflow_url)
+        prefix = TEST_SERVER + "jobs/"
+        assert(job_url.index(prefix) == 0)
+    end 
+    
+    def test_create_data
+        inputs = {}
+        inputs['colour'] = Document::Data.new('red')
+        inputs['animal'] = Document::Data.new('snake')
+        data_document = @service.create_data_doc(inputs)
+        parsed = @service.parse_data_doc(data_document)
+        assert_equal(inputs, parsed)
+    end
+    
+    def test_upload_data
+        inputs = {}
+        inputs["colour"] = Document::Data.new("red")
+        inputs["animal"] = Document::Data.new("snake")
+        data_url = @service.upload_data(inputs)
+        prefix = TEST_SERVER + "data/"
+        assert(data_url.index(prefix) == 0)
+    end
+	
+    def test_submit_job_with_data
+        inputs = {}
+        inputs["colour"] = Document::Data.new("red")
+        inputs["animal"] = Document::Data.new("snake")
+        workflow_url = @service.upload_workflow(COLOUR_ANIMAL_WF)
+        data_url = @service.upload_data(inputs)
+        job_url = @service.submit_job(workflow_url, data_url)
+    end
+	
+    def test_get_job_status
+        workflow_url = @service.upload_workflow(ANIMAL_WF)
+        job_url = @service.submit_job(workflow_url)
+        status = @service.get_job_status(job_url)
+        assert(Enactor::Status.valid?(status))
+    end
+        
+    def test_get_job_created_date
+        workflow_url = @service.upload_workflow(ANIMAL_WF)
+        job_url = @service.submit_job(workflow_url)
+		time = @service.get_job_created_date(job_url)
+		assert(time.kind_of?(DateTime))
+    end
+        
+    def test_get_job_modified_date
+        workflow_url = @service.upload_workflow(ANIMAL_WF)
+        job_url = @service.submit_job(workflow_url)
+		time = @service.get_job_modified_date(job_url)
+		assert(time.kind_of?(DateTime))
+    end
+        
+    def test_finished
+        workflow_url = @service.upload_workflow(ANIMAL_WF)
+        job_url = @service.submit_job(workflow_url)
+        # Assuming our server is not VERY quick
+        assert(address@hidden(job_url))
+    end
+                         
+    def test_job_outputs_size
+        workflow_url = @service.upload_workflow(ANIMAL_WF)
+        job_url = @service.submit_job(workflow_url)
+        @service.wait_for_job(job_url, 30)
+		assert_equal(481, @service.get_job_outputs_size(job_url))
+    end
+        
+    def test_wait_for_job
+        workflow_url = @service.upload_workflow(ANIMAL_WF)
+        job_url = @service.submit_job(workflow_url)
+        now = Time.now
+        timeout = 1
+        status = @service.wait_for_job(job_url, timeout)
+        after = Time.now
+
+        # Should be at least some milliseconds longer than the timeout
+        assert(after - now > timeout)
+        assert(address@hidden(job_url))
+    end
+        
+    def test_execute
+        # Note: This test might take a minute or so to complete
+        results = @service.execute_sync(ANIMAL_WF)
+        assert_equal(1, results.length)
+        assert_equal("frog", results["animal"].value)
+    end
+        
+    def test_execute_with_data
+        # Note: This test might take a minute or so to complete
+        inputs = {}
+        inputs["colour"] = Document::Data.new("red")
+        inputs["animal"] = Document::Data.new("snake")
+        workflow_url = @service.upload_workflow(COLOUR_ANIMAL_WF)
+        results = @service.execute_sync(nil, workflow_url, inputs)
+
+        assert_equal(1, results.length)
+        assert_equal("redsnake", results["coulouredAnimal"].value)
+    end
+        
+    def test_execute_with_multiple_data
+        # Note: This test might take a minute or so to complete
+        inputs = {}
+        inputs["colour"] = Document::Data.new(["red", "green"])
+        inputs["animal"] = Document::Data.new(["rabbit", "mouse", "cow"])
+        workflow_url = @service.upload_workflow(COLOUR_ANIMAL_WF)
+        results = @service.execute_sync(nil, workflow_url, inputs)
+
+        assert_equal(1, results.length)
+        animals = results["coulouredAnimal"].value
+
+		assert_equal(2, animals.length)
+		animals = animals[0] + animals[1]
+		assert_equal(6, animals.length)
+
+        assert(animals.include?("redmouse"))
+        assert(animals.include?("greenrabbit"))
+        assert(!animals.include?("redsnake"))
+    end
+	
+end
\ No newline at end of file

Added: trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/test/ts_taverna.rb (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/test/ts_taverna.rb	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-scufl-0.7.1/test/ts_taverna.rb	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,4 @@
+$:.unshift File.join(File.dirname(__FILE__), ".")
+
+require 'test/unit' 
+require 'tc_client' 

Added: trunk/vendor/plugins/mannie-taverna-t2flow-0.1.1/LICENCE (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-t2flow-0.1.1/LICENCE	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-t2flow-0.1.1/LICENCE	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,165 @@
+		   GNU LESSER GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+  This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+  0. Additional Definitions. 
+
+  As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+  "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+  An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+  A "Combined Work" is a work produced by combining or linking an
+Application with the Library.  The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+  The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+  The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+  1. Exception to Section 3 of the GNU GPL.
+
+  You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+  2. Conveying Modified Versions.
+
+  If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+   a) under this License, provided that you make a good faith effort to
+   ensure that, in the event an Application does not supply the
+   function or data, the facility still operates, and performs
+   whatever part of its purpose remains meaningful, or
+
+   b) under the GNU GPL, with none of the additional permissions of
+   this License applicable to that copy.
+
+  3. Object Code Incorporating Material from Library Header Files.
+
+  The object code form of an Application may incorporate material from
+a header file that is part of the Library.  You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+   a) Give prominent notice with each copy of the object code that the
+   Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the object code with a copy of the GNU GPL and this license
+   document.
+
+  4. Combined Works.
+
+  You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+   a) Give prominent notice with each copy of the Combined Work that
+   the Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the Combined Work with a copy of the GNU GPL and this license
+   document.
+
+   c) For a Combined Work that displays copyright notices during
+   execution, include the copyright notice for the Library among
+   these notices, as well as a reference directing the user to the
+   copies of the GNU GPL and this license document.
+
+   d) Do one of the following:
+
+       0) Convey the Minimal Corresponding Source under the terms of this
+       License, and the Corresponding Application Code in a form
+       suitable for, and under terms that permit, the user to
+       recombine or relink the Application with a modified version of
+       the Linked Version to produce a modified Combined Work, in the
+       manner specified by section 6 of the GNU GPL for conveying
+       Corresponding Source.
+
+       1) Use a suitable shared library mechanism for linking with the
+       Library.  A suitable mechanism is one that (a) uses at run time
+       a copy of the Library already present on the user's computer
+       system, and (b) will operate properly with a modified version
+       of the Library that is interface-compatible with the Linked
+       Version. 
+
+   e) Provide Installation Information, but only if you would otherwise
+   be required to provide such information under section 6 of the
+   GNU GPL, and only to the extent that such information is
+   necessary to install and execute a modified version of the
+   Combined Work produced by recombining or relinking the
+   Application with a modified version of the Linked Version. (If
+   you use option 4d0, the Installation Information must accompany
+   the Minimal Corresponding Source and Corresponding Application
+   Code. If you use option 4d1, you must provide the Installation
+   Information in the manner specified by section 6 of the GNU GPL
+   for conveying Corresponding Source.)
+
+  5. Combined Libraries.
+
+  You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+   a) Accompany the combined library with a copy of the same work based
+   on the Library, uncombined with any other library facilities,
+   conveyed under the terms of this License.
+
+   b) Give prominent notice with the combined library that part of it
+   is a work based on the Library, and explaining where to find the
+   accompanying uncombined form of the same work.
+
+  6. Revised Versions of the GNU Lesser General Public License.
+
+  The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+  Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+  If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.

Added: trunk/vendor/plugins/mannie-taverna-t2flow-0.1.1/README.rdoc (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-t2flow-0.1.1/README.rdoc	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-t2flow-0.1.1/README.rdoc	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,80 @@
+= Taverna[http://taverna.sourceforge.net] 2 Interaction Gem
+
+Authors::       Emmanuel Tagarira, David Withers
+Version::       0.1.1
+Contact::       mailto:address@hidden
+URL::           http://taverna.sourceforge.net/
+Licence::       LGPL 3 (See LICENCE or http://www.gnu.org/licenses/lgpl.html)
+Copyright::     (c) 2008-2009 University of Manchester, UK
+
+
+
+== Synopsis
+
+This is a Ruby library to support the interaction with Taverna[http://taverna.sourceforge.net] version 2 workflows (T2Flows).  This relies on the functionality provided by the libxml library.  To be able to utilise this gem to its full potential, you will need to have the following installed on your system.
+- GraphViz[http://www.graphviz.org/Download.php] (a graph visualization package)
+- Rdoc gem
+- Darkfish-Rdoc gem
+
+
+
+== The T2Flow Model Implementation
+
+Much like the Taverna[http://taverna.sourceforge.net] 1 Scufl model, T2Flows contain Processors, Sinks, and Sources.  T2Flows however, encapsulate these elements within Dataflow objects.  A Dataflow objects is the container for all the different elements present within the Taverna[http://taverna.sourceforge.net] 2 workflows, hence a single T2Flow may have one or more dataflows.  WorkflowDescriptions and Links, from the original Taverna[http://taverna.sourceforge.net] 1 workflows (Scufl), have been renamed in T2Flows to DataflowAnnotations and Datalinks respectively.  DataflowAnnotations, however, allow for multiple titles, authors, and descriptions, as opposed to the single value attributes held for Scufls.
+
+
+
+== Installation
+To install the gems required by the Taverna 2 gem library, type into your command prompt:
+  [sudo] gem install libxml-ruby
+  [sudo] gem install rdoc
+  [sudo] gem install darkfish-rdoc
+
+When you have the required gems on your system, you may install this gem using the following commands:
+  gem sources -a http://gems.github.com
+  [sudo] gem install mannie-taverna-t2flow
+
+
+
+== Usage
+
+To be able to generate at least a T2Flow model using the gem, you need to include in your ruby code the following lines:
+  require "t2flow/model.rb"
+  require "t2flow/parser.rb"
+  
+To generate the model you can then use the gem as follows:
+  foo = File.new("path/to/workflow/file", "r")
+  bar = T2Flow::Parser.new.parse(foo)
+
+Alternatively:
+  foo = File.new("path/to/workflow/file", "r").read
+  bar = T2Flow::Parser.new.parse(foo)
+
+You will then be able to use your T2Flow model to retrieve information about the workflow by invoking the different methods and attributes.
+  bar.INVOKED
+... where INVOKED is the method or attribute required.
+
+You can also interact with remote workflows.
+  require "open-uri"
+  
+  foo = Uri.parse("xxxx://uri_to_workflow").read
+  bar = T2Flow::Parser.new.parse(foo)
+
+To be enable you to draw images of the T2Flow, you need to include:
+  require "t2flow/dot.rb"
+
+To be able to use any functionality included in "t2flow/dot.rb", you need to have GraphViz[http://www.graphviz.org/Download.php] installed on your system.  Once this package has been installed, you may use the gem to draw an image showing the structure of the T2Flow as follows.
+  out_file = File.new("path/to/file/you/want/the/dot/script/to/be/written", "w+")
+  T2Flow::Dot.new.write_dot(out_file, bar)
+  `dot -Tpng -o"path/to/the/output/image" #{out_file.path}`
+The last line draws a PNG image using +out_file+.  To learn more about dot, try typing into your command prompt:
+  % man dot
+or
+  % dot -h
+
+
+  
+== References
+
+[1] http://taverna.sourceforge.net
+[2] http://www.graphviz.org
\ No newline at end of file

Added: trunk/vendor/plugins/mannie-taverna-t2flow-0.1.1/Release_Notes.rdoc (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-t2flow-0.1.1/Release_Notes.rdoc	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-t2flow-0.1.1/Release_Notes.rdoc	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,8 @@
+= Version 0.1.1
+Released:: Wednesday, September 16, 2009
+
+== Added Functionality
+- Retrieval of Taverna local workers.
+
+=== New instance method in T2Flow::Model
+      local_workers

Added: trunk/vendor/plugins/mannie-taverna-t2flow-0.1.1/lib/t2flow/dot.rb (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-t2flow-0.1.1/lib/t2flow/dot.rb	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-t2flow-0.1.1/lib/t2flow/dot.rb	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,250 @@
+module T2Flow
+  
+  # This class enables you to write the script will will be used by dot
+  # (which is part of GraphViz[http://www.graphviz.org/Download.php])
+  # to generate the image showing the structure of a given model.
+  # To get started quickly, you could try:
+  #   out_file = File.new("path/to/file/you/want/the/dot/script/to/be/written", "w+")
+  #   workflow = File.new("path/to/workflow/file", "r").read
+  #   model = T2Flow::Parser.new.parse(workflow)
+  #   T2Flow::Dot.new.write_dot(out_file, model)
+  #   `dot -Tpng -o"path/to/the/output/image" #{out_file.path}`
+  class Dot
+
+    @@processor_colours = {
+      'apiconsumer' => 'palegreen',
+      'beanshell' => 'burlywood2',
+      'biomart' => 'lightcyan2',                      
+      'local' => 'mediumorchid2',
+      'biomobywsdl' => 'darkgoldenrod1',
+      'biomobyobject' => 'gold',
+      'biomobyparser' => 'white',
+      'inferno' => 'violetred1',
+      'notification' => 'mediumorchid2',
+      'rdfgenerator' => 'purple',
+      'rserv' => 'lightgoldenrodyellow',
+      'seqhound' => '#836fff',
+      'soaplabwsdl' => 'lightgoldenrodyellow',
+      'stringconstant' => 'lightsteelblue',
+      'talisman' => 'plum2',
+      'bsf' => 'burlywood2',
+      'abstractprocessor' => 'lightgoldenrodyellow',
+      'rshell' => 'lightgoldenrodyellow',
+      'arbitrarywsdl' => 'darkolivegreen3',
+      'workflow' => 'crimson'}
+    
+    @@fill_colours = %w{white aliceblue antiquewhite beige}
+    
+    @@ranksep = '0.22'
+    @@nodesep = '0.05'
+    
+    # Creates a new dot object for interaction.
+    def initialize
+      # @port_style IS CURRENTLY UNUSED. IGNORE!!!
+      @port_style = 'none' # 'all', 'bound' or 'none'
+    end
+    
+    # Writes to the given stream (File, StringIO, etc) the script to generate
+    # the image showing the internals of the given workflow model.  
+    # === Usage
+    #   stream = File.new("path/to/file/you/want/the/dot/script/to/be/written", "w+")
+    #   workflow = .......
+    #   model = T2Flow::Parser.new.parse(workflow)
+    #   T2Flow::Dot.new.write_dot(stream, model)
+    def write_dot(stream, model)
+      @t2flow_model = model
+      stream.puts 'digraph t2flow_graph {'
+      stream.puts ' graph ['
+      stream.puts '  style=""'
+      stream.puts '  labeljust="left"'
+      stream.puts '  clusterrank="local"'
+      stream.puts "  ranksep=\"#@@ranksep\""
+      stream.puts "  nodesep=\"#@@nodesep\""
+      stream.puts ' ]'
+      stream.puts
+      stream.puts ' node ['
+      stream.puts '  fontname="Helvetica",'
+      stream.puts '  fontsize="10",'
+      stream.puts '  fontcolor="black", '
+      stream.puts '  shape="box",'
+      stream.puts '  height="0",'
+      stream.puts '  width="0",'
+      stream.puts '  color="black",'
+      stream.puts '  fillcolor="lightgoldenrodyellow",'
+      stream.puts '  style="filled"'
+      stream.puts ' ];'
+      stream.puts
+      stream.puts ' edge ['
+      stream.puts '  fontname="Helvetica",'
+      stream.puts '  fontsize="8",'
+      stream.puts '  fontcolor="black",'
+      stream.puts '  color="black"'
+      stream.puts ' ];'
+      write_dataflow(stream, model.main)
+      stream.puts '}'
+      
+      stream.flush
+    end
+    
+    def write_dataflow(stream, dataflow, prefix="", name="", depth=0) # :nodoc:
+      if name != ""
+        stream.puts "subgraph cluster_#{prefix}#{name} {"
+        stream.puts " label=\"#{name}\""
+        stream.puts ' fontname="Helvetica"'
+        stream.puts ' fontsize="10"'
+        stream.puts ' fontcolor="black"'
+        stream.puts ' clusterrank="local"'
+        stream.puts " fillcolor=\"#{@@fill_colours[depth % @@fill_colours.length]}\""
+        stream.puts ' style="filled"'
+      end
+      dataflow.processors.each {|processor| write_processor(stream, processor, prefix, depth)}
+      write_source_cluster(stream, dataflow.sources, prefix)
+      write_sink_cluster(stream, dataflow.sinks, prefix)
+      dataflow.datalinks.each {|link| write_link(stream, link, dataflow, prefix)}
+      dataflow.coordinations.each {|coordination| write_coordination(stream, coordination, dataflow, prefix)}
+      if name != ""
+        stream.puts '}'
+      end
+    end
+    
+    def write_processor(stream, processor, prefix, depth) # :nodoc:
+      # nested workflows
+      if "#{processor.type}" == "workflow"
+        dataflow = @t2flow_model.dataflow(processor.dataflow_id)
+        write_dataflow(stream, dataflow, prefix + dataflow.annotations.name, dataflow.annotations.name, depth.next)
+      else
+        stream.puts " \"#{prefix}#{processor.name}\" ["
+        stream.puts "  fillcolor=\"#{get_colour processor.type}\","
+        stream.puts '  shape="box",'
+        stream.puts '  style="filled",'
+        stream.puts '  height="0",'
+        stream.puts '  width="0",'
+        stream.puts "  label=\"#{processor.name}\""
+        stream.puts ' ];'
+      end
+    end
+    
+    def write_source_cluster(stream, sources, prefix) # :nodoc:
+      if sources.length > 0
+        stream.puts " subgraph cluster_#{prefix}sources {"
+        stream.puts '  style="dotted"'
+        stream.puts '  label="Workflow Inputs"'
+        stream.puts '  fontname="Helvetica"'
+        stream.puts '  fontsize="10"'
+        stream.puts '  fontcolor="black"'
+        stream.puts '  rank="same"'
+        stream.puts " \"#{prefix}WORKFLOWINTERNALSOURCECONTROL\" ["
+        stream.puts '  shape="triangle",'
+        stream.puts '  width="0.2",'
+        stream.puts '  height="0.2",'
+        stream.puts '  fillcolor="brown1"'
+        stream.puts '  label=""'
+        stream.puts ' ]'
+        sources.each {|source| write_source(stream, source, prefix)}
+        stream.puts ' }'
+      end
+    end
+    
+    def write_source(stream, source, prefix) # :nodoc:
+      stream.puts " \"#{prefix}WORKFLOWINTERNALSOURCE_#{source.name}\" ["
+      stream.puts '   shape="box",'
+      stream.puts "   label=\"#{source.name}\""
+      stream.puts '   width="0",'
+      stream.puts '   height="0",'
+      stream.puts '   fillcolor="skyblue"'
+      stream.puts ' ]' 
+    end
+    
+    def write_sink_cluster(stream, sinks, prefix) # :nodoc:
+      if sinks.length > 0
+        stream.puts " subgraph cluster_#{prefix}sinks {"
+        stream.puts '  style="dotted"'
+        stream.puts '  label="Workflow Outputs"'
+        stream.puts '  fontname="Helvetica"'
+        stream.puts '  fontsize="10"'
+        stream.puts '  fontcolor="black"'
+        stream.puts '  rank="same"'
+        stream.puts " \"#{prefix}WORKFLOWINTERNALSINKCONTROL\" ["
+        stream.puts '  shape="invtriangle",'
+        stream.puts '  width="0.2",'
+        stream.puts '  height="0.2",'
+        stream.puts '  fillcolor="chartreuse3"'
+        stream.puts '  label=""'
+        stream.puts ' ]'
+        sinks.each {|sink| write_sink(stream, sink, prefix)}
+        stream.puts ' }'
+      end
+    end
+    
+    def write_sink(stream, sink, prefix) # :nodoc:
+      stream.puts " \"#{prefix}WORKFLOWINTERNALSINK_#{sink.name}\" ["
+      stream.puts '   shape="box",'
+      stream.puts "   label=\"#{sink.name}\""
+      stream.puts '   width="0",'
+      stream.puts '   height="0",'
+      stream.puts '   fillcolor="lightsteelblue2"'
+      stream.puts ' ]'     
+    end
+    
+    def write_link(stream, link, dataflow, prefix) # :nodoc:
+      if dataflow.sources.select{|s| s.name == link.source} != []
+        stream.write " \"#{prefix}WORKFLOWINTERNALSOURCE_#{link.source}\""
+      else 
+        processor = dataflow.processors.select{|p| p.name == link.source.split(':')[0]}[0]
+        if "#{processor.type}" == "workflow"
+          df = @t2flow_model.dataflow(processor.dataflow_id)
+          stream.write " \"#{prefix}#{df.annotations.name}WORKFLOWINTERNALSINK_#{link.source.split(':')[1]}\""
+        else
+          stream.write " \"#{prefix}#{processor.name}\""
+        end
+      end
+      stream.write '->'
+      if dataflow.sinks.select{|s| s.name == link.sink} != []
+        stream.write "\"#{prefix}WORKFLOWINTERNALSINK_#{link.sink}\""
+      else 
+        processor = dataflow.processors.select{|p| p.name == link.sink.split(':')[0]}[0]
+        if "#{processor.type}" == "workflow"
+          df = @t2flow_model.dataflow(processor.dataflow_id)
+          stream.write "\"#{prefix}#{df.annotations.name}WORKFLOWINTERNALSOURCE_#{link.sink.split(':')[1]}\""
+        else
+          stream.write "\"#{prefix}#{processor.name}\""
+        end
+      end
+      stream.puts ' ['
+      stream.puts ' ];'
+    end
+    
+    def write_coordination(stream, coordination, dataflow, prefix) # :nodoc:
+      stream.write " \"#{prefix}#{coordination.control}" 
+      processor = dataflow.processors.select{|p| p.name == coordination.control}[0]
+      
+      stream.write 'WORKFLOWINTERNALSINKCONTROL' if "#{processor.type}" == "workflow"
+      stream.write '"->"'
+      stream.write "#{prefix}#{coordination.target}"
+      processor = dataflow.processors.select{|p| p.name == coordination.target}[0]
+      stream.write 'WORKFLOWINTERNALSOURCECONTROL' if "#{processor.type}" == "workflow"
+      stream.write "\""
+      stream.puts ' ['
+      stream.puts '  color="gray",'
+      stream.puts '  arrowhead="odot",'
+      stream.puts '  arrowtail="none"'
+      stream.puts ' ];'
+    end
+    
+    def get_colour(processor_name) # :nodoc:
+      colour = @@processor_colours[processor_name]
+      if colour
+        colour
+      else 
+        'white'
+      end  
+    end
+    
+    # Returns true if the given name is a processor; false otherwise
+    def Dot.is_processor?(processor_name)
+      true if @@processor_colours[processor_name]
+    end
+    
+  end
+  
+end

Added: trunk/vendor/plugins/mannie-taverna-t2flow-0.1.1/lib/t2flow/model.rb (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-t2flow-0.1.1/lib/t2flow/model.rb	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-t2flow-0.1.1/lib/t2flow/model.rb	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,337 @@
+# This is the module containing the T2Flow model implementation i.e. the model structure/definition and all its internals.
+
+module T2Flow # :nodoc:
+  
+  # The model for a given Taverna 2 workflow.
+  class Model
+    # The list of all the dataflows that make up the workflow.
+    attr_accessor :dataflows
+    
+    # The list of any dependencies that have been found inside the workflow.
+    attr_accessor :dependencies
+    
+    # Creates an empty model for a Taverna 2 workflow.
+    def initialize
+      @dataflows = []
+    end
+    
+    # Retrieve the top level dataflow ie the MAIN (containing) dataflow
+    def main
+      @dataflows[0]
+    end
+    
+    # Retrieve the dataflow with the given ID
+    def dataflow(df_id)
+      df = @dataflows.select { |x| x.dataflow_id == df_id }
+      return df[0]
+    end
+    
+    # Retrieve ALL the processors containing beanshells within the workflow.
+    def beanshells
+      self.all_processors.select { |x| x.type == "beanshell" }
+    end
+    
+    # Retrieve ALL processors of that are webservices WITHIN the model.
+    def web_services
+      self.all_processors.select { |x| x.type =~ /wsdl|soaplab|biomoby/i }
+    end
+    
+    # Retrieve ALL local workers WITHIN the workflow
+    def local_workers
+      self.all_processors.select { |x| x.type =~ /local/i }
+    end
+    
+    # Retrieve the datalinks from the top level of a nested workflow.
+    # If the workflow is not nested, retrieve all datalinks.
+    def datalinks
+      self.main.datalinks
+    end
+    
+    # Retrieve ALL the datalinks within a nested workflow
+    def all_datalinks
+      links = []
+      @dataflows.each { |dataflow| links << dataflow.datalinks }
+      return links.flatten
+    end
+    
+    # Retrieve the annotations specific to the workflow.  This does not return 
+    # any annotations from workflows encapsulated within the main workflow.
+    def annotations
+      self.main.annotations
+    end
+    
+    # Retrieve processors from the top level of a nested workflow.
+    # If the workflow is not nested, retrieve all processors.
+    def processors
+      self.main.processors
+    end
+    
+    # Retrieve ALL the processors found in a nested workflow
+    def all_processors
+      procs =[]
+      @dataflows.each { |dataflow| procs << dataflow.processors }
+      return procs.flatten
+    end
+    
+    # Retrieve the sources(inputs) to the workflow
+    def sources
+      self.main.sources
+    end
+    
+    # Retrieve ALL the sources(inputs) within the workflow
+    def all_sources
+      sources =[]
+      @dataflows.each { |dataflow| sources << dataflow.sources }
+      return sources.flatten
+    end
+    
+    # Retrieve the sinks(outputs) to the workflow
+    def sinks
+      self.main.sinks
+    end
+    
+    # Retrieve ALL the sinks(outputs) within the workflow
+    def all_sinks
+      sinks =[]
+      @dataflows.each { |dataflow| sinks << dataflow.sinks }
+      return sinks.flatten
+    end
+    
+    # Retrieve the unique dataflow ID for the top level dataflow.
+    def model_id
+      self.main.dataflow_id
+    end
+    
+    # For the given dataflow, return the beanshells and/or services which 
+    # have direct links to or from the given processor.
+    # If no dataflow is specified, the top-level dataflow is used.
+    # This does a recursive search in nested workflows.
+    # == Usage
+    #   my_processor = model.processor[0]
+    #   linked_processors = model.get_processors_linked_to(my_processor)
+    #   processors_feeding_into_my_processor = linked_processors.sources
+    #   processors_feeding_from_my_processor = linked_processors.sinks
+    def get_processor_links(processor)
+      return nil unless processor
+      proc_links = ProcessorLinks.new
+      
+      # SOURCES
+      sources = self.all_datalinks.select { |x| x.sink =~ /#{processor.name}:.+/ }
+      proc_links.sources = []
+
+      # SINKS
+      sinks = self.all_datalinks.select { |x| x.source =~ /#{processor.name}:.+/ }
+      proc_links.sinks = []
+      temp_sinks = []
+      sinks.each { |x| temp_sinks << x.sink }
+      
+      # Match links by port into format
+      # my_port:name_of_link_im_linked_to:its_port
+      sources.each do |connection|
+        link = connection.sink
+        connected_proc_name = link.split(":")[0]
+        my_connection_port = link.split(":")[1]
+        
+        if my_connection_port
+          source = my_connection_port << ":" << connection.source
+          proc_links.sources << source if source.split(":").size == 3
+        end
+      end
+      
+      sinks.each do |connection|
+        link = connection.source
+        connected_proc_name = link.split(":")[0]
+        my_connection_port = link.split(":")[1]
+        
+        if my_connection_port
+          sink = my_connection_port << ":" << connection.sink
+          proc_links.sinks << sink if sink.split(":").size == 3
+        end
+      end
+      
+      return proc_links
+    end
+  end
+  
+  
+  
+  # The entities within the Taverna 2 mdoel which contains the different 
+  # elements of the workflows; processors, sinks, sources, etc...
+  class Dataflow
+    # This returns a DataflowAnnotation object.
+    attr_accessor :annotations
+    
+    # Retrieve the list of processors specific to the dataflow.
+    attr_accessor :processors
+    
+    # Retrieve the list of datalinks specific to the dataflow.
+    attr_accessor :datalinks
+    
+    # Retrieve the list of sources specific to the dataflow.
+    attr_accessor :sources
+    
+    # Retrieve the list of sinks specific to the dataflow.
+    attr_accessor :sinks
+    
+    # Retrieve the list of coordinations specific to the dataflow.
+    attr_accessor :coordinations
+    
+    # The unique identifier of the dataflow.
+    attr_accessor :dataflow_id
+    
+    # The role of the workflow
+    attr_accessor :role
+
+    # Creates a new Dataflow object.
+    def initialize
+      @annotations = DataflowAnnotation.new
+      @processors = []
+      @datalinks = []
+      @sources = []
+      @sinks = []
+      @coordinations = []
+    end
+    
+    # Retrieve beanshell processors specific to this dataflow.
+    def beanshells
+      @processors.select { |x| x.type == "beanshell" }
+    end
+  end
+
+
+  
+  # This is the (shim) object within the workflow.  This can be a beanshell,
+  # a webservice, a workflow, etc...
+  class Processor
+    # A string containing name of the processor.
+    attr_accessor :name 
+    
+    # A string containing the description of the processor if available.  
+    # Returns nil otherwise.
+    attr_accessor :description
+    
+    # A string for the type of processor, e.g. beanshell, workflow, webservice, etc...
+    attr_accessor :type 
+    
+    # For processors that have type "dataflow", this is the the reference 
+    # to the dataflow.  For all other processor types, this is nil.
+    attr_accessor :dataflow_id
+    
+    # This only has a value in beanshell processors.  This is the actual script
+    # embedded with the processor which does all the "work"
+    attr_accessor :script
+    
+    # This is a list of inputs that the processor can take in.
+    attr_accessor :inputs
+    
+    # This is a list of outputs that the processor can produce.
+    attr_accessor :outputs
+    
+    # For processors of type "arbitrarywsdl", this is the URI to the location
+    # of the wsdl file.
+    attr_accessor :wsdl
+    
+    # For processors of type "arbitrarywsdl", this is the operation invoked.
+    attr_accessor :wsdl_operation
+    
+    # For soaplab and biomoby services, this is the endpoint URI.
+    attr_accessor :endpoint
+    
+    # Authority name for the biomoby service.
+    attr_accessor :biomoby_authority_name
+
+    # Service name for the biomoby service. This is not necessarily the same 
+    # as the processors name.
+    attr_accessor :biomoby_service_name
+    
+    # Category for the biomoby service.
+    attr_accessor :biomoby_category
+
+    # Value for string constants
+    attr_accessor :value
+
+  end
+
+
+  # This object is returned after invoking model.get_processor_links(processor)
+  # .  The object contains two lists of processors.  Each element consists of: 
+  # the input or output port the processor uses as a link, the name of the
+  # processor being linked, and the port of the processor used for the linking,
+  # all seperated by a colon (:) i.e. 
+  #   my_port:name_of_processor:processor_port
+  class ProcessorLinks
+    # The processors whose output is fed as input into the processor used in
+    # model.get_processors_linked_to(processor).
+    attr_accessor :sources
+    
+    # A list of processors that are fed the output from the processor (used in
+    # model.get_processors_linked_to(processor) ) as input.
+    attr_accessor :sinks
+  end
+  
+  
+  
+  # This is the annotation object specific to the dataflow it belongs to.
+  # A DataflowAnnotation contains metadata about a given dataflow element.
+  class DataflowAnnotation
+    # The name used of the dataflow
+    attr_accessor :name
+    
+    # A list of titles that have been assigned to the dataflow.
+    attr_accessor :titles
+    
+    # A list ot descriptive strings about the dataflow.
+    attr_accessor :descriptions
+    
+    # A list of authors of the dataflow
+    attr_accessor :authors
+  end
+  
+  
+  
+  # This represents a connection between any of the following pair of entities:
+  # {processor -> processor}, {workflow -> workflow}, {workflow -> processor}, 
+  # and {processor -> workflow}.
+  class Datalink
+    # The name of the source (the starting point of the connection).
+    attr_accessor :source
+    
+    # The name of the sink (the endpoint of the connection).
+    attr_accessor :sink
+  end
+  
+  
+  
+  # This is a representation of the 'Run after...' function in Taverna
+  # where the selected processor or workflow is set to run after another.
+  class Coordination
+    # The name of the processor/workflow which is to run first.
+    attr_accessor :control
+    
+    # The name of the processor/workflow which is to run after the control.
+    attr_accessor :target
+  end
+  
+  
+  
+  # This is the start node of a Datalink.  Each source has a name and a port
+  # which is seperated by a colon; ":".
+  # This is represented as "source of a processor:port_name".
+  # A string that does not contain a colon can often be returned, signifiying
+  # a workflow source as opposed to that of a processor.
+  class Source
+  	attr_accessor :name, :descriptions, :example_values
+  end
+  
+  
+  
+  # This is the start node of a Datalink.  Each sink has a name and a port
+  # which is seperated by a colon; ":".
+  # This is represented as "sink of a processor:port_name".
+  # A string that does not contain a colon can often be returned, signifiying
+  # a workflow sink as opposed to that of a processor.
+  class Sink
+	  attr_accessor :name, :descriptions, :example_values
+  end  	
+
+end

Added: trunk/vendor/plugins/mannie-taverna-t2flow-0.1.1/lib/t2flow/parser.rb (0 => 2347)


--- trunk/vendor/plugins/mannie-taverna-t2flow-0.1.1/lib/t2flow/parser.rb	                        (rev 0)
+++ trunk/vendor/plugins/mannie-taverna-t2flow-0.1.1/lib/t2flow/parser.rb	2010-03-26 16:20:10 UTC (rev 2347)
@@ -0,0 +1,255 @@
+require "libxml"
+
+module T2Flow
+  
+  class Parser
+    # Returns the model for the given t2flow_file.
+    # The method accepts objects of classes File, StringIO and String only.
+    # ===Usage
+    #   foo = ... # stuff to initialize foo here
+    #   bar = T2Flow::Parser.new.parse(foo)
+    def parse(t2flow)
+      case t2flow.class.to_s
+        when /^string$/i
+          document = LibXML::XML::Parser.string(t2flow).parse 
+        when /^stringio|file$/i
+          t2flow.rewind
+          document = LibXML::XML::Parser.string(t2flow.read).parse 
+        else 
+          raise "Error parsing file."
+      end
+
+      root = document.root
+      raise "Doesn't appear to be a workflow!" if root.name != "workflow"
+      version = root["version"]
+      
+      create_model(root, version)
+    end
+    
+    def create_model(element, version) # :nodoc:
+      model = Model.new
+      
+      local_depends = element.find("//localDependencies")
+      if local_depends
+        local_depends.each do |dependency|
+          dependency.each do |dep| 
+            model.dependencies = [] if model.dependencies.nil?
+            model.dependencies << dep.content unless dep.content =~ /^\s*$/
+          end
+        end
+        model.dependencies.uniq! if model.dependencies
+      end
+    
+      element.each do |dataflow|
+        dataflow_obj = Dataflow.new
+        dataflow_obj.dataflow_id = dataflow["id"]
+        dataflow_obj.role = dataflow["role"]
+        
+        dataflow.each do |elt|
+          case elt.name
+            when "name"
+              dataflow_obj.annotations.name = elt.content
+            when "inputPorts"
+              elt.each { |port| add_source(dataflow_obj, port) }
+            when "outputPorts"
+              elt.each { |port| add_sink(dataflow_obj, port) }
+            when "processors"
+              elt.each { |proc| add_processor(dataflow_obj, proc) }
+            when "datalinks"
+              elt.each { |link| add_link(dataflow_obj, link) }
+            when "conditions"
+              elt.each { |coord| add_coordination(dataflow_obj, coord) }
+            when "annotations"
+              elt.each { |ann| add_annotation(dataflow_obj, ann) }
+          end # case elt.name
+        end # dataflow.each
+        
+        model.dataflows << dataflow_obj
+      end # element.each
+      
+      temp = model.processors.select { |x| x.type == "workflow" }
+      temp.each do |proc|
+        df = model.dataflow(proc.dataflow_id)
+        df.annotations.name = proc.name
+      end
+      
+      return model   
+    end
+    
+    def add_source(dataflow, port) # :nodoc:
+      source = Source.new
+      
+      port.each do |elt|
+        case elt.name
+          when "name": source.name = elt.content
+          when "annotations"
+            elt.each do |ann|
+              node = LibXML::XML::Parser.string("#{ann}").parse
+              content_node = node.find_first("//annotationBean")
+              content = content_node.child.next.content
+      
+              case content_node["class"]
+                when /freetextdescription/i
+                  source.descriptions = [] unless source.descriptions
+                  source.descriptions << content
+                when /examplevalue/i
+                  source.example_values = [] unless source.example_values
+                  source.example_values << content
+              end # case
+            end # elt.each
+        end # case
+      end # port.each
+      
+      dataflow.sources << source
+    end
+    
+    def add_sink(dataflow, port) # :nodoc:
+      sink = Sink.new
+      
+      port.each do |elt|
+        case elt.name
+          when "name": sink.name = elt.content
+          when "annotations"
+            elt.each do |ann|
+              node = LibXML::XML::Parser.string("#{ann}").parse
+              content_node = node.find_first("//annotationBean")
+              content = content_node.child.next.content
+      
+              case content_node["class"]
+                when /freetextdescription/i
+                  sink.descriptions = [] unless sink.descriptions
+                  sink.descriptions << content
+                when /examplevalue/i
+                  sink.example_values = [] unless sink.example_values
+                  sink.example_values << content
+              end # case
+            end # elt.each
+        end # case
+      end # port.each
+      
+      dataflow.sinks << sink
+    end
+    
+    def add_processor(dataflow, element) # :nodoc:
+      processor = Processor.new
+      
+      temp_inputs = []
+      temp_outputs = []
+      
+      element.each do |elt|
+        case elt.name
+          when "name"
+            processor.name = elt.content
+          when /inputports/i # ports from services
+            elt.each { |port| 
+              port.each { |x| temp_inputs << x.content if x.name=="name" }
+            }
+          when /outputports/i # ports from services
+            elt.each { |port| 
+              port.each { |x| temp_outputs << x.content if x.name=="name" }
+            }
+          when "activities" # a processor can only have one kind of activity
+            activity = elt.child
+            activity.each do |node|
+              if node.name == "configBean"
+                  activity_node = node.child
+                  
+                  if node["encoding"] == "dataflow"
+                    processor.dataflow_id = activity_node["ref"]
+                    processor.type = "workflow"
+                  else
+                    processor.type = (activity_node.name =~ /martquery/i ?
+                        "biomart" : activity_node.name.split(".")[-2])
+                    
+                    activity_node.each do |value_node|
+                      case value_node.name
+                        when "wsdl"
+                          processor.wsdl = value_node.content
+                        when "operation"
+                          processor.wsdl_operation = value_node.content
+                        when /endpoint/i
+                          processor.endpoint = value_node.content
+                        when /servicename/i
+                          processor.biomoby_service_name = value_node.content
+                        when /authorityname/i
+                          processor.biomoby_authority_name = value_node.content
+                        when "category"
+                          processor.biomoby_category = value_node.content
+                        when "script"
+                          processor.script = value_node.content
+                        when "value"
+                          processor.value = value_node.content
+                        when "inputs" # ALL ports present in beanshell
+                          value_node.each { |input| 
+                            input.each { |x| 
+                              processor.inputs = [] if processor.inputs.nil?
+                              processor.inputs << x.content if x.name == "name" 
+                            }
+                          }
+                        when "outputs" # ALL ports present in beanshell
+                          value_node.each { |output| 
+                            output.each { |x| 
+                              processor.outputs = [] if processor.outputs.nil?
+                              processor.outputs << x.content if x.name == "name" 
+                            }
+                          }
+                      end # case value_node.name
+                    end # activity_node.each
+                  end # if else node["encoding"] == "dataflow"
+              end # if node.name == "configBean"
+            end # activity.each
+        end # case elt.name
+      end # element.each
+      
+      processor.inputs = temp_inputs if processor.inputs.nil? && !temp_inputs.empty?
+      processor.outputs = temp_outputs if processor.outputs.nil? && !temp_outputs.empty?
+      dataflow.processors << processor
+    end
+    
+    def add_link(dataflow, link) # :nodoc:
+      datalink = Datalink.new
+      
+      link.each do |sink_source|
+        case sink_source.name
+          when "sink"
+            datalink.sink = sink_source.first.content
+            datalink.sink += ":" + sink_source.last.content if sink_source["type"] == "processor"
+          when "source"
+            datalink.source = sink_source.first.content
+            datalink.source += ":" + sink_source.last.content if sink_source["type"] == "processor"
+        end
+      end
+      
+      dataflow.datalinks << datalink
+    end
+    
+    def add_coordination(dataflow, condition) # :nodoc:
+      coordination = Coordination.new
+      
+      coordination.control = condition["control"]
+      coordination.target = condition["target"]
+      
+      dataflow.coordinations << coordination
+    end
+    
+    def add_annotation(dataflow, annotation) # :nodoc:
+      node = LibXML::XML::Parser.string("#{annotation}").parse
+      content_node = node.find_first("//annotationBean")
+      content = content_node.child.next.content
+      
+      case content_node["class"]
+        when /freetextdescription/i
+          dataflow.annotations.descriptions = [] unless dataflow.annotations.descriptions
+          dataflow.annotations.descriptions << content
+        when /descriptivetitle/i
+          dataflow.annotations.titles = [] unless dataflow.annotations.titles
+          dataflow.annotations.titles << content
+        when /author/i
+          dataflow.annotations.authors = [] unless dataflow.annotations.authors
+          dataflow.annotations.authors << content
+        end # case
+    end
+    
+  end
+  
+end

reply via email to

[Prev in Thread] Current Thread [Next in Thread]