use of org.springframework.data.mongodb.core.aggregation.TypeBasedAggregationOperationContext in project spring-data-mongodb by spring-projects.
the class MongoTemplate method aggregate.
/* (non-Javadoc)
* @see org.springframework.data.mongodb.core.MongoOperations#aggregate(org.springframework.data.mongodb.core.aggregation.TypedAggregation, java.lang.String, java.lang.Class)
*/
@Override
public <O> AggregationResults<O> aggregate(TypedAggregation<?> aggregation, String inputCollectionName, Class<O> outputType) {
Assert.notNull(aggregation, "Aggregation pipeline must not be null!");
AggregationOperationContext context = new TypeBasedAggregationOperationContext(aggregation.getInputType(), mappingContext, queryMapper);
return aggregate(aggregation, inputCollectionName, outputType, context);
}
use of org.springframework.data.mongodb.core.aggregation.TypeBasedAggregationOperationContext in project spring-data-mongodb by spring-projects.
the class ReactiveMongoTemplate method aggregate.
/*
* (non-Javadoc)
* @see org.springframework.data.mongodb.core.ReactiveMongoOperations#aggregate(org.springframework.data.mongodb.core.aggregation.TypedAggregation, java.lang.String, java.lang.Class)
*/
@Override
public <O> Flux<O> aggregate(TypedAggregation<?> aggregation, String inputCollectionName, Class<O> outputType) {
Assert.notNull(aggregation, "Aggregation pipeline must not be null!");
AggregationOperationContext context = new TypeBasedAggregationOperationContext(aggregation.getInputType(), mappingContext, queryMapper);
return aggregate(aggregation, inputCollectionName, outputType, context);
}
use of org.springframework.data.mongodb.core.aggregation.TypeBasedAggregationOperationContext 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.TypeBasedAggregationOperationContext in project spring-data-mongodb by spring-projects.
the class MongoTemplate method aggregateStream.
/* (non-Javadoc)
* @see org.springframework.data.mongodb.core.MongoOperations#aggregateStream(org.springframework.data.mongodb.core.aggregation.TypedAggregation, java.lang.String, java.lang.Class)
*/
@Override
public <O> CloseableIterator<O> aggregateStream(TypedAggregation<?> aggregation, String inputCollectionName, Class<O> outputType) {
Assert.notNull(aggregation, "Aggregation pipeline must not be null!");
AggregationOperationContext context = new TypeBasedAggregationOperationContext(aggregation.getInputType(), mappingContext, queryMapper);
return aggregateStream(aggregation, inputCollectionName, outputType, context);
}
use of org.springframework.data.mongodb.core.aggregation.TypeBasedAggregationOperationContext 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