[jboss-user] [jBPM] - How to get list of tasks for all users and processes

Maurice de Chateau do-not-reply at jboss.com
Mon May 17 05:05:25 EDT 2010

Maurice de Chateau [http://community.jboss.org/people/MohReece] replied to the discussion

"How to get list of tasks for all users and processes"

To view the discussion, visit: http://community.jboss.org/message/543347#543347

Hi Kiran,

When you're looking for tasks (I'm guessing you're interested in TaskInstances instead of their definitions here) you have the possibility to use the jBPM API, but because in this API the tasks are mostly referred to through the process instance or the user they correspond to, that can be a bit cumbersome. You'd get something like the following:

JbpmContext jbpmCtx = JbpmConfiguration.getInstance().createJbpmContext();
        try {
            List<TaskInstance> allTasks = new ArrayList<TaskInstance>();
            List<ProcessDefinition> pds = jbpmCtx.getGraphSession().findAllProcessDefinitions();
            for (ProcessDefinition pd : pds) {
                List<ProcessInstance> pis = jbpmCtx.getGraphSession().findProcessInstances(pd.getId());
                for (ProcessInstance pi : pis) {
                    List<TaskInstance> tis = jbpmCtx.getTaskMgmtSession().findTaskInstancesByProcessInstance(pi);

            // allTasks now contains all available tasks...

        } finally {

It's probably easier to try to get the list of task instances more directly from the jBPM database, much like the reply above indicates. But if you're not keen on using SQL (or HQL) in you're queries, something like the following would do the trick as well:

List<TaskInstance> allTasks = jbpmCtx.getSession().createCriteria(TaskInstance.class).list();

Hope this helps...



Reply to this message by going to Community

Start a new discussion in jBPM at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100517/ec068387/attachment-0001.html 

More information about the jboss-user mailing list