cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting tasks by task variable values

ilyagalahov
Champ in-the-making
Champ in-the-making
Hello!

Is it possible to sort TaskQuery.list() results by task variable values or process variable values ?
We ought to implement it via custom ibatis mappings. Is it possible via core functionality ?

Regards, Ilya.
8 REPLIES 8

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Ilya,
TaskQuery does not support sort by variable value.

You can implement your own native queries or extend ibatis mappings.

Regards
Martin

Thanks for your answer.

Should we expect this feature in next versions of engine ?

Don't you have any mapping examples with sorting by task vars ?

Regards

Ilya

ilyagalahov
Champ in-the-making
Champ in-the-making
We are using activiti with alfresco.

To show tasks in client's ui grids with sorting and filtering we store alfresco document properties in process variables.

To allow sorting and filtering in ui grids, we implemented custom ibatis mappings.

But the problem is in that we should store document properties in any process and subprocess, and tables ACT_RU_VARIABLE and ACT_HI_VARINST become very big. With every BP action created about 300 variables.

When we tried to load document properties from alfresco node itself, it was very slowly Smiley Sad

We tried to store variables in one, "main" process by document, but with this approach mapping became very complex and unmaintainable.

Any ideas will be helpful.

Ilya.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,
Ideas:
  • do not store all variables in history tables (implement your own listener and listen only to relevant changes),
  • optimize DB,
  • not store document variables in the process
Regards
Martin

Hello Martin!

Thanks for your answer.

– >do not store all variables in history tables (implement your own listener and listen only to relevant changes)

     Does it mean,  we need to turn off history (history level = none) and write to this tables on our own ?

     Where can I read about it ?

Regards

Ilya.

jbarrez
Star Contributor
Star Contributor
Storing that many variables for each process instance is not a good idea, it'll lead to some poor performance.
I'd guess optimizing the db + query is the first thing to try.

Turning off history and listen to events, as Martin suggests, is surely an option, but a heavy one. I would first try to optimize the process, try to store way less data and try to optimize the query (indices maybe?)

cacaponkayaker
Champ in-the-making
Champ in-the-making
We are trying to do the same thing: show tasks in client's ui grids with sorting and filtering.  If you don't suggest that we store the values for the grid in user variables, where should we put them?

For historic variables we implemented CustomHistoryManager which extends HistoryManager and then mocked unnecessary methods. You could override History manager in "activitiProcessEngineConfiguration" bean in "customSessionFactories" property.
So now we can store only necessary tasks and variables in historic tables. We do not store information about processes.