use of io.vertigo.dynamo.task.metamodel.TaskDefinition 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());
}
}
use of io.vertigo.dynamo.task.metamodel.TaskDefinition in project vertigo by KleeGroup.
the class ItemSearchLoader method getTaskDefinition.
private TaskDefinition getTaskDefinition(final SearchChunk<Item> searchChunk) {
final Domain doItems = definitionSpace.resolve("DO_DT_ITEM_DTC", Domain.class);
final String sql = searchChunk.getAllURIs().stream().map(uri -> uri.getId().toString()).collect(Collectors.joining(", ", "select * from ITEM where ID in (", ")"));
return TaskDefinition.builder("TK_LOAD_ALL_ITEMS").withEngine(TaskEngineSelect.class).withRequest(sql).withPackageName(TaskEngineSelect.class.getPackage().getName()).withOutRequired("dtc", doItems).build();
}
use of io.vertigo.dynamo.task.metamodel.TaskDefinition in project vertigo by KleeGroup.
the class AbstractStoreManagerTest method testSelectCountCars.
@Test
public void testSelectCountCars() {
final TaskDefinition taskDefinition = TaskDefinition.builder("TK_COUNT_CARS").withEngine(TaskEngineSelect.class).withRequest("select count(*) from CAR").withOutRequired("count", Domain.builder("DO_COUNT", DataType.Long).build()).build();
try (VTransactionWritable tx = transactionManager.createCurrentTransaction()) {
final Task task = Task.builder(taskDefinition).build();
final long count = taskManager.execute(task).getResult();
// -----
Assert.assertEquals(9, count);
}
}
use of io.vertigo.dynamo.task.metamodel.TaskDefinition in project vertigo by KleeGroup.
the class AbstractStoreManagerTest method nativeInsertCar.
protected void nativeInsertCar(final Car car) {
Assertion.checkArgument(car.getId() == null, "L'id n'est pas null {0}", car.getId());
// -----
final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
final Domain doCar = definitionSpace.resolve("DO_DT_CAR_DTO", Domain.class);
final TaskDefinition taskDefinition = TaskDefinition.builder("TK_INSERT_CAR").withEngine(TaskEngineProc.class).withRequest("insert into CAR (ID, FAM_ID,MANUFACTURER, MODEL, DESCRIPTION, YEAR, KILO, PRICE, MTY_CD) values " + "(NEXT VALUE FOR SEQ_CAR, #DTO_CAR.FAM_ID#, #DTO_CAR.MANUFACTURER#, #DTO_CAR.MODEL#, #DTO_CAR.DESCRIPTION#, #DTO_CAR.YEAR#, #DTO_CAR.KILO#, #DTO_CAR.PRICE#, #DTO_CAR.MTY_CD#)").addInRequired("DTO_CAR", doCar).build();
final Task task = Task.builder(taskDefinition).addValue("DTO_CAR", car).build();
final TaskResult taskResult = taskManager.execute(task);
nop(taskResult);
}
use of io.vertigo.dynamo.task.metamodel.TaskDefinition in project vertigo by KleeGroup.
the class SqlUtil method execRequests.
public static void execRequests(final VTransactionManager transactionManager, final TaskManager taskManager, final List<String> requests, final String taskName, final Optional<String> optDataSpace) {
// A chaque test on recrée la table famille
try (VTransactionWritable transaction = transactionManager.createCurrentTransaction()) {
for (final String request : requests) {
final TaskDefinition taskDefinition = TaskDefinition.builder(taskName).withEngine(TaskEngineProc.class).withRequest(request).withDataSpace(optDataSpace.orElse(null)).build();
final Task task = Task.builder(taskDefinition).build();
taskManager.execute(task);
}
}
}
Aggregations