DATACOUCH-305 - Adapt to API changes in repository interfaces.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013, 2014 the original author or authors.
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -13,19 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.couchbase.repository.query;
|
||||
|
||||
import org.springframework.data.repository.core.EntityInformation;
|
||||
import org.springframework.data.repository.core.support.RepositoryFactorySupport;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Marker interface for the Couchbase Entity Information.
|
||||
*
|
||||
* @author Michael Nitschinger
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public interface CouchbaseEntityInformation<T, ID extends Serializable> extends EntityInformation<T, ID> {
|
||||
|
||||
}
|
||||
public interface CouchbaseEntityInformation<T, ID> extends EntityInformation<T, ID> {}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class CouchbaseRepositoryFactory extends RepositoryFactorySupport {
|
||||
* @return entity information for that domain class.
|
||||
*/
|
||||
@Override
|
||||
public <T, ID extends Serializable> CouchbaseEntityInformation<T, ID> getEntityInformation(final Class<T> domainClass) {
|
||||
public <T, ID> CouchbaseEntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
|
||||
|
||||
CouchbasePersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(domainClass);
|
||||
return new MappingCouchbaseEntityInformation<T, ID>((CouchbasePersistentEntity<T>) entity);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* Copyright 2013-2017 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.
|
||||
@@ -13,11 +13,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.couchbase.repository.support;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentEntity;
|
||||
import org.springframework.data.couchbase.repository.query.CouchbaseEntityInformation;
|
||||
import org.springframework.data.repository.core.support.PersistentEntityInformation;
|
||||
@@ -26,18 +23,17 @@ import org.springframework.data.repository.core.support.PersistentEntityInformat
|
||||
* Entity Information container.
|
||||
*
|
||||
* @author Michael Nitschinger
|
||||
* @author Oliver Grieke
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class MappingCouchbaseEntityInformation<T, ID extends Serializable>
|
||||
extends PersistentEntityInformation<T, ID>
|
||||
implements CouchbaseEntityInformation<T, ID> {
|
||||
public class MappingCouchbaseEntityInformation<T, ID> extends PersistentEntityInformation<T, ID>
|
||||
implements CouchbaseEntityInformation<T, ID> {
|
||||
|
||||
/**
|
||||
* Create a new Information container.
|
||||
*
|
||||
* @param entity the entity of the container.
|
||||
*/
|
||||
public MappingCouchbaseEntityInformation(final CouchbasePersistentEntity<T> entity) {
|
||||
public MappingCouchbaseEntityInformation(CouchbasePersistentEntity<T> entity) {
|
||||
super(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public class ReactiveCouchbaseRepositoryFactory extends ReactiveRepositoryFactor
|
||||
* @return entity information for that domain class.
|
||||
*/
|
||||
@Override
|
||||
public <T, ID extends Serializable> CouchbaseEntityInformation<T, ID> getEntityInformation(final Class<T> domainClass) {
|
||||
public <T, ID> CouchbaseEntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
|
||||
CouchbasePersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(domainClass);
|
||||
|
||||
return new MappingCouchbaseEntityInformation<T, ID>((CouchbasePersistentEntity<T>) entity);
|
||||
|
||||
@@ -89,7 +89,7 @@ public class SimpleCouchbaseRepository<T, ID extends Serializable> implements Co
|
||||
}
|
||||
|
||||
@Override
|
||||
public <S extends T> Iterable<S> save(Iterable<S> entities) {
|
||||
public <S extends T> Iterable<S> saveAll(Iterable<S> entities) {
|
||||
Assert.notNull(entities, "The given Iterable of entities must not be null!");
|
||||
|
||||
List<S> result = new ArrayList<S>();
|
||||
@@ -101,19 +101,19 @@ public class SimpleCouchbaseRepository<T, ID extends Serializable> implements Co
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<T> findOne(ID id) {
|
||||
public Optional<T> findById(ID id) {
|
||||
Assert.notNull(id, "The given id must not be null!");
|
||||
return Optional.ofNullable(couchbaseOperations.findById(id.toString(), entityInformation.getJavaType()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean exists(ID id) {
|
||||
public boolean existsById(ID id) {
|
||||
Assert.notNull(id, "The given id must not be null!");
|
||||
return couchbaseOperations.exists(id.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(ID id) {
|
||||
public void deleteById(ID id) {
|
||||
Assert.notNull(id, "The given id must not be null!");
|
||||
couchbaseOperations.remove(id.toString());
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public class SimpleCouchbaseRepository<T, ID extends Serializable> implements Co
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Iterable<? extends T> entities) {
|
||||
public void deleteAll(Iterable<? extends T> entities) {
|
||||
Assert.notNull(entities, "The given Iterable of entities must not be null!");
|
||||
for (T entity : entities) {
|
||||
couchbaseOperations.remove(entity);
|
||||
@@ -142,7 +142,7 @@ public class SimpleCouchbaseRepository<T, ID extends Serializable> implements Co
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<T> findAll(final Iterable<ID> ids) {
|
||||
public Iterable<T> findAllById(final Iterable<ID> ids) {
|
||||
final ResolvedView resolvedView = determineView();
|
||||
ViewQuery query = ViewQuery.from(resolvedView.getDesignDocument(), resolvedView.getViewName());
|
||||
query.reduce(false);
|
||||
|
||||
@@ -101,14 +101,14 @@ public class SimpleReactiveCouchbaseRepository<T, ID extends Serializable> imple
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <S extends T> Flux<S> save(Iterable<S> entities) {
|
||||
public <S extends T> Flux<S> saveAll(Iterable<S> entities) {
|
||||
Assert.notNull(entities, "The given Iterable of entities must not be null!");
|
||||
return mapFlux(operations.save(entities));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <S extends T> Flux<S> save(Publisher<S> entityStream) {
|
||||
public <S extends T> Flux<S> saveAll(Publisher<S> entityStream) {
|
||||
Assert.notNull(entityStream, "The given Iterable of entities must not be null!");
|
||||
return Flux.from(entityStream)
|
||||
.flatMap(object -> save(object));
|
||||
@@ -116,7 +116,7 @@ public class SimpleReactiveCouchbaseRepository<T, ID extends Serializable> imple
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Mono<T> findOne(ID id) {
|
||||
public Mono<T> findById(ID id) {
|
||||
Assert.notNull(id, "The given id must not be null!");
|
||||
return mapMono(operations.findById(id.toString(), entityInformation.getJavaType()).toSingle())
|
||||
.onErrorResume(throwable -> {
|
||||
@@ -130,24 +130,24 @@ public class SimpleReactiveCouchbaseRepository<T, ID extends Serializable> imple
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Mono<T> findOne(Mono<ID> mono) {
|
||||
public Mono<T> findById(Mono<ID> mono) {
|
||||
Assert.notNull(mono, "The given mono must not be null!");
|
||||
return mono.flatMap(
|
||||
this::findOne);
|
||||
this::findById);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Mono<Boolean> exists(ID id) {
|
||||
public Mono<Boolean> existsById(ID id) {
|
||||
Assert.notNull(id, "The given id must not be null!");
|
||||
return mapMono(operations.exists(id.toString()).toSingle());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Mono<Boolean> exists(Mono<ID> mono) {
|
||||
public Mono<Boolean> existsById(Mono<ID> mono) {
|
||||
return mono.flatMap(
|
||||
this::exists);
|
||||
this::existsById);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -162,7 +162,7 @@ public class SimpleReactiveCouchbaseRepository<T, ID extends Serializable> imple
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Flux<T> findAll(final Iterable<ID> ids) {
|
||||
public Flux<T> findAllById(final Iterable<ID> ids) {
|
||||
final ResolvedView resolvedView = determineView();
|
||||
ViewQuery query = ViewQuery.from(resolvedView.getDesignDocument(), resolvedView.getViewName());
|
||||
query.reduce(false);
|
||||
@@ -177,15 +177,15 @@ public class SimpleReactiveCouchbaseRepository<T, ID extends Serializable> imple
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Flux<T> findAll(Publisher<ID> entityStream) {
|
||||
public Flux<T> findAllById(Publisher<ID> entityStream) {
|
||||
Assert.notNull(entityStream, "The given entityStream must not be null!");
|
||||
return Flux.from(entityStream)
|
||||
.flatMap(entity -> findOne(entity));
|
||||
.flatMap(entity -> findById(entity));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Mono<Void> delete(ID id) {
|
||||
public Mono<Void> deleteById(ID id) {
|
||||
Assert.notNull(id, "The given id must not be null!");
|
||||
return mapMono(operations.remove(id.toString()).map(res -> Observable.<Void>empty()).toSingle());
|
||||
}
|
||||
@@ -199,7 +199,7 @@ public class SimpleReactiveCouchbaseRepository<T, ID extends Serializable> imple
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Mono<Void> delete(Iterable<? extends T> entities) {
|
||||
public Mono<Void> deleteAll(Iterable<? extends T> entities) {
|
||||
Assert.notNull(entities, "The given Iterable of entities must not be null!");
|
||||
return mapMono(operations
|
||||
.remove(entities)
|
||||
@@ -209,7 +209,7 @@ public class SimpleReactiveCouchbaseRepository<T, ID extends Serializable> imple
|
||||
|
||||
|
||||
@Override
|
||||
public Mono<Void> delete(Publisher<? extends T> entityStream) {
|
||||
public Mono<Void> deleteAll(Publisher<? extends T> entityStream) {
|
||||
Assert.notNull(entityStream, "The given publisher of entities must not be null!");
|
||||
return Flux.from(entityStream)
|
||||
.flatMap(entity -> delete(entity)).single();
|
||||
|
||||
Reference in New Issue
Block a user