Agree with Ronald. That was what I also thought would be the case. Hence the question,
The fact that jbpm now automatically adds an outcome to the list is quite
counter-intuitive actually as that list of outcomes is what we present to the user as
possible actions he can take as part of completing the task. So by choosing the action we
are saying that the completion is implied. If an action is not chosen then we need to
implicitly select an action/transition and then complete it. And that is being handled as
expected.
Let me see if I can make a point with an example:
Here's the processdefinition:
| <?xml version="1.0" encoding="UTF-8"?>
|
| <process key="CompletedOutcome"
| name="CompletedOutcome"
|
xmlns="http://jbpm.org/4.0/jpdl">
|
| <start g="20,20,48,48">
| <transition to="Please Pick A Designation"/>
| </start>
|
| <task name="Please Pick A Designation"
g="96,16,127,52">
| <assignment-handler
| class="org.jbpm.examples.task.assignmenthandler.AssignTask">
| <field name="assignee">
| <string value="shekharv"/>
| </field>
| </assignment-handler>
| <transition name="Manager" to="Manager"/>
| <transition name="Programmer" to="Manager"/>
| </task>
|
| <end name="Manager" g="255,16,88,52"/>
| <end name="Manager" g="255,16,88,75"/>
|
| </process>
|
Here's the unit test: Am trying to mimic how a client application would interact with
jbpm.
| public void test_task_has_correct_outcome() {
|
| ProcessInstance pi =
|
executionService.startProcessInstanceByKey("CompletedOutcome");
|
| List<Task> tasks = taskService.findPersonalTasks("shekharv");
|
| System.out.println("shekharv has to complete the following task:"
| + tasks.get(0).getName());
|
| Set<String> outcomes = taskService
| .getOutcomes(tasks.get(0).getDbid());
|
| System.out.println("Task \"" + tasks.get(0).getName()
| + "\" has the following possible outcomes:");
|
| assertTrue(outcomes.contains("Stage 1"));
| assertTrue(outcomes.contains("Stage 2"));
| //assertTrue(outcomes.size() == 2);
|
| for (String outcome : outcomes) {
| System.out.println(outcome);
| }
|
| taskService.completeTask(tasks.get(0).getDbid()
| , "Stage 1");
|
| }
|
output of the test case:
| shekharv has to complete the following task:Please Pick A Designation
| Task "Please Pick A Designation" has the following possible outcomes:
| Manager
| Programmer
| completed
|
So the user will now see an option of 'completed', and depending on how the
transitions are ordered in that task node it might result in either the
"Manager" activity selected or the "Programmer". On the lighter end,
that is scary :)
In the context of this workflow the transition 'completed' does not even make
sense.
Another example is, what if I have workflows and the actions depicted in a non-english
language, people might not even understand what 'completed' means.
So if jbpm adds that transition by default the client applications have to filter it out,
they will not have any other option but to.
sorry about the length of the post, it just grew on me!
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4241311#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...