public class ReactiveCosmosTemplate extends Object implements ReactiveCosmosOperations, org.springframework.context.ApplicationContextAware
| Modifier and Type | Field and Description |
|---|---|
private List<String> |
containerNameCache |
private com.azure.data.cosmos.CosmosClient |
cosmosClient |
private static String |
COUNT_VALUE_KEY |
private String |
databaseName |
private Function<Class<?>,CosmosEntityInformation<?,?>> |
entityInfoCreator |
private boolean |
isPopulateQueryMetrics |
private MappingCosmosConverter |
mappingCosmosConverter |
private ResponseDiagnosticsProcessor |
responseDiagnosticsProcessor |
| Constructor and Description |
|---|
ReactiveCosmosTemplate(CosmosDbFactory cosmosDbFactory,
MappingCosmosConverter mappingCosmosConverter,
String dbName)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
private void |
applyVersioning(Class<?> domainType,
com.azure.data.cosmos.CosmosItemProperties cosmosItemProperties,
com.azure.data.cosmos.CosmosItemRequestOptions options) |
private void |
assertValidId(Object id) |
reactor.core.publisher.Mono<Long> |
count(DocumentQuery query,
boolean isCrossPartitionQuery,
String containerName) |
reactor.core.publisher.Mono<Long> |
count(DocumentQuery query,
String containerName)
Count
|
reactor.core.publisher.Mono<Long> |
count(String containerName)
Count
|
reactor.core.publisher.Mono<com.azure.data.cosmos.CosmosContainerResponse> |
createCollectionIfNotExists(CosmosEntityInformation information)
Creates a container if it doesn't already exist
|
reactor.core.publisher.Mono<com.azure.data.cosmos.CosmosContainerResponse> |
createContainerIfNotExists(CosmosEntityInformation information)
Creates a container if it doesn't already exist
|
<T> reactor.core.publisher.Flux<T> |
delete(DocumentQuery query,
Class<T> domainType,
String containerName)
Delete items matching query
|
reactor.core.publisher.Mono<Void> |
deleteAll(String containerName,
String partitionKeyName)
Delete all items in a container
|
reactor.core.publisher.Mono<Void> |
deleteById(String containerName,
Object id,
com.azure.data.cosmos.PartitionKey partitionKey)
Delete an item by id
|
void |
deleteContainer(String containerName)
Delete container with container name
|
private reactor.core.publisher.Mono<com.azure.data.cosmos.CosmosItemProperties> |
deleteItem(com.azure.data.cosmos.CosmosItemProperties cosmosItemProperties,
List<String> partitionKeyNames,
String containerName,
Class<?> domainType) |
private reactor.core.publisher.Flux<com.azure.data.cosmos.FeedResponse<com.azure.data.cosmos.CosmosItemProperties>> |
executeQuery(com.azure.data.cosmos.SqlQuerySpec sqlQuerySpec,
String containerName,
com.azure.data.cosmos.FeedOptions options) |
reactor.core.publisher.Mono<Boolean> |
exists(DocumentQuery query,
Class<?> domainType,
String containerName)
Exists
|
reactor.core.publisher.Mono<Boolean> |
existsById(Object id,
Class<?> domainType,
String containerName)
Exists
|
<T> reactor.core.publisher.Flux<T> |
find(DocumentQuery query,
Class<T> domainType,
String containerName)
Find items
|
<T> reactor.core.publisher.Flux<T> |
findAll(Class<T> domainType)
Find all items in a given container
|
<T> reactor.core.publisher.Flux<T> |
findAll(com.azure.data.cosmos.PartitionKey partitionKey,
Class<T> domainType) |
<T> reactor.core.publisher.Flux<T> |
findAll(String containerName,
Class<T> domainType)
Find all items in a given container
|
<T> reactor.core.publisher.Mono<T> |
findById(Object id,
Class<T> domainType)
Find by id
|
<T> reactor.core.publisher.Mono<T> |
findById(Object id,
Class<T> domainType,
com.azure.data.cosmos.PartitionKey partitionKey)
Find by id
|
<T> reactor.core.publisher.Mono<T> |
findById(String containerName,
Object id,
Class<T> domainType)
Find by id
|
private reactor.core.publisher.Flux<com.azure.data.cosmos.CosmosItemProperties> |
findItems(DocumentQuery query,
Class<?> domainType,
String containerName) |
String |
getContainerName(Class<?> domainType) |
MappingCosmosConverter |
getConverter() |
private CosmosEntityInformation<?,?> |
getCosmosEntityInformation(Class<?> domainType) |
private reactor.core.publisher.Mono<Long> |
getCountValue(DocumentQuery query,
boolean isCrossPartitionQuery,
String containerName) |
private List<String> |
getPartitionKeyNames(Class<?> domainType) |
<T> reactor.core.publisher.Mono<T> |
insert(String containerName,
Object objectToSave,
com.azure.data.cosmos.PartitionKey partitionKey)
Insert
|
<T> reactor.core.publisher.Mono<T> |
insert(T objectToSave)
Insert
|
<T> reactor.core.publisher.Mono<T> |
insert(T objectToSave,
com.azure.data.cosmos.PartitionKey partitionKey)
Insert
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
private <T> T |
toDomainObject(Class<T> domainType,
com.azure.data.cosmos.CosmosItemProperties cosmosItemProperties) |
<T> reactor.core.publisher.Mono<T> |
upsert(String containerName,
T object,
com.azure.data.cosmos.PartitionKey partitionKey)
Upsert
|
<T> reactor.core.publisher.Mono<T> |
upsert(T object,
com.azure.data.cosmos.PartitionKey partitionKey)
Upsert
|
private static final String COUNT_VALUE_KEY
private final MappingCosmosConverter mappingCosmosConverter
private final String databaseName
private final com.azure.data.cosmos.CosmosClient cosmosClient
private final ResponseDiagnosticsProcessor responseDiagnosticsProcessor
private final boolean isPopulateQueryMetrics
private Function<Class<?>,CosmosEntityInformation<?,?>> entityInfoCreator
public ReactiveCosmosTemplate(CosmosDbFactory cosmosDbFactory, MappingCosmosConverter mappingCosmosConverter, String dbName)
cosmosDbFactory - the cosmosdbfactorymappingCosmosConverter - the mappingCosmosConverterdbName - database namepublic void setApplicationContext(@NonNull
org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansException
setApplicationContext in interface org.springframework.context.ApplicationContextAwareapplicationContext - the application contextorg.springframework.beans.BeansException - the bean exceptionpublic reactor.core.publisher.Mono<com.azure.data.cosmos.CosmosContainerResponse> createCollectionIfNotExists(CosmosEntityInformation information)
createCollectionIfNotExists in interface ReactiveCosmosOperationsinformation - the CosmosEntityInformationpublic reactor.core.publisher.Mono<com.azure.data.cosmos.CosmosContainerResponse> createContainerIfNotExists(CosmosEntityInformation information)
createContainerIfNotExists in interface ReactiveCosmosOperationsinformation - the CosmosEntityInformationpublic <T> reactor.core.publisher.Flux<T> findAll(String containerName, Class<T> domainType)
findAll in interface ReactiveCosmosOperationscontainerName - the containerNamedomainType - the domainTypepublic <T> reactor.core.publisher.Flux<T> findAll(Class<T> domainType)
findAll in interface ReactiveCosmosOperationsdomainType - the domainTypepublic <T> reactor.core.publisher.Flux<T> findAll(com.azure.data.cosmos.PartitionKey partitionKey,
Class<T> domainType)
findAll in interface ReactiveCosmosOperationspublic <T> reactor.core.publisher.Mono<T> findById(Object id, Class<T> domainType)
findById in interface ReactiveCosmosOperationsid - the iddomainType - the domainTypepublic <T> reactor.core.publisher.Mono<T> findById(String containerName, Object id, Class<T> domainType)
findById in interface ReactiveCosmosOperationscontainerName - the containernameid - the iddomainType - the entity classpublic <T> reactor.core.publisher.Mono<T> findById(Object id, Class<T> domainType, com.azure.data.cosmos.PartitionKey partitionKey)
findById in interface ReactiveCosmosOperationsid - the iddomainType - the entity classpartitionKey - partition Keypublic <T> reactor.core.publisher.Mono<T> insert(T objectToSave,
com.azure.data.cosmos.PartitionKey partitionKey)
insert in interface ReactiveCosmosOperationsobjectToSave - the object to savepartitionKey - the partition keypublic <T> reactor.core.publisher.Mono<T> insert(T objectToSave)
objectToSave - the object to savepublic <T> reactor.core.publisher.Mono<T> insert(String containerName, Object objectToSave, com.azure.data.cosmos.PartitionKey partitionKey)
insert in interface ReactiveCosmosOperationscontainerName - the container nameobjectToSave - the object to savepartitionKey - the partition keypublic <T> reactor.core.publisher.Mono<T> upsert(T object,
com.azure.data.cosmos.PartitionKey partitionKey)
upsert in interface ReactiveCosmosOperationsobject - the object to upsertpartitionKey - the partition keypublic <T> reactor.core.publisher.Mono<T> upsert(String containerName, T object, com.azure.data.cosmos.PartitionKey partitionKey)
upsert in interface ReactiveCosmosOperationscontainerName - the container nameobject - the object to savepartitionKey - the partition keypublic reactor.core.publisher.Mono<Void> deleteById(String containerName, Object id, com.azure.data.cosmos.PartitionKey partitionKey)
deleteById in interface ReactiveCosmosOperationscontainerName - the container nameid - the idpartitionKey - the partition keypublic reactor.core.publisher.Mono<Void> deleteAll(String containerName, String partitionKeyName)
deleteAll in interface ReactiveCosmosOperationscontainerName - the container namepartitionKeyName - the partition key pathpublic <T> reactor.core.publisher.Flux<T> delete(DocumentQuery query, Class<T> domainType, String containerName)
delete in interface ReactiveCosmosOperationsquery - the document querydomainType - the entity classcontainerName - the container namepublic <T> reactor.core.publisher.Flux<T> find(DocumentQuery query, Class<T> domainType, String containerName)
find in interface ReactiveCosmosOperationsquery - the document querydomainType - the entity classcontainerName - the container namepublic reactor.core.publisher.Mono<Boolean> exists(DocumentQuery query, Class<?> domainType, String containerName)
exists in interface ReactiveCosmosOperationsquery - the document querydomainType - the entity classcontainerName - the container namepublic reactor.core.publisher.Mono<Boolean> existsById(Object id, Class<?> domainType, String containerName)
existsById in interface ReactiveCosmosOperationsid - the iddomainType - the entity classcontainerName - the containercontainer nam,epublic reactor.core.publisher.Mono<Long> count(String containerName)
count in interface ReactiveCosmosOperationscontainerName - the container namepublic reactor.core.publisher.Mono<Long> count(DocumentQuery query, String containerName)
count in interface ReactiveCosmosOperationsquery - the document querycontainerName - the container namepublic MappingCosmosConverter getConverter()
getConverter in interface ReactiveCosmosOperationspublic reactor.core.publisher.Mono<Long> count(DocumentQuery query, boolean isCrossPartitionQuery, String containerName)
private reactor.core.publisher.Mono<Long> getCountValue(DocumentQuery query, boolean isCrossPartitionQuery, String containerName)
private reactor.core.publisher.Flux<com.azure.data.cosmos.FeedResponse<com.azure.data.cosmos.CosmosItemProperties>> executeQuery(com.azure.data.cosmos.SqlQuerySpec sqlQuerySpec,
String containerName,
com.azure.data.cosmos.FeedOptions options)
public void deleteContainer(@NonNull
String containerName)
deleteContainer in interface ReactiveCosmosOperationscontainerName - the container namepublic String getContainerName(Class<?> domainType)
getContainerName in interface ReactiveCosmosOperationsdomainType - the domain classprivate reactor.core.publisher.Flux<com.azure.data.cosmos.CosmosItemProperties> findItems(@NonNull
DocumentQuery query,
@NonNull
Class<?> domainType,
@NonNull
String containerName)
private void assertValidId(Object id)
private reactor.core.publisher.Mono<com.azure.data.cosmos.CosmosItemProperties> deleteItem(@NonNull
com.azure.data.cosmos.CosmosItemProperties cosmosItemProperties,
@NonNull
List<String> partitionKeyNames,
String containerName,
@NonNull
Class<?> domainType)
private <T> T toDomainObject(@NonNull
Class<T> domainType,
com.azure.data.cosmos.CosmosItemProperties cosmosItemProperties)
private void applyVersioning(Class<?> domainType, com.azure.data.cosmos.CosmosItemProperties cosmosItemProperties, com.azure.data.cosmos.CosmosItemRequestOptions options)
private CosmosEntityInformation<?,?> getCosmosEntityInformation(Class<?> domainType)
Copyright © 2020 Microsoft. All rights reserved.