use of io.vertigo.dynamo.task.model.TaskBuilder 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();
}
use of io.vertigo.dynamo.task.model.TaskBuilder in project vertigo by KleeGroup.
the class TaskProxyMethod method createTask.
private static Task createTask(final TaskDefinition taskDefinition, final Method method, final Object[] args) {
final TaskBuilder taskBuilder = Task.builder(taskDefinition);
for (int i = 0; i < method.getParameters().length; i++) {
final Parameter parameter = method.getParameters()[i];
final boolean optional = Optional.class.isAssignableFrom(parameter.getType());
final TaskInput taskAttributeAnnotation = parameter.getAnnotation(TaskInput.class);
final Object arg;
if (optional) {
arg = ((Optional) (args[i])).orElse(null);
} else {
arg = args[i];
}
taskBuilder.addValue(taskAttributeAnnotation.name(), arg);
}
return taskBuilder.build();
}
use of io.vertigo.dynamo.task.model.TaskBuilder in project vertigo by KleeGroup.
the class BrokerNNImpl method processNN.
private int processNN(final String taskDefinitionName, final String request, final String dataSpace, final DtField sourceField, final Object sourceValue, final DtField targetField, final Object targetValue) {
// FieldName
final String sourceFieldName = sourceField.getName();
final TaskDefinitionBuilder taskDefinitionBuilder = TaskDefinition.builder(taskDefinitionName).withEngine(TaskEngineProc.class).withDataSpace(dataSpace).withRequest(request).addInRequired(sourceFieldName, sourceField.getDomain());
if (targetField != null) {
taskDefinitionBuilder.addInRequired(targetField.getName(), targetField.getDomain());
}
// OUT, obligatoire
final TaskDefinition taskDefinition = taskDefinitionBuilder.withOutRequired(AbstractTaskEngineSQL.SQL_ROWCOUNT, integerDomain).build();
/* Création de la tache. */
final TaskBuilder taskBuilder = Task.builder(taskDefinition).addValue(sourceFieldName, sourceValue);
if (targetField != null) {
taskBuilder.addValue(targetField.getName(), targetValue);
}
return taskManager.execute(taskBuilder.build()).getResult();
}
Aggregations