Search in sources :

Example 46 with TaskDefinition

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());
    }
}
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 47 with TaskDefinition

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();
}
Also used : AbstractSqlSearchLoader(io.vertigo.dynamox.search.AbstractSqlSearchLoader) SearchChunk(io.vertigo.dynamo.search.metamodel.SearchChunk) TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Item(io.vertigo.dynamo.search.data.domain.Item) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) URI(io.vertigo.dynamo.domain.model.URI) DtObjectUtil(io.vertigo.dynamo.domain.util.DtObjectUtil) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Domain(io.vertigo.dynamo.domain.metamodel.Domain) Task(io.vertigo.dynamo.task.model.Task) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) DtList(io.vertigo.dynamo.domain.model.DtList) SearchIndex(io.vertigo.dynamo.search.model.SearchIndex) Collectors(java.util.stream.Collectors) VTransactionManager(io.vertigo.commons.transaction.VTransactionManager) SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Home(io.vertigo.app.Home) List(java.util.List) TaskManager(io.vertigo.dynamo.task.TaskManager) SearchManager(io.vertigo.dynamo.search.SearchManager) TaskEngineSelect(io.vertigo.dynamox.task.TaskEngineSelect) Assertion(io.vertigo.lang.Assertion) Domain(io.vertigo.dynamo.domain.metamodel.Domain)

Example 48 with TaskDefinition

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);
    }
}
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) Test(org.junit.Test)

Example 49 with TaskDefinition

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);
}
Also used : TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) TaskEngineProc(io.vertigo.dynamox.task.TaskEngineProc) TaskResult(io.vertigo.dynamo.task.model.TaskResult) Domain(io.vertigo.dynamo.domain.metamodel.Domain)

Example 50 with TaskDefinition

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);
        }
    }
}
Also used : TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task) TaskEngineProc(io.vertigo.dynamox.task.TaskEngineProc) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable)

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