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();
}
}
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());
}
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());
}
}
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());
}
}
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());
}
}
Aggregations