/** * Returns the collection the given entity type shall be persisted to. * * @param entityClass must not be {@literal null}. * @return */ private String getCollectionNameForEntity(Class<? extends ChangeSetBacked> entityClass) { return mongoTemplate.getCollectionName(entityClass); } }
private String getCollectionName() { return StringUtils.hasText(collection) ? collection : template.getCollectionName(domainType); } }
private String getCollectionName() { return StringUtils.hasText(collection) ? collection : template.getCollectionName(domainType); } }
private String getCollectionName() { return StringUtils.hasText(collection) ? collection : template.getCollectionName(domainType); } }
private String getCollectionName() { return StringUtils.hasText(collection) ? collection : template.getCollectionName(domainType); } }
private String getCollectionName() { return StringUtils.hasText(collection) ? collection : template.getCollectionName(domainType); }
private String getCollectionName(Aggregation aggregation) { if (StringUtils.hasText(collection)) { return collection; } if (aggregation instanceof TypedAggregation) { TypedAggregation<?> typedAggregation = (TypedAggregation<?>) aggregation; if (typedAggregation.getInputType() != null) { return template.getCollectionName(typedAggregation.getInputType()); } } return template.getCollectionName(domainType); } }
private String getCollectionName() { return StringUtils.hasText(collection) ? collection : template.getCollectionName(domainType); } }
private String getCollectionName() { return StringUtils.hasText(collection) ? collection : template.getCollectionName(domainType); } }
private String getCollectionName() { return StringUtils.hasText(collection) ? collection : template.getCollectionName(domainType); } }
private String getCollectionName() { return StringUtils.hasText(collection) ? collection : template.getCollectionName(domainType); } }
private String getCollectionName() { return StringUtils.hasText(collection) ? collection : template.getCollectionName(domainType); }
private String getCollectionName(Aggregation aggregation) { if (StringUtils.hasText(collection)) { return collection; } if (aggregation instanceof TypedAggregation) { TypedAggregation<?> typedAggregation = (TypedAggregation<?>) aggregation; if (typedAggregation.getInputType() != null) { return template.getCollectionName(typedAggregation.getInputType()); } } return template.getCollectionName(domainType); } }
/** * Returns the collection the given entity type shall be persisted to. * * @param entityClass must not be {@literal null}. * @return */ private String getCollectionNameForEntity(Class<? extends ChangeSetBacked> entityClass) { return mongoTemplate.getCollectionName(entityClass); } }
@Autowired private MongoTemplate mongoTemplate; DBCollection collection = mongoTemplate.getCollection(mongoTemplate.getCollectionName(MyDocument.class)));
@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); }
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(); }
void onAfterDelete(Class<?> stateful, DBObject obj) { if (stateful != null && getClazz().isAssignableFrom(stateful)) { Criteria criteria = new Criteria("managedId").is(obj.get(this.getIdField().getName())). and("managedCollection").is(getMongoTemplate().getCollectionName(getClazz())). and("managedField").is(this.getStateField().getName()); this.getMongoTemplate().remove(new Query(criteria), StateDocumentImpl.class); } } }
protected StateDocumentImpl createStateDocument(T stateful) throws IllegalArgumentException, IllegalAccessException, SecurityException, NoSuchFieldException { StateDocumentImpl stateDoc = new StateDocumentImpl(); stateDoc.setPersisted(false); stateDoc.setId(new ObjectId().toHexString()); stateDoc.setState(getStartState().getName()); stateDoc.setManagedCollection(getMongoTemplate().getCollectionName(stateful.getClass())); stateDoc.setManagedField(this.getStateField().getName()); setStateDocument(stateful, stateDoc); return stateDoc; }
@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(); }