use of org.springframework.data.mongodb.core.aggregation.PrefixingDelegatingAggregationOperationContext in project spring-data-mongodb by spring-projects.
the class ChangeStreamTask method prepareFilter.
List<Document> prepareFilter(MongoTemplate template, ChangeStreamOptions options) {
if (!options.getFilter().isPresent()) {
return Collections.emptyList();
}
Object filter = options.getFilter().get();
if (filter instanceof Aggregation) {
Aggregation agg = (Aggregation) filter;
AggregationOperationContext context = agg instanceof TypedAggregation ? new TypeBasedAggregationOperationContext(((TypedAggregation<?>) agg).getInputType(), template.getConverter().getMappingContext(), queryMapper) : Aggregation.DEFAULT_CONTEXT;
return agg.toPipeline(new PrefixingDelegatingAggregationOperationContext(context, "fullDocument", blacklist));
} else if (filter instanceof List) {
return (List<Document>) filter;
} else {
throw new IllegalArgumentException("ChangeStreamRequestOptions.filter mut be either an Aggregation or a plain list of Documents");
}
}
use of org.springframework.data.mongodb.core.aggregation.PrefixingDelegatingAggregationOperationContext in project spring-data-mongodb by spring-projects.
the class ReactiveMongoTemplate method changeStream.
/*
* (non-Javadoc)
* @see org.springframework.data.mongodb.core.ReactiveMongoOperations#tail(org.springframework.data.mongodb.core.aggregation.Aggregation, java.lang.Class, org.springframework.data.mongodb.core.ChangeStreamOptions, java.lang.String)
*/
@Override
public <T> Flux<ChangeStreamEvent<T>> changeStream(@Nullable Aggregation filter, Class<T> resultType, ChangeStreamOptions options, String collectionName) {
Assert.notNull(resultType, "Result type must not be null!");
Assert.notNull(options, "ChangeStreamOptions must not be null!");
Assert.hasText(collectionName, "Collection name must not be null or empty!");
if (filter == null) {
return changeStream(Collections.emptyList(), resultType, options, collectionName);
}
AggregationOperationContext context = filter instanceof TypedAggregation ? new TypeBasedAggregationOperationContext(((TypedAggregation) filter).getInputType(), mappingContext, queryMapper) : Aggregation.DEFAULT_CONTEXT;
return changeStream(filter.toPipeline(new PrefixingDelegatingAggregationOperationContext(context, "fullDocument", Arrays.asList("operationType", "fullDocument", "documentKey", "updateDescription", "ns"))), resultType, options, collectionName);
}
Aggregations