当前位置: 首页>>代码示例>>Java>>正文


Java AggregationResults.getMappedResults方法代码示例

本文整理汇总了Java中org.springframework.data.mongodb.core.aggregation.AggregationResults.getMappedResults方法的典型用法代码示例。如果您正苦于以下问题:Java AggregationResults.getMappedResults方法的具体用法?Java AggregationResults.getMappedResults怎么用?Java AggregationResults.getMappedResults使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.data.mongodb.core.aggregation.AggregationResults的用法示例。


在下文中一共展示了AggregationResults.getMappedResults方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAppInfoByAppNames

import org.springframework.data.mongodb.core.aggregation.AggregationResults; //导入方法依赖的package包/类
@Override
public List<ApplicationDTO> getAppInfoByAppNames(List<String> names) {

    Aggregation aggregation = newAggregation(
        match(Criteria.where("appname").in(names).and("timestamp").exists(true)),
        sort(new Sort(DESC, "timestamp")),
        project("appname", "platform", "starrating",
                    "timestamp", "comment", "authorName","url"),
        group("appname", "platform")
            .push(new BasicDBObject("author", "$authorName")
                .append("rate", "$starrating" )
                .append("timestamp", "$timestamp")
                .append("comment", "$comment")
                .append("url", "$url")
            ).as("reviews"),
        project("appname", "platform")
            .and("reviews").slice(8, 0)
    );

    //Convert the aggregation result into a List
    AggregationResults<ApplicationDTO> groupResults
            = mongoTemplate.aggregate(aggregation, Review.class, ApplicationDTO.class);

    return groupResults.getMappedResults();
}
 
开发者ID:BBVA,项目名称:mirrorgate,代码行数:26,代码来源:ReviewRepositoryImpl.java

示例2: getLastReviewPerApplication

import org.springframework.data.mongodb.core.aggregation.AggregationResults; //导入方法依赖的package包/类
@Override
public List<ApplicationReviewsDTO> getLastReviewPerApplication(List<String> names){

    Aggregation aggregation = newAggregation(
        match(Criteria.where("appname").in(names)),
        sort(new Sort(DESC, "timestamp")),
        group("appname", "platform")
            .first("platform").as("platform")
            .first("appname").as("appName")
            .first("appname").as("appId")
            .first("commentId").as("commentId")
    );

    //Convert the aggregation result into a List
    AggregationResults<ApplicationReviewsDTO> groupResults
        = mongoTemplate.aggregate(aggregation, Review.class, ApplicationReviewsDTO.class);

    return groupResults.getMappedResults();

}
 
开发者ID:BBVA,项目名称:mirrorgate,代码行数:21,代码来源:ReviewRepositoryImpl.java

示例3: getAverageRateByAppNamesAfterTimestamp

import org.springframework.data.mongodb.core.aggregation.AggregationResults; //导入方法依赖的package包/类
@Override
public List<ApplicationDTO> getAverageRateByAppNamesAfterTimestamp(List<String> names, Long timestamp) {

    Aggregation aggregation = newAggregation(
            match(Criteria.where("appname").in(names).and("timestamp").gte(timestamp)),
            group("appname", "platform")
                    .count().as("votesShortTerm")
                    .sum("starrating").as("ratingShortTerm")
    );

    //Convert the aggregation result into a List
    AggregationResults<ApplicationDTO> groupResults
            = mongoTemplate.aggregate(aggregation, Review.class, ApplicationDTO.class);

    return groupResults.getMappedResults();

}
 
开发者ID:BBVA,项目名称:mirrorgate,代码行数:18,代码来源:ReviewRepositoryImpl.java

示例4: getUniqueEndUsersCountByTime

import org.springframework.data.mongodb.core.aggregation.AggregationResults; //导入方法依赖的package包/类
public List<UniqueEndUsersCountAtTime> getUniqueEndUsersCountByTime(){
    long midnightInMillis = LocalDate.now().atStartOfDay(ZoneId.systemDefault()).toEpochSecond()*1000;
    Aggregation agg = newAggregation(
            match(Criteria.where("dateTimeinMillis").gte(midnightInMillis)),
            group("sessionId").min("dateTimeinMillis").as("time").push("sessionId").as("sessionId"),
            project("sessionId","time").and("time").minus(midnightInMillis).as("time"),
            project("sessionId","time").and("time").divide(1000*60*5).as("time"),
            project("sessionId","time").and("time").mod(1).as("mod"),
            project("sessionId","time").and("time").minus("mod").as("time"),
            group("time").count().as("count").push("time").as("time")
    );


    AggregationResults groupResults
            = mongoTemplate.aggregate(agg, Event.class, UniqueEndUsersCountAtTime.class);
    List<UniqueEndUsersCountAtTime> result = groupResults.getMappedResults();

    return result;
}
 
开发者ID:badalgeek,项目名称:EventStreamAnalytics,代码行数:20,代码来源:EventRepositoryImpl.java

示例5: findOrphans

import org.springframework.data.mongodb.core.aggregation.AggregationResults; //导入方法依赖的package包/类
public List<OrphanedTest> findOrphans(Collection<String> existingConfigurations) {
  Aggregation aggregation = Aggregation.newAggregation(
    match(Criteria.where("testName").nin(existingConfigurations)),
    group("testName").max("created").as("latestCreatedDate").count().as("count"),
    project("latestCreatedDate", "count").and("testName").previousOperation());

  AggregationResults<OrphanedTest> orphanedTests = mongoTemplate.aggregate(aggregation,
    DECISIONS_COLLECTION_NAME,
    OrphanedTest.class);

  return orphanedTests.getMappedResults();
}
 
开发者ID:ImmobilienScout24,项目名称:switchman,代码行数:13,代码来源:AbTestDecisionService.java

示例6: findCommentsCountGreaterThanBoardIdAndBoard

import org.springframework.data.mongodb.core.aggregation.AggregationResults; //导入方法依赖的package包/类
/**
 * boardItem의 boardId 기준 이상의 댓글 수를 가져온다
 *
 * @param boardId 기준이 되는 boardItem의 boardId
 */
@Override
public List<CommonCount> findCommentsCountGreaterThanBoardIdAndBoard(ObjectId boardId, Constants.BOARD_TYPE board) {
    AggregationOperation match1 = Aggregation.match(Criteria.where("article._id").gt(boardId).and("article.board").is(board.name()));
    AggregationOperation group = Aggregation.group("article").count().as("count");
    AggregationOperation sort = Aggregation.sort(Sort.Direction.DESC, "count");
    //AggregationOperation limit = Aggregation.limit(Constants.BOARD_TOP_LIMIT);
    Aggregation aggregation = Aggregation.newAggregation(match1, group, sort/*, limit*/);
    AggregationResults<CommonCount> results = mongoTemplate.aggregate(aggregation, Constants.COLLECTION_ARTICLE_COMMENT, CommonCount.class);

    return results.getMappedResults();
}
 
开发者ID:JakduK,项目名称:jakduk-api,代码行数:17,代码来源:ArticleCommentRepositoryImpl.java

示例7: getSprintSampleForStatus

import org.springframework.data.mongodb.core.aggregation.AggregationResults; //导入方法依赖的package包/类
@Override
public List<Sprint> getSprintSampleForStatus(String[] status, String collectorId) {
    Aggregation agg = newAggregation(
            match(where("sSprintAssetState").in((Object[]) status).and("collectorId").is(collectorId)),
            firstFeatureFields(group("sSprintID","sSprintAssetState")),
            firstSprintFields(group("sSprintID","sSprintAssetState"))
                    .push(new BasicDBObject(FEATURE_FIELDS)).as("features")
    );
    AggregationResults<Sprint> aggregate =
            mongoTemplate.aggregate(agg, "feature", Sprint.class);

    return aggregate.getMappedResults();
}
 
开发者ID:BBVA,项目名称:mirrorgate,代码行数:14,代码来源:SprintRepositoryImpl.java

示例8: getActiveDashboards

import org.springframework.data.mongodb.core.aggregation.AggregationResults; //导入方法依赖的package包/类
@Override
public List<Dashboard> getActiveDashboards() {

    Aggregation aggregation = newAggregation(
            sort(new Sort(Sort.Direction.DESC, "lastModification")),
            firstDashboardFields(group("name")),
            match(Criteria.where("status").nin(DELETED, TRANSIENT)),
            project(DASHBOARD_FIELDS.keySet().toArray(new String[]{})).andExclude("_id")
    );

    //Convert the aggregation result into a List
    AggregationResults<Dashboard> groupResults
            = mongoTemplate.aggregate(aggregation, Dashboard.class, Dashboard.class);
    return groupResults.getMappedResults();
}
 
开发者ID:BBVA,项目名称:mirrorgate,代码行数:16,代码来源:DashboardRepositoryImpl.java

示例9: shouldCategorizeBooksInBuckets

import org.springframework.data.mongodb.core.aggregation.AggregationResults; //导入方法依赖的package包/类
/**
 * Categorize books by their page count into buckets.
 */
@Test
public void shouldCategorizeBooksInBuckets() {

	Aggregation aggregation = newAggregation( //
			replaceRoot("volumeInfo"), //
			match(Criteria.where("pageCount").exists(true)),
			bucketAuto("pageCount", 10) //
					.withGranularity(Granularities.SERIES_1_2_5) //
					.andOutput("title").push().as("titles") //
					.andOutput("titles").count().as("count"));

	AggregationResults<BookFacetPerPage> result = operations.aggregate(aggregation, "books", BookFacetPerPage.class);

	List<BookFacetPerPage> mappedResults = result.getMappedResults();

	BookFacetPerPage facet_20_to_100_pages = mappedResults.get(0);
	assertThat(facet_20_to_100_pages.getMin()).isEqualTo(20);
	assertThat(facet_20_to_100_pages.getMax()).isEqualTo(100);
	assertThat(facet_20_to_100_pages.getCount()).isEqualTo(12);

	BookFacetPerPage facet_100_to_500_pages = mappedResults.get(1);
	assertThat(facet_100_to_500_pages.getMin()).isEqualTo(100);
	assertThat(facet_100_to_500_pages.getMax()).isEqualTo(500);
	assertThat(facet_100_to_500_pages.getCount()).isEqualTo(63);
	assertThat(facet_100_to_500_pages.getTitles()).contains("Spring Data");
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:30,代码来源:SpringBooksIntegrationTests.java

示例10: getCustomerCount

import org.springframework.data.mongodb.core.aggregation.AggregationResults; //导入方法依赖的package包/类
public List<UniqueCustomerCountByDeviceType> getCustomerCount() {

        Aggregation agg = newAggregation(
                group("deviceId","sessionId"),
                group("deviceId").first("deviceId").as("deviceType").count().as("total")
        );

        //Convert the aggregation result into a List
        AggregationResults groupResults
                = mongoTemplate.aggregate(agg, (Class<?>) Event.class, UniqueCustomerCountByDeviceType.class);
        List<UniqueCustomerCountByDeviceType> result = groupResults.getMappedResults();

        return result;
    }
 
开发者ID:badalgeek,项目名称:EventStreamAnalytics,代码行数:15,代码来源:EventRepositoryImpl.java

示例11: getResults

import org.springframework.data.mongodb.core.aggregation.AggregationResults; //导入方法依赖的package包/类
@RequestMapping(value = "/results", method = RequestMethod.GET)
public ResponseEntity<Map<String, List<VoteCount>>> getResults() {

    Aggregation aggregation = Aggregation.newAggregation(
            Aggregation.group("vote").count().as("count"),
            project("count").and("vote").previousOperation(),
            sort(Sort.Direction.DESC, "count")
    );

    AggregationResults<VoteCount> groupResults
            = mongoTemplate.aggregate(aggregation, Vote.class, VoteCount.class);
    List<VoteCount> results = groupResults.getMappedResults();
    return new ResponseEntity<>(Collections.singletonMap("results", results), HttpStatus.OK);
}
 
开发者ID:ThoughtWorksInc,项目名称:voter-service,代码行数:15,代码来源:VoteController.java

示例12: getWinners

import org.springframework.data.mongodb.core.aggregation.AggregationResults; //导入方法依赖的package包/类
@RequestMapping(value = "/winners", method = RequestMethod.GET)
public ResponseEntity<Map<String, List<VoteCount>>> getWinners() {

    Aggregation aggregation = Aggregation.newAggregation(
            Aggregation.group("vote").count().as("count"),
            match(Criteria.where("count").is(getWinnersVotesInt())),
            project("count").and("vote").previousOperation(),
            sort(Sort.Direction.ASC, "vote")
    );

    AggregationResults<VoteCount> groupResults
            = mongoTemplate.aggregate(aggregation, Vote.class, VoteCount.class);
    List<VoteCount> results = groupResults.getMappedResults();
    return new ResponseEntity<>(Collections.singletonMap("results", results), HttpStatus.OK);
}
 
开发者ID:ThoughtWorksInc,项目名称:voter-service,代码行数:16,代码来源:VoteController.java

示例13: getUniqueServiceNumbers

import org.springframework.data.mongodb.core.aggregation.AggregationResults; //导入方法依赖的package包/类
public List<BasicDBObject> getUniqueServiceNumbers(List<String> serviceNumbers){
        /*
         db.booking.aggregate(
...    [
...      { $group : { _id : "$serviceNumber", serviceName: { $addToSet: "$serviceName" } } }
...    ]
... )
         */
        Aggregation agg = newAggregation(match(where("serviceNumber").nin(serviceNumbers)),
                group("serviceNumber").addToSet("serviceName").as("serviceName"));
        AggregationResults<BasicDBObject> groupResults
                = mongoTemplate.aggregate(agg, Booking.class, BasicDBObject.class);
        List<BasicDBObject> result = groupResults.getMappedResults();
        return result;
    }
 
开发者ID:srinikandula,项目名称:mybus,代码行数:16,代码来源:GSTFilterMongoDAO.java

示例14: getBookingDueTotalsByService

import org.springframework.data.mongodb.core.aggregation.AggregationResults; //导入方法依赖的package包/类
public List<BasicDBObject> getBookingDueTotalsByService(String branchOfficeId){
    //db.booking.aggregate([{ $match: { 'due': true } },{$group:{_id:"$serviceNumber",total:{$sum:"$netAmt"}}}])
    /*
    Aggregation agg = newAggregation(
            match(Criteria.where("due").is(true)),
            group("hosting").count().as("total"),
            project("total").and("hosting").previousOperation(),
            sort(Sort.Direction.DESC, "total");*/
    List<Criteria> match = new ArrayList<>();
    Criteria criteria = new Criteria();
    if(branchOfficeId != null) {
        List<String> agentNames = agentMongoDAO.findAgentNamesByOfficeId(branchOfficeId);
        if (agentNames != null && !agentNames.isEmpty()) {
            match.add(where("bookedBy").in(agentNames));
        }
    }
    match.add(where("due").is(true));
    criteria.andOperator(match.toArray(new Criteria[match.size()]));
    Aggregation agg = newAggregation(
            match(criteria),
            group("serviceNumber").sum("netAmt").as("totalDue"),
            sort(Sort.Direction.DESC, "totalDue"));

    AggregationResults<BasicDBObject> groupResults
            = mongoTemplate.aggregate(agg, Booking.class, BasicDBObject.class);
    List<BasicDBObject> result = groupResults.getMappedResults();
    return result;
}
 
开发者ID:srinikandula,项目名称:mybus,代码行数:29,代码来源:BookingMongoDAO.java

示例15: getBookingCountsByPhone

import org.springframework.data.mongodb.core.aggregation.AggregationResults; //导入方法依赖的package包/类
public Page<BasicDBObject> getBookingCountsByPhone(Pageable pageable){
    /**
     * db.booking.aggregate(
     [
     {
     $group:
     {
     _id: { phoneNo:  "$phoneNo"},
     count: { $sum: 1 }
     }
     },{
     $sort:{count:1}
     }
     ]
     )
     */

    long total = getTotalDistinctPhoneNumbers();
    Aggregation agg = newAggregation(
            group("phoneNo").count().as("totalBookings"),
            sort(Sort.Direction.DESC, "totalBookings"),
            skip((long)pageable.getPageNumber() * pageable.getPageSize()),
            limit(pageable.getPageSize()));
    AggregationResults<BasicDBObject> groupResults
            = mongoTemplate.aggregate(agg, Booking.class, BasicDBObject.class);
    List<BasicDBObject> result = groupResults.getMappedResults();
    return new PageImpl<>(result, pageable, total);
}
 
开发者ID:srinikandula,项目名称:mybus,代码行数:29,代码来源:BookingMongoDAO.java


注:本文中的org.springframework.data.mongodb.core.aggregation.AggregationResults.getMappedResults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。