Allow the name of a list to be specified as a "namefilter" param in GET /arbitrary/resources/search. Any names in the list will be included in the search (same as if they were specified manually via &name=).

This commit is contained in:
CalDescent 2023-04-14 17:44:06 +01:00
parent 20893879ca
commit ea7a2224d3

View File

@ -172,6 +172,7 @@ public class ArbitraryResource {
@Parameter(description = "Query (searches both name and identifier fields)") @QueryParam("query") String query,
@Parameter(description = "Identifier (searches identifier field only)") @QueryParam("identifier") String identifier,
@Parameter(description = "Name (searches name field only)") @QueryParam("name") List<String> names,
@Parameter(description = "Filter names by list (partial matches allowed)") @QueryParam("namefilter") String nameListFilter,
@Parameter(description = "Prefix only (if true, only the beginning of fields are matched)") @QueryParam("prefix") Boolean prefixOnly,
@Parameter(description = "Default resources (without identifiers) only") @QueryParam("default") Boolean defaultResource,
@Parameter(ref = "limit") @QueryParam("limit") Integer limit,
@ -185,6 +186,11 @@ public class ArbitraryResource {
boolean defaultRes = Boolean.TRUE.equals(defaultResource);
boolean usePrefixOnly = Boolean.TRUE.equals(prefixOnly);
if (nameListFilter != null) {
// Load names from supplied list of names
names.addAll(ResourceListManager.getInstance().getStringsInList(nameListFilter));
}
List<ArbitraryResourceInfo> resources = repository.getArbitraryRepository()
.searchArbitraryResources(service, query, identifier, names, usePrefixOnly, defaultRes, limit, offset, reverse);