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;
}
Aggregations