cancel
Showing results for 
Search instead for 
Did you mean: 

WorkflowService and SortOrder

vincent-kali
Star Contributor
Star Contributor

Dear all,

I'm using the WorkflowService JAVA API to write a web service that returns a list of workflow instances matching a set of criterias. The response is displayed in an aikau page using traditional paginated list components.

I note that WorkflowService has a method "getWorflows" accepting 'maxItems' and 'skipCount' as parameters for pagination, but no 'sortBy' criteria (how to build a paginated list without being able to sort the results ?).

My questions:

- What is the default sortOrder internally used by  'getWorflows' method ?

- Is there any way to change this sortOrder using public API ?

Thanks !

5 REPLIES 5

afaust
Legendary Innovator
Legendary Innovator

Using the Alfresco API you cannot sort the workflows. You'd have to circumvent it and use Activiti API directly (which of course is not recommended by Alfresco). The default sort order is by process instance duration, so the time that the workflow has been running, but only if a maxItems higher than 0 has been specified.

Thanks axel. I'll check Activiti API.

Any plan to make this feature available in public API in a near feature ?

afaust
Legendary Innovator
Legendary Innovator

I am not an Alfresco Engineer, so I can't give a reliable / official answer. But considering that Alfresco is considering to move the workflow engine completely out of the Repository at some point in the future, I would not bet on it. It has also been this way for years, so you'd have to find an extremely influential, paying customer to convince Alfresco to change it now....

vincent-kali
Star Contributor
Star Contributor

OK, I do not have this kind of Customer on hand 🙂

vincent-kali
Star Contributor
Star Contributor

For those who are interested in, the code is here:

org.alfresco.repo.workflow.activiti.ActivitiWorkflowEngine, method 'getWorkflowsInternal'

...

 query.orderByProcessInstanceDuration().desc().listPage(skipCount, maxItems);

...

and doc: https://www.activiti.org/javadocs/org/activiti/engine/history/HistoricProcessInstanceQuery.html

But I can't see the default sortOrder where no pagination is requested... ?

And what would be the correct way to write a new implementation of WorkflowEngine with additional sorting capabilities ? (how to make it working with current wf services?)