suggestion: add current_workitems methods

29 views
Skip to first unread message

ddeng

unread,
Jun 19, 2012, 2:12:36 PM6/19/12
to openwfe...@googlegroups.com
Hi Guys:
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

Any comment is helpful
Thanks!

John Mettraux

unread,
Jun 19, 2012, 2:38:04 PM6/19/12
to openwfe...@googlegroups.com
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

ddeng

unread,
Jun 19, 2012, 2:47:09 PM6/19/12
to openwfe...@googlegroups.com
Thanks John
I came up with this when I was looking through the source code of ruote-kit

It uses similar approach when it displays the current workitems for each process, and the if a user want to work on a process, the user can click on that item and proceed it.

In this case, the user needs to know the current workitems only for a particular process. Because the workitems may need to prioritized based on which process it's in and  on the requirement of the user.

ddeng

unread,
Jun 19, 2012, 4:17:38 PM6/19/12
to openwfe...@googlegroups.com
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
    wfid1=@dashboard.launch(pdef)
    wfid2=@dashboard.launch(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:

John Mettraux

unread,
Jun 19, 2012, 4:26:19 PM6/19/12
to openwfe...@googlegroups.com

On Tue, Jun 19, 2012 at 01:17:38PM -0700, ddeng wrote:
>
> (...)
>
> 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?

Hello, it's an issue (evoked in the thread with Marco at

https://groups.google.com/d/topic/openwferu-users/OyqAsofSt-Q/discussion

)

I have to rework the StorageParticipant.

As a workaround, you can use the by_participant method of the storage
participant, so that you list only the workitems for a given participant
name.

John Mettraux

unread,
Jun 19, 2012, 5:13:31 PM6/19/12
to openwfe...@googlegroups.com
2012/6/20 John Mettraux <jmet...@gmail.com>:
>
> On Tue, Jun 19, 2012 at 01:17:38PM -0700, ddeng wrote:
>>
>> (...)
>>
>> 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?
>
> Hello, it's an issue (evoked in the thread with Marco at
>
>  https://groups.google.com/d/topic/openwferu-users/OyqAsofSt-Q/discussion

Hello Deng,

added record for this issue at : https://github.com/jmettraux/ruote/issues/51


Many thanks,

--
John Mettraux   -   http://lambda.io/processi
Reply all
Reply to author
Forward
0 new messages