-
Notifications
You must be signed in to change notification settings - Fork 194
Scope and collection API for template. #1133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
c008466
46072dc
36de313
a806631
c814a10
3cce0b3
5cf142d
da5eebe
0d1d779
2349784
5b1402d
b4b9b10
7d85b55
56b984b
3db9e30
ef59886
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,16 +25,16 @@ | |
| </properties> | ||
|
|
||
| <dependencyManagement> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.testcontainers</groupId> | ||
| <artifactId>testcontainers-bom</artifactId> | ||
| <version>${testcontainers}</version> | ||
| <type>pom</type> | ||
| <scope>import</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| </dependencyManagement> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.testcontainers</groupId> | ||
| <artifactId>testcontainers-bom</artifactId> | ||
| <version>${testcontainers}</version> | ||
| <type>pom</type> | ||
| <scope>import</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| </dependencyManagement> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
|
|
@@ -173,6 +173,7 @@ | |
| <dependency> | ||
| <groupId>io.projectreactor</groupId> | ||
| <artifactId>reactor-test</artifactId> | ||
| <version>3.1.0.RELEASE</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
|
|
@@ -279,6 +280,14 @@ | |
| <groupId>org.asciidoctor</groupId> | ||
| <artifactId>asciidoctor-maven-plugin</artifactId> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <configuration> | ||
| <source>8</source> | ||
| <target>8</target> | ||
| </configuration> | ||
| </plugin> | ||
|
||
| </plugins> | ||
| </build> | ||
| </project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |
| import org.springframework.data.couchbase.core.mapping.CouchbaseMappingContext; | ||
| import org.springframework.data.couchbase.core.mapping.CouchbasePersistentEntity; | ||
| import org.springframework.data.couchbase.core.mapping.CouchbasePersistentProperty; | ||
| import org.springframework.data.couchbase.core.support.PseudoArgs; | ||
| import org.springframework.data.mapping.context.MappingContext; | ||
| import org.springframework.lang.Nullable; | ||
|
|
||
|
|
@@ -60,14 +61,14 @@ public CouchbaseTemplate(final CouchbaseClientFactory clientFactory, final Couch | |
| this.converter = converter; | ||
| this.templateSupport = new CouchbaseTemplateSupport(converter, translationService); | ||
| this.reactiveCouchbaseTemplate = new ReactiveCouchbaseTemplate(clientFactory, converter, translationService); | ||
|
|
||
| this.mappingContext = this.converter.getMappingContext(); | ||
| if (mappingContext instanceof CouchbaseMappingContext) { | ||
| CouchbaseMappingContext cmc = (CouchbaseMappingContext) mappingContext; | ||
| if (cmc.isAutoIndexCreation()) { | ||
| indexCreator = new CouchbasePersistentEntityIndexCreator(cmc, this); | ||
| } | ||
| } | ||
| if (mappingContext instanceof CouchbaseMappingContext) { | ||
| CouchbaseMappingContext cmc = (CouchbaseMappingContext) mappingContext; | ||
| if (cmc.isAutoIndexCreation()) { | ||
| indexCreator = new CouchbasePersistentEntityIndexCreator(cmc, this); | ||
| } | ||
| } | ||
| } | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just formatting changes |
||
|
|
||
| @Override | ||
|
|
@@ -184,4 +185,12 @@ private void prepareIndexCreator(final ApplicationContext context) { | |
| TemplateSupport support() { | ||
| return templateSupport; | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritDoc} | ||
| */ | ||
| public void setThreadLocalArgs(PseudoArgs pseudoArgs) { | ||
|
||
| reactiveCouchbaseTemplate.setThreadLocalArgs(pseudoArgs); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * Copyright 2012-2020 the original author or authors | ||
| * Copyright 2012-2021 the original author or authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
|
|
@@ -18,16 +18,29 @@ | |
| import java.util.Collection; | ||
| import java.util.Map; | ||
|
|
||
| import org.springframework.data.couchbase.core.support.InCollection; | ||
| import org.springframework.data.couchbase.core.support.InScope; | ||
| import org.springframework.data.couchbase.core.support.OneAndAllExists; | ||
| import org.springframework.data.couchbase.core.support.WithCollection; | ||
| import org.springframework.data.couchbase.core.support.WithExistsOptions; | ||
|
|
||
| import com.couchbase.client.java.kv.ExistsOptions; | ||
|
|
||
| /** | ||
| * Insert Operations | ||
| * | ||
| * @author Christoph Strobl | ||
| * @since 2.0 | ||
| */ | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm just adding javadoc that was missing. As near as I can figure, the original author was Christoph |
||
| public interface ExecutableExistsByIdOperation { | ||
|
|
||
| /** | ||
| * Checks if the document exists in the bucket. | ||
| */ | ||
| ExecutableExistsById existsById(); | ||
|
|
||
| /** | ||
| * Terminating operations invoking the actual execution. | ||
| */ | ||
| interface TerminatingExistsById extends OneAndAllExists { | ||
|
|
||
| /** | ||
|
|
@@ -36,6 +49,7 @@ interface TerminatingExistsById extends OneAndAllExists { | |
| * @param id the ID to perform the operation on. | ||
| * @return true if the document exists, false otherwise. | ||
| */ | ||
| @Override | ||
| boolean one(String id); | ||
|
|
||
| /** | ||
|
|
@@ -44,20 +58,59 @@ interface TerminatingExistsById extends OneAndAllExists { | |
| * @param ids the ids to check. | ||
| * @return a map consisting of the document IDs as the keys and if they exist as the value. | ||
| */ | ||
| @Override | ||
| Map<String, Boolean> all(Collection<String> ids); | ||
| } | ||
|
|
||
| /** | ||
| * Fluent method to specify options. | ||
| * | ||
| * @param <T> the entity type to use for the results. | ||
| */ | ||
| interface ExistsByIdWithOptions<T> extends TerminatingExistsById, WithExistsOptions<T> { | ||
| /** | ||
| * Fluent method to specify options to use for execution | ||
| * | ||
| * @param options options to use for execution | ||
| */ | ||
| @Override | ||
| TerminatingExistsById withOptions(ExistsOptions options); | ||
| } | ||
|
|
||
| interface ExistsByIdWithCollection extends TerminatingExistsById, WithCollection { | ||
| /** | ||
| * | ||
| * Fluent method to specify the collection. | ||
| * | ||
| * @param <T> the entity type to use for the results. | ||
| */ | ||
| interface ExistsByIdInCollection<T> extends ExistsByIdWithOptions<T>, InCollection<T> { | ||
| /** | ||
| * With a different collection | ||
| * | ||
| * @param collection the collection to use. | ||
| */ | ||
| @Override | ||
| ExistsByIdWithOptions<T> inCollection(String collection); | ||
| } | ||
|
|
||
| /** | ||
| * Fluent method to specify the scope. | ||
| * | ||
| * @param <T> the entity type to use for the results. | ||
| */ | ||
| interface ExistsByIdInScope<T> extends ExistsByIdInCollection<T>, InScope<T> { | ||
| /** | ||
| * Allows to specify a different collection than the default one configured. | ||
| * With a different scope | ||
| * | ||
| * @param collection the collection to use in this scope. | ||
| * @param scope the scope to use. | ||
| */ | ||
| TerminatingExistsById inCollection(String collection); | ||
| @Override | ||
| ExistsByIdInCollection<T> inScope(String scope); | ||
| } | ||
|
|
||
| interface ExecutableExistsById extends ExistsByIdWithCollection {} | ||
| /** | ||
| * Provides methods for constructing KV exists operations in a fluent way. | ||
| */ | ||
| interface ExecutableExistsById extends ExistsByIdInScope {} | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
latest one is 3.4.6, might cause issues with testing when using such an old version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to 3.4.6. Seems ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed one instance and removed the other (duplicate).