/** * Get the {@link MappingContext} to use in repositories. It is extracted from the default {@link RxJavaCouchbaseOperations}. * * @return the mapping context. */ public MappingContext<? extends CouchbasePersistentEntity<?>, CouchbasePersistentProperty> getMappingContext() { return defaultOperations.getConverter().getMappingContext(); }
/** * Get the {@link MappingContext} to use in repositories. It is extracted from the default {@link RxJavaCouchbaseOperations}. * * @return the mapping context. */ public MappingContext<? extends CouchbasePersistentEntity<?>, CouchbasePersistentProperty> getMappingContext() { return defaultOperations.getConverter().getMappingContext(); }
protected Object executeSingleProjection(N1qlQuery query, final Class<?> typeToRead) { logIfNecessary(query); return couchbaseOperations.findByN1QLProjection(query, Map.class) .map(m -> { if (m.size() > 1) { throw new CouchbaseQueryExecutionException("Query returning primitive got more values than expected: " + m.size()); } Object v = m.values().iterator().next(); return this.couchbaseOperations.getConverter().getConversionService().convert(v, typeToRead); }); }
protected Object executeSingleProjection(N1qlQuery query, final Class<?> typeToRead) { logIfNecessary(query); return couchbaseOperations.findByN1QLProjection(query, Map.class) .map(m -> { if (m.size() > 1) { throw new CouchbaseQueryExecutionException("Query returning primitive got more values than expected: " + m.size()); } Object v = m.values().iterator().next(); return this.couchbaseOperations.getConverter().getConversionService().convert(v, typeToRead); }); }
protected String getTypeField() { return getCouchbaseOperations().getConverter().getTypeKey(); }
protected String getTypeField() { return getCouchbaseOperations().getConverter().getTypeKey(); }
public ReactiveStringN1qlBasedQuery(String statement, CouchbaseQueryMethod queryMethod, RxJavaCouchbaseOperations couchbaseOperations, SpelExpressionParser spelParser, QueryMethodEvaluationContextProvider evaluationContextProvider) { super(queryMethod, couchbaseOperations); this.queryParser = new StringBasedN1qlQueryParser(statement, queryMethod, getCouchbaseOperations().getCouchbaseBucket().name(), getCouchbaseOperations().getConverter(), getTypeField(), getTypeValue()); this.parser = spelParser; this.evaluationContextProvider = evaluationContextProvider; }
public ReactiveStringN1qlBasedQuery(String statement, CouchbaseQueryMethod queryMethod, RxJavaCouchbaseOperations couchbaseOperations, SpelExpressionParser spelParser, QueryMethodEvaluationContextProvider evaluationContextProvider) { super(queryMethod, couchbaseOperations); this.queryParser = new StringBasedN1qlQueryParser(statement, queryMethod, getCouchbaseOperations().getCouchbaseBucket().name(), getCouchbaseOperations().getConverter(), getTypeField(), getTypeValue()); this.parser = spelParser; this.evaluationContextProvider = evaluationContextProvider; }
viewAsync = buildAllView(viewIndexed, metadata, rxjava1CouchbaseOperations.getCouchbaseBucket(), rxjava1CouchbaseOperations.getConverter().getTypeKey()); n1qlSecondaryAsync = buildN1qlSecondary(n1qlSecondaryIndexed, metadata, rxjava1CouchbaseOperations.getCouchbaseBucket(), rxjava1CouchbaseOperations.getConverter().getTypeKey());
viewAsync = buildAllView(viewIndexed, metadata, rxjava1CouchbaseOperations.getCouchbaseBucket(), rxjava1CouchbaseOperations.getConverter().getTypeKey()); n1qlSecondaryAsync = buildN1qlSecondary(n1qlSecondaryIndexed, metadata, rxjava1CouchbaseOperations.getCouchbaseBucket(), rxjava1CouchbaseOperations.getConverter().getTypeKey());
@SuppressWarnings("unchecked") @Override public Flux<T> findAll(Sort sort) { Assert.notNull(sort); //prepare elements of the query WherePath selectFrom = N1qlUtils.createSelectFromForEntity(getCouchbaseOperations().getCouchbaseBucket().name()); Expression whereCriteria = N1qlUtils.createWhereFilterForEntity(null, getCouchbaseOperations().getConverter(), getEntityInformation()); //apply the sort com.couchbase.client.java.query.dsl.Sort[] orderings = N1qlUtils.createSort(sort, getCouchbaseOperations().getConverter()); Statement st = selectFrom.where(whereCriteria).orderBy(orderings); //fire the query ScanConsistency consistency = getCouchbaseOperations().getDefaultConsistency().n1qlConsistency(); N1qlQuery query = N1qlQuery.simple(st, N1qlParams.build().consistency(consistency)); return mapFlux(getCouchbaseOperations().findByN1QL(query, getEntityInformation().getJavaType())); }
@SuppressWarnings("unchecked") @Override public Flux<T> findAll(Sort sort) { Assert.notNull(sort); //prepare elements of the query WherePath selectFrom = N1qlUtils.createSelectFromForEntity(getCouchbaseOperations().getCouchbaseBucket().name()); Expression whereCriteria = N1qlUtils.createWhereFilterForEntity(null, getCouchbaseOperations().getConverter(), getEntityInformation()); //apply the sort com.couchbase.client.java.query.dsl.Sort[] orderings = N1qlUtils.createSort(sort, getCouchbaseOperations().getConverter()); Statement st = selectFrom.where(whereCriteria).orderBy(orderings); //fire the query ScanConsistency consistency = getCouchbaseOperations().getDefaultConsistency().n1qlConsistency(); N1qlQuery query = N1qlQuery.simple(st, N1qlParams.build().consistency(consistency)); return mapFlux(getCouchbaseOperations().findByN1QL(query, getEntityInformation().getJavaType())); }
@Override protected Statement getStatement(ParameterAccessor accessor, Object[] runtimeParameters, ReturnedType returnedType) { String bucketName = getCouchbaseOperations().getCouchbaseBucket().name(); Expression bucket = N1qlUtils.escapedBucket(bucketName); FromPath select; if (partTree.isCountProjection()) { select = select(count("*")); } else { select = N1qlUtils.createSelectClauseForEntity(bucketName, returnedType, this.getCouchbaseOperations().getConverter()); } WherePath selectFrom = select.from(bucket); N1qlQueryCreator queryCreator = new N1qlQueryCreator(partTree, accessor, selectFrom, getCouchbaseOperations().getConverter(), getQueryMethod()); LimitPath selectFromWhereOrderBy = queryCreator.createQuery(); this.placeHolderValues = queryCreator.getPlaceHolderValues(); if (partTree.isLimiting()) { return selectFromWhereOrderBy.limit(partTree.getMaxResults()); } else { return selectFromWhereOrderBy; } } }
@Override protected Statement getStatement(ParameterAccessor accessor, Object[] runtimeParameters, ReturnedType returnedType) { String bucketName = getCouchbaseOperations().getCouchbaseBucket().name(); Expression bucket = N1qlUtils.escapedBucket(bucketName); FromPath select; if (partTree.isCountProjection()) { select = select(count("*")); } else { select = N1qlUtils.createSelectClauseForEntity(bucketName, returnedType, this.getCouchbaseOperations().getConverter()); } WherePath selectFrom = select.from(bucket); N1qlQueryCreator queryCreator = new N1qlQueryCreator(partTree, accessor, selectFrom, getCouchbaseOperations().getConverter(), getQueryMethod()); LimitPath selectFromWhereOrderBy = queryCreator.createQuery(); this.placeHolderValues = queryCreator.getPlaceHolderValues(); if (partTree.isLimiting()) { return selectFromWhereOrderBy.limit(partTree.getMaxResults()); } else { return selectFromWhereOrderBy; } } }
method.getViewAnnotation(), baseQuery, operations.getConverter()); ViewQueryCreator.DerivedViewQuery result = creator.createQuery();
method.getViewAnnotation(), baseQuery, operations.getConverter()); ViewQueryCreator.DerivedViewQuery result = creator.createQuery();
@Override public Object execute(Object[] runtimeParams) { String designDoc = method.getDimensionalAnnotation().designDocument(); String viewName = method.getDimensionalAnnotation().spatialViewName(); int dimensions = method.getDimensionalAnnotation().dimensions(); PartTree tree = new PartTree(method.getName(), method.getEntityInformation().getJavaType()); //prepare a spatial view query to be used as a base for the query creator SpatialViewQuery baseSpatialQuery = SpatialViewQuery.from(designDoc, viewName) .stale(operations.getDefaultConsistency().viewConsistency()); //use the SpatialViewQueryCreator to complete it SpatialViewQueryCreator creator = new SpatialViewQueryCreator(dimensions, tree, new ReactiveCouchbaseParameterAccessor(method, runtimeParams), baseSpatialQuery, operations.getConverter()); SpatialViewQueryCreator.SpatialViewQueryWrapper finalQuery = creator.createQuery(); //execute the spatial query return execute(finalQuery); }
@Override public Object execute(Object[] runtimeParams) { String designDoc = method.getDimensionalAnnotation().designDocument(); String viewName = method.getDimensionalAnnotation().spatialViewName(); int dimensions = method.getDimensionalAnnotation().dimensions(); PartTree tree = new PartTree(method.getName(), method.getEntityInformation().getJavaType()); //prepare a spatial view query to be used as a base for the query creator SpatialViewQuery baseSpatialQuery = SpatialViewQuery.from(designDoc, viewName) .stale(operations.getDefaultConsistency().viewConsistency()); //use the SpatialViewQueryCreator to complete it SpatialViewQueryCreator creator = new SpatialViewQueryCreator(dimensions, tree, new ReactiveCouchbaseParameterAccessor(method, runtimeParams), baseSpatialQuery, operations.getConverter()); SpatialViewQueryCreator.SpatialViewQueryWrapper finalQuery = creator.createQuery(); //execute the spatial query return execute(finalQuery); }