Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -173,6 +173,7 @@
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<version>3.1.0.RELEASE</version>
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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).

<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -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>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed. Shouldn't need this.

</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just formatting changes


@Override
Expand Down Expand Up @@ -184,4 +185,12 @@ private void prepareIndexCreator(final ApplicationContext context) {
TemplateSupport support() {
return templateSupport;
}

/**
* {@inheritDoc}
*/
public void setThreadLocalArgs(PseudoArgs pseudoArgs) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is something internal, can it 1) be package private or 2) if not, add a comment that it is internal?

Copy link
Collaborator Author

@mikereiche mikereiche May 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to package private.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused. Removed.

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.
Expand All @@ -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
*/
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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 {

/**
Expand All @@ -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);

/**
Expand All @@ -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 {}

}
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.
Expand All @@ -15,13 +15,14 @@
*/
package org.springframework.data.couchbase.core;

import org.springframework.data.couchbase.core.ReactiveExistsByIdOperationSupport.ReactiveExistsByIdSupport;

import java.util.Collection;
import java.util.Map;

import org.springframework.data.couchbase.core.ReactiveExistsByIdOperationSupport.ReactiveExistsByIdSupport;
import org.springframework.util.Assert;

import com.couchbase.client.java.kv.ExistsOptions;

public class ExecutableExistsByIdOperationSupport implements ExecutableExistsByIdOperation {

private final CouchbaseTemplate template;
Expand All @@ -32,17 +33,25 @@ public class ExecutableExistsByIdOperationSupport implements ExecutableExistsByI

@Override
public ExecutableExistsById existsById() {
return new ExecutableExistsByIdSupport(template, null);
return new ExecutableExistsByIdSupport(template, null, null, null);
}

static class ExecutableExistsByIdSupport implements ExecutableExistsById {

private final CouchbaseTemplate template;
private final String scope;
private final String collection;
private final ExistsOptions options;

private final ReactiveExistsByIdSupport reactiveSupport;

ExecutableExistsByIdSupport(final CouchbaseTemplate template, final String collection) {
ExecutableExistsByIdSupport(final CouchbaseTemplate template, final String scope, final String collection,
final ExistsOptions options) {
this.template = template;
this.reactiveSupport = new ReactiveExistsByIdSupport(template.reactive(), collection);
this.scope = scope;
this.collection = collection;
this.options = options;
this.reactiveSupport = new ReactiveExistsByIdSupport(template.reactive(), scope, collection, options);
}

@Override
Expand All @@ -56,11 +65,22 @@ public Map<String, Boolean> all(final Collection<String> ids) {
}

@Override
public TerminatingExistsById inCollection(final String collection) {
public ExistsByIdWithOptions inCollection(final String collection) {
Assert.hasText(collection, "Collection must not be null nor empty.");
return new ExecutableExistsByIdSupport(template, collection);
return new ExecutableExistsByIdSupport(template, scope, collection, options);
}

@Override
public TerminatingExistsById withOptions(final ExistsOptions options) {
Assert.notNull(options, "Options must not be null.");
return new ExecutableExistsByIdSupport(template, scope, collection, options);
}

@Override
public ExistsByIdInCollection inScope(final String scope) {
Assert.hasText(scope, "Scope must not be null nor empty.");
return new ExecutableExistsByIdSupport(template, scope, collection, options);
}
}

}
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.
Expand All @@ -21,14 +21,23 @@

import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.data.couchbase.core.query.AnalyticsQuery;
import org.springframework.data.couchbase.core.support.InCollection;
import org.springframework.data.couchbase.core.support.InScope;
import org.springframework.data.couchbase.core.support.OneAndAll;
import org.springframework.data.couchbase.core.support.WithAnalyticsConsistency;
import org.springframework.data.couchbase.core.support.WithAnalyticsOptions;
import org.springframework.data.couchbase.core.support.WithAnalyticsQuery;
import org.springframework.lang.Nullable;

import com.couchbase.client.java.analytics.AnalyticsOptions;
import com.couchbase.client.java.analytics.AnalyticsScanConsistency;

public interface ExecutableFindByAnalyticsOperation {
/**
* FindByAnalytics Operations
*
* @author Christoph Strobl
* @since 2.0
*/public interface ExecutableFindByAnalyticsOperation {

/**
* Queries the analytics service.
Expand Down Expand Up @@ -117,8 +126,53 @@ interface FindByAnalyticsWithQuery<T> extends TerminatingFindByAnalytics<T>, Wit

}

/**
* Fluent method to specify options.
*
* @param <T> the entity type to use.
*/
interface FindByAnalyticsWithOptions<T> extends FindByAnalyticsWithQuery<T>, WithAnalyticsOptions<T> {
/**
* Fluent method to specify options to use for execution
*
* @param options to use for execution
*/
@Override
FindByAnalyticsWithQuery<T> withOptions(AnalyticsOptions options);
}

/**
* Fluent method to specify the collection.
*
* @param <T> the entity type to use for the results.
*/
interface FindByAnalyticsInCollection<T> extends FindByAnalyticsWithOptions<T>, InCollection<T> {
/**
* With a different collection
*
* @param collection the collection to use.
*/
@Override
FindByAnalyticsWithOptions<T> inCollection(String collection);
}

/**
* Fluent method to specify the scope.
*
* @param <T> the entity type to use for the results.
*/
interface FindByAnalyticsInScope<T> extends FindByAnalyticsInCollection<T>, InScope<T> {
/**
* With a different scope
*
* @param scope the scope to use.
*/
@Override
FindByAnalyticsInCollection<T> inScope(String scope);
}

@Deprecated
interface FindByAnalyticsConsistentWith<T> extends FindByAnalyticsWithQuery<T> {
interface FindByAnalyticsConsistentWith<T> extends FindByAnalyticsInScope<T> {

/**
* Allows to override the default scan consistency.
Expand All @@ -138,9 +192,24 @@ interface FindByAnalyticsWithConsistency<T> extends FindByAnalyticsConsistentWit
* @param scanConsistency the custom scan consistency to use for this analytics query.
*/
FindByAnalyticsConsistentWith<T> withConsistency(AnalyticsScanConsistency scanConsistency);
}

/**
* Result type override (Optional).
*/
interface FindByAnalyticsWithProjection<T> extends FindByAnalyticsWithConsistency<T> {

/**
* Define the target type fields should be mapped to. <br />
* Skip this step if you are anyway only interested in the original domain type.
*
* @param returnType must not be {@literal null}.
* @return new instance of {@link FindByAnalyticsWithConsistency}.
* @throws IllegalArgumentException if returnType is {@literal null}.
*/
<R> FindByAnalyticsWithConsistency<R> as(Class<R> returnType);
}

interface ExecutableFindByAnalytics<T> extends FindByAnalyticsWithConsistency<T> {}
interface ExecutableFindByAnalytics<T> extends FindByAnalyticsWithProjection<T> {}

}
Loading