This content has been marked as final.
Show 5 replies
-
1. Re: Query on remaining task
kukeltje Aug 24, 2009 10:00 AM (in response to freak182)Display where? In the tasklist? Or the taskform of this task? Or.....?
-
2. Re: Query on remaining task
freak182 Aug 24, 2009 10:43 PM (in response to freak182)Hello,
Sorry, just wanted to have the list of all possible task.
Thanks a lot.
Cheers. -
3. Re: Query on remaining task
eechenjie Aug 25, 2009 3:58 AM (in response to freak182)Try TaskQuery, it may be useful to you
-
4. Re: Query on remaining task
kukeltje Aug 25, 2009 4:39 AM (in response to freak182)all non-completed but started tasks are in the console. You *might* need to use the refresh button though
-
5. Re: Query on remaining task
freak182 Aug 26, 2009 5:49 AM (in response to freak182)Hello,
Just wanted to share how I accomplished this query. although it is not, let say hibernate way or jbpm way, but it work.@SuppressWarnings("unchecked") public List<Task> findNextTasksByProcessInstance(final ProcessInstance process) { try { return (List<Task>) jbpmTemplate.execute(new JbpmCallback() { public Object doInJbpm(JbpmContext context) throws JbpmException { final long processDefId = process.getProcessDefinition().getId(); final GraphSession sess = context.getGraphSession(); final ProcessDefinition def = sess.getProcessDefinition(processDefId); final Map<String, Task> task = def.getTaskMgmtDefinition().getTasks(); final Set<String> taskSet = task.keySet(); final Session session = context.getSession(); final Query query = session.getNamedQuery("findNextTasksByProcessInstance"); query.setEntity("processInstance", process); final List<String> taskInstance = query.list(); return JbpmEngineUtils.getNextTasks(taskSet, taskInstance, task); } }); } catch (Exception e) { throw new CCTIException("No task instance get", e); } }
then subtract the activeTask from possibletask:public static List<String> getNextTasks(Set<String> possibleTask,List<String> completedTask,Map<String,Task> task) { final List<String> nextTasks = new ArrayList<String>(); final Set<String> tmpPossibleTask = new HashSet<String>(possibleTask); final List<String> tmpActiveTask = new ArrayList<String>(completedTask); final Map<String, Task> mapTask = new HashMap<String, Task>(task); for(String s : tmpActiveTask) { if ( tmpPossibleTask.contains(s) ) { tmpPossibleTask.remove(s); } } Iterator<String> ite = tmpPossibleTask.iterator(); while (ite.hasNext()) { final String string = ite.next(); final Task taskLeft = mapTask.get(string); nextTasks.add(taskLeft.getDescription()); } return nextTasks; }