Search in sources :

Example 1 with DocumentCallbackHandler

use of org.springframework.data.mongodb.core.DocumentCallbackHandler in project commons-dao by reportportal.

the class LaunchRepositoryCustomImpl method findLatestWithCallback.

@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);
}
Also used : java.util(java.util) CacheConfiguration(com.epam.ta.reportportal.config.CacheConfiguration) Cacheable(org.springframework.cache.annotation.Cacheable) Status(com.epam.ta.reportportal.database.entity.Status) Autowired(org.springframework.beans.factory.annotation.Autowired) AggregationOperation(org.springframework.data.mongodb.core.aggregation.AggregationOperation) TestItemIssueType(com.epam.ta.reportportal.database.entity.item.issue.TestItemIssueType) QueryBuilder(com.epam.ta.reportportal.database.search.QueryBuilder) AggregationUtils.matchOperationFromFilter(com.epam.ta.reportportal.database.dao.aggregation.AggregationUtils.matchOperationFromFilter) BasicDBList(com.mongodb.BasicDBList) Query.query(org.springframework.data.mongodb.core.query.Query.query) IN_PROGRESS(com.epam.ta.reportportal.database.entity.Status.IN_PROGRESS) ModifiableQueryBuilder.findModifiedLaterThanPeriod(com.epam.ta.reportportal.database.search.ModifiableQueryBuilder.findModifiedLaterThanPeriod) Lists(com.google.common.collect.Lists) DBObject(com.mongodb.DBObject) DocumentCallbackHandler(org.springframework.data.mongodb.core.DocumentCallbackHandler) Launch(com.epam.ta.reportportal.database.entity.Launch) TestItem(com.epam.ta.reportportal.database.entity.item.TestItem) Duration(java.time.Duration) AddFieldsOperation.addFields(com.epam.ta.reportportal.database.dao.aggregation.AddFieldsOperation.addFields) Update(org.springframework.data.mongodb.core.query.Update) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) Project(com.epam.ta.reportportal.database.entity.Project) MongoTemplate(org.springframework.data.mongodb.core.MongoTemplate) ObjectId.isValid(org.bson.types.ObjectId.isValid) Criteria.where(org.springframework.data.mongodb.core.query.Criteria.where) Queryable(com.epam.ta.reportportal.database.search.Queryable) Filter(com.epam.ta.reportportal.database.search.Filter) AggregationResults(org.springframework.data.mongodb.core.aggregation.AggregationResults) Streams(com.google.common.collect.Streams) Page(org.springframework.data.domain.Page) Aggregation(org.springframework.data.mongodb.core.aggregation.Aggregation) Collectors(java.util.stream.Collectors) SortingOperation.sorting(com.epam.ta.reportportal.database.dao.aggregation.SortingOperation.sorting) Criteria(org.springframework.data.mongodb.core.query.Criteria) Query(org.springframework.data.mongodb.core.query.Query) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) UpdateStatisticsQueryBuilder(com.epam.ta.reportportal.database.search.UpdateStatisticsQueryBuilder) Modifiable(com.epam.ta.reportportal.database.entity.Modifiable) ObjectId(org.bson.types.ObjectId) GroupOperation(org.springframework.data.mongodb.core.aggregation.GroupOperation) Pattern(java.util.regex.Pattern) DESC(org.springframework.data.domain.Sort.Direction.DESC) StatisticSubType(com.epam.ta.reportportal.database.entity.statistics.StatisticSubType) PageImpl(org.springframework.data.domain.PageImpl) BasicDBList(com.mongodb.BasicDBList) DBObject(com.mongodb.DBObject) Launch(com.epam.ta.reportportal.database.entity.Launch) AggregationOperation(org.springframework.data.mongodb.core.aggregation.AggregationOperation)

Aggregations

CacheConfiguration (com.epam.ta.reportportal.config.CacheConfiguration)1 AddFieldsOperation.addFields (com.epam.ta.reportportal.database.dao.aggregation.AddFieldsOperation.addFields)1 AggregationUtils.matchOperationFromFilter (com.epam.ta.reportportal.database.dao.aggregation.AggregationUtils.matchOperationFromFilter)1 SortingOperation.sorting (com.epam.ta.reportportal.database.dao.aggregation.SortingOperation.sorting)1 Launch (com.epam.ta.reportportal.database.entity.Launch)1 Modifiable (com.epam.ta.reportportal.database.entity.Modifiable)1 Project (com.epam.ta.reportportal.database.entity.Project)1 Status (com.epam.ta.reportportal.database.entity.Status)1 IN_PROGRESS (com.epam.ta.reportportal.database.entity.Status.IN_PROGRESS)1 TestItem (com.epam.ta.reportportal.database.entity.item.TestItem)1 TestItemIssueType (com.epam.ta.reportportal.database.entity.item.issue.TestItemIssueType)1 StatisticSubType (com.epam.ta.reportportal.database.entity.statistics.StatisticSubType)1 Filter (com.epam.ta.reportportal.database.search.Filter)1 ModifiableQueryBuilder.findModifiedLaterThanPeriod (com.epam.ta.reportportal.database.search.ModifiableQueryBuilder.findModifiedLaterThanPeriod)1 QueryBuilder (com.epam.ta.reportportal.database.search.QueryBuilder)1 Queryable (com.epam.ta.reportportal.database.search.Queryable)1 UpdateStatisticsQueryBuilder (com.epam.ta.reportportal.database.search.UpdateStatisticsQueryBuilder)1 Lists (com.google.common.collect.Lists)1 Streams (com.google.common.collect.Streams)1 BasicDBList (com.mongodb.BasicDBList)1