Search in sources :

Example 51 with TaskDefinition

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

the class TaskProxyMethod method invoke.

@Override
public Object invoke(final Method method, final Object[] args) {
    final TaskDefinition taskDefinition = createTaskDefinition(method);
    final Task task = createTask(taskDefinition, method, args);
    final TaskResult taskResult = getTaskManager().execute(task);
    if (taskDefinition.getOutAttributeOption().isPresent()) {
        return taskResult.getResult();
    }
    return Void.TYPE;
}
Also used : TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task) TaskResult(io.vertigo.dynamo.task.model.TaskResult)

Example 52 with TaskDefinition

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

the class BrokerBatchImpl method getList.

private DtList<E> getList(final DtDefinition dtDefinition, final String fieldName, final DtList<E> dtc) {
    // On splitte la collection par paquet
    final List<DtList<E>> paquet = new ArrayList<>();
    DtList<E> tmp = null;
    for (int i = 0; i < dtc.size(); i++) {
        if (i % GET_LIST_PAQUET_SIZE == 0) {
            tmp = new DtList<>(dtc.getDefinition());
            paquet.add(tmp);
        }
        if (tmp != null) {
            tmp.add(dtc.get(i));
        }
    }
    // On génère la requête
    // Corps de la requete
    // On génère maintenant la requête proc batch
    final DtDefinition dtDef = dtc.getDefinition();
    final String dtcName = getDtcName(dtDef);
    final String inDtcName = dtcName + "_IN";
    final String request = new StringBuilder("select * from ").append(dtDef.getLocalName()).append(" where ").append(fieldName).append(" in (#").append(inDtcName).append(".ROWNUM.").append(fieldName).append("#)").toString();
    // Exécution de la tache
    final Domain dtcDomain = Home.getApp().getDefinitionSpace().resolve(DOMAIN_PREFIX + SEPARATOR + dtDef.getName() + "_DTC", Domain.class);
    final String taskName = "TK_LOAD_BY_LST_" + fieldName + "_" + dtDef.getLocalName();
    final TaskDefinition taskDefinition = TaskDefinition.builder(taskName).withEngine(TaskEngineSelect.class).withDataSpace(dtDef.getDataSpace()).withRequest(request).addInRequired(inDtcName, dtcDomain).withOutRequired("out", dtcDomain).build();
    // On exécute par paquet
    final DtList<E> ret = new DtList<>(dtDefinition);
    for (final DtList<E> paq : paquet) {
        /* Création de la tache. */
        final Task task = Task.builder(taskDefinition).addValue(inDtcName, paq).build();
        // Exécution de la tache
        final DtList<E> result = taskManager.execute(task).getResult();
        ret.addAll(result);
    }
    return ret;
}
Also used : Task(io.vertigo.dynamo.task.model.Task) TaskEngineSelect(io.vertigo.dynamox.task.TaskEngineSelect) ArrayList(java.util.ArrayList) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Domain(io.vertigo.dynamo.domain.metamodel.Domain) DtList(io.vertigo.dynamo.domain.model.DtList)

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