Class | Ruote::Workitem |
In: |
lib/ruote/workitem.rb
|
Parent: | Object |
A workitem can be thought of an "execution token", but with a payload (fields).
The payload/fields MUST be JSONifiable.
h | [R] |
Given a JSON String, decodes and returns a Ruote::Workitem instance.3 If the decode thing is not an object/hash, will raise an ArgumentError.
Shortcut for lookup(key)
workitem.fields['customer']['city'] # or workitem.lookup('customer.city') # or workitem['customer.city']
Shortcut for set_field(key, value)
workitem.fields['customer']['city'] = 'Toronto' # or workitem.set_field('customer.city', 'Toronto') # or workitem['customer.city'] = 'Toronto'
For a simple key
workitem.lookup('toto')
is equivalent to
workitem.fields['toto']
but for a complex key
workitem.lookup('toto.address')
is equivalent to
workitem.fields['toto']['address']
Used by some participants, returns the "owner" of the workitem. Mostly used when reserving workitems.
Sometimes a value is passed as a[n expression] parameter or as a workitem field, with priority to the parameter.
sequence do set 'f:country' => 'uruguay' participant 'toto' # in toto, workitem.param_or_field(:country) will yield 'uruguay' participant 'toto', :country => 'argentina' # workitem.param_or_field(:country) will yield 'argentina' end
When a participant is invoked like in
accounting 'do_invoice', :customer => 'acme corp'
then
p workitem.params # => { 'ref' => 'accounting', 'do_invoice' => nil, 'customer' => 'acme corp' }
and
p workitem.param_text # => 'do_invoice'
It returns nil when there is no text passed directly.
Shortcut for wi.fields[‘params’]
When a participant is invoked like in
participant :ref => 'toto', :task => 'x"
then
p workitem.params # => { 'ref' => 'toto', 'task' => 'x' }
The participant for which this item is destined. Will be nil when the workitem is transiting inside of its process instance (as opposed to when it‘s being delivered outside of the engine).
How many times was this workitem re_dispatched ?
It‘s used by LocalParticipant re_dispatch mostly, or by participant which poll a resource and re_dispatch after a while.
A shortcut to the value in the field named result
This field is used by the if expression for instance to determine if it should branch to its ‘then’ or its ‘else’.
Like lookup allows for nested lookups, set_field can be used to set sub fields directly.
workitem.set_field('customer.address.city', 'Pleasantville')
Warning : if the customer and address field and subfield are not present or are not hashes, set_field will simply create a "customer.address.city" field and set its value to "Pleasantville".
Returns the String id for this workitem (something like "0_0!!20100507-wagamama").
It‘s in fact a shortcut for
Ruote::FlowExpressionId.to_storage_id(h.fei)
Returns the name of the sub-workflow the workitem is currently in. (If it‘s in the main flow, it will return the name of the main flow, if that flow has a name…)
Shortcut to the temporary/trailing fields
groups.google.com/group/openwferu-users/browse_thread/thread/981dba6204f31ccc
Returns the "workflow instance id" (unique process instance id) of the process instance which issued this workitem.