On Thu, Jul 29, 2010 at 05:00:26PM +0900, John Mettraux wrote: > > On Thu, Jul 29, 2010 at 09:46:18AM +0200, Asier wrote: > > > > I also have checked the new .position attribute and thinked about > > one petition I've made some time ago. With this addition how could I > > know if one received workitem belongs to the last step in a > > workflow? I know this isn't easy to know but it should be very > > useful because it allows to archive executed workflow instances and > > perform some batch tasks. > > > > It's only a "naive" petition because I can model it adding some > > participants at the end of the workflow like: > > > > <sequence> > > > > <participant name="alice" task="approve"/> > > <participant name="alice" task="approve"/> > > > > <!-- batch tasks --> > > <participant name="amqp-archive" qeue="admin" /> > > <participant name="amqp-statistics" qeue="admin" /> > > </sequence> > > Maybe you could take some inspiration from the method last? described in this > message : > > http://groups.google.com/group/openwferu-users/msg/dbbe512cbe38c561 > > Maybe a last_participant? method could be of value. I'll try to do it. It's > an interesting challenge.
Asier, I've been toying with : ( http://gist.github.com/497698 ) ---8<--- require 'ruote' pdef = Ruote.define do sequence do participant 'alpha' participant 'bravo' concurrence do participant 'alpha' participant 'bravo' end participant 'charly' end end #p pdef def flatten (pdef, acc=[]) if pdef.first == 'participant' acc << pdef else pdef.last.each do |child| flatten(child, acc) end end acc end flat = flatten(pdef) flat.each do |e| p e end --->8--- Which outputs : ["participant", {"alpha"=>nil}, []] ["participant", {"bravo"=>nil}, []] ["participant", {"alpha"=>nil}, []] ["participant", {"bravo"=>nil}, []] ["participant", {"charly"=>nil}, []] where "charly" is the last participant. But what about cases where : ---8<--- pdef = Ruote.define do sequence do participant 'alpha' participant 'bravo' concurrence do participant 'alpha' participant 'bravo' end participant 'charly', :if => '${something} == true' end end --->8--- Alpha or bravo or charly could be the last... And that flatten thing doesn't take into account cases like ---8<--- pdef = Ruote.define do sequence do alpha bravo concurrence do alpha bravo end charly end end --->8--- Where the alpha, bravo and co could be subprocess names... 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
