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.addAll(tis);
}
}
// allTasks now contains all available tasks...
} finally {
jbpmCtx.close();
}
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...
Regards,
Maurice
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/543347#543347]
Start a new discussion in jBPM at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]