Search in sources :

Example 51 with Aggregation

use of org.springframework.data.mongodb.core.aggregation.Aggregation in project ocvn by devgateway.

the class AbstractFlagReleaseSearchController method releaseFlagSearch.

@JsonView(Views.Internal.class)
public List<DBObject> releaseFlagSearch(@ModelAttribute @Valid final YearFilterPagingRequest filter) {
    Aggregation agg = newAggregation(match(where("flags.flaggedStats.0").exists(true).and(getFlagProperty()).is(true).andOperator(getYearDefaultFilterCriteria(filter, MongoConstants.FieldNames.TENDER_PERIOD_START_DATE))), unwind("flags.flaggedStats"), match(where(getFlagProperty()).is(true)), project("ocid", "tender.procuringEntity.name", "tender.tenderPeriod", "flags", "tender.title", "tag").and("tender.value").as("tender.value").and("awards.value").as("awards.value").andExclude(Fields.UNDERSCORE_ID), sort(Sort.Direction.DESC, "flags.flaggedStats.count"), skip(filter.getSkip()), limit(filter.getPageSize()));
    AggregationResults<DBObject> results = mongoTemplate.aggregate(agg, "release", DBObject.class);
    List<DBObject> list = results.getMappedResults();
    return list;
}
Also used : Aggregation.newAggregation(org.springframework.data.mongodb.core.aggregation.Aggregation.newAggregation) Aggregation(org.springframework.data.mongodb.core.aggregation.Aggregation) DBObject(com.mongodb.DBObject) JsonView(com.fasterxml.jackson.annotation.JsonView)

Aggregations

DBObject (com.mongodb.DBObject)51 Aggregation (org.springframework.data.mongodb.core.aggregation.Aggregation)51 ApiOperation (io.swagger.annotations.ApiOperation)44 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)44 BasicDBObject (com.mongodb.BasicDBObject)41 Aggregation.newAggregation (org.springframework.data.mongodb.core.aggregation.Aggregation.newAggregation)40 CustomProjectionOperation (org.devgateway.toolkit.persistence.mongo.aggregate.CustomProjectionOperation)30 CustomGroupingOperation (org.devgateway.toolkit.persistence.mongo.aggregate.CustomGroupingOperation)12 CustomOperation (org.devgateway.toolkit.persistence.mongo.aggregate.CustomOperation)9 JsonView (com.fasterxml.jackson.annotation.JsonView)4 CustomUnwindOperation (org.devgateway.toolkit.persistence.mongo.aggregate.CustomUnwindOperation)2 Date (java.util.Date)1 CustomSortingOperation (org.devgateway.toolkit.persistence.mongo.aggregate.CustomSortingOperation)1 Criteria (org.springframework.data.mongodb.core.query.Criteria)1