Search in sources :

Example 1 with DtListURIForCriteria

use of io.vertigo.dynamo.domain.model.DtListURIForCriteria in project vertigo by KleeGroup.

the class AbstractStoreManagerTest method testSelectCarCachedRowMax.

@Test
public void testSelectCarCachedRowMax() {
    try (VTransactionWritable tx = transactionManager.createCurrentTransaction()) {
        final DtListURI someCars = new DtListURIForCriteria<>(dtDefinitionCar, null, 3);
        final DtList<Car> dtc1 = storeManager.getDataStore().findAll(someCars);
        Assert.assertEquals(3, dtc1.size());
        // -----
        final DtListURI allCars = new DtListURIForCriteria<>(dtDefinitionCar, null, null);
        final DtList<Car> dtc = storeManager.getDataStore().findAll(allCars);
        Assert.assertEquals(9, dtc.size());
    }
}
Also used : Car(io.vertigo.dynamo.store.data.domain.car.Car) DtListURI(io.vertigo.dynamo.domain.model.DtListURI) DtListURIForCriteria(io.vertigo.dynamo.domain.model.DtListURIForCriteria) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Test(org.junit.Test)

Example 2 with DtListURIForCriteria

use of io.vertigo.dynamo.domain.model.DtListURIForCriteria in project vertigo by KleeGroup.

the class AbstractStoreManagerTest method testGetFamille.

/**
 * On vérifie que la liste est vide.
 */
@Test
public void testGetFamille() {
    try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final DtListURI allFamilles = new DtListURIForCriteria<>(dtDefinitionFamille, null, null);
        final DtList<Famille> dtc = storeManager.getDataStore().findAll(allFamilles);
        Assert.assertNotNull(dtc);
        Assert.assertTrue("La liste des famille est vide", dtc.isEmpty());
        transaction.commit();
    }
}
Also used : Famille(io.vertigo.dynamo.store.data.domain.famille.Famille) DtListURI(io.vertigo.dynamo.domain.model.DtListURI) DtListURIForCriteria(io.vertigo.dynamo.domain.model.DtListURIForCriteria) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Test(org.junit.Test)

Example 3 with DtListURIForCriteria

use of io.vertigo.dynamo.domain.model.DtListURIForCriteria in project vertigo by KleeGroup.

the class AbstractStoreManagerTest method testAddFamille.

/**
 * On charge une liste, ajoute un element et recharge la liste pour verifier l'ajout.
 */
@Test
public void testAddFamille() {
    try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final DtListURI allFamilles = new DtListURIForCriteria<>(dtDefinitionFamille, null, null);
        DtList<Famille> dtc = storeManager.getDataStore().findAll(allFamilles);
        Assert.assertEquals(0, dtc.size());
        // -----
        final Famille famille = new Famille();
        famille.setLibelle("encore un");
        final Famille createdFamille = storeManager.getDataStore().create(famille);
        // on attend un objet avec un ID non null ?
        Assert.assertNotNull(createdFamille.getFamId());
        // -----
        dtc = storeManager.getDataStore().findAll(allFamilles);
        Assert.assertEquals(1, dtc.size());
        transaction.commit();
    }
}
Also used : Famille(io.vertigo.dynamo.store.data.domain.famille.Famille) DtListURI(io.vertigo.dynamo.domain.model.DtListURI) DtListURIForCriteria(io.vertigo.dynamo.domain.model.DtListURIForCriteria) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Test(org.junit.Test)

Example 4 with DtListURIForCriteria

use of io.vertigo.dynamo.domain.model.DtListURIForCriteria in project vertigo by KleeGroup.

the class CachedStoreManagerTest method testAddFamille.

/**
 * On charge une liste, ajoute un element et recharge la liste pour verifier l'ajout.
 */
@Override
@Test
public void testAddFamille() {
    // ce test est modifier car le cache n'est pas transactionnel : la liste n'est pas accessible sans commit
    try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final DtListURI allFamilles = new DtListURIForCriteria<>(dtDefinitionFamille, null, null);
        final DtList<Famille> dtc = storeManager.getDataStore().findAll(allFamilles);
        Assert.assertEquals(0, dtc.size());
        // -----
        final Famille famille = new Famille();
        famille.setLibelle("encore un");
        final Famille createdFamille = storeManager.getDataStore().create(famille);
        // on attend un objet avec un ID non null ?
        Assert.assertNotNull(createdFamille.getFamId());
        transaction.commit();
    }
    try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final DtListURI allFamilles = new DtListURIForCriteria<>(dtDefinitionFamille, null, null);
        final DtList<Famille> dtc = storeManager.getDataStore().findAll(allFamilles);
        Assert.assertEquals(1, dtc.size());
    }
}
Also used : Famille(io.vertigo.dynamo.store.data.domain.famille.Famille) DtListURI(io.vertigo.dynamo.domain.model.DtListURI) DtListURIForCriteria(io.vertigo.dynamo.domain.model.DtListURIForCriteria) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Test(org.junit.Test) AbstractStoreManagerTest(io.vertigo.dynamo.store.datastore.AbstractStoreManagerTest)

Example 5 with DtListURIForCriteria

use of io.vertigo.dynamo.domain.model.DtListURIForCriteria in project vertigo by KleeGroup.

the class CacheDataStore method loadNullable.

private synchronized <E extends Entity> E loadNullable(final DtDefinition dtDefinition, final URI<E> uri) {
    final E entity;
    if (cacheDataStoreConfig.isReloadedByList(dtDefinition)) {
        // On ne charge pas les cache de façon atomique.
        final DtListURI dtcURIAll = new DtListURIForCriteria<>(dtDefinition, null, null);
        // on charge la liste complete (et on remplit les caches)
        loadList(dtcURIAll);
        entity = cacheDataStoreConfig.getDataCache().getDtObject(uri);
    } else {
        // On charge le cache de façon atomique à partir du dataStore
        entity = getPhysicalStore(dtDefinition).readNullable(dtDefinition, uri);
        if (entity != null) {
            cacheDataStoreConfig.getDataCache().putDtObject(entity);
        }
    }
    return entity;
}
Also used : DtListURI(io.vertigo.dynamo.domain.model.DtListURI) DtListURIForCriteria(io.vertigo.dynamo.domain.model.DtListURIForCriteria)

Aggregations

DtListURI (io.vertigo.dynamo.domain.model.DtListURI)5 DtListURIForCriteria (io.vertigo.dynamo.domain.model.DtListURIForCriteria)5 VTransactionWritable (io.vertigo.commons.transaction.VTransactionWritable)4 Test (org.junit.Test)4 Famille (io.vertigo.dynamo.store.data.domain.famille.Famille)3 Car (io.vertigo.dynamo.store.data.domain.car.Car)1 AbstractStoreManagerTest (io.vertigo.dynamo.store.datastore.AbstractStoreManagerTest)1