In Files

Parent

Class/Module Index [+]

Quicksearch

Ruote::FlowExpressionId

The FlowExpressionId (fei for short) is an process expression identifier. Each expression when instantiated gets a unique fei.

Feis are also used in workitems, where the fei is the fei of the

participant

expression that emitted the workitem.

Feis can thus indicate the position of a workitem in a process tree.

Feis contain four pieces of information :

Constants

CHILD_SEP

Attributes

h[R]

Public Class Methods

child_id(h) click to toggle source

Returns child_id... For an expid of '0_1_4', this will be 4.

# File lib/ruote/fei.rb, line 143
def self.child_id (h)
  h['expid'].split(CHILD_SEP).last.to_i
end
direct_child?(parent_fei, other_fei) click to toggle source
# File lib/ruote/fei.rb, line 151
def self.direct_child? (parent_fei, other_fei)

  ] sub_wfid wfid engine_id ].each do |k|
    return false if parent_fei[k] != other_fei[k]
  end

  pei = other_fei['expid'].split(CHILD_SEP)[0..-2].join(CHILD_SEP)

  (pei == parent_fei['expid'])
end
extract(arg) click to toggle source

Attempts at extracting a FlowExpressionId from the given argument (workitem, string, ...)

Uses .extract_h

# File lib/ruote/fei.rb, line 167
def self.extract (arg)

  FlowExpressionId.new(extract_h(arg))
end
extract_h(arg) click to toggle source

Attempts at extracting a FlowExpressionId (as a Hash instance) from the given argument (workitem, string, ...)

# File lib/ruote/fei.rb, line 175
def self.extract_h (arg)

  if arg.is_a?(Hash)
    return arg if arg['expid']
    return arg['fei'] if arg['fei']
  end

  return extract_h(arg.fei) if arg.respond_to?(:fei)
  return arg.h if arg.is_a?(Ruote::FlowExpressionId)
  return arg.h['fei'] if arg.is_a?(Ruote::Workitem)

  if arg.is_a?(String)

    ss = arg.split('!')

    return {
      'engine_id' => ss[-4] || 'engine',
      'expid' => ss[-3], 'sub_wfid' => ss[-2], 'wfid' => ss[-1] }
  end

  raise ArgumentError.new(
    "couldn't extract fei out of instance of #{arg.class}")
end
from_id(s, engine_id='engine') click to toggle source

Turns the result of to_storage_id back to a FlowExpressionId instance.

# File lib/ruote/fei.rb, line 108
def self.from_id (s, engine_id='engine')

  extract("#{engine_id}!#{s}")
end
is_a_fei?(h) click to toggle source

Returns true if the h is a representation of a FlowExpressionId instance.

# File lib/ruote/fei.rb, line 135
def self.is_a_fei? (h)

  h.respond_to?(:keys) &&
  (h.keys - [ 'sub_wfid' ]).sort == ] engine_id expid wfid ]
end
new(h) click to toggle source
# File lib/ruote/fei.rb, line 73
def initialize (h)

  @h = h
  class << h; include Ruote::HashDot; end
end
to_storage_id(hfei) click to toggle source
# File lib/ruote/fei.rb, line 99
def self.to_storage_id (hfei)

  hfei.respond_to?(:to_storage_id) ?
    hfei.to_storage_id :
    "#{hfei['expid']}!#{hfei['sub_wfid']}!#{hfei['wfid']}"
end

Public Instance Methods

==(other) click to toggle source
# File lib/ruote/fei.rb, line 124
def == (other)

  return false unless other.is_a?(Ruote::FlowExpressionId)

  (hash == other.hash)
end
Also aliased as: eql?
child_id() click to toggle source

Returns the last number in the expid. For instance, if the expid is '0_5_7', the child_id will be '7'.

# File lib/ruote/fei.rb, line 116
def child_id
  h.expid.split(CHILD_SEP).last.to_i
end
engine_id() click to toggle source
# File lib/ruote/fei.rb, line 91
def engine_id
  @h['engine_id']
end
eql?(other) click to toggle source
Alias for: ==
expid() click to toggle source
# File lib/ruote/fei.rb, line 79
def expid
  @h['expid']
end
hash() click to toggle source
# File lib/ruote/fei.rb, line 120
def hash
  to_storage_id.hash
end
sub_wfid() click to toggle source
# File lib/ruote/fei.rb, line 87
def sub_wfid
  @h['sub_wfid']
end
to_h() click to toggle source
# File lib/ruote/fei.rb, line 147
def to_h
  @h
end
to_storage_id() click to toggle source
# File lib/ruote/fei.rb, line 95
def to_storage_id
  "#{@h['expid']}!#{@h['sub_wfid']}!#{@h['wfid']}"
end
wfid() click to toggle source
# File lib/ruote/fei.rb, line 83
def wfid
  @h['wfid']
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.