Class: Scufl::Parser
- Inherits:
-
Object
- Object
- Scufl::Parser
- Defined in:
- lib/scufl/parser.rb
Instance Method Summary collapse
-
#add_coordination(model, element, version) ⇒ Object
:nodoc:.
-
#add_link(model, element, version) ⇒ Object
:nodoc:.
-
#add_processor(model, element, version) ⇒ Object
:nodoc:.
-
#add_sink(model, element, version) ⇒ Object
:nodoc:.
-
#add_source(model, element, version) ⇒ Object
:nodoc:.
-
#create_model(element, version) ⇒ Object
:nodoc:.
-
#parse(scufl) ⇒ Object
Returns the model for the given t2flow_file.
-
#set_description(model, element, version) ⇒ Object
:nodoc:.
Instance Method Details
#add_coordination(model, element, version) ⇒ Object
:nodoc:
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/scufl/parser.rb', line 34 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 |
#add_link(model, element, version) ⇒ Object
:nodoc:
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/scufl/parser.rb', line 47 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 |
#add_processor(model, element, version) ⇒ Object
:nodoc:
98 99 100 101 102 103 104 105 106 107 108 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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/scufl/parser.rb', line 98 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. = 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 |
#add_sink(model, element, version) ⇒ Object
:nodoc:
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/scufl/parser.rb', line 81 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') { || .each_element('s:description') {|description| sink.description = description.text} } end model.sinks.push sink end |
#add_source(model, element, version) ⇒ Object
:nodoc:
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/scufl/parser.rb', line 64 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') { || .each_element('s:description') {|description| source.description = description.text} } end model.sources.push source end |
#create_model(element, version) ⇒ Object
:nodoc:
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/scufl/parser.rb', line 21 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 |
#parse(scufl) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/scufl/parser.rb', line 11 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 |
#set_description(model, element, version) ⇒ Object
:nodoc:
177 178 179 180 181 182 183 184 |
# File 'lib/scufl/parser.rb', line 177 def set_description(model, element, version) # :nodoc: = element.attribute('author') title = element.attribute('title') model.description. = .value if model.description.title = title.value if title model.description.description = element.text end |