use of nl.knaw.huygens.timbuctoo.v5.graphql.datafetchers.dto.ConfiguredFilter in project timbuctoo by HuygensING.
the class PaginationArgumentsHelper method getPaginationArguments.
public PaginationArguments getPaginationArguments(DataFetchingEnvironment environment) {
String cursor = "";
int count = DEFAULT_COUNT;
if (environment.containsArgument("cursor") && (environment.getArgument("cursor") instanceof String)) {
cursor = new String(DECODER.decode((String) environment.getArgument("cursor")), Charsets.UTF_8);
}
if (environment.containsArgument("count")) {
count = environment.getArgument("count");
}
ConfiguredFilter filter = null;
for (Map.Entry<String, CollectionFilter> entry : collectionFilters.entrySet()) {
if (environment.containsArgument(entry.getKey())) {
String searchQuery = environment.getArgument(entry.getKey());
String cursorArg = cursor;
int countArg = count;
String dataSetId = ((DatabaseResult) environment.getSource()).getDataSet().getMetadata().getCombinedId();
String fieldName = environment.getFieldDefinition().getName();
filter = () -> entry.getValue().query(dataSetId, fieldName, searchQuery, cursorArg, countArg);
break;
}
}
return PaginationArguments.create(count, cursor, Optional.ofNullable(filter));
}
Aggregations