Class: CPEE::ProcessTransformation::Target::CPEE
- Defined in:
- lib/cpee/processtransformation/cpee.rb
Instance Method Summary collapse
- #generate ⇒ Object
- #print_Break(node, res) ⇒ Object
- #print_Conditional(node, res) ⇒ Object
- #print_Loop(node, res) ⇒ Object
- #print_Node(node, res) ⇒ Object
- #print_Parallel(node, res) ⇒ Object
Methods inherited from Default
#generate_for_list, #initialize, #output_to_document
Constructor Details
This class inherits a constructor from CPEE::ProcessTransformation::Target::Default
Instance Method Details
#generate ⇒ Object
30 31 32 33 34 |
# File 'lib/cpee/processtransformation/cpee.rb', line 30 def generate res = XML::Smart.string("<description xmlns='http://cpee.org/ns/description/1.0'/>") res.register_namespace 'd', 'http://cpee.org/ns/description/1.0' output_to_document res end |
#print_Break(node, res) ⇒ Object
36 37 38 |
# File 'lib/cpee/processtransformation/cpee.rb', line 36 def print_Break(node,res) res.add('escape') end |
#print_Conditional(node, res) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/cpee/processtransformation/cpee.rb', line 88 def print_Conditional(node,res) s1 = res.add('d:choose', 'mode' => node.mode) node.sub.each do |branch| s2 = if branch.condition.any? a = s1.add('d:alternative','condition' => branch.condition.join(' or ')) a.attributes['language'] = branch.condition_type unless branch.condition_type.nil? a else s1.add('d:otherwise') end branch.attributes.each do |k,v| s2.attributes[k] = v end generate_for_list(branch,s2) end if (x = s1.find('d:otherwise')).any? s1.add x end s1 end |
#print_Loop(node, res) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cpee/processtransformation/cpee.rb', line 40 def print_Loop(node,res) if node.sub.length == 2 && node.sub[1].condition.empty? && ((node.sub[1].length == 1 && node.sub[1][0].class.name.gsub(/\w+:+/,'') == 'Break') || node.sub[1].length == 0) s1 = res.add('loop', 'pre_test' => node.sub[0].condition.empty? ? 'true' : node.sub[0].condition.join(' && ')) s1.attributes['language'] = node.sub[0].condition_type unless node.sub[0].condition_type.nil? node.sub[0].attributes.each do |k,v| s1.attributes[k] = v end generate_for_list(node.sub[0],s1) else s1 = res.add('loop', 'pre_test' => 'true') print_Conditional(node,s1) end s1 end |
#print_Node(node, res) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/cpee/processtransformation/cpee.rb', line 55 def print_Node(node,res) if node.endpoints.empty? && !node.script.nil? && node.script.strip != '' n = res.add('d:manipulate', node.script, 'id' => "a#{node.niceid}") n.attributes['output'] = node.script_var unless node.script_var.nil? n.attributes['language'] = node.script_type unless node.script_type.nil? else n = res.add('d:call', 'id' => "a#{node.niceid}", 'endpoint' => node.endpoints.join(',')) p = n.add('d:parameters') p.add('d:label',"\"#{node.label.gsub(/"/,"\\\"")}\"") p.add('d:method',node.methods.join(',') || 'post') p.add('d:type',":#{node.type}") p.add('d:mid',"'#{node.id}'") par = p.add('d:parameters') node.parameters.each do |k,v| par.add(k,v) end if !node.script.nil? && node.script.strip != '' x = n.add('d:finalize',node.script) x.attributes['output'] = node.script_var unless node.script_var.nil? x.attributes['language'] = node.script_type unless node.script_type.nil? end end end |
#print_Parallel(node, res) ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/cpee/processtransformation/cpee.rb', line 79 def print_Parallel(node,res) s1 = res.add('parallel','wait' => node.wait) node.sub.each do |branch| s2 = s1.add('parallel_branch') generate_for_list(branch,s2) end s1 end |