On 6/20/06, Florent Robineau <[EMAIL PROTECTED]> wrote:
James Strachan a écrit :
> On 6/20/06, Florent Robineau <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> I've been trying to use the beanflow component to build a workflow, but
>> I seem not to be able to get it right. My goal is to use the beanflow
>> component to register a state (and then persist it into a database) and
>> to allow to do transitions between states (based on permissions granted
>> to the user, but this is another matter). So, so far I do not need my
>> workflow to change steps by itself since each change of state should be
>> triggered by an external event.
> OK
>
> BTW it'd be nice to have an example test program where the workflow is
> implemented using JPA (EJB 3 persistence).
Actually, I'm working with Hibernate (and Acegi for the security
aspect). I'll let you know in case I have anything worth being a
persistence example for beanflow.

Great! You using 3.x with the JPA annotations?


>> - if my enum is <startStep, middleStep, endStep>, what use is there for
>> the methods startStep(), middleStep() and endStep()? Are they
>> automatically called by the introspector when the state of the workflow
>> changes?
> Yes. So the idea is there are N steps available to be executed. When &
> how states are transitioned can be defined by external events or by
> the workflow itself (such as for loops & joins and so forth).
>
> So the general idea is to have a Java method for each step which
> executes the business logic; then the enum represents the current step
> you are on. (You can just use a String for the method name if you
> prefer).
Ok, I think I get it now. I guess I have to put the business method
within the startStep(), middleStep(), ... methods, whereas the security
aspect should be taken care of in the transition methods (for instance
with Acegi annotations).

Yet I would like to filter the access to the transition methods on two
criteria: the user permissions and the previous state. For instance,
let's say you need some role for step1 -> step2 and step2 -> step3, but
another role for step1 -> step3 directly. Thus in my example I have to
know in which state is the workflow at the time the transition method is
called so as to determine wether the user has the right to go to step3.
How could I do that? With a getCurrentStep() {return this.nextStep;}?

And thanks for your previous explanation that did part of the trick.

There's a few different ways we can do this. One of the main ideas of
BeanFlow is for the 'workflow stuff' to get out of the way and let
folks just write regular Java code for most things; so we can use
various regular Java ways to fix things.

e.g. one solution could be to override the setNextStep() to validate
with Acegi on the current and next step and use both of those values
to determine if the current security context can be used to change the
next step.

We could implement that as an interceptor applied to any workflow - or
just add a method in the Workflow base class that you could override
in a common base class you use for your workflows
--

James
-------
http://radio.weblogs.com/0112098/

Reply via email to