From 33fdffab2fcec6ecd14e4e476f47d3f33ac90ce5 Mon Sep 17 00:00:00 2001 From: Michael Nitschinger Date: Mon, 11 May 2020 15:05:53 +0200 Subject: [PATCH] DATACOUCH-539 - Deprecate annotations before GA This changeset also brings back deleted annotations so that they do not cause build issues in other components. --- .../couchbase/core/query/Dimensional.java | 1 + .../core/query/N1qlPrimaryIndexed.java | 36 +++++++++++ .../core/query/N1qlSecondaryIndexed.java | 47 ++++++++++++++ .../data/couchbase/core/query/View.java | 1 + .../couchbase/core/query/ViewIndexed.java | 64 +++++++++++++++++++ 5 files changed, 149 insertions(+) create mode 100644 src/main/java/org/springframework/data/couchbase/core/query/N1qlPrimaryIndexed.java create mode 100644 src/main/java/org/springframework/data/couchbase/core/query/N1qlSecondaryIndexed.java create mode 100644 src/main/java/org/springframework/data/couchbase/core/query/ViewIndexed.java diff --git a/src/main/java/org/springframework/data/couchbase/core/query/Dimensional.java b/src/main/java/org/springframework/data/couchbase/core/query/Dimensional.java index 58223340..6b24c21d 100644 --- a/src/main/java/org/springframework/data/couchbase/core/query/Dimensional.java +++ b/src/main/java/org/springframework/data/couchbase/core/query/Dimensional.java @@ -33,6 +33,7 @@ import org.springframework.data.annotation.QueryAnnotation; @Retention(RetentionPolicy.RUNTIME) @Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE }) @QueryAnnotation +@Deprecated public @interface Dimensional { /** The name of the design document to be queried */ String designDocument(); diff --git a/src/main/java/org/springframework/data/couchbase/core/query/N1qlPrimaryIndexed.java b/src/main/java/org/springframework/data/couchbase/core/query/N1qlPrimaryIndexed.java new file mode 100644 index 00000000..815de56c --- /dev/null +++ b/src/main/java/org/springframework/data/couchbase/core/query/N1qlPrimaryIndexed.java @@ -0,0 +1,36 @@ +/* + * Copyright 2012-2020 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.data.couchbase.core.query; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.data.couchbase.repository.CouchbaseRepository; + +/** + * This annotation is targeted at {@link CouchbaseRepository Repository} interfaces, indicating that the framework + * should ensure a N1QL Primary Index is present on the repository's associated bucket when the repository is created. + * + * @author Simon Baslé + */ +@Deprecated +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface N1qlPrimaryIndexed { +} diff --git a/src/main/java/org/springframework/data/couchbase/core/query/N1qlSecondaryIndexed.java b/src/main/java/org/springframework/data/couchbase/core/query/N1qlSecondaryIndexed.java new file mode 100644 index 00000000..a4d1e403 --- /dev/null +++ b/src/main/java/org/springframework/data/couchbase/core/query/N1qlSecondaryIndexed.java @@ -0,0 +1,47 @@ +/* + * Copyright 2012-2020 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.data.couchbase.core.query; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.data.couchbase.repository.CouchbaseRepository; + +/** + * This annotation is targeted at {@link CouchbaseRepository Repository} interfaces, indicating that the framework + * should ensure a N1QL Secondary Index is present when the repository is instantiated. + *

+ * Said index will relate to the "type" field (the one bearing type information) and restrict on documents that match + * the repository's entity class. + *

+ * Be sure to also use {@link N1qlPrimaryIndexed} to make sure the PRIMARY INDEX is there as well. + * + * @author Simon Baslé + */ +@Target({ ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +@Deprecated +public @interface N1qlSecondaryIndexed { + + /** + * the name of the index to be created, in the repository's associated bucket namespace. + */ + String indexName(); + +} diff --git a/src/main/java/org/springframework/data/couchbase/core/query/View.java b/src/main/java/org/springframework/data/couchbase/core/query/View.java index 6de0d9c5..7ade9db0 100644 --- a/src/main/java/org/springframework/data/couchbase/core/query/View.java +++ b/src/main/java/org/springframework/data/couchbase/core/query/View.java @@ -33,6 +33,7 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) // don't set @QueryAnnotation, as it causes problems with reduce and replacing count() method, the reduce detection // needs to be improved +@Deprecated public @interface View { /** diff --git a/src/main/java/org/springframework/data/couchbase/core/query/ViewIndexed.java b/src/main/java/org/springframework/data/couchbase/core/query/ViewIndexed.java new file mode 100644 index 00000000..43b21215 --- /dev/null +++ b/src/main/java/org/springframework/data/couchbase/core/query/ViewIndexed.java @@ -0,0 +1,64 @@ +/* + * Copyright 2012-2020 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.data.couchbase.core.query; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.data.couchbase.repository.CouchbaseRepository; + +/** + * This annotation is targeted at {@link CouchbaseRepository Repository} interfaces, indicating that the framework + * should ensure a View is present when the repository is instantiated. + *

+ * The view must at least be described as a design document name and view name. Default map function will filter + * documents on the type associated to the repository, and default reduce function is "_count". + *

+ * One can specify a custom reduce function as well as a non-default map function. + * + * @author Simon Baslé + */ +@Target({ ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +@Deprecated +public @interface ViewIndexed { + + /** + * The design document in which to create/look for the view. Usually to create the backing view for CRUD methods, the + * expected designDoc value is the entity's simple class name, with a lowercase first letter (eg. a UserInfo + * repository would expect a design document named "userInfo"). + */ + String designDoc(); + + /** + * The name of the view, defaults to "all" (which is what CRUD methods expect by default). + */ + String viewName() default "all"; + + /** + * The map function to use (default is empty, which will trigger a default map function filtering on the repository's + * associated entity type). + */ + String mapFunction() default ""; + + /** + * The reduce function to use (default is built in "_count" reduce function). + */ + String reduceFunction() default "_count"; +}