Search and list elements of Bonita Engine
Learn how to use search and list methods of the Bonita Engine APIs.
List elements
The following example shows how to use a list method to see the archived activity instances:
List<ArchivedActivityInstance> archivedActivityInstances =
TenantAPIAccessor.getProcessAPI(session).getArchivedActivityInstances(instance.getId(), 0, 100, ActivityInstanceCriterion.NAME_ASC);
The advantage of using list is that it is a single query, so has better performance. It is also simpler to code.
Search elements
The following example shows how to use a search method to see the archived activity instances.
SearchOptionsBuilder searchBuilder = new SearchOptionsBuilder(0, 100);
searchBuilder.sort(ArchivedActivityInstanceSearchDescriptor.NAME, Order.ASC);
SearchResult<ArchivedActivityInstance> archActivitResult = TenantAPIAccessor.getProcessAPI(session).searchArchivedActivities(searchBuilder.done());
The advantage of using search is that you can specify filters to get a more precise set of results, which can be more efficient. Several filters can be added. By default, an implicit AND clause is added when several filters are added. If the need is different,
you can have an OR clause, of more complex clauses. See SearchOptionsBuilder methods for filtering that matches your needs.
The following example is a more precise search for archived activity instances, using a filter:
SearchOptionsBuilder searchBuilder = new SearchOptionsBuilder(0, 100);
// implicit AND clause between the following two filters:
searchBuilder.filter(ArchivedActivityInstanceSearchDescriptor.ROOT_PROCESS_INSTANCE_ID, processInstance.getId());
searchBuilder.filter(ArchivedActivityInstanceSearchDescriptor.ASSIGNEE_ID, myUser.getId());
searchBuilder.sort(ArchivedActivityInstanceSearchDescriptor.NAME, Order.ASC);
SearchResult<ArchivedActivityInstance> archActivitResult = TenantAPIAccessor.getProcessAPI(session).searchArchivedActivities(searchBuilder.done());
Below is another example of a more complex search filtering.
SearchOptionsBuilder sob = new SearchOptionsBuilder(0, 10);
sob.filter(HumanTaskInstanceSearchDescriptor.PROCESS_INSTANCE_ID, myProcessInstance.getId());
sob.or();
sob.differentFrom</b>(HumanTaskInstanceSearchDescriptor.ASSIGNEE_ID, myUser.getId());
Case sensitivity
All Search requests done using search terms are case-insensitive but filtering IS case-sensitive.
Phrase in database | Search string | Matches |
---|---|---|
Hello Charles |
|
yes |
Hello Charles |
|
no |
Hello Charles |
|
yes |
Hello Charles |
|
yes |
Like-based search
Search uses a "like-based" algorithm for searching, and finds matches where the search string occurs anywhere in a phrase or a word. As of 2024.1, "Word-based" and βStart withβ search algorithms cannot be configured anymore as they are obsolete.β
When you want to search on several terms, separate them with a space β β character to perform a search on all terms (OR). There is no way to search for the space β β character.