Class | OpenWFE::EqualsExpression |
In: |
lib/openwfe/expressions/fe_equals.rb
|
Parent: | ComparisonExpression |
The ‘equals’ expression compares two values. If those values are equal, the field (attribute) of the workitem named ‘result’ will be set to true (else false).
Usually, this expression is used within the ‘if’ expression.
<if> <equals field-value="customer_name" other-value="Dupont" /> <!-- then --> <participant ref="special_salesman" /> <!-- else --> <participant ref="ordinary_salesman" /> </if>
(The ‘if’ expression reads the ‘result’ field to route the flow either towards the then branch, either towards the else one).
With a Ruby process definition, a variation on the same ‘equals’ :
equals :field_value => "phone", :other_value => "090078367" equals :field_val => "phone", :other_value => "090078367" equals :f_value => "phone", :other_value => "090078367" equals :f_val => "phone", :other_value => "090078367" equals :f_val => "phone", :other_val => "090078367"
Thus, note that ‘variable’ in an expression attribute can be shortened to ‘var’ or ‘v’. ‘value’ can be shortened to ‘val’ and ‘field’ to ‘f’.
Usually, the "test" attribute of the "if" expression is preferred over this ‘equals’ expression, like in :
<if test="${f:customer_name} == Dupont"> <!-- then --> <participant ref="special_salesman" /> <!-- else --> <participant ref="ordinary_salesman" /> </if>
Another shortcut : the ‘participant’ and the ‘subprocess’ expressions accept an optional ‘if’ (or ‘unless’) attribute, so that ifs can be contracted to :
participant :ref => "toto", :if => "${f:customer_name} == Alfred" subprocess :ref => "special_delivery", :if => "'${f:special}' != ''"
This also works with the implicit form of the participant and the subprocess :
toto :if => "${f:customer_name} == Alfred" special_delivery :if => "'${f:special}' != ''"