Should be a basic thing to do but the API does not offer it yet. However there is a JIRA issue about it and it should be included in the upcoming 4.3-release.
Please vote here and maybe also state your use case:
I don't know if there is a workaround right now.
It is possible to get the outcomes if your current wait node is a task node. Since task node is the node for manual tasks, it might somewhat serve your purpose. This is the code for getting outcome for a task node:
If the wait node is some other wait node like "state" node, then there is no standard way to get the outcome. However you can still manage to get them, but the code may not look as clean.
//executionImpl can be obtained in multiple ways //typically it can be obtained by type casting current process instance //ExecutionImpl executionImpl = (ExecutionImpl)processInstance; executionImpl.getActivity().getOutgoingTransitions();
Thanks for clarifying this, Santanu. For the workaround you have supplied IMHO there should be a "clean" way to do it using the API. If you have not yet done it maybe you want to vote for the issue.
getOutcomes does work, but the overhead of convert states to tasks is way too much...
getOutgoingTransitions() always returns an empty list! - I think its broken - or maybe I am not using it correctly.
The requirement has changed: Now, we (me) need to supply the UI with the entire map at startup. As in: The UI starts up, and requests for the "action map" -> which is a list of who can perform which transitions.
Unfortunately, I cannot find any easy way of storing role information with the diagram itself: the who can do what part. So, for now, I am thinking of adding an "allowedRoles" to each transition element. Will have to parse the jpdl file myself to get this information out of the file, but I will have all the data in one place.
The unfortunate downside is that I won't be able to use the UI to edit the jpdl diagram...
Is there an alternative way?
I completely agree with you. The code I have given there is nothing more than a work around. There should be some method may be part of either Execution/OpenExecution interface and/or ExecutionService which does the job properly. And I have already voted for the issue.
If your requirement is to show all the tasks possible by an user even if the task is not currently active, then that will be fairly difficult to achieve. Data model of Jbpm4 does not support that. So you will have to change there. Since "Task" is the representation of manual tasks in Jbpm4, it makes sense to have actors/roles/swimlanes for tasks. Actors with something else does not make much sense.
If you are using spring, then it should be easy with getoutcomes as well.. just cache at application level using aop the following items - initial state, transition to outcome state, process definition and version