Hi John,

In my particular use case I need to check whether 4 fields in the
workitem have changed. Example:

  [...]

  # save important workitem fields in workflow variables...
  set :variable => 'key1', :value => "${f:key1}"
  set :variable => 'key2', :value => "${f:key2}"
  set :variable => 'key3', :value => "${f:key3}"

  # this active participant may alter key1, key2 or key3
  participant :ref => "alpha"

  # then check whether this keys have changed their value...
  # i call decision participant

  participant :ref => "decision"
  _if :test => "${f:continue}" do

  [...]

Would it be possible to access workflow variables from the decision
participant context? If not, how could I use workflow variables?
Aren't workflow variables good for doing this kind of things?

Thanks a lot for your help.
Kind regards.

Gonzalo.




On Sep 9, 2:07 am, John Mettraux <[email protected]> wrote:
> On Wed, Sep 9, 2009 at 12:38 AM, Gonzalo<[email protected]> wrote:
>
> > I'm trying to use the _if :test => "" construct in a workflow. I
> > succeeded with just one comparison:
>
> > _if :test => "${color} == "green" do
> > [...]
>
> > But if I try to nest several comparisons with boolean operators (and,
> > or...) it doesn't work:
>
> >  _if :test => "${key0} == ${fields:key0} and
> >                    ${key1} == ${fields:key1} and
> >                    ${key2} == ${fields:key2} and
> >                    ${key3} == ${fields:key3}" do
> > [...]
>
> > Is it supported? Maybe I'm using a wrong syntax or there's a better
> > way to do this stuff.
>
> Hello Gonzalo,
>
> I've added a test to ruote 0.9 that covers your question :
>
>  http://github.com/jmettraux/ruote/blob/b76e754e7c2d12f28b515be025b733...
>
> Note the use of the :rtest attribute instead of :test, ruby evaluation
> is performed on the value of the :rtest attribute thus more
> complicated checks are performed.
>
> In this evaluated Ruby code, the workitem is bound under "wi" and the
> expression under "fe", it's thus OK to write wi.field_name or
> wi.fields['field_name'] and fe.lookup_variable("v0").
>
> It should be said that it's maybe better to put big decision logic
> into dedicated participants and then have light "if" nodes.
>
>   sequence do
>     participant "decide"
>     _if :test => "${f:take_umbrella}" do
>       participant "rainy_day"
>       participant "sunny_day"
>     end
>   end
>
>   #...
>
>   engine.register_participant :decide do |workitem|
>     workitem.fields['take_umbrella'] = case workitem.fields['weather']
>     when "rain" then true
>     when "cloudy" then true
>     else false
>     end
>   end
>
> Of course, it all depends on your use case, but it's good to have
> decision logic decoupled from execution logic.
>
> Best regards,
>
> --
> John Mettraux   -  http://jmettraux.wordpress.com
--~--~---------~--~----~------------~-------~--~----~
you received this message because you are subscribed to the "ruote users" group.
to post : send email to [email protected]
to unsubscribe : send email to [email protected]
more options : http://groups.google.com/group/openwferu-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to