On Mon, Jun 25, 2012 at 12:28:37PM +0200, Mario Camou wrote:
>
> I have an _if in a workflow where I need to check the values of a couple of
> fields and also call a participant. This would be the pseudocode:
>
> if ( ! (f:slot.blocked or f:slot.status == BLOCKED) or check_permissions) do
> // whatever
> end
>
> Where slot.blocked and slot.status are workitem fields and
> check_permissions is a participant which gets some data from the workitem,
> accesses a REST service and returns true if the user is allowed to perform
> the action. What I currently have is this:
>
> (snip)
Hello Mario,
I tend to do it this way:
---8<---
pdef = Ruote.define do
#set 'blocked' => false
set 'permitted' => false
check_status 'blocked'
check_permissions if '${blocked}'
# not blocked or permitted
_if 'not ${blocked} or ${permitted}' do
# do it
end
#
# or
#
do_it :if => 'not ${blocked} or ${permitted}'
end
class StatusChecker
include Ruote::LocalParticipant
def on_workitem
status_name = param_text()
workitem[status_name] =
workitem["slot.#{status_name}"] ||
workitem["slot.status"] == status_name
reply
end
def on_cancel
# nothing to do
end
end
class PermissionChecker
include Ruote::LocalParticipant
def on_workitem
workitem['permitted'] = do_that_rest_call
reply
end
def on_cancel
# nothing to do
end
end
ruote.register 'check_status', StatusChecker
ruote.register 'check_permissions', PermissionChecker
--->8---
I think it reads better than nested ifs. I try to reuse the participants for
status checking and permission checking across the process portfolio.
I hope it helps.
--
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