Wow... Thanks so much for the insight John :D Of course though, I do have a few questions about it ;) I'll go inline:
On 3 November 2010 03:21, John Mettraux <[email protected]> wrote: > > 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. > In the prepare_witness_report_reception (and the WitnessReportController#update) you're saying that there is only one wfid, and in the simple case we've got above I can wrap my head around that part. What about in the case where there are concurrent branches of the workflow? For example: pdef = Ruote.process_definition 'incidents' do concurrence do # Branch 1 sequence do # before that ... clerk :task => 'record witnesses' prepare_witness_report_reception receive_witness_reports # and then ... end # Branch 2 sequence do # before that ... clerk :task => 'record people involved' prepare_involvement_report_reception receive_involvement_reports # and then ... end end end In this case, we could be in either branch, with a similar setup in each branch. I can see how this can work when we're creating db records in the prepare_*_report_reception participant, since we're saving the wfid right there. Lets suppose that the object operated on in the db is used by many things, is there a way to find the relevant wfid by querying the storage participant? Are there any other cases where there would be multiple wfid's? Thanks heaps for your feedback John. Daniel > > 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]<openwferu-users%[email protected]> > more options : http://groups.google.com/group/openwferu-users?hl=en -- 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
