cancel
Showing results for 
Search instead for 
Did you mean: 

How to query tasks matching more than one candidate group?

tstephen
Champ on-the-rise
Champ on-the-rise
Hi,

Anyone able to suggest a way to do this without hitting the database for each candidate group and then having to merge and sort in memory? What I had in mind was something like:
List<Task> tasks = processEngine.getTaskService().createTaskQuery().taskCandidateGroupIn("group1", "group2");

Is this a reasonable enhancement request?
regards,
Tim
6 REPLIES 6

tstephen
Champ on-the-rise
Champ on-the-rise
I realised it may not have been clear that I want an OR semantic. In other words I'd like tasks that match any of the groups supplied not all.

I had a look through the code and it looks like someone else has been thinking in this direction already as the query selectTaskByQueryCriteriaSql in the Task.xml mapping file is already written to support more than one candidate group. Anyone object to me creating a JIRA to expose this in the TaskQuery interface?

Tim

frederikherema1
Star Contributor
Star Contributor
Tim,

The multiple groups are used internally (when querying for task for which user is candidate). But I don't see a problem in exposing this in the query…

tstephen
Champ on-the-rise
Champ on-the-rise
I have created http://jira.codehaus.org/browse/ACT-796 and attached a patch to it.

Tim

nicolasfranck
Champ in-the-making
Champ in-the-making
Is this reflected anywhere in rest api?

something like:

POST query/process-instances

{
  "candidateGroupIn": ["group1","group2"]
}

cmj
Champ in-the-making
Champ in-the-making
REST support should have been implemented in 5.16 (https://jira.codehaus.org/browse/ACT-2013), but it doesn't work for me in 5.16.3. In fact I didn't manage to query for multiple candidateGroups by any method:

GET http://localhost:8080/activiti-rest/service/runtime/tasks?candidateGroup=mygroup
=> works

GET http://localhost:8080/activiti-rest/service/runtime/tasks?candidateGroups=mygroup[,…]
=> seems to ignore the filter

POST http://localhost:8080/activiti-rest/service/query/tasks
{
  "candidateGroupIn": ["group1", "group2"]
}
=> org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "candidateGroupIn" (Class org.activiti.rest.service.api.runtime.task.TaskQueryRequest), not marked as ignorable

jbarrez
Star Contributor
Star Contributor
Hmmm odd. The commit does contain a unit test for it: https://github.com/smirzai/Activiti/commit/59fcf446f11c52fe015b9fb21d61f72112642483

And it indeed seems to use the json approach for querying.  From the code, i don't see anything wrong … but obviously it's not working for you. Can you see the difference between what you are doing and what is tested in the unit test?