On Tue, Nov 02, 2010 at 04:31:39AM -0700, Daniel N wrote: > > I'm guessing here... I'd really appreciate some feedback on how to go > about something like this.
Hello Daniel, I've a gist ( http://gist.github.com/659879 ) as variant for you : ---8<--- # process definition pdef = Ruote.process_definition 'incidents' do sequence do # before that ... clerk :task => 'record witnesses' prepare_witness_report_reception receive_witness_reports # and then ... end end # custom participant class PrepareReportReception include LocalParticipant def consume(workitem) workitem.fields['witnesses'].each do |witness| # a) create report resource (db), which contain incident_id and wfid Report.new(workitem.fields['incident_id'], witness) # b) fire email to witness #... end reply_to_engine(workitem) # let the flow resume end def cancel(fei, flavour) # a) nuke report resource in db # b) there's no b) since you can't cancel an STMP despatch end end # app/controller/witness_report.rb class WitnessReportController def update report = Report.find(params[:id]) # update report ... if report.all_the_reports_for_that_case_have_been_received # unleash the flow workitem = RuoteKit.engine.storage_participant.by_wfid(report.wfid).first # we know there is 1! workitem for this process instance workitem.fields['report_count'] = report.all_the_reports_count # some additional info before proceeding RuoteKit.engine.storage_participant.proceed(workitem) # the flow will resume after 'receive_witness_reports' end end end # participant registration, somewhere like config/initializers/ruote.rb RuoteKit.engine.register do prepare_witness_report_reception PrepareReportReception catchall # which covers clerk and receive_witness_reports end --->8--- This gist has 3 participants, 'clerk' and 'receive_witness_reports' are covered by 'catchall' while 'prepare_witness_report_reception' is a custom participant. 'clerk' is meant to let its workitem by accessed by the clerks in your organizations. I guess you have a form for registering witness info and email. ---8<--- class ClerkWorklistController def index @workitems = RuoteKit.engine.storage_participant.by_participant_name('clerk') end end --->8--- 'receive_witness_reports' doesn't need any controller / worklist / whatever, it's only a temporary storage for workitems. Its workitems are flushed by the WitnessReportController#update method. The PrepareReportReception creates the report objects/resources (1 per witness) and then fires an email to each participant. The report model has some methods to know when the receiving job is over. One thing to take care of is the case wherer not all the witnesses have replied but the flow should continue anyway. Maybe placing a timeout on "receive_witness_reports" and making the tail of the flow aware of such cases... Maybe for the next iteration of this discussion. It's one way of doing it. I hope it's not too cryptic. Questions are welcome, cheers, -- 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
