cancel
Showing results for 
Search instead for 
Did you mean: 

List tasks by list of key : missing feature?

bam
Champ in-the-making
Champ in-the-making
Hello,

I would like to do one simple query to retrieve a list of tasks : "Please give me tasks A and B".
I don't want to use the task name, as it's written in human-readable French and not a technical ID in my processes.

I want to use the task definition key, which is my technical id, that I can use in my Java code and for i18n.

I was happy to find taskNameIn(<list>) on TaskQuery, but can't find anything other than taskDefinitionKey(<single_id>).

Is there any other way to list them?
Another attribute that I could use?

Could you plan to add this useful function to the engine API ?

Thank you,
Regards.
4 REPLIES 4

jbarrez
Star Contributor
Star Contributor
/**
   * Only select tasks with the given taskDefinitionKey.
   * The task definition key is the id of the userTask:
   * &lt;userTask id="xxx" …/&gt;
   **/
  T taskDefinitionKey(String key);
 

Use the or() function to combine them if you need A and B.

bam
Champ in-the-making
Champ in-the-making
Hello Joram,

Thanks for you reply. I know taskDefinitionKey(<id>) exist, like explained in my post, but it's not working with a list of values like taskNameIn(<list>) does.

Using the or() predicate would result in something like this:

taskQuery = taskQuery.or();
for (String taskName : taskNames) {
taskQuery = taskQuery.taskDefinitionKey(taskName);
}
taskQuery = taskQuery.endOr();

Instead of simply calling

taskQuery = taskQuery.taskDefinitionKeyIn(taskNames);

I think that should be one useful function to add to the engine. Don't you?

Thanks,
Regards.

bam
Champ in-the-making
Champ in-the-making
Actually, my previous code with the or() doesn't work. If you look at the or() implementation, there's only one "key" variable that is overridden each time you can the taskDefinitionKey()…

jbarrez
Star Contributor
Star Contributor
That is indeed correct. Im not sure about the query, I havent seen the use case before where you are only interested in tasks using it;s BPMN id … typically people have inboxes of various tasks instead only specific tasks.

But if you think it is a good feature, you are always more than welcome to provide a pull request for it.