Class | OpenWFE::WhenExpression |
In: |
lib/openwfe/expressions/fe_when.rb
|
Parent: | WaitingExpression |
The ‘when’ expression will trigger a consequence when a condition is met, like in
<when test="${variable:over} == true"> <participant ref="toto" /> </when>
where the participant "toto" will receive a workitem when the (local) variable "over" has the value true.
This is also possible :
<when> <equals field-value="done" other-value="true" /> <participant ref="toto" /> </when>
The ‘when’ expression by defaults, evaluates every 10 seconds its condition clause. A different frequency can be stated via the "frequency" attribute :
_when :test => "${completion_level} == 4", :frequency => "1s" participant "next_stage" end
will check for the completion_level value every second. The scheduler itself is by default ‘waking up’ every 250 ms, so setting a frequency to something smaller than that value might prove useless. (Note than in the Ruby process definition, the ‘when’ got escaped to ‘_when’ not to conflict with the ‘when’ keyword of the Ruby language).
The when expression understands the ‘timeout’ attribute like the participant expression does. Thus
_when :test => "${cows} == 'do fly'", :timeout => "1y" participant "me" end
will timeout after one year (participant "me" will not receive a workitem).
condition_sub_id | [RW] | |
consequence_triggered | [RW] |
# File lib/openwfe/expressions/fe_when.rb, line 103 103: def apply (workitem) 104: 105: return reply_to_parent(workitem) \ 106: if @children.size < 1 107: 108: @condition_sub_id = -1 109: @consequence_triggered = false 110: 111: super workitem 112: end
# File lib/openwfe/expressions/fe_when.rb, line 114 114: def reply (workitem) 115: 116: #ldebug do 117: # "reply() @consequence_triggered is '#{@consequence_triggered}'" 118: #end 119: 120: return reply_to_parent(workitem) \ 121: if @consequence_triggered 122: 123: super workitem 124: end