cancel
Showing results for 
Search instead for 
Did you mean: 

retrieving task with variables values using single api call

ganeshr
Champ in-the-making
Champ in-the-making
is it possible to get all tasks with variables names and values using TaskService
Using the following service able to retrieve tasks but each task does not contain complete information like variables and its values.
     processEngine.getTaskService.createTaskQuery().list();

Would like to know if there is any single service call, using that I should retrieve list of tasks with variables and values.
5 REPLIES 5

frederikherema1
Star Contributor
Star Contributor
There is no single API call that can achieve this. You'll have to query the tasks first, and for each task, fetch the variables separately.

ganeshr
Champ in-the-making
Champ in-the-making
but every of operation above goes to database. If I have list of 100 tasks I'll make 100 queries to DB. I don't want to use this approach. Is there any other way to get task variables?
can it be possible to customize the call?

frederikherema1
Star Contributor
Star Contributor
In the activiti-api, tasks are considered as light-weight objects, spawned by a process (or created by yourself). It was an explicit choice to keep them lightweight and excluding the properties all together. The NativeQuery won't work for you either because the TaskEntity doesn't contain any mappings for the properties.

If you want this in a single query, you'll have to write your own SQL and new mapping in iBatis OR alter the Task-entity and Task.xml mapping file, to include the variables…

ganeshr
Champ in-the-making
Champ in-the-making
can you please share the path where these files are existing. Task-entity and Task.xml mapping files.
And how complexity is involved in changing this mapping files?

frederikherema1
Star Contributor
Star Contributor
modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/Task.xml and modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/TaskEntity.java.

This will involve copying parts from the VariableInstance.xml mapping (or referencing result-mappings and queries from that file) in order to make the Task-queries in Task.xml, join in the variables as well… The other thing to do is to alter the result-mapping (resultMap id="taskResultMap") and TaskEntity, to add a map of variables to it.

More info on altering the myBatis mappings, can be found on google and myBatis docs, as this is not something Activiti-specific…