-
1. Re: How to get list of tasks for all users and processes
walterjs May 17, 2010 4:15 AM (in response to kshen)You can use an HQL query like this:
hql.append("select hpi, hti, ht ");
hql.append("from ");
hql.append(HistoryTaskInstanceImpl.class.getName());
hql.append(" as hti ");
hql.append(" left join hti.historyTask as ht ");
hql.append(" join hti.historyProcessInstance as hpi ");
appendWhereClause(" hpi.state = '" + active + "' ", hql);
-
2. Re: How to get list of tasks for all users and processes
mohreece May 17, 2010 5:24 AM (in response to kshen)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 your 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
-
3. Re: How to get list of tasks for all users and processes
kshen May 17, 2010 7:28 PM (in response to mohreece)Maurice, thanks for your reply. This is exactly what I was looking for. I will try this out and keep you posted.