Search in sources :

Example 1 with DtListURI

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

the class LuceneIndexPlugin method indexList.

private <D extends DtObject> RamLuceneIndex<D> indexList(final DtList<D> fullDtc, final boolean storeValue) throws IOException {
    // TODO : gestion du cache a revoir... et le lien avec le CacheStore.
    // L'index devrait être interrogé par le Broker ? on pourrait alors mettre en cache dans le DataCache.
    final DtListURI dtcUri = fullDtc.getURI();
    // no cache if no URI
    final boolean useCache = dtcUri != null;
    RamLuceneIndex<D> index;
    if (useCache) {
        final String indexName = "INDEX_" + dtcUri.urn();
        final String cacheContext = getIndexCacheContext(fullDtc.getDefinition());
        // TODO non threadSafe.
        Map<String, RamLuceneIndex> luceneIndexMap = Map.class.cast(cacheManager.get(CACHE_LUCENE_INDEX, cacheContext));
        if (luceneIndexMap == null) {
            luceneIndexMap = new HashMap<>();
        }
        if (!luceneIndexMap.containsKey(indexName)) {
            index = createIndex(fullDtc, storeValue);
            luceneIndexMap.put(indexName, index);
            cacheManager.put(CACHE_LUCENE_INDEX, cacheContext, luceneIndexMap);
            return index;
        }
        return luceneIndexMap.get(indexName);
    }
    return createIndex(fullDtc, storeValue);
}
Also used : DtListURI(io.vertigo.dynamo.domain.model.DtListURI)

Example 2 with DtListURI

use of io.vertigo.dynamo.domain.model.DtListURI 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 3 with DtListURI

use of io.vertigo.dynamo.domain.model.DtListURI 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 4 with DtListURI

use of io.vertigo.dynamo.domain.model.DtListURI 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 5 with DtListURI

use of io.vertigo.dynamo.domain.model.DtListURI 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)

Aggregations

DtListURI (io.vertigo.dynamo.domain.model.DtListURI)9 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 Account (io.vertigo.account.account.Account)2 AccountGroup (io.vertigo.account.account.AccountGroup)2 AccountMapperHelper (io.vertigo.account.impl.account.AccountMapperHelper)2 AccountStorePlugin (io.vertigo.account.impl.account.AccountStorePlugin)2 AbstractAccountStorePlugin (io.vertigo.account.plugins.account.store.AbstractAccountStorePlugin)2 Home (io.vertigo.app.Home)2 Criteria (io.vertigo.dynamo.criteria.Criteria)2 Criterions (io.vertigo.dynamo.criteria.Criterions)2 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)2 DtField (io.vertigo.dynamo.domain.metamodel.DtField)2 AssociationDefinition (io.vertigo.dynamo.domain.metamodel.association.AssociationDefinition)2 AssociationNNDefinition (io.vertigo.dynamo.domain.metamodel.association.AssociationNNDefinition)2 AssociationSimpleDefinition (io.vertigo.dynamo.domain.metamodel.association.AssociationSimpleDefinition)2 DtListURIForNNAssociation (io.vertigo.dynamo.domain.metamodel.association.DtListURIForNNAssociation)2 DtListURIForSimpleAssociation (io.vertigo.dynamo.domain.metamodel.association.DtListURIForSimpleAssociation)2