On Thu, Jul 21, 2011 at 09:32:25AM -0700, Nando Sola wrote: > > I'm working on a proof of concept, where a human proceeds a parent > "fill_form" participant with a special field set to "true". In this > case, a new child "fill_form" is fired in parallel, allowing our human > to complete both forms (parent and child) at the same time. > > The catch here, is that the process can only be finished, once the > parent and all its children forms are filled. > > Here's my sketch: > > (...) > > When new children forms are launched, the "child" process variable is > incremented and multiple workitems are handed to the user. Just as > expected. > > The problem seems to be, that the variable is never decremented, so > the cursor is never broken. > > Is this an expected behaviour with :forget and process variables? Am I > misunderstanding its scope? IMHO, process vars should always be > accesible. Or maybe I'm just taking the wrong approach to this > pattern?
Hello Nando, when forgetting a branch, that branch becomes independent and its variable lookup ends at its own, new, root. So it's intended. Your point of view makes sense, maybe it's time we rethink the forget/lose concepts. For now when forgetting, I copy all the variables at the new root. OK, that's work. For now, I would suggest : (https://gist.github.com/1099025) ---8<--- require 'rubygems' require 'ruote' engine = Ruote::Engine.new(Ruote::Worker.new(Ruote::HashStorage.new)) pdef = Ruote.define do citerator :on => 'parent', :to_var => 'type', :merge => 'highest' do cursor do fill :form => '${v:type}' sequence :if => '${launch}' do add_branch 'child' rewind end end end end $children = 4 class FillParticipant include Ruote::LocalParticipant def consume(workitem) p "in for #{workitem.params['form']}" workitem.fields['form'] = workitem.params['form'] # just to know which branch won at the end if workitem.params['form'] == 'parent' workitem.fields['launch'] = ($children > 0) $children = $children - 1 else workitem.fields['launch'] = false end reply(workitem) end end engine.register do fill FillParticipant end #engine.noisy = true wfid = engine.launch(pdef) r = engine.wait_for(wfid) puts; p r['workitem']['fields'] # to know which branch won at the end --->8--- It's not exactly the same logic you intended, but it's very close. It leverages http://ruote.rubyforge.org/exp/concurrent_iterator.html and http://ruote.rubyforge.org/exp/add_branches.html The merge on the "citerator" is set to "highest" so that the workitem of the "parent" branch wins. I hope this is a valid answer, 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
