Skip to content

Commit 0bdecef

Browse files
committed
Revert "Scopes and collections for repositories (#1149)"
This reverts commit 1581712.
1 parent 0983e66 commit 0bdecef

File tree

97 files changed

+960
-2615
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+960
-2615
lines changed

src/main/java/org/springframework/data/couchbase/SimpleCouchbaseClientFactory.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors
2+
* Copyright 2012-2020 the original author or authors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.data.couchbase;
1718

1819
import java.util.function.Supplier;
@@ -32,9 +33,6 @@
3233

3334
/**
3435
* The default implementation of a {@link CouchbaseClientFactory}.
35-
*
36-
* @author Michael Nitschinger
37-
* @author Michael Reiche
3836
*/
3937
public class SimpleCouchbaseClientFactory implements CouchbaseClientFactory {
4038

@@ -76,7 +74,7 @@ private SimpleCouchbaseClientFactory(final Supplier<Cluster> cluster, final Stri
7674

7775
@Override
7876
public CouchbaseClientFactory withScope(final String scopeName) {
79-
return new SimpleCouchbaseClientFactory(cluster, bucket.name(), scopeName != null ? scopeName : getScope().name());
77+
return new SimpleCouchbaseClientFactory(cluster, bucket.name(), scopeName);
8078
}
8179

8280
@Override

src/main/java/org/springframework/data/couchbase/config/AbstractCouchbaseConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.HashSet;
2323
import java.util.Set;
2424

25+
import org.springframework.beans.factory.annotation.Autowired;
2526
import org.springframework.beans.factory.config.BeanDefinition;
2627
import org.springframework.context.annotation.Bean;
2728
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;

src/main/java/org/springframework/data/couchbase/core/CouchbaseTemplate.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.springframework.data.couchbase.core.mapping.CouchbaseMappingContext;
2929
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentEntity;
3030
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentProperty;
31+
import org.springframework.data.couchbase.core.support.PseudoArgs;
3132
import org.springframework.data.mapping.context.MappingContext;
3233
import org.springframework.lang.Nullable;
3334

@@ -106,25 +107,13 @@ public <T> ExecutableFindByAnalytics<T> findByAnalytics(Class<T> domainType) {
106107
}
107108

108109
@Override
109-
@Deprecated
110110
public ExecutableRemoveById removeById() {
111-
return removeById(null);
111+
return new ExecutableRemoveByIdOperationSupport(this).removeById();
112112
}
113113

114114
@Override
115-
public ExecutableRemoveById removeById(Class<?> domainType) {
116-
return new ExecutableRemoveByIdOperationSupport(this).removeById(domainType);
117-
}
118-
119-
@Override
120-
@Deprecated
121115
public ExecutableExistsById existsById() {
122-
return existsById(null);
123-
}
124-
125-
@Override
126-
public ExecutableExistsById existsById(Class<?> domainType) {
127-
return new ExecutableExistsByIdOperationSupport(this).existsById(domainType);
116+
return new ExecutableExistsByIdOperationSupport(this).existsById();
128117
}
129118

130119
@Override

src/main/java/org/springframework/data/couchbase/core/CouchbaseTemplateSupport.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
package org.springframework.data.couchbase.core;
1919

20-
import org.slf4j.Logger;
21-
import org.slf4j.LoggerFactory;
2220
import org.springframework.beans.BeansException;
2321
import org.springframework.context.ApplicationContext;
2422
import org.springframework.context.ApplicationContextAware;
@@ -40,6 +38,9 @@
4038
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
4139
import org.springframework.util.Assert;
4240

41+
import org.slf4j.Logger;
42+
import org.slf4j.LoggerFactory;
43+
4344
/**
4445
* Internal encode/decode support for CouchbaseTemplate.
4546
*

src/main/java/org/springframework/data/couchbase/core/ExecutableExistsByIdOperation.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,8 @@ public interface ExecutableExistsByIdOperation {
3636
/**
3737
* Checks if the document exists in the bucket.
3838
*/
39-
@Deprecated
4039
ExecutableExistsById existsById();
4140

42-
/**
43-
* Checks if the document exists in the bucket.
44-
*/
45-
ExecutableExistsById existsById(Class<?> domainType);
46-
4741
/**
4842
* Terminating operations invoking the actual execution.
4943
*/
@@ -84,6 +78,7 @@ interface ExistsByIdWithOptions<T> extends TerminatingExistsById, WithExistsOpti
8478
}
8579

8680
/**
81+
*
8782
* Fluent method to specify the collection.
8883
*
8984
* @param <T> the entity type to use for the results.

src/main/java/org/springframework/data/couchbase/core/ExecutableExistsByIdOperationSupport.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,26 @@ public class ExecutableExistsByIdOperationSupport implements ExecutableExistsByI
3232
}
3333

3434
@Override
35-
@Deprecated
3635
public ExecutableExistsById existsById() {
37-
return existsById(null);
38-
}
39-
40-
@Override
41-
public ExecutableExistsById existsById(Class<?> domainType) {
42-
return new ExecutableExistsByIdSupport(template, domainType, null, null, null);
36+
return new ExecutableExistsByIdSupport(template, null, null, null);
4337
}
4438

4539
static class ExecutableExistsByIdSupport implements ExecutableExistsById {
4640

4741
private final CouchbaseTemplate template;
48-
private final Class<?> domainType;
4942
private final String scope;
5043
private final String collection;
5144
private final ExistsOptions options;
5245

5346
private final ReactiveExistsByIdSupport reactiveSupport;
5447

55-
ExecutableExistsByIdSupport(final CouchbaseTemplate template, final Class<?> domainType, final String scope,
56-
final String collection, final ExistsOptions options) {
48+
ExecutableExistsByIdSupport(final CouchbaseTemplate template, final String scope, final String collection,
49+
final ExistsOptions options) {
5750
this.template = template;
58-
this.domainType = domainType;
5951
this.scope = scope;
6052
this.collection = collection;
6153
this.options = options;
62-
this.reactiveSupport = new ReactiveExistsByIdSupport(template.reactive(), domainType, scope, collection, options);
54+
this.reactiveSupport = new ReactiveExistsByIdSupport(template.reactive(), scope, collection, options);
6355
}
6456

6557
@Override
@@ -74,18 +66,20 @@ public Map<String, Boolean> all(final Collection<String> ids) {
7466

7567
@Override
7668
public ExistsByIdWithOptions inCollection(final String collection) {
77-
return new ExecutableExistsByIdSupport(template, domainType, scope, collection, options);
69+
Assert.hasText(collection, "Collection must not be null nor empty.");
70+
return new ExecutableExistsByIdSupport(template, scope, collection, options);
7871
}
7972

8073
@Override
8174
public TerminatingExistsById withOptions(final ExistsOptions options) {
8275
Assert.notNull(options, "Options must not be null.");
83-
return new ExecutableExistsByIdSupport(template, domainType, scope, collection, options);
76+
return new ExecutableExistsByIdSupport(template, scope, collection, options);
8477
}
8578

8679
@Override
8780
public ExistsByIdInCollection inScope(final String scope) {
88-
return new ExecutableExistsByIdSupport(template, domainType, scope, collection, options);
81+
Assert.hasText(scope, "Scope must not be null nor empty.");
82+
return new ExecutableExistsByIdSupport(template, scope, collection, options);
8983
}
9084
}
9185

src/main/java/org/springframework/data/couchbase/core/ExecutableFindByAnalyticsOperationSupport.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,14 @@ public FindByAnalyticsWithQuery<T> withOptions(final AnalyticsOptions options) {
9797

9898
@Override
9999
public FindByAnalyticsInCollection<T> inScope(final String scope) {
100+
Assert.hasText(scope, "Scope must not be null nor empty.");
100101
return new ExecutableFindByAnalyticsSupport<>(template, domainType, returnType, query, scanConsistency, scope,
101102
collection, options);
102103
}
103104

104105
@Override
105106
public FindByAnalyticsWithConsistency<T> inCollection(final String collection) {
107+
Assert.hasText(collection, "Collection must not be null nor empty.");
106108
return new ExecutableFindByAnalyticsSupport<>(template, domainType, returnType, query, scanConsistency, scope,
107109
collection, options);
108110
}

src/main/java/org/springframework/data/couchbase/core/ExecutableFindByIdOperationSupport.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,19 @@ public TerminatingFindById<T> withOptions(final GetOptions options) {
7777

7878
@Override
7979
public FindByIdWithOptions<T> inCollection(final String collection) {
80+
Assert.hasText(collection, "Collection must not be null nor empty.");
8081
return new ExecutableFindByIdSupport<>(template, domainType, scope, collection, options, fields);
8182
}
8283

8384
@Override
8485
public FindByIdInCollection<T> inScope(final String scope) {
86+
Assert.hasText(scope, "Scope must not be null nor empty.");
8587
return new ExecutableFindByIdSupport<>(template, domainType, scope, collection, options, fields);
8688
}
8789

8890
@Override
8991
public FindByIdInScope<T> project(String... fields) {
90-
Assert.notEmpty(fields, "Fields must not be null.");
92+
Assert.notEmpty(fields, "Fields must not be null nor empty.");
9193
return new ExecutableFindByIdSupport<>(template, domainType, scope, collection, options, Arrays.asList(fields));
9294
}
9395

src/main/java/org/springframework/data/couchbase/core/ExecutableFindByQueryOperationSupport.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ static class ExecutableFindByQuerySupport<T> implements ExecutableFindByQuery<T>
6868
this.returnType = returnType;
6969
this.query = query;
7070
this.reactiveSupport = new ReactiveFindByQuerySupport<T>(template.reactive(), domainType, returnType, query,
71-
scanConsistency, scope, collection, options, distinctFields,
72-
new NonReactiveSupportWrapper(template.support()));
71+
scanConsistency, scope, collection, options, distinctFields, new NonReactiveSupportWrapper(template.support()));
7372
this.scanConsistency = scanConsistency;
7473
this.scope = scope;
7574
this.collection = collection;
@@ -127,12 +126,8 @@ public <R> FindByQueryWithConsistency<R> as(final Class<R> returnType) {
127126
@Override
128127
public FindByQueryWithProjection<T> distinct(final String[] distinctFields) {
129128
Assert.notNull(distinctFields, "distinctFields must not be null!");
130-
// Coming from an annotation, this cannot be null.
131-
// But a non-null but empty distinctFields means distinct on all fields
132-
// So to indicate do not use distinct, we use {"-"} from the annotation, and here we change it to null.
133-
String[] dFields = distinctFields.length == 1 && "-".equals(distinctFields[0]) ? null : distinctFields;
134129
return new ExecutableFindByQuerySupport<>(template, domainType, returnType, query, scanConsistency, scope,
135-
collection, options, dFields);
130+
collection, options, distinctFields);
136131
}
137132

138133
@Override
@@ -159,12 +154,14 @@ public TerminatingFindByQuery<T> withOptions(final QueryOptions options) {
159154

160155
@Override
161156
public FindByQueryInCollection<T> inScope(final String scope) {
157+
Assert.hasText(scope, "Scope must not be null nor empty.");
162158
return new ExecutableFindByQuerySupport<>(template, domainType, returnType, query, scanConsistency, scope,
163159
collection, options, distinctFields);
164160
}
165161

166162
@Override
167163
public FindByQueryWithConsistency<T> inCollection(final String collection) {
164+
Assert.hasText(collection, "Collection must not be null nor empty.");
168165
return new ExecutableFindByQuerySupport<>(template, domainType, returnType, query, scanConsistency, scope,
169166
collection, options, distinctFields);
170167
}

src/main/java/org/springframework/data/couchbase/core/ExecutableFindFromReplicasByIdOperationSupport.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
import java.util.Collection;
1919

2020
import org.springframework.data.couchbase.core.ReactiveFindFromReplicasByIdOperationSupport.ReactiveFindFromReplicasByIdSupport;
21-
import org.springframework.util.Assert;
2221

2322
import com.couchbase.client.java.kv.GetAnyReplicaOptions;
23+
import org.springframework.util.Assert;
2424

2525
public class ExecutableFindFromReplicasByIdOperationSupport implements ExecutableFindFromReplicasByIdOperation {
2626

@@ -54,7 +54,7 @@ static class ExecutableFindFromReplicasByIdSupport<T> implements ExecutableFindF
5454
this.options = options;
5555
this.returnType = returnType;
5656
this.reactiveSupport = new ReactiveFindFromReplicasByIdSupport<>(template.reactive(), domainType, returnType,
57-
scope, collection, options, new NonReactiveSupportWrapper(template.support()));
57+
scope, collection, options, new NonReactiveSupportWrapper(template.support()));
5858
}
5959

6060
@Override
@@ -75,11 +75,13 @@ public TerminatingFindFromReplicasById<T> withOptions(final GetAnyReplicaOptions
7575

7676
@Override
7777
public FindFromReplicasByIdWithOptions<T> inCollection(final String collection) {
78+
Assert.hasText(collection, "Collection must not be null nor empty.");
7879
return new ExecutableFindFromReplicasByIdSupport<>(template, domainType, returnType, scope, collection, options);
7980
}
8081

8182
@Override
8283
public FindFromReplicasByIdInCollection<T> inScope(final String scope) {
84+
Assert.hasText(scope, "Scope must not be null nor empty.");
8385
return new ExecutableFindFromReplicasByIdSupport<>(template, domainType, returnType, scope, collection, options);
8486
}
8587

src/main/java/org/springframework/data/couchbase/core/ExecutableInsertByIdOperationSupport.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,14 @@ public TerminatingInsertById<T> withOptions(final InsertOptions options) {
8989

9090
@Override
9191
public InsertByIdInCollection<T> inScope(final String scope) {
92+
Assert.hasText(scope, "Scope must not be null nor empty.");
9293
return new ExecutableInsertByIdSupport<>(template, domainType, scope, collection, options, persistTo, replicateTo,
9394
durabilityLevel, expiry);
9495
}
9596

9697
@Override
9798
public InsertByIdWithOptions<T> inCollection(final String collection) {
99+
Assert.hasText(collection, "Collection must not be null nor empty.");
98100
return new ExecutableInsertByIdSupport<>(template, domainType, scope, collection, options, persistTo, replicateTo,
99101
durabilityLevel, expiry);
100102
}

src/main/java/org/springframework/data/couchbase/core/ExecutableRemoveByIdOperation.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.Collection;
1919
import java.util.List;
2020

21+
import org.springframework.data.couchbase.core.query.WithConsistency;
2122
import org.springframework.data.couchbase.core.support.InCollection;
2223
import org.springframework.data.couchbase.core.support.InScope;
2324
import org.springframework.data.couchbase.core.support.OneAndAllId;
@@ -38,12 +39,6 @@ public interface ExecutableRemoveByIdOperation {
3839
/**
3940
* Removes a document.
4041
*/
41-
ExecutableRemoveById removeById(Class<?> domainType);
42-
43-
/**
44-
* Removes a document.
45-
*/
46-
@Deprecated
4742
ExecutableRemoveById removeById();
4843

4944
/**

0 commit comments

Comments
 (0)