Search in sources :

Example 6 with SuperHero

use of io.vertigo.dynamo.task.data.domain.SuperHero in project vertigo by KleeGroup.

the class TaskEngineSelectDynamicTest method testWhereInTab.

/**
 * Test exécution d'une tache.
 */
@Test
public void testWhereInTab() {
    try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final TaskDefinition taskDefinition = registerTaskList("TK_WHERE_ID_TEST", "select * from SUPER_HERO  where\tID in\t(#DTC_SUPER_HERO_IN.ROWNUM.ID#)");
        final DtList<SuperHero> ids = DtList.of(createSuperHero(10001L + 1), createSuperHero(10001L + 3));
        final Task task = Task.builder(taskDefinition).addValue(DTC_SUPER_HERO_IN, ids).build();
        final DtList<SuperHero> resultList = taskManager.execute(task).getResult();
        Assert.assertEquals(2, resultList.size());
        Assert.assertEquals(10001L + 1, resultList.get(0).getId().longValue());
        Assert.assertEquals(10001L + 3, resultList.get(1).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) Test(org.junit.Test)

Example 7 with SuperHero

use of io.vertigo.dynamo.task.data.domain.SuperHero in project vertigo by KleeGroup.

the class TaskEngineSelectDynamicTest method testScriptVar.

/**
 * Test des scripts.
 */
@Test
public void testScriptVar() {
    try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final TaskDefinition taskDefinition = registerTaskObject("TK_SCRIPT_TEST", "select * from SUPER_HERO <%if(dtoSuperHero.getId() == 10002L) {%>where ID = #DTO_SUPER_HERO.ID#<%}%>");
        final SuperHero superHero = new SuperHero();
        superHero.setId(10001L + 1);
        final Task task = Task.builder(taskDefinition).addValue(DTO_SUPER_HERO, superHero).build();
        final DtList<SuperHero> resultList = taskManager.execute(task).getResult();
        Assert.assertEquals(1, resultList.size());
        Assert.assertEquals(10001L + 1, resultList.get(0).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) Test(org.junit.Test)

Example 8 with SuperHero

use of io.vertigo.dynamo.task.data.domain.SuperHero in project vertigo by KleeGroup.

the class SuperHeroDataBase method populateSuperHero.

void populateSuperHero(final StoreManager storeManager, final int size) {
    try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        // -----
        for (int i = 0; i < size; i++) {
            final SuperHero superHero = new SuperHero();
            superHero.setName("SuperHero ( " + i + ")");
            storeManager.getDataStore().create(superHero);
        }
        transaction.commit();
    }
}
Also used : SuperHero(io.vertigo.dynamo.task.data.domain.SuperHero) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable)

Example 9 with SuperHero

use of io.vertigo.dynamo.task.data.domain.SuperHero in project vertigo by KleeGroup.

the class TaskEngineProcBatchTest method testInsertBatchWithAdditionalParam.

/**
 * Tests batch insertion with a task
 */
@Test
public void testInsertBatchWithAdditionalParam() {
    final String request = new StringBuilder("insert into SUPER_HERO(ID, NAME) values (").append("#").append(DTC_SUPER_HERO_IN + ".ID").append("# , ").append("#").append(OTHER_PARAM_IN).append("# ) ").toString();
    final TaskDefinition taskDefinition = TaskDefinition.builder("TK_TEST_INSERT_BATCH").withEngine(TaskEngineProcBatch.class).addInRequired(DTC_SUPER_HERO_IN, getApp().getDefinitionSpace().resolve(DO_DT_SUPER_HERO_DTC, Domain.class)).addInRequired(OTHER_PARAM_IN, getApp().getDefinitionSpace().resolve(DO_STRING, Domain.class)).withRequest(request).build();
    final DtList<SuperHero> superHeroes = SuperHeroDataBase.getSuperHeroes();
    final Task task = Task.builder(taskDefinition).addValue(DTC_SUPER_HERO_IN, superHeroes).addValue(OTHER_PARAM_IN, "test").build();
    try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        taskManager.execute(task);
        transaction.commit();
    }
    Assert.assertEquals(superHeroes.size(), selectHeroes().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) Domain(io.vertigo.dynamo.domain.metamodel.Domain) Test(org.junit.Test)

Example 10 with SuperHero

use of io.vertigo.dynamo.task.data.domain.SuperHero in project vertigo by KleeGroup.

the class TaskEngineProcBatchTest method testInsertBatchPrimitive.

/**
 * Tests batch insertion with a task
 */
@Test
public void testInsertBatchPrimitive() {
    final String request = new StringBuilder("insert into SUPER_HERO(ID, NAME) values (").append("#").append(SUPER_HERO_ID_LIST_IN).append("# , 'test' ").append(" )").toString();
    final TaskDefinition taskDefinition = TaskDefinition.builder("TK_TEST_INSERT_BATCH").withEngine(TaskEngineProcBatch.class).addInRequired(SUPER_HERO_ID_LIST_IN, getApp().getDefinitionSpace().resolve(DO_LONGS, Domain.class)).withRequest(request).build();
    final List<Long> superHeroesIds = SuperHeroDataBase.getSuperHeroes().stream().map(superHero -> superHero.getId()).collect(Collectors.toList());
    final Task task = Task.builder(taskDefinition).addValue(SUPER_HERO_ID_LIST_IN, superHeroesIds).build();
    try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        taskManager.execute(task);
        transaction.commit();
    }
    Assert.assertEquals(superHeroesIds.size(), selectHeroes().size());
}
Also used : TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) AbstractTestCaseJU4(io.vertigo.AbstractTestCaseJU4) Test(org.junit.Test) Domain(io.vertigo.dynamo.domain.metamodel.Domain) Task(io.vertigo.dynamo.task.model.Task) DtList(io.vertigo.dynamo.domain.model.DtList) Collectors(java.util.stream.Collectors) VTransactionManager(io.vertigo.commons.transaction.VTransactionManager) TaskEngineProcBatch(io.vertigo.dynamox.task.TaskEngineProcBatch) Inject(javax.inject.Inject) SuperHero(io.vertigo.dynamo.task.data.domain.SuperHero) List(java.util.List) TaskManager(io.vertigo.dynamo.task.TaskManager) TaskEngineSelect(io.vertigo.dynamox.task.TaskEngineSelect) Assert(org.junit.Assert) TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task) TaskEngineProcBatch(io.vertigo.dynamox.task.TaskEngineProcBatch) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Domain(io.vertigo.dynamo.domain.metamodel.Domain) Test(org.junit.Test)

Aggregations

SuperHero (io.vertigo.dynamo.task.data.domain.SuperHero)20 VTransactionWritable (io.vertigo.commons.transaction.VTransactionWritable)18 TaskDefinition (io.vertigo.dynamo.task.metamodel.TaskDefinition)17 Task (io.vertigo.dynamo.task.model.Task)17 Test (org.junit.Test)17 DtList (io.vertigo.dynamo.domain.model.DtList)7 Domain (io.vertigo.dynamo.domain.metamodel.Domain)3 TaskEngineProcBatch (io.vertigo.dynamox.task.TaskEngineProcBatch)2 AbstractTestCaseJU4 (io.vertigo.AbstractTestCaseJU4)1 VTransactionManager (io.vertigo.commons.transaction.VTransactionManager)1 TaskManager (io.vertigo.dynamo.task.TaskManager)1 TaskEngineSelect (io.vertigo.dynamox.task.TaskEngineSelect)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Assert (org.junit.Assert)1