Extreme newbie confused on basic process definitions

34 views
Skip to first unread message

Josh Adams

unread,
May 29, 2012, 8:38:19 AM5/29/12
to openwfe...@googlegroups.com
Hi everyone,

So I'm brand new to ruote.  I've built ad-hoc workflow-lite systems for my projects in the past (essentially state machines, implicit workflow spread across multiple models, and background workers pushing state).  Obviously this is sub-optimal, and declarative workflow seems much nicer.

So I've been trying to get my head around ruote.  However, I can't seem to get the most basic example involving anything dynamic to work.  As an example, I'm just trying to do a really basic if statement and I cannot get it to work to save my life.

Ruote.process_definition :name => 'if_example', :revision => '0.1' do
  sequence do
    requestor :task => 'request_business_trip_application_form'
    participant 'hr'
    participant 'ceo', :if => '${f:amount} > 25000'
  end
end

I'm using ruote-on-rails to play around with the pdefs, and so I plug that sucker in and add a form for the task that has an 'amount' field.  I fill it in with 30000.  When the 'hr' participant picks it up, the workitem looks like this:

{"fields":{"amount":"30000"},"params":{"hr":null},"dispatched_at":"2012-05-29 12:36:52.202034 UTC"}

However, when I advance the workflow it's just done - the CEO doesn't get handed the workitem.  I've done about five different variants of this, and I'm sure it's something dumb I'm doing, but I can't seem to get past the most basic example here.

I've also tried modifying the workitem to make the amount be an integer rather than a string, and that failed as well.

Any help is appreciated.  Thanks tons,

-Josh Adams

John Mettraux

unread,
May 29, 2012, 4:36:52 PM5/29/12
to openwfe...@googlegroups.com

On Tue, May 29, 2012 at 05:38:19AM -0700, Josh Adams wrote:
> Hi everyone,

Hello Josh,

welcome to ruote's mailing list.

> So I'm brand new to ruote. I've built ad-hoc workflow-lite systems for my
> projects in the past (essentially state machines, implicit workflow spread
> across multiple models, and background workers pushing state). Obviously
> this is sub-optimal, and declarative workflow seems much nicer.

Nice description, I'll steal it one day ;-)

Those systems are robust, declarative workflows may be a bit brittle. We have
to learn all the tools.

> Ruote.process_definition :name => 'if_example', :revision => '0.1' do
> sequence do
> requestor :task => 'request_business_trip_application_form'
> participant 'hr'
> participant 'ceo', :if => '${f:amount} > 25000'
> end
> end
>
> I'm using ruote-on-rails to play around with the pdefs, and so I plug that
> sucker in and add a form for the task that has an 'amount' field. I fill
> it in with 30000. When the 'hr' participant picks it up, the workitem
> looks like this:
>
> {"fields":{"amount":"30000"},"params":{"hr":null},"dispatched_at":"2012-05-29
> 12:36:52.202034 UTC"}
>
> However, when I advance the workflow it's just done - the CEO doesn't get
> handed the workitem. I've done about five different variants of this, and
> I'm sure it's something dumb I'm doing, but I can't seem to get past the
> most basic example here.
>
> I've also tried modifying the workitem to make the amount be an integer
> rather than a string, and that failed as well.

I have the impression that you're using ruote 2.2.0.

I've played with

https://gist.github.com/2830509

---8<---
require 'ruote'

$dboard = Ruote::Dashboard.new(Ruote::Worker.new(Ruote::HashStorage.new))
$dboard.noisy = true

pdef = Ruote.define do
requestor :task => 'request_business_trip_application_form'
participant 'hr'
participant 'ceo', :if => '${f:amount} > 25000'
end

class MyParticipant
include Ruote::LocalParticipant
def on_workitem
puts "+++ #{workitem.participant_name} +++"
reply
end
end

$dboard.register do
catchall MyParticipant
end

print 'amount? '
amount = gets.strip

wfid = $dboard.launch(pdef, 'amount' => amount)
$dboard.wait_for(wfid)
--->8---

with ruote 2.3.0 and it worked. 2.3.0 (master branch pulled in via Bundler)
features improved condition evulation. I guess you're on 2.2.0 and the :if
gets poorly evaluated.


I hope this will help, cheers,

--
John Mettraux - http://lambda.io/jmettraux

Josh Adams

unread,
May 30, 2012, 11:46:35 AM5/30/12
to openwfe...@googlegroups.com
welcome to ruote's mailing list.

Thanks :)  For what it's worth, for everyone else, my problem ended up being that the field was actually "field.amount" due to some stupidity on my part - once I got past that, ruote itself worked precisely as I'd expected.

Cheers,

-Josh
Reply all
Reply to author
Forward
0 new messages