Class: CPEE::ProcessTransformation::Target::CPEE

Inherits:
Default
  • Object
show all
Defined in:
lib/cpee/processtransformation/cpee.rb

Instance Method Summary collapse

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

#generateObject



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


36
37
38
# File 'lib/cpee/processtransformation/cpee.rb', line 36

def print_Break(node,res)
  res.add('escape')
end


92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/cpee/processtransformation/cpee.rb', line 92

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


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# 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', 'mode' => 'pre_test', 'condition' => 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', 'mode' => 'pre_test', 'condition' => 'true')
    if node.sub.length == 1
      generate_for_list(node.sub[0],s1)
    else
      print_Conditional(node,s1)
    end
  end
  s1
end


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/cpee/processtransformation/cpee.rb', line 59

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:arguments')
    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


83
84
85
86
87
88
89
90
# File 'lib/cpee/processtransformation/cpee.rb', line 83

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