Search in sources :

Example 1 with TaskDefinition

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

the class CarSearchLoader method loadCarList.

private DtList<Car> loadCarList(final SearchChunk<Car> searchChunk) {
    final TaskDefinition taskLoadCars = getTaskLoadCarList(searchChunk);
    final Task task = Task.builder(taskLoadCars).build();
    return getTaskManager().execute(task).getResult();
}
Also used : TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task)

Example 2 with TaskDefinition

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

the class CarSearchLoader method getTaskLoadCarList.

private TaskDefinition getTaskLoadCarList(final SearchChunk<Car> searchChunk) {
    final Domain doCarList = definitionSpace.resolve("DO_DT_CAR_DTC", Domain.class);
    final String sql = searchChunk.getAllURIs().stream().map(uri -> uri.getId().toString()).collect(Collectors.joining(", ", "select * from CAR where ID in (", ")"));
    return TaskDefinition.builder("TK_LOAD_ALL_CARS").withEngine(TaskEngineSelect.class).withRequest(sql).withPackageName(TaskEngineSelect.class.getPackage().getName()).withOutRequired("dtc", doCarList).build();
}
Also used : AbstractSqlSearchLoader(io.vertigo.dynamox.search.AbstractSqlSearchLoader) SearchChunk(io.vertigo.dynamo.search.metamodel.SearchChunk) TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) 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) Car(io.vertigo.dynamo.search_2_4.data.domain.Car) 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 3 with TaskDefinition

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

the class TaskGeneratorPlugin method builDtDefinitiondMap.

private static Map<DtDefinition, List<TaskDefinition>> builDtDefinitiondMap() {
    final Collection<TaskDefinition> taskDefinitions = Home.getApp().getDefinitionSpace().getAll(TaskDefinition.class);
    final Map<DtDefinition, List<TaskDefinition>> taskDefinitionsMap = new LinkedHashMap<>();
    // ---
    // Par défaut, On crée pour chaque DT une liste vide des taches lui étant associées.
    final Collection<DtDefinition> dtDefinitions = Home.getApp().getDefinitionSpace().getAll(DtDefinition.class);
    for (final DtDefinition dtDefinition : dtDefinitions) {
        taskDefinitionsMap.put(dtDefinition, new ArrayList<TaskDefinition>());
    }
    // ---
    for (final TaskDefinition taskDefinition : taskDefinitions) {
        final TaskDefinitionModel templateTaskDefinition = new TaskDefinitionModel(taskDefinition);
        final DtDefinition dtDefinition = getDtDefinition(templateTaskDefinition);
        final boolean dao = dtDefinition != null;
        if (dao) {
            // Dans le cas d'un DTO ou DTC en sortie on considère que la tache est liée au DAO.
            taskDefinitionsMap.get(dtDefinition).add(taskDefinition);
        }
    }
    return taskDefinitionsMap;
}
Also used : TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) ArrayList(java.util.ArrayList) List(java.util.List) TaskDefinitionModel(io.vertigo.studio.plugins.mda.task.model.TaskDefinitionModel) LinkedHashMap(java.util.LinkedHashMap)

Example 4 with TaskDefinition

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

the class SqlDataStorePlugin method findByCriteria.

/**
 * {@inheritDoc}
 */
@Override
public <E extends Entity> DtList<E> findByCriteria(final DtDefinition dtDefinition, final Criteria<E> criteria, final Integer maxRows) {
    Assertion.checkNotNull(dtDefinition);
    Assertion.checkNotNull(criteria);
    // ---
    final String tableName = getTableName(dtDefinition);
    final String requestedFields = getRequestedFields(dtDefinition);
    final String taskName = getListTaskName(tableName);
    final Tuples.Tuple2<String, CriteriaCtx> tuple = criteria.toSql(sqlDialect);
    final String where = tuple.getVal1();
    final String request = createLoadAllLikeQuery(tableName, requestedFields, where, maxRows);
    final TaskDefinitionBuilder taskDefinitionBuilder = TaskDefinition.builder(taskName).withEngine(TaskEngineSelect.class).withDataSpace(dataSpace).withRequest(request);
    final CriteriaCtx ctx = tuple.getVal2();
    // IN, Optional
    for (final String attributeName : ctx.getAttributeNames()) {
        taskDefinitionBuilder.addInOptional(attributeName, dtDefinition.getField(ctx.getDtFieldName(attributeName)).getDomain());
    }
    // OUT, obligatoire
    final TaskDefinition taskDefinition = taskDefinitionBuilder.withOutRequired("dtc", Home.getApp().getDefinitionSpace().resolve(DOMAIN_PREFIX + SEPARATOR + dtDefinition.getName() + "_DTC", Domain.class)).build();
    final TaskBuilder taskBuilder = Task.builder(taskDefinition);
    for (final String attributeName : ctx.getAttributeNames()) {
        taskBuilder.addValue(attributeName, ctx.getAttributeValue(attributeName));
    }
    return taskManager.execute(taskBuilder.build()).getResult();
}
Also used : TaskBuilder(io.vertigo.dynamo.task.model.TaskBuilder) TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) CriteriaCtx(io.vertigo.dynamo.criteria.CriteriaCtx) Tuples(io.vertigo.lang.Tuples) TaskDefinitionBuilder(io.vertigo.dynamo.task.metamodel.TaskDefinitionBuilder)

Example 5 with TaskDefinition

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

the class SqlDataStorePlugin method count.

/**
 * {@inheritDoc}
 */
@Override
public int count(final DtDefinition dtDefinition) {
    Assertion.checkNotNull(dtDefinition);
    Assertion.checkArgument(dtDefinition.isPersistent(), "DtDefinition is not  persistent");
    // -----
    final String tableName = getTableName(dtDefinition);
    final String taskName = TASK.TK_COUNT + "_" + tableName;
    final Domain countDomain = Domain.builder("DO_COUNT", DataType.Long).build();
    final String request = "select count(*) from " + tableName;
    final TaskDefinition taskDefinition = TaskDefinition.builder(taskName).withEngine(TaskEngineSelect.class).withDataSpace(dataSpace).withRequest(request).withOutRequired("count", countDomain).build();
    final Task task = Task.builder(taskDefinition).build();
    final Long count = taskManager.execute(task).getResult();
    return count.intValue();
}
Also used : TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task) Domain(io.vertigo.dynamo.domain.metamodel.Domain)

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