On Mon, Jun 27, 2011 at 06:58:29AM -0700, jpgilman wrote: > > I have the user entering an expiration date. I need to fire a > notification participant at various intervals around that date (.e.g > 60 days before, 30 days before, 5 days after, etc.) > > I've tried a bunch of things but am not putting the pieces together. > I've looked in the documentation but couldn't find a sample that > matched up to my use case. I tried using dollar notation to calculate > the date, but that failed.
Hello John, here is a suggestion (https://gist.github.com/1048959) : ---8<--- Ruote.process_definition do user :task => 'specify expiration date' compute_notifications :scheme => [ -60, -30, 5, 10 ] concurrence :count => 1 do # # Since :lose is set to true for the iterator, it will never reply to # the concurrence. The concurrence is set to resume after 1 branch replied. # Thus when do_the_job replies, the flow will resume (with the iterator # being cancelled. do_the_job iterator :on => 'f:notifications', :to => 'f:wait', :lose => true do sequence do wait '${wait}' notification end end end end # somewhere else ... class ComputeNotifications include Ruote::LocalParticipant def consume(workitem) exdate = Time.parse(workitem.field['expiration_date']) scheme = workitem.params['scheme'] || [ -28, -7, 0, 7 ] prev = scheme.first workitem.fields['notifications'] = [ exdate + scheme.shift * 24 * 3600 ] + scheme.collect { |delta| pr, prev = prev, delta; "#{(pr - delta).abs}d" } reply_to_engine(workitem) end end --->8--- 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
