Skip to content

Commit

Permalink
Merge branch 'release-10.0.0' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
vhemery committed Feb 29, 2024
2 parents 07d461d + 89e4de6 commit c51dea8
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 c51dea8

Please sign in to comment.