Search in sources :

Example 36 with TaskDefinition

use of io.vertigo.dynamo.task.metamodel.TaskDefinition in project vertigo by KleeGroup.

the class TaskEngineProcBatchTest method selectHeroes.

private DtList<SuperHero> selectHeroes() {
    final TaskDefinition taskDefinition = TaskDefinition.builder("TK_SELECT_HEROES").withEngine(TaskEngineSelect.class).withRequest("select * from SUPER_HERO").withOutRequired(DTC_SUPER_HERO_OUT, getApp().getDefinitionSpace().resolve(DO_DT_SUPER_HERO_DTC, Domain.class)).build();
    final Task task = Task.builder(taskDefinition).build();
    try (VTransactionWritable tx = transactionManager.createCurrentTransaction()) {
        return taskManager.execute(task).getResult();
    }
}
Also used : TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task) TaskEngineSelect(io.vertigo.dynamox.task.TaskEngineSelect) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable)

Example 37 with TaskDefinition

use of io.vertigo.dynamo.task.metamodel.TaskDefinition 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)

Example 38 with TaskDefinition

use of io.vertigo.dynamo.task.metamodel.TaskDefinition in project vertigo by KleeGroup.

the class TaskEngineSelectDynamicTest method testWhereInEmpty.

/**
 * Test exécution d'une tache.
 */
@Test
public void testWhereInEmpty() {
    try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final TaskDefinition taskDefinition = registerTaskList("TK_WHERE_ID_TEST", "select * from SUPER_HERO 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(0, 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 39 with TaskDefinition

use of io.vertigo.dynamo.task.metamodel.TaskDefinition in project vertigo by KleeGroup.

the class TaskEngineSelectDynamicTest method testWhereIn.

/**
 * Test exécution d'une tache.
 */
@Test
public void testWhereIn() {
    try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final TaskDefinition taskDefinition = registerTaskList("TK_WHERE_ID_TEST", "select * from SUPER_HERO  where ID in (#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 40 with TaskDefinition

use of io.vertigo.dynamo.task.metamodel.TaskDefinition in project vertigo by KleeGroup.

the class TaskEngineSelectDynamicTest method testWhereInParenthesis.

/**
 * Test exécution d'une tache.
 */
@Test
public void testWhereInParenthesis() {
    try (final VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
        final TaskDefinition taskDefinition = registerTaskList("TK_WHERE_ID_TEST", "select * from SUPER_HERO  where\t(ID 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)

Aggregations

TaskDefinition (io.vertigo.dynamo.task.metamodel.TaskDefinition)52 Task (io.vertigo.dynamo.task.model.Task)39 Test (org.junit.Test)26 VTransactionWritable (io.vertigo.commons.transaction.VTransactionWritable)24 SuperHero (io.vertigo.dynamo.task.data.domain.SuperHero)17 Domain (io.vertigo.dynamo.domain.metamodel.Domain)11 TaskEngineSelect (io.vertigo.dynamox.task.TaskEngineSelect)11 DtList (io.vertigo.dynamo.domain.model.DtList)10 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)7 DefinitionSpace (io.vertigo.core.definition.DefinitionSpace)6 TaskEngineProc (io.vertigo.dynamox.task.TaskEngineProc)6 ArrayList (java.util.ArrayList)6 DtField (io.vertigo.dynamo.domain.metamodel.DtField)5 List (java.util.List)5 URI (io.vertigo.dynamo.domain.model.URI)4 VTransactionManager (io.vertigo.commons.transaction.VTransactionManager)3 TaskManager (io.vertigo.dynamo.task.TaskManager)3 TaskResult (io.vertigo.dynamo.task.model.TaskResult)3 Collectors (java.util.stream.Collectors)3 Inject (javax.inject.Inject)3