Skip to content

Commit

Permalink
Merge branch 'master' into release-10.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vhemery committed Feb 29, 2024
2 parents 21cd755 + c286916 commit 89e4de6
Showing 1 changed file with 34 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,28 +86,50 @@ public ItemSearchResult<ArchivedCaseItem> search(final int page, final int resul
final String orders,
final Map<String, String> filters) {

final SearchOptionsBuilder builder = buildSearchOptions(page, resultsByPage, search, orders, filters);

// Run search depending on filters passed
final SearchResult<ArchivedProcessInstance> searchResult = runSearch(filters, builder);

// Convert to ConsoleItems
return new ItemSearchResult<>(
page,
resultsByPage,
searchResult.getCount(),
convertEngineToConsoleItemsList(searchResult.getResult()));
}

protected SearchOptionsBuilder buildSearchOptions(final int page, final int resultsByPage, final String search,
final String orders, final Map<String, String> filters) {
// Build search
final SearchOptionsBuilder builder = SearchOptionsBuilderUtil.buildSearchOptions(page, resultsByPage, orders,
search);

addStringFilterToSearchBuilder(filters, builder, ArchivedCaseItem.ATTRIBUTE_PROCESS_NAME,
ProcessInstanceSearchDescriptor.NAME);
ArchivedProcessInstancesSearchDescriptor.NAME);
addLongFilterToSearchBuilder(filters, builder, ArchivedCaseItem.ATTRIBUTE_PROCESS_ID,
ProcessInstanceSearchDescriptor.PROCESS_DEFINITION_ID);
ArchivedProcessInstancesSearchDescriptor.PROCESS_DEFINITION_ID);
addLongFilterToSearchBuilder(filters, builder, ArchivedCaseItem.ATTRIBUTE_STARTED_BY_USER_ID,
ProcessInstanceSearchDescriptor.STARTED_BY);
ArchivedProcessInstancesSearchDescriptor.STARTED_BY);
addLongFilterToSearchBuilder(filters, builder, ArchivedCaseItem.ATTRIBUTE_SOURCE_OBJECT_ID,
ArchivedProcessInstancesSearchDescriptor.SOURCE_OBJECT_ID);

// Run search depending on filters passed
final SearchResult<ArchivedProcessInstance> searchResult = runSearch(filters, builder);
addCallerFilterToSearchBuilderIfNecessary(filters, builder);
return builder;
}

// Convert to ConsoleItems
return new ItemSearchResult<>(
page,
resultsByPage,
searchResult.getCount(),
convertEngineToConsoleItemsList(searchResult.getResult()));
void addCallerFilterToSearchBuilderIfNecessary(final Map<String, String> filters,
final SearchOptionsBuilder builder) {
/*
* By default we add a caller filter of -1 to avoid having sub processes.
* If caller is forced to any then we don't need to add the filter.
*/
if (!filters.containsKey(CaseItem.FILTER_CALLER)) {
builder.filter(ArchivedProcessInstancesSearchDescriptor.CALLER_ID, -1);
} else if (!"any".equalsIgnoreCase(filters.get(CaseItem.FILTER_CALLER))) {
builder.filter(ArchivedProcessInstancesSearchDescriptor.CALLER_ID,
MapUtil.getValueAsLong(filters, CaseItem.FILTER_CALLER));
}
}

// Overridden for testing
Expand Down Expand Up @@ -136,8 +158,7 @@ protected SearchResult<ArchivedProcessInstance> runSearch(final Map<String, Stri
MapUtil.getValueAsLong(filters, ArchivedCaseItem.FILTER_SUPERVISOR_ID), builder.done());
}

if (filters.containsKey(CaseItem.FILTER_CALLER)
&& "any".equalsIgnoreCase(filters.get(CaseItem.FILTER_CALLER))) {
if (filters.containsKey(CaseItem.FILTER_CALLER)) {
builder.filter(ArchivedProcessInstancesSearchDescriptor.STATE_ID,
ProcessInstanceState.COMPLETED.getId());
return processAPI.searchArchivedProcessInstancesInAllStates(builder.done());
Expand Down

0 comments on commit 89e4de6

Please sign in to comment.