views:

14

answers:

1

Hi all, For every task node in a process definition, i want to dynamically (programtically) add a self transition (from and to transition to the same node) to each task node. Can you tell me can this be done as part of JBPM v3.2 and if there are any issues that can crop up if i choose this approach ?

A: 

You don't need to do this dinamically. You can do it straight into your workflow.

What do you mean dinamically? When you are deploying the workflow or while you are already processing it?

If it is while deploying, before you call the deployProcessDefinition method, you can take the xml it will deploy and edit it before making the deploy.

If it is while you are already processing, I can think of 2 possible options:

  1. If you want a new instance of the task to be created when the self transition is taken, you will need to make some hacks in the database to change the already deployed workflow;
  2. If it is ok to use the same instance of the task, you can change the Transition.take method to don't propagate the event when you take the transition to the same task.

For both options, you should pay atention for problems with the ProcessLog. I don't know if JBPM will have a problem for writing the logs for transitions that don't really exist.

Rodrigo
@Rodrigo,Adding dynamically means once i create the process instance, i want to add a self transition to all nodes progrmatically.So in your words, i want to add a transition when i m processing it.Do you know the API that JBPM provides to add a new transition to a task node ( programatically).
Cshah
You can't do it like that. When you deploy the process definition, it creates all the steps of it in the database. Later, when you create a process instance, the steps are already configured in the database, and you can't change it. What you can do is when you deploy the process definition, before you call the deployProcessDefinition, you take the xml file and edit it programatically to add your transitions.
Rodrigo