本文整理了Java中org.springframework.data.mongodb.core.MongoTemplate.aggregate()
方法的一些代码示例,展示了MongoTemplate.aggregate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MongoTemplate.aggregate()
方法的具体详情如下:
包路径:org.springframework.data.mongodb.core.MongoTemplate
类名称:MongoTemplate
方法名:aggregate
暂无
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
public <O> AggregationResults<O> aggregate(Aggregation aggregation, String collectionName, Class<O> outputType) {
return aggregate(aggregation, collectionName, outputType, null);
}
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
public AggregationResults<T> all() {
return template.aggregate(aggregation, getCollectionName(aggregation), domainType);
}
代码示例来源:origin: spring-projects/spring-data-mongodb
@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);
}
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
public <O> AggregationResults<O> aggregate(Aggregation aggregation, Class<?> inputType, Class<O> outputType) {
return aggregate(aggregation, operations.determineCollectionName(inputType), outputType,
new TypeBasedAggregationOperationContext(inputType, mappingContext, queryMapper));
}
代码示例来源:origin: spring-projects/spring-data-mongodb
@Override
public <O> AggregationResults<O> aggregate(TypedAggregation<?> aggregation, Class<O> outputType) {
return aggregate(aggregation, operations.determineCollectionName(aggregation.getInputType()), outputType);
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
@Override
public <O> AggregationResults<O> aggregate(Aggregation aggregation, String collectionName, Class<O> outputType) {
return aggregate(aggregation, collectionName, outputType, null);
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
@Override
public AggregationResults<T> all() {
return template.aggregate(aggregation, getCollectionName(aggregation), domainType);
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
@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);
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
@Override
public <O> AggregationResults<O> aggregate(Aggregation aggregation, Class<?> inputType, Class<O> outputType) {
return aggregate(aggregation, operations.determineCollectionName(inputType), outputType,
new TypeBasedAggregationOperationContext(inputType, mappingContext, queryMapper));
}
代码示例来源:origin: org.springframework.data/spring-data-mongodb
@Override
public <O> AggregationResults<O> aggregate(TypedAggregation<?> aggregation, Class<O> outputType) {
return aggregate(aggregation, operations.determineCollectionName(aggregation.getInputType()), outputType);
}
代码示例来源:origin: com.epam.reportportal/commons-dao
private Long countLatestLaunches(Queryable filter) {
Long total = 0L;
final String countKey = "count";
List<AggregationOperation> operations = latestLaunchesAggregationOperationsList(filter);
operations.add(Aggregation.count().as(countKey));
Map result = mongoTemplate.aggregate(newAggregation(operations), Launch.class, Map.class).getUniqueMappedResult();
if (null != result && result.containsKey(countKey)) {
total = Long.valueOf(result.get(countKey).toString());
}
return total;
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public List<String> findLogIdsByItemRefs(List<String> ids) {
Aggregation aggregation = newAggregation(match(where("testItemRef").in(ids)), group("id"));
AggregationResults<Map> results = mongoTemplate.aggregate(aggregation, Log.class, Map.class);
return results.getMappedResults().stream().map(it -> it.get("_id").toString()).collect(toList());
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public List<String> findItemIdsByLaunchRef(List<String> launchRefs) {
Aggregation aggregation = newAggregation(match(where(LAUNCH_REFERENCE).in(launchRefs)), group(ID_REFERENCE));
AggregationResults<Map> aggregationResults = mongoTemplate.aggregate(aggregation, TestItem.class, Map.class);
return aggregationResults.getMappedResults().stream().map(it -> it.get("_id").toString()).collect(toList());
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public List<String> findLaunchIdsByProjectIds(List<String> ids) {
Aggregation aggregation = newAggregation(match(where(PROJECT_ID_REFERENCE).in(ids)), group(ID_REFERENCE));
AggregationResults<Map> results = mongoTemplate.aggregate(aggregation, Launch.class, Map.class);
return results.getMappedResults().stream().map(it -> it.get("_id").toString()).collect(toList());
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public List<String> getUniqueTicketsCount(List<Launch> launches) {
List<String> launchIds = launches.stream().map(Launch::getId).collect(toList());
Aggregation aggregation = newAggregation(match(where(LAUNCH_REFERENCE).in(launchIds)), match(where(ISSUE_TICKET).exists(true)),
unwind(ISSUE_TICKET), group(ISSUE_TICKET)
);
// Count be as
// Aggregation.group("issue.externalSystemIssues").count().as("count");
// but keep a whole
AggregationResults<Map> result = mongoTemplate.aggregate(aggregation, TestItem.class, Map.class);
return result.getMappedResults().stream().map(entry -> entry.get("ticketId").toString()).collect(toList());
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public List<String> findDistinctValues(String launchId, String containsValue, String distinctBy) {
Aggregation aggregation = newAggregation(match(where(LAUNCH_REFERENCE).is(launchId)), unwind(distinctBy),
match(where(distinctBy).regex("(?i).*" + Pattern.quote(containsValue) + ".*")), group(distinctBy)
);
AggregationResults<Map> result = mongoTemplate.aggregate(aggregation, TestItem.class, Map.class);
return result.getMappedResults().stream().map(entry -> entry.get("_id").toString()).collect(toList());
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public void findLatestWithCallback(Queryable filter, Sort sort, List<String> contentFields, long limit,
DocumentCallbackHandler callbackHandler) {
List<AggregationOperation> operations = latestLaunchesAggregationOperationsList(filter);
operations.add(sort(sort));
operations.add(limit(limit));
DBObject results = mongoTemplate.aggregate(newAggregation(operations), mongoTemplate.getCollectionName(Launch.class), Launch.class)
.getRawResults();
BasicDBList result = (BasicDBList) results.get(RESULT);
result.stream().map(it -> (DBObject) it).forEach(callbackHandler::processDocument);
}
代码示例来源:origin: com.epam.reportportal/commons-dao
private List<Launch> findLatest(Queryable filter, Pageable pageable) {
List<AggregationOperation> operations = latestLaunchesAggregationOperationsList(filter);
operations.add(sort(pageable.getSort()));
operations.add(skip((long) pageable.getPageNumber() * pageable.getPageSize()));
operations.add(limit(pageable.getPageSize()));
return mongoTemplate.aggregate(newAggregation(operations), mongoTemplate.getCollectionName(Launch.class), Launch.class)
.getMappedResults();
}
代码示例来源:origin: microcks/microcks
public List<ServiceCount> countServicesByType() {
Aggregation aggregation = newAggregation(
project("type"),
group("type").count().as("number"),
project("number").and("type").previousOperation(),
sort(DESC, "number")
);
AggregationResults<ServiceCount> results = template.aggregate(aggregation, Service.class, ServiceCount.class);
return results.getMappedResults();
}
}
代码示例来源:origin: com.epam.reportportal/commons-dao
@Override
public List<RetryObject> findRetries(String launchId) {
Aggregation aggregation = newAggregation(match(where(LAUNCH_REFERENCE).is(launchId).and("retryProcessed").exists(true)),
sort(new Sort(Sort.Direction.ASC, "start_time")), group(Fields.fields("$uniqueId")).push(ROOT).as("retries")
);
return mongoTemplate.aggregate(aggregation, mongoTemplate.getCollectionName(TestItem.class), RetryObject.class).getMappedResults();
}
内容来源于网络,如有侵权,请联系作者删除!