Hi John:
 I am trying to use all method to get workitems for a particular 
participant.
 I am not sure if it is a problem, could you please take a second to look 
at the following code?

   pdef = Ruote.process_definition do
      sequence :on_error=>:error_handler do
        alpha :id => "alpha"
        bravo :id => "bravo"
      end
    end

    pdef2 = Ruote.process_definition do
      sequence :on_error=>:error_handler do
        alpha :id => "alpha2222"
        bravo :id => "bravo2222"
      end
    end

    @dashboard.register_participant "alpha", TimeoutParticipant
    @dashboard.register_participant "bravo", TimeoutParticipant
    @dashboard.register_participant :error_handler do |item|
      puts "[error_handler]"
      puts "class:#{item.error["class"]} message:#{item.error["message"]}"
    end

    #launch process1 and process2
    [email protected](pdef)
    [email protected](pdef2)
    sleep(1)
    
    *#step1*
    puts "[all] for alpha"
    puts @dashboard.participant("alpha").all.inspect
    
    #finish work for process1
    @dashboard.process(wfid1).current_work_items.each{|wi| 
@dashboard.storage_participant.proceed(wi)}
    sleep(1)
   
   * #step2*
    puts "[after proceeding all] for alpha"
    puts @dashboard.participant("alpha").all.inspect


As you suggested, I am using all to find all the available workitems for 
alpha. In  step1(see comment), it correctly gives me two workitems which 
have id of "alpha" and "alpha222"

Then I proceed the process1. So after that, process1 should be at bravo 
step. I expect that the alpha participant should have only 1 workitem that 
is in process2(since the item in process1 is already proceeded).
But in step2, I got 2 workitems which are alpha222 and bravo. How does 
bravo become the workitem for alpha?

Is it a issue or do I use it in a wrong way?

On Tuesday, June 19, 2012 2:38:04 PM UTC-4, John Mettraux wrote:
>
>
> On Tue, Jun 19, 2012 at 11:12:36AM -0700, ddeng wrote: 
> > 
> > I found my self always using some duplicated code to access current work 
> > item in Ruote. So I wrote a simple extension that includes a method for 
> > quick accessing the current workitems given a process positions: 
> > 
> > Could you please have a look at the code and see if I am reinventing the 
> > wheels? 
> > 
> > class Ruote::ProcessStatus 
> >   def current_work_items 
> >     current_positions=self.position 
> >     items=current_positions.collect { |pos| 
> >       self.stored_workitems.find { |wi| 
> >         #puts "#{wi.fei.sid} <> #{pos[0]}" 
> >         wi.fei.sid==pos[0] } 
> >     } 
> >     return items 
> >   end 
> > end 
>
> Hello, 
>
> the "normal" use case goes like "hey I want to know what workitems are 
> available for my users", and it's usually done via something like 
>
>   workitems = dashboard.storage_participant.all 
>
> As a human participant, you don't want to list process instances and then 
> list workitems. You directly list the work that's for you, whatever the 
> process. 
>
> If, for whatever reason, you feel like listing all the processes, then 
> Ruote::ProcessStatus#store_workitems (which you use) should return the 
> same 
> list (probably different order) as your 
> Ruote::ProcessStatus#current_work_items. I don't understand why you come 
> up 
> with this. 
>
>
> Best regards, 
>
> -- 
> John Mettraux - http://lambda.io/jmettraux 
>
>

-- 
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

Reply via email to