use of com.couchbase.client.java.query.QueryScanConsistency in project spring-data-couchbase by spring-projects.
the class OptionsBuilder method buildQueryOptions.
static QueryOptions buildQueryOptions(Query query, QueryOptions options, QueryScanConsistency scanConsistency) {
options = options != null ? options : QueryOptions.queryOptions();
if (query.getParameters() != null) {
if (query.getParameters() instanceof JsonArray) {
options.parameters((JsonArray) query.getParameters());
} else {
options.parameters((JsonObject) query.getParameters());
}
}
Meta meta = query.getMeta() != null ? query.getMeta() : new Meta();
QueryOptions.Built optsBuilt = options.build();
JsonObject optsJson = getQueryOpts(optsBuilt);
QueryScanConsistency metaQueryScanConsistency = meta.get(SCAN_CONSISTENCY) != null ? ((ScanConsistency) meta.get(SCAN_CONSISTENCY)).query() : null;
QueryScanConsistency qsc = fromFirst(QueryScanConsistency.NOT_BOUNDED, getScanConsistency(optsJson), scanConsistency, metaQueryScanConsistency);
Duration timeout = fromFirst(Duration.ofSeconds(0), getTimeout(optsBuilt), meta.get(TIMEOUT));
RetryStrategy retryStrategy = fromFirst(null, getRetryStrategy(optsBuilt), meta.get(RETRY_STRATEGY));
if (qsc != null) {
options.scanConsistency(qsc);
}
if (timeout != null) {
options.timeout(timeout);
}
if (retryStrategy != null) {
options.retryStrategy(retryStrategy);
}
if (LOG.isTraceEnabled()) {
LOG.trace("query options: {}", getQueryOpts(options.build()));
}
return options;
}
use of com.couchbase.client.java.query.QueryScanConsistency in project spring-data-couchbase by spring-projects.
the class CouchbaseRepositoryBase method buildQueryScanConsistency.
/**
* Get the QueryScanConsistency from <br>
* 1. The method annotation (method *could* be available from crudMethodMetadata)<br>
* 2. The repository<br>
* 3. The entity<br>
* 4. otherwise null<br>
* This can be overriden in the operation method by<br>
* 1. Options.scanConsistency (?)<br>
* AbstractCouchbaseQueryBase.applyAnnotatedConsistencyIfPresent() <br>
* CouchbaseRepository get picked up? If I have the following, will the annotation be picked up?<br>
* Only via crudMethodMetadata<br>
* \@ScanConsistency(query=QueryScanConsistency.REQUEST_PLUS)<br>
* List<T> findAll();<br>
*/
QueryScanConsistency buildQueryScanConsistency() {
ScanConsistency sc = crudMethodMetadata.getScanConsistency();
QueryScanConsistency fromMeta = sc != null ? sc.query() : null;
QueryScanConsistency fromAnnotation = OptionsBuilder.annotationAttribute(ScanConsistency.class, "query", QueryScanConsistency.NOT_BOUNDED, new AnnotatedElement[] { getJavaType(), repositoryInterface });
return OptionsBuilder.fromFirst(QueryScanConsistency.NOT_BOUNDED, fromMeta, fromAnnotation);
}
Aggregations