Class: T2Flow::Model
- Inherits:
-
Object
- Object
- T2Flow::Model
- Defined in:
- lib/t2flow/model.rb
Overview
The model for a given Taverna 2 workflow.
Instance Attribute Summary collapse
-
#dataflows ⇒ Object
The list of all the dataflows that make up the workflow.
-
#dependencies ⇒ Object
The list of any dependencies that have been found inside the workflow.
Instance Method Summary collapse
-
#all_datalinks ⇒ Object
Retrieve ALL the datalinks within a nested workflow.
-
#all_processors ⇒ Object
Retrieve ALL the processors found in a nested workflow.
-
#all_sinks ⇒ Object
Retrieve ALL the sinks(outputs) within the workflow.
-
#all_sources ⇒ Object
Retrieve ALL the sources(inputs) within the workflow.
-
#annotations ⇒ Object
Retrieve the annotations specific to the workflow.
-
#beanshells ⇒ Object
Retrieve ALL the processors containing beanshells within the workflow.
-
#dataflow(df_id) ⇒ Object
Retrieve the dataflow with the given ID.
-
#datalinks ⇒ Object
Retrieve the datalinks from the top level of a nested workflow.
-
#get_processor_links(processor) ⇒ Object
For the given dataflow, return the beanshells and/or services which have direct links to or from the given processor.
-
#initialize ⇒ Model
constructor
Creates an empty model for a Taverna 2 workflow.
-
#main ⇒ Object
Retrieve the top level dataflow ie the MAIN (containing) dataflow.
-
#model_id ⇒ Object
Retrieve the unique dataflow ID for the top level dataflow.
-
#processors ⇒ Object
Retrieve processors from the top level of a nested workflow.
-
#sinks ⇒ Object
Retrieve the sinks(outputs) to the workflow.
-
#sources ⇒ Object
Retrieve the sources(inputs) to the workflow.
-
#web_services ⇒ Object
Retrieve ALL processors of that are webservices WITHIN the model.
Constructor Details
#initialize ⇒ Model
Creates an empty model for a Taverna 2 workflow.
14 15 16 |
# File 'lib/t2flow/model.rb', line 14 def initialize @dataflows = [] end |
Instance Attribute Details
#dataflows ⇒ Object
The list of all the dataflows that make up the workflow.
8 9 10 |
# File 'lib/t2flow/model.rb', line 8 def dataflows @dataflows end |
#dependencies ⇒ Object
The list of any dependencies that have been found inside the workflow.
11 12 13 |
# File 'lib/t2flow/model.rb', line 11 def dependencies @dependencies end |
Instance Method Details
#all_datalinks ⇒ Object
Retrieve ALL the datalinks within a nested workflow
46 47 48 49 50 |
# File 'lib/t2flow/model.rb', line 46 def all_datalinks links = [] @dataflows.each { |dataflow| links << dataflow.datalinks } return links.flatten end |
#all_processors ⇒ Object
Retrieve ALL the processors found in a nested workflow
65 66 67 68 69 |
# File 'lib/t2flow/model.rb', line 65 def all_processors procs =[] @dataflows.each { |dataflow| procs << dataflow.processors } return procs.flatten end |
#all_sinks ⇒ Object
Retrieve ALL the sinks(outputs) within the workflow
89 90 91 92 93 |
# File 'lib/t2flow/model.rb', line 89 def all_sinks sinks =[] @dataflows.each { |dataflow| sinks << dataflow.sinks } return sinks.flatten end |
#all_sources ⇒ Object
Retrieve ALL the sources(inputs) within the workflow
77 78 79 80 81 |
# File 'lib/t2flow/model.rb', line 77 def all_sources sources =[] @dataflows.each { |dataflow| sources << dataflow.sources } return sources.flatten end |
#annotations ⇒ Object
Retrieve the annotations specific to the workflow. This does not return any annotations from workflows encapsulated within the main workflow.
54 55 56 |
# File 'lib/t2flow/model.rb', line 54 def annotations self.main.annotations end |
#beanshells ⇒ Object
Retrieve ALL the processors containing beanshells within the workflow.
30 31 32 |
# File 'lib/t2flow/model.rb', line 30 def beanshells self.all_processors.select { |x| x.type == "beanshell" } end |
#dataflow(df_id) ⇒ Object
Retrieve the dataflow with the given ID
24 25 26 27 |
# File 'lib/t2flow/model.rb', line 24 def dataflow(df_id) df = @dataflows.select { |x| x.dataflow_id == df_id } return df[0] end |
#datalinks ⇒ Object
Retrieve the datalinks from the top level of a nested workflow. If the workflow is not nested, retrieve all datalinks.
41 42 43 |
# File 'lib/t2flow/model.rb', line 41 def datalinks self.main.datalinks end |
#get_processor_links(processor) ⇒ Object
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
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/t2flow/model.rb', line 109 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 |
#main ⇒ Object
Retrieve the top level dataflow ie the MAIN (containing) dataflow
19 20 21 |
# File 'lib/t2flow/model.rb', line 19 def main @dataflows[0] end |
#model_id ⇒ Object
Retrieve the unique dataflow ID for the top level dataflow.
96 97 98 |
# File 'lib/t2flow/model.rb', line 96 def model_id self.main.dataflow_id end |
#processors ⇒ Object
Retrieve processors from the top level of a nested workflow. If the workflow is not nested, retrieve all processors.
60 61 62 |
# File 'lib/t2flow/model.rb', line 60 def processors self.main.processors end |
#sinks ⇒ Object
Retrieve the sinks(outputs) to the workflow
84 85 86 |
# File 'lib/t2flow/model.rb', line 84 def sinks self.main.sinks end |
#sources ⇒ Object
Retrieve the sources(inputs) to the workflow
72 73 74 |
# File 'lib/t2flow/model.rb', line 72 def sources self.main.sources end |
#web_services ⇒ Object
Retrieve ALL processors of that are webservices WITHIN the model.
35 36 37 |
# File 'lib/t2flow/model.rb', line 35 def web_services self.all_processors.select { |x| x.type =~ /wsdl|soaplab|biomoby/i } end |