Search in sources :

Example 61 with VTransactionWritable

use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.

the class TaskEngineSelectDynamicTest method testWhereNotIn.

/**
 * Test exécution d'une tache.
 */
@Test
public void testWhereNotIn() {
    try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final TaskDefinition taskDefinition = registerTaskList("TK_WHERE_ID_TEST", "select * from SUPER_HERO where ID not in (#DTC_SUPER_HERO_IN.ROWNUM.ID#)");
        final DtList<SuperHero> ids = new DtList<>(SuperHero.class);
        final Task task = Task.builder(taskDefinition).addValue(DTC_SUPER_HERO_IN, ids).build();
        ids.add(createSuperHero(10001L + 1));
        ids.add(createSuperHero(10001L + 3));
        ids.add(createSuperHero(10001L + 5));
        ids.add(createSuperHero(10001L + 6));
        ids.add(createSuperHero(10001L + 7));
        ids.add(createSuperHero(10001L + 8));
        final DtList<SuperHero> resultList = taskManager.execute(task).getResult();
        Assert.assertEquals(4, resultList.size());
        Assert.assertEquals(10001L + 0, resultList.get(0).getId().longValue());
        Assert.assertEquals(10001L + 2, resultList.get(1).getId().longValue());
        Assert.assertEquals(10001L + 4, resultList.get(2).getId().longValue());
        Assert.assertEquals(10001L + 9, resultList.get(3).getId().longValue());
    }
}
Also used : SuperHero(io.vertigo.dynamo.task.data.domain.SuperHero) TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) DtList(io.vertigo.dynamo.domain.model.DtList) Test(org.junit.Test)

Example 62 with VTransactionWritable

use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.

the class TaskEngineSelectDynamicTest method testWhereNotIn2200.

/**
 * Test where in avec 2200 Id a exclure.
 */
@Test
public void testWhereNotIn2200() {
    superHeroDataBase.populateSuperHero(storeManager, 4500);
    try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final TaskDefinition taskDefinition = registerTaskList("TK_WHERE_ID_TEST", "select * from SUPER_HERO  where ID not in (#DTC_SUPER_HERO_IN.ROWNUM.ID#)");
        final DtList<SuperHero> ids = new DtList<>(SuperHero.class);
        for (int i = 0; i < 2200; i++) {
            ids.add(createSuperHero(10001L + 2 * i));
        }
        final Task task = Task.builder(taskDefinition).addValue(DTC_SUPER_HERO_IN, ids).build();
        final DtList<SuperHero> resultList = taskManager.execute(task).getResult();
        Assert.assertEquals(10 + 4500 - 2200, resultList.size());
    }
}
Also used : SuperHero(io.vertigo.dynamo.task.data.domain.SuperHero) TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) DtList(io.vertigo.dynamo.domain.model.DtList) Test(org.junit.Test)

Example 63 with VTransactionWritable

use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.

the class TaskEngineSelectDynamicTest method testWhereNotInEmpty.

/**
 * Test exécution d'une tache.
 */
@Test
public void testWhereNotInEmpty() {
    try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final TaskDefinition taskDefinition = registerTaskList("TK_WHERE_ID_TEST", "select * from SUPER_HERO where ID not in (#DTC_SUPER_HERO_IN.ROWNUM.ID#)");
        final DtList<SuperHero> ids = new DtList<>(SuperHero.class);
        final Task task = Task.builder(taskDefinition).addValue(DTC_SUPER_HERO_IN, ids).build();
        final DtList<SuperHero> resultList = taskManager.execute(task).getResult();
        Assert.assertEquals(10, resultList.size());
    }
}
Also used : SuperHero(io.vertigo.dynamo.task.data.domain.SuperHero) TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) DtList(io.vertigo.dynamo.domain.model.DtList) Test(org.junit.Test)

Example 64 with VTransactionWritable

use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.

the class TaskEngineSelectDynamicTest method testScriptVarList.

/**
 * Test des scripts.
 */
@Test
public void testScriptVarList() {
    try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final TaskDefinition taskDefinition = registerTaskList("TK_SCRIPT_TEST", "select * from SUPER_HERO <%if(!dtcSuperHeroIn.isEmpty()) {%>where ID in (#DTC_SUPER_HERO_IN.ROWNUM.ID#)<%}%>");
        final DtList<SuperHero> ids = new DtList<>(SuperHero.class);
        final Task task = Task.builder(taskDefinition).addValue(DTC_SUPER_HERO_IN, ids).build();
        final DtList<SuperHero> resultList = taskManager.execute(task).getResult();
        Assert.assertEquals(10, resultList.size());
    }
}
Also used : SuperHero(io.vertigo.dynamo.task.data.domain.SuperHero) TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) DtList(io.vertigo.dynamo.domain.model.DtList) Test(org.junit.Test)

Example 65 with VTransactionWritable

use of io.vertigo.commons.transaction.VTransactionWritable in project vertigo by KleeGroup.

the class ItemSearchLoader method loadData.

/**
 * {@inheritDoc}
 */
@Override
public List<SearchIndex<Item, Item>> loadData(final SearchChunk<Item> searchChunk) {
    final SearchIndexDefinition indexDefinition = searchManager.findFirstIndexDefinitionByKeyConcept(Item.class);
    try (final VTransactionWritable tx = getTransactionManager().createCurrentTransaction()) {
        final List<SearchIndex<Item, Item>> result = new ArrayList<>();
        final DtDefinition dtDefinition = DtObjectUtil.findDtDefinition(Item.class);
        for (final Item item : loadItems(searchChunk)) {
            final URI<Item> uri = new URI<>(dtDefinition, item.getId());
            result.add(SearchIndex.createIndex(indexDefinition, uri, item));
        }
        return result;
    }
}
Also used : Item(io.vertigo.dynamo.search.data.domain.Item) SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition) SearchIndex(io.vertigo.dynamo.search.model.SearchIndex) ArrayList(java.util.ArrayList) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) URI(io.vertigo.dynamo.domain.model.URI)

Aggregations

VTransactionWritable (io.vertigo.commons.transaction.VTransactionWritable)80 Test (org.junit.Test)63 Car (io.vertigo.dynamo.store.data.domain.car.Car)22 TaskDefinition (io.vertigo.dynamo.task.metamodel.TaskDefinition)22 Task (io.vertigo.dynamo.task.model.Task)22 SuperHero (io.vertigo.dynamo.task.data.domain.SuperHero)18 DtList (io.vertigo.dynamo.domain.model.DtList)7 Flower (io.vertigo.dynamo.kvstore.data.Flower)6 Famille (io.vertigo.dynamo.store.data.domain.famille.Famille)6 SqlConnection (io.vertigo.database.sql.connection.SqlConnection)5 DtListURI (io.vertigo.dynamo.domain.model.DtListURI)5 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)4 DtListURIForCriteria (io.vertigo.dynamo.domain.model.DtListURIForCriteria)4 URI (io.vertigo.dynamo.domain.model.URI)4 Item (io.vertigo.dynamo.search.data.domain.Item)4 SearchIndexDefinition (io.vertigo.dynamo.search.metamodel.SearchIndexDefinition)4 Car (io.vertigo.dynamo.search_2_4.data.domain.Car)4 TaskEngineSelect (io.vertigo.dynamox.task.TaskEngineSelect)4 ArrayList (java.util.ArrayList)4 Domain (io.vertigo.dynamo.domain.metamodel.Domain)3