Search in sources :

Example 16 with BucketManager

use of jakarta.nosql.keyvalue.BucketManager in project jnosql-diana-driver by eclipse.

the class KeyValueEntityManagerFactoryTest method shouldCreateKeyValueEntityManager.

@Test
public void shouldCreateKeyValueEntityManager() {
    BucketManager keyValueEntityManager = managerFactory.getBucketManager(BUCKET_NAME);
    assertNotNull(keyValueEntityManager);
}
Also used : BucketManager(jakarta.nosql.keyvalue.BucketManager) Test(org.junit.jupiter.api.Test)

Example 17 with BucketManager

use of jakarta.nosql.keyvalue.BucketManager in project jnosql-diana by eclipse.

the class DelQueryParser method prepare.

public KeyValuePreparedStatement prepare(String query, BucketManager manager) {
    DelQuery delQuery = provider.apply(query);
    Params params = Params.newParams();
    List<Value> values = delQuery.getKeys().stream().map(k -> Values.getValue(k, params)).collect(toList());
    return DefaultKeyValuePreparedStatement.del(values, manager, params, query);
}
Also used : Value(jakarta.nosql.Value) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) DelQuery(jakarta.nosql.query.DelQuery) QueryException(jakarta.nosql.QueryException) BucketManager(jakarta.nosql.keyvalue.BucketManager) KeyValuePreparedStatement(jakarta.nosql.keyvalue.KeyValuePreparedStatement) ServiceLoaderProvider(jakarta.nosql.ServiceLoaderProvider) DelQueryProvider(jakarta.nosql.query.DelQuery.DelQueryProvider) Params(jakarta.nosql.Params) DelQuery(jakarta.nosql.query.DelQuery) Value(jakarta.nosql.Value) Params(jakarta.nosql.Params)

Example 18 with BucketManager

use of jakarta.nosql.keyvalue.BucketManager in project jnosql-diana by eclipse.

the class DelQueryParser method query.

Stream<Value> query(String query, BucketManager manager) {
    DelQuery delQuery = provider.apply(query);
    Params params = Params.newParams();
    List<Value> values = delQuery.getKeys().stream().map(k -> Values.getValue(k, params)).collect(toList());
    if (params.isNotEmpty()) {
        throw new QueryException("To run a query with a parameter use a PrepareStatement instead.");
    }
    List<Object> keys = values.stream().map(Value::get).collect(toList());
    manager.delete(keys);
    return Stream.empty();
}
Also used : Value(jakarta.nosql.Value) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) DelQuery(jakarta.nosql.query.DelQuery) QueryException(jakarta.nosql.QueryException) BucketManager(jakarta.nosql.keyvalue.BucketManager) KeyValuePreparedStatement(jakarta.nosql.keyvalue.KeyValuePreparedStatement) ServiceLoaderProvider(jakarta.nosql.ServiceLoaderProvider) DelQueryProvider(jakarta.nosql.query.DelQuery.DelQueryProvider) Params(jakarta.nosql.Params) DelQuery(jakarta.nosql.query.DelQuery) QueryException(jakarta.nosql.QueryException) Value(jakarta.nosql.Value) Params(jakarta.nosql.Params)

Example 19 with BucketManager

use of jakarta.nosql.keyvalue.BucketManager in project jnosql-diana by eclipse.

the class TemplateBean method create.

@Override
public KeyValueTemplate create(CreationalContext<KeyValueTemplate> creationalContext) {
    KeyValueTemplateProducer producer = getInstance(KeyValueTemplateProducer.class);
    BucketManager manager = getManager();
    return producer.get(manager);
}
Also used : KeyValueTemplateProducer(jakarta.nosql.mapping.keyvalue.KeyValueTemplateProducer) BucketManager(jakarta.nosql.keyvalue.BucketManager)

Example 20 with BucketManager

use of jakarta.nosql.keyvalue.BucketManager in project jnosql-diana by eclipse.

the class BucketManagerConverterTest method shouldReturnBucket.

@Test
public void shouldReturnBucket() {
    final String prefix = UUID.randomUUID().toString();
    System.setProperty(prefix, prefix);
    System.setProperty(prefix + ".settings.key", "value");
    System.setProperty(prefix + ".settings.key2", "value2");
    System.setProperty(prefix + ".provider", KeyValueConfigurationMock.class.getName());
    System.setProperty(prefix + ".database", "bucket");
    final BucketManager bucketManager = config.getValue(prefix, BucketManager.class);
    final BucketManagerMock bucket = BucketManagerMock.class.cast(bucketManager);
    Assertions.assertEquals("bucket", bucket.getBucketName());
    System.clearProperty(prefix);
    System.clearProperty(prefix + ".settings.key");
    System.clearProperty(prefix + ".settings.key2");
    System.clearProperty(prefix + ".provider");
    System.clearProperty(prefix + ".database");
}
Also used : BucketManager(jakarta.nosql.keyvalue.BucketManager) BucketManagerMock(org.eclipse.jnosql.mapping.keyvalue.configuration.KeyValueConfigurationMock.BucketManagerMock) Test(org.junit.jupiter.api.Test)

Aggregations

BucketManager (jakarta.nosql.keyvalue.BucketManager)25 BucketManagerFactory (jakarta.nosql.keyvalue.BucketManagerFactory)8 AfterAll (org.junit.jupiter.api.AfterAll)8 Test (org.junit.jupiter.api.Test)7 Params (jakarta.nosql.Params)4 QueryException (jakarta.nosql.QueryException)4 ServiceLoaderProvider (jakarta.nosql.ServiceLoaderProvider)4 Value (jakarta.nosql.Value)4 KeyValuePreparedStatement (jakarta.nosql.keyvalue.KeyValuePreparedStatement)4 Person (jakarta.nosql.tck.entities.Person)4 User (jakarta.nosql.tck.entities.User)4 List (java.util.List)4 Collectors.toList (java.util.stream.Collectors.toList)4 Stream (java.util.stream.Stream)4 Produces (javax.enterprise.inject.Produces)4 CouchbaseKeyValueConfiguration (org.eclipse.jnosql.communication.couchbase.keyvalue.CouchbaseKeyValueConfiguration)3 Database (jakarta.nosql.mapping.Database)2 KeyValueTemplateProducer (jakarta.nosql.mapping.keyvalue.KeyValueTemplateProducer)2 DelQuery (jakarta.nosql.query.DelQuery)2 DelQueryProvider (jakarta.nosql.query.DelQuery.DelQueryProvider)2