-
Notifications
You must be signed in to change notification settings - Fork 192
DATACOUCH-588 - Part 2 of framework changes. Add support for projecti… #1040
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
Merged
mikereiche
merged 1 commit into
master
from
datacouch_part_2_of_n_framework_projection_distinct
Jan 14, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,10 @@ | |
|
||
import java.util.Collection; | ||
|
||
import org.springframework.data.couchbase.core.support.OneAndAllId; | ||
import org.springframework.data.couchbase.core.support.WithCollection; | ||
import org.springframework.data.couchbase.core.support.WithProjectionId; | ||
|
||
public interface ExecutableFindByIdOperation { | ||
|
||
/** | ||
|
@@ -26,7 +30,7 @@ public interface ExecutableFindByIdOperation { | |
*/ | ||
<T> ExecutableFindById<T> findById(Class<T> domainType); | ||
|
||
interface TerminatingFindById<T> { | ||
interface TerminatingFindById<T> extends OneAndAllId<T> { | ||
|
||
/** | ||
* Finds one document based on the given ID. | ||
|
@@ -46,7 +50,7 @@ interface TerminatingFindById<T> { | |
|
||
} | ||
|
||
interface FindByIdWithCollection<T> extends TerminatingFindById<T> { | ||
interface FindByIdWithCollection<T> extends TerminatingFindById<T>, WithCollection<T> { | ||
|
||
/** | ||
* Allows to specify a different collection than the default one configured. | ||
|
@@ -57,7 +61,7 @@ interface FindByIdWithCollection<T> extends TerminatingFindById<T> { | |
|
||
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. if each with-er returns ExecutableFindById, then there is no need to chain the interfaces. |
||
} | ||
|
||
interface FindByIdWithProjection<T> extends FindByIdWithCollection<T> { | ||
interface FindByIdWithProjection<T> extends FindByIdWithCollection<T>, WithProjectionId<T> { | ||
|
||
/** | ||
* Load only certain fields for the document. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,13 @@ | |
|
||
import org.springframework.dao.IncorrectResultSizeDataAccessException; | ||
import org.springframework.data.couchbase.core.query.Query; | ||
import org.springframework.data.couchbase.core.query.QueryCriteriaDefinition; | ||
import org.springframework.data.couchbase.core.support.OneAndAll; | ||
import org.springframework.data.couchbase.core.support.WithCollection; | ||
import org.springframework.data.couchbase.core.support.WithConsistency; | ||
import org.springframework.data.couchbase.core.support.WithDistinct; | ||
import org.springframework.data.couchbase.core.support.WithProjection; | ||
import org.springframework.data.couchbase.core.support.WithQuery; | ||
import org.springframework.lang.Nullable; | ||
|
||
import com.couchbase.client.java.query.QueryScanConsistency; | ||
|
@@ -34,7 +41,7 @@ public interface ExecutableFindByQueryOperation { | |
*/ | ||
<T> ExecutableFindByQuery<T> findByQuery(Class<T> domainType); | ||
|
||
interface TerminatingFindByQuery<T> { | ||
interface TerminatingFindByQuery<T> extends OneAndAll<T> { | ||
/** | ||
* Get exactly zero or one result. | ||
* | ||
|
@@ -107,7 +114,7 @@ default Optional<T> first() { | |
* @author Christoph Strobl | ||
* @since 2.0 | ||
*/ | ||
interface FindByQueryWithQuery<T> extends TerminatingFindByQuery<T> { | ||
interface FindByQueryWithQuery<T> extends TerminatingFindByQuery<T>, WithQuery<T> { | ||
|
||
/** | ||
* Set the filter for the query to be used. | ||
|
@@ -117,30 +124,90 @@ interface FindByQueryWithQuery<T> extends TerminatingFindByQuery<T> { | |
*/ | ||
TerminatingFindByQuery<T> matching(Query query); | ||
|
||
/** | ||
* Set the filter {@link QueryCriteriaDefinition criteria} to be used. | ||
* | ||
* @param criteria must not be {@literal null}. | ||
* @return new instance of {@link ExecutableFindByQuery}. | ||
* @throws IllegalArgumentException if criteria is {@literal null}. | ||
*/ | ||
default TerminatingFindByQuery<T> matching(QueryCriteriaDefinition criteria) { | ||
return matching(Query.query(criteria)); | ||
} | ||
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. mongo provides a matching(Criteria) method. |
||
|
||
} | ||
|
||
interface FindByQueryInCollection<T> extends FindByQueryWithQuery<T>, WithCollection<T> { | ||
|
||
/** | ||
* Allows to override the default scan consistency. | ||
* | ||
* @param collection the collection to use for this query. | ||
*/ | ||
FindByQueryWithQuery<T> inCollection(String collection); | ||
|
||
} | ||
|
||
interface FindByQueryConsistentWith<T> extends FindByQueryWithQuery<T> { | ||
@Deprecated | ||
interface FindByQueryConsistentWith<T> extends FindByQueryInCollection<T> { | ||
|
||
/** | ||
* Allows to override the default scan consistency. | ||
* | ||
* @param scanConsistency the custom scan consistency to use for this query. | ||
*/ | ||
FindByQueryConsistentWith<T> consistentWith(QueryScanConsistency scanConsistency); | ||
@Deprecated | ||
FindByQueryInCollection<T> consistentWith(QueryScanConsistency scanConsistency); | ||
|
||
} | ||
|
||
interface FindByQueryInCollection<T> extends FindByQueryConsistentWith<T> { | ||
interface FindByQueryWithConsistency<T> extends FindByQueryConsistentWith<T>, WithConsistency<T> { | ||
|
||
/** | ||
* Allows to override the default scan consistency. | ||
* | ||
* @param collection the collection to use for this query. | ||
* @param scanConsistency the custom scan consistency to use for this query. | ||
*/ | ||
FindByQueryConsistentWith<T> withConsistency(QueryScanConsistency scanConsistency); | ||
|
||
} | ||
|
||
/** | ||
* Result type override (Optional). | ||
*/ | ||
interface FindByQueryWithProjection<T> extends FindByQueryWithConsistency<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 FindByQueryWithProjection}. | ||
* @throws IllegalArgumentException if returnType is {@literal null}. | ||
*/ | ||
<R> FindByQueryWithConsistency<R> as(Class<R> returnType); | ||
} | ||
|
||
/** | ||
* Distinct Find support. | ||
*/ | ||
interface FindByQueryWithDistinct<T> extends FindByQueryWithProjection<T>, WithDistinct<T> { | ||
|
||
/** | ||
* Finds the distinct values for a specified {@literal field} across a single collection | ||
* | ||
* @param distinctFields name of the field. Must not be {@literal null}. | ||
* @return new instance of {@link ExecutableFindByQuery}. | ||
* @throws IllegalArgumentException if field is {@literal null}. | ||
*/ | ||
FindByQueryInCollection<T> inCollection(String collection); | ||
FindByQueryWithProjection<T> distinct(String[] distinctFields); | ||
|
||
} | ||
|
||
interface ExecutableFindByQuery<T> extends FindByQueryInCollection<T> {} | ||
/** | ||
* {@link ExecutableFindByQuery} provides methods for constructing lookup operations in a fluent way. | ||
*/ | ||
|
||
interface ExecutableFindByQuery<T> extends FindByQueryWithDistinct<T> {} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I've removed as much of the dependencies as possible.
There's no need for every interface to extend TerminatingFindById. It's sufficient for ExecutableFindById to extend it.