Commit Graph

67 Commits

Author SHA1 Message Date
Subhashni Balakrishnan
53e3285098 DATACOUCH-341 - Add kotlin extension functions
Motivation
----------
Add kotin extension methods to couchbase and reactive couchbase
operations as required.

Changes
-------
Extensions leveraging reified type has been added.

Results
-------
It is now possible to use reified types rather than passing the java
class reference to some operation functions.

Original pull request: #160.
2018-03-13 10:02:00 -07:00
Mark Paluch
a46f8160a9 DATACOUCH-368 - Export composable repositories via CDI.
We now export composable repositories through our CDI extension. Repositories can now be customized either by a single custom implementation (as it was before) and by providing fragment interfaces along their fragment implementation.

This change aligns CDI support with the existing RepositoryFactory support we provide within a Spring application context.
2018-03-12 16:55:30 +01:00
Subhashni Balakrishnan
0960f11a9c DATACOUCH-322 - Add RBAC username and password support
Motivation
----------
Couchbase server 5.0 allows role based access control and this allows
for users to be created and granted access to use bucket. Expose this
feature in SDC.

Changes
-------
1. Couchbase configurations allow for user name to be set. The user password
property is still retrieved from bucket password property.
2. CouchbaseFactoryBean has additional constructor for the username
property.
3. Couchbase bucket schema for xml configurations also includes username
property.
4. Integration tests have been restructured majorly to accomadate for
username
    - Testcontainers are used to allow for container based testing.
    - Container based testing is optional, it can be configured using
      resources/server.properties

Results
-------
The RBAC change has been tested with pre 5.0 and 5.0+ versions using
containers. The tests pass.

Original pull request: #158.
2018-03-07 15:09:15 -08:00
Subhashni Balakrishnan
039e106032 DATACOUCH-362 - Use dynamic proxying
Dynamic proxying for couchbase environment instead of an explicit no shutdown
proxy.

Original pull request: #157.

DATACOUCH-363 - Upgrade to 2.5.5

Java client upgrade. Remove the dcpEnabled property from
CouchbaseEnvironment factory bean and parser.

Original pull request: #157.
2018-03-07 13:26:55 -08:00
Mark Paluch
5268ad20c0 DATACOUCH-336 - Upgrade to OpenWebBeans 2.0.1 2017-09-18 15:40:57 +02:00
MLabusquiere
761c08517b DATACOUCH-329 - Save repo return with the generated id
Original pull request: #151.
2017-08-24 13:49:00 -07:00
Subhashni Balakrishnan
047921956b DATACOUCH-309 Convert IDs as well if custom conversions are available in Simple Repository
Original pull request: #146.
2017-06-12 17:26:45 -07:00
Subhashni Balakrishnan
70343b0ac1 DATACOUCH-296 Add support for delete n1ql queries
Changes to support delete query by query derivation and SpEL based
queries.
- Adds a N1qlMutateQueryCreator which constucts the delete query
using dsl.
- Adds new SpEL values delete and returning required for delete
queries.

Original pull request: #144.
2017-06-12 17:22:53 -07:00
Oliver Gierke
22205678ef DATACOUCH-305 - Adapt to API changes in repository interfaces. 2017-05-03 17:48:06 +02:00
Subhashni Balakrishnan
069ceea65c DATACOUCH-275 Key auto generation using Attributes, UUID
Original pull request: #142.
2017-04-12 14:38:21 -07:00
Alexander Derkach
6429dca5e6 DATACOUCH-287 - Add CAS operations to RxJavaCouchbaseOperations.
Original pull request: #135.
2017-04-06 06:57:53 -07:00
Mark Paluch
141dbefd3d DATACOUCH-273 - Integrate Data Commons Java 8 upgrade branch.
Replace PersistentEntity.doWithProperties(…) and .doWithAssociations(…) with stream processing using PersistentEntity.getPersistentProperties() and PersistentEntity.getAssociations().
2017-03-24 09:57:13 +01:00
Subhashni Balakrishnan
1c33ccc4c8 DATACOUCH-279 - Re-add AbstractCouchbaseDataConfiguration
Motivation
----------
AbstractCouchbaseDataConfiguration was removed and
AbstractCouchbaseConfiguration was made the only configuration support
which implemented CouchbaseConfigurer. This broke integration with
Spring boot as they used CouchbaseConfigurer to auto configure client
initialization properties.

Changes
-------
Bring back support for AbstractCouchbaseDataConfiguration which allows the use
of CouchbaseConfigurer. Also added a similar configuration support for reactive
data repositories. Common beans between reactive and blocking are implemented
in CouchbaseConfigurationSupport class. The existing tests in
AbstractCouchbaseDataConfigurationTest does test this scenario. However the
previous commit had also changed the test because of the unawareness of spring
boot integration.

Results
-------
It is now possible to configure SDC with CouchbaseConfigurer instead of
only having to extend from AbstractCouchbaseConfiguration.
2017-02-07 10:15:00 +01:00
Subhashni Balakrishnan
c26053868c DATACOUCH-265 - Verify entity filter is not added, if n1ql.filter is not in query
Original pull request: #128.
2017-02-05 13:08:38 -08:00
Subhashni Balakrishnan
5d36ecc12b DATACOUCH-265 - Support pageable and sort for String based SpEL queries
Original pull request: #128.
2017-02-05 13:08:38 -08:00
Subhashni Balakrishnan
162d8124ab DATACOUCH-260 - Update to 2.4.1 and fix tests
Adapted changes to 3.0 branch

Original pull request: #131.
2017-02-05 13:08:38 -08:00
Subhashni Balakrishnan
d62f4bbe8c DATACOUCH-146 - Reactive repositories support
- Adds experimental support for reactor types in reactive CRUD and Sorting
  repositories using RxJava1Template
- Refactor configuration and query classes to be reusable by reactive repositories

Original pull request: #130.
2017-02-05 10:34:57 -08:00
Subhashni Balakrishnan
b52dee3a3c DATACOUCH-251 - Wrap base where criteria with parenthesis for OR expressions.
Base criteria for the query should be wrapped before adding the entity filter criteria so the priority of filtering is clear.
2016-12-20 10:57:47 +01:00
Subhashni Balakrishnan
ce356f827f DATACOUCH-246 - Projections support for query derivation.
Used the result processor projecting information to just fetch the selected fields and again to post process results to projection object/interfaces.

Added test for projection using DTO.

Original pull request: #122.
2016-12-02 18:04:12 +01:00
Simon Baslé
415d8a2d23 DATACOUCH-241 - Document mixing SpEL and N1QL placeholders 2016-08-18 12:55:24 +02:00
Simon Baslé
d6b63c305a DATACOUCH-227 - Keep isOrderRetained view param, bump to SDK 2.2.8 2016-06-13 16:28:50 +02:00
Anastasiia Smirnova
811c024041 DATACOUCH-224 - Improve concurrent save/insert, optimistic locking 2016-05-10 15:48:34 +02:00
Mark Paluch
db4c24d9f1 DATACOUCH-203 - Use Set to store qualifiers in CDI extension.
Qualifiers are now stored in their original set instead of using the toString representation.
2016-03-15 14:13:14 +01:00
Simon Baslé
4aa823722a DATACOUCH-212 - Take Version/CAS into account on save
This change takes the `Version` annotated field into account when performing a `save` (either in the `CouchbaseTemplate` or transitively in a `CouchbaseRepository`).

Having such a field with a non-zero value means that a CAS is available, activating optimistic locking. Version 1.4 and below of Spring Data Couchbase was taking this CAS into account, whereas in 2.0 we switched to using `upsert` internally, which ignores the CAS.

This change brings the behavior of `save` (when there's a non-zero CAS) closer to what was observed in 1.4 versions: an `OptimisticLockingFailureException` can now be raised in case of CAS mismatch.
2016-03-14 20:00:16 +01:00
Simon Baslé
39fb52d2a6 DATACOUCH-91 - Support auditing (via java config)
This commit adds support for auditing via the use of the four annotations (CreatedBy, LastModifiedBy, CreationDate, LastModificationDate), enabled via the EnableCouchbaseAuditing annotation.

As couchbase entities MUST have an id, the only case where the creation event can be detected is when the entity has a Version annotated field.
2016-03-11 15:35:35 +01:00
Simon Baslé
dea461458b DATACOUCH-215 - Separate SDK/SDC beans in javaconfig
This commit allows to separate creation of beans dedicated to Spring Data Couchbase from the ones that can be made more common (SDK instances) and now can be provided externally through a a strategy interface, `CouchbaseConfigurer`.

Rather than having to extend a few methods from the base Configuration
class, `CouchbaseConfigurer` represents all the components that the Spring Data integration requires.
2016-03-11 10:58:38 +01:00
James Thomson
8357122950 DATACOUCH-211 - Applying sort that's passed in via the Pagenate object in call to N1qlCouchbaseRepository::findAll 2016-03-10 21:31:23 +00:00
James Thomson
0149144bc0 DATACOUCH-214 - Adding case insensitive sorting
Closes #105
2016-03-10 22:10:47 +01:00
Andrzej Wisłowski
40e4212ad7 DATACOUCH-59 - Allow expiry touch on read
Configuration is based on Document annotation. When read of document takes place then touch action is executed on document. It is an asynchronous action so it does not block read. It is executed only on single reads (not view-based or N1QL-based ones).
2016-02-23 14:51:27 +01:00
Simon Baslé
056a04a030 DATACOUCH-207 - Fix integration test, wrong bean constant used 2016-02-22 16:53:53 +01:00
Simon Baslé
338eb38f46 DATACOUCH-207 - Makes all BeanNames constants public 2016-02-22 16:00:01 +01:00
Simon Baslé
2f251e0ba9 DATACOUCH-209 - Change default Consistency to READ_YOUR_OWN_WRITES
Formerly UPDATE_AFTER, but the inconsistent view this would give eg. while writing tests or exploring Spring Data Couchbase was confusing to users.
2016-02-22 15:42:40 +01:00
Simon Baslé
0095313342 DATACOUCH-199 - Make automatic index creation opt-in
In addition to annotating the repository with xxxIndexed annotations, user must now opt-in to the feature by redefining the indexManager bean in the configuration. This is so production use of this feature is actively discouraged.
2016-02-05 18:08:05 +01:00
Simon Baslé
6d747e97f5 DATACOUCH-180 - Allow named parameters in inline N1QL queries
Choice of placeholder "mode" is determined by the syntax used inside the query, early during repository instantiation.

An IllegalArgumentException is thrown if both named and positional parameters are used.
2016-02-02 15:23:53 +01:00
Simon Baslé
524e8202f6 DATACOUCH-196 - Fix ViewIndexed generated map and improve usability
The generated view's default map function now emits meta.id so that CRUD findAll(ids) works.

The default value for the view name is now "all".

The ViewIndexed isn't documented as applicable to METHODs (deferred feature).
2016-01-29 17:20:57 +01:00
Simon Baslé
8f5e9e3df8 DATACOUCH-187 - Allow counting queries and single projections.
This change allows simple projections to types long, boolean, String when an inline N1QL query uses an aggregation function like AVG, COUNT.

The projection's result must be a single row with a single key/value pair in the N1QL response. Only the value gets returned.
2016-01-27 12:23:16 +01:00
Simon Baslé
6876e179f3 DATACOUCH-190 - Document SpEL support example. 2016-01-18 18:30:59 +01:00
Simon Baslé
15d0d27d71 DATACOUCH-189 - Test and document how to change repo implementation
Added an integration test for custom method customization.
Moved the integration test for base class customization.
Put the samples in the documentation in a new "Changing Repository Behaviour" section.
2016-01-18 18:29:03 +01:00
Simon Baslé
a1955a0af5 DATACOUCH-184 - Fix support for defining repository base class
This fixes the fact that EnableCouchbaseRepository(repositoryBaseClass = Something.class) was ignored.

Now using reflection to choose the target implementation. Note that custom base classes MUST extend SimpleCouchbaseRepository (or its subclass N1qlCouchbaseRepository).

An example in the form of an integration test has been added in src/integration/java/org/springframework/data/couchbase/repository/base/RepositoryBaseTest.java.
2016-01-07 18:16:14 +01:00
Simon Baslé
aa3f9c380b DATACOUCH-176 - Geo false positive autoelimination
So far with geo queries a bounding box approximation was performed on Circle and Polygon queries (since Couchbase internally only supports Bounding Box queries).

It was confusing since in previous iteration it was up to the user to remove these false positives "after the fact" in code calling the repository.

This change allows for the framework to retain enough information to perform false positives elimination automatically and transparently for the user.
2015-12-01 11:02:08 +01:00
Simon Baslé
b78ed124ec DATACOUCH-173 - Add cleanup on some integration tests 2015-11-16 16:34:57 +01:00
Simon Baslé
2378e7145b DATACOUCH-166 - Improve SpEL support, prefix is now #{ 2015-11-16 14:15:50 +01:00
Simon Baslé
2f68740247 DATACOUCH-161 - Improve multitemplate mapping configuration
The configuration step made it look like a new mapping was necessary in overrides, whereas it is actually possible and clearer to mutate the base mapping.

Added a convenience method to get the MappingContext from the repository mapping.
2015-11-16 14:08:33 +01:00
Simon Baslé
95ea97244a DATACOUCH-172 - Fix PagingAndSorting consistency
Default consistency from template wasn't used in PagingAndSorting findAll methods.
2015-11-16 14:02:36 +01:00
Simon Baslé
40d131aab0 DATACOUCH-169 - Automatic index creation
Main indexes (ie indexes that can be used by repositories to retrieve ALL the documents of a particular entity type) are covered.

Repository interfaces can be annotated with an annotation for each type of main index that can be automatically created.

The IndexManager is responsible for creating said indexes (potentially skipping creation if an index is already in place, or if the IndexManager has been configured to skip it, see constructor).
Since IndexManager is created as a bean (either in JavaConfig or xml), there can be a different instance eg. in Prod vs Dev.

Added doc and integration test.

Renamed package core.view to core.query since it now contains various non-view related annotations and classes.
2015-11-16 13:57:38 +01:00
Simon Baslé
8ed7d7e336 DATACOUCH-174 - Fix declaration of repositories in xml 2015-11-16 10:02:33 +01:00
Simon Baslé
58d98c5f28 DATACOUCH-168 - Support and document all reduce functions
Detection whether or not reduce should be activated is now centralized. Triggers are:
  - using the count prefix instead of find in method name
  - setting reduce = true in the View annotation explicitly.

The reduce can thus be returning any kind of value (added an integration example with _stats), which is now properly documented.
2015-10-20 18:15:55 +02:00
Simon Baslé
ec129e86a8 DATACOUCH-166 - Add basic SpEL support
Added the step of parsing SpEL expressions delimited by ${ } in StringN1qlBasedQuery, then the actual evaluation of each expression.

Refactored StringN1qlBasedQuery to use SpEL across the board, including for N1QL specific placeholders (SELECT-FROM, WHERE filter, etc...).

Refactored StringN1qlBasedQuery to use local methods rather than static methods, and amended the unit tests accordingly (using mocks).

Refactored getStatement and getCountStatement so they can see the parameters passed in at runtime.

Added unit tests + integration test.

Added SpEL support example in documentation.
2015-10-20 18:06:50 +02:00
Simon Baslé
6294b03f46 DATACOUCH-165 - Fix geo integration test (bad merge multiBucket) 2015-10-16 16:53:08 +02:00
Simon Baslé
a2f26f4310 DATACOUCH-165 - Add geospatial support
Add support for geo queries through the use of Spatial Views. This needs the query method to be annotated with @Dimensional (or a meta-annotation of it that is runtime retained).

See SpatialViewQueryCreator javadoc for supported part types and corresponding expected arguments (to be documented).
In a nutshell WITHIN Box (other shapes supported but approximated to bounding box), NEAR Point+Distance (approximated to bounding box), plus a few simple operators for dimensions beyond 2.

When approximating, a DEBUG log is made along the logging of the query.

Conversion methods from Shapes to bounding boxes are done in a GeoUtils class.

Unit and Integration test of the feature.

Added documentation for @Dimensional query derivation.
2015-10-14 15:26:22 +02:00