Object
A 'view' on the status of a process instance.
Returned by the process and the processes methods of the Engine.
# File lib/ruote/engine/process_status.rb, line 46 def initialize (context, expressions, errors) @expressions = expressions.collect { |e| Ruote::Exp::FlowExpression.from_h(context, e) } @expressions.sort! { |a, b| a.fei.expid <=> b.fei.expid } @errors = errors.collect { |e| ProcessError.new(e) } @errors.sort! { |a, b| a.fei.expid <=> b.fei.expid } end
Returns a hash fei => variable_hash containing all the variable bindings (expression by expression) of the process instance.
# File lib/ruote/engine/process_status.rb, line 106 def all_variables @expressions.inject({}) do |h, exp| h[exp.fei] = exp.variables if exp.variables h end end
Returns the current version of the process definition tree. If no manipulation (gardening) was performed on the tree, this method yields the same result as the original_tree method.
# File lib/ruote/engine/process_status.rb, line 228 def current_tree h = Ruote.decompose_tree(original_tree) @expressions.sort { |e0, e1| e0.fei.expid <=> e1.fei.expid }.each { |e| tree = if v = e.tree[1]['_triggered'] t = original_tree_from_parent(e).dup t[1]['_triggered'] = v t else e.tree end h.merge!(Ruote.decompose_tree(tree, e.fei.expid)) } Ruote.recompose_tree(h) end
# File lib/ruote/engine/process_status.rb, line 144 def definition_name root_expression.attribute('name') || root_expression.attribute_text end
# File lib/ruote/engine/process_status.rb, line 149 def definition_revision root_expression.attribute('revision') end
# File lib/ruote/engine/process_status.rb, line 176 def inspect s = "== #{self.class} ==\n" s << " expressions : #{@expressions.size}\n" @expressions.each do |e| s << " #{e.fei.to_storage_id} : #{e}\n" end s << " errors : #{@errors.size}\n" @errors.each do |e| s << " #{e.fei.to_storage_id} :\n" if e.fei s << " #{e.inspect}\n" end s end
Returns a Time instance indicating when the process instance was launched.
# File lib/ruote/engine/process_status.rb, line 164 def launched_time root_expression.created_time end
Returns the process definition tree as it was when this process instance was launched.
# File lib/ruote/engine/process_status.rb, line 157 def original_tree root_expression.original_tree end
Returns the expression at the root of the process instance.
# File lib/ruote/engine/process_status.rb, line 59 def root_expression #@expressions.find { |e| e.fei.expid == '0' && e.fei.sub_wfid == nil } # vanilla implementation root_expressions.first end
Given an expression id, returns the root (top ancestor) for its expression.
# File lib/ruote/engine/process_status.rb, line 84 def root_expression_for (fei) sfei = Ruote.sid(fei) exp = @expressions.find { |fe| sfei == Ruote.sid(fe.fei) } return nil unless exp return exp if exp.parent_id.nil? root_expression_for(exp.parent_id) end
Returns a list of all the expressions that have no parent expression. The list is sorted with the deeper (closer to the original root) first.
# File lib/ruote/engine/process_status.rb, line 70 def root_expressions roots = @expressions.select { |e| e.h.parent_id == nil } roots = roots.inject({}) { |h, e| h["#{e.h.fei['expid']}__#{e.h.fei['sub_wfid']}"] = e; h } roots.keys.sort.collect { |k| roots[k] } end
# File lib/ruote/engine/process_status.rb, line 192 def to_dot (opts={}) s = [ "digraph \"process wfid #{wfid}\" {" ] @expressions.each { |e| s.push(*e.send(:to_dot, opts)) } @errors.each { |e| s.push(*e.send(:to_dot, opts)) } s << "}" s.join("\n") end
# File lib/ruote/engine/process_status.rb, line 202 def to_h h = {} ] wfid definition_name definition_revision original_tree current_tree variables tags ].each { |m| h[m] = self.send(m) } h['launched_time'] = launched_time.to_s # all_variables and all_tags ? h['root_expression'] = nil h['expressions'] = @expressions.collect { |e| e.fei.to_h } h['errors'] = @errors.collect { |e| e.to_h } h end
# File lib/ruote/engine/process_status.rb, line 169 def to_s "(process_status wfid '#{wfid}', " + "expressions #{@expressions.size}, " + "errors #{@errors.size})" end
Generated with the Darkfish Rdoc Generator 2.