use of io.vertigo.dynamo.task.metamodel.TaskDefinitionBuilder 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.metamodel.TaskDefinitionBuilder in project vertigo by KleeGroup.
the class TaskProxyMethod method createTaskDefinition.
private static TaskDefinition createTaskDefinition(final Method method) {
final io.vertigo.dynamo.task.proxy.TaskAnnotation taskAnnotation = method.getAnnotation(io.vertigo.dynamo.task.proxy.TaskAnnotation.class);
final TaskDefinitionBuilder taskDefinitionBuilder = TaskDefinition.builder(taskAnnotation.name()).withEngine(taskAnnotation.taskEngineClass()).withRequest(taskAnnotation.request()).withDataSpace(taskAnnotation.dataSpace().isEmpty() ? null : taskAnnotation.dataSpace());
if (hasOut(method)) {
final Domain outDomain = findOutDomain(method);
if (isOutOptional(method)) {
taskDefinitionBuilder.withOutOptional("OUT", outDomain);
} else {
taskDefinitionBuilder.withOutRequired("OUT", outDomain);
}
}
for (final Parameter parameter : method.getParameters()) {
final TaskInput taskAttributeAnnotation = parameter.getAnnotation(TaskInput.class);
// test if the parameter is an optional type
final boolean optional = Optional.class.isAssignableFrom(parameter.getType());
if (optional) {
taskDefinitionBuilder.addInOptional(taskAttributeAnnotation.name(), resolveDomain(taskAttributeAnnotation.domain()));
} else {
taskDefinitionBuilder.addInRequired(taskAttributeAnnotation.name(), resolveDomain(taskAttributeAnnotation.domain()));
}
}
return taskDefinitionBuilder.build();
}
use of io.vertigo.dynamo.task.metamodel.TaskDefinitionBuilder 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();
}
use of io.vertigo.dynamo.task.metamodel.TaskDefinitionBuilder in project vertigo by KleeGroup.
the class TaskDynamicRegistry method createTaskDefinition.
private static TaskDefinition createTaskDefinition(final DslDefinition xtaskDefinition) {
final String taskDefinitionName = xtaskDefinition.getName();
final String request = (String) xtaskDefinition.getPropertyValue(KspProperty.REQUEST);
Assertion.checkNotNull(taskDefinitionName);
final Class<? extends TaskEngine> taskEngineClass = getTaskEngineClass(xtaskDefinition);
final String dataSpace = (String) xtaskDefinition.getPropertyValue(KspProperty.DATA_SPACE);
final TaskDefinitionBuilder taskDefinitionBuilder = TaskDefinition.builder(taskDefinitionName).withEngine(taskEngineClass).withDataSpace(dataSpace).withRequest(request).withPackageName(xtaskDefinition.getPackageName());
for (final DslDefinition xtaskAttribute : xtaskDefinition.getChildDefinitions(TaskGrammar.TASK_ATTRIBUTE)) {
final String attributeName = xtaskAttribute.getName();
Assertion.checkNotNull(attributeName);
final String domainName = xtaskAttribute.getDefinitionLinkName("domain");
final Domain domain = Home.getApp().getDefinitionSpace().resolve(domainName, Domain.class);
// -----
final boolean required = (Boolean) xtaskAttribute.getPropertyValue(KspProperty.NOT_NULL);
if (isInValue((String) xtaskAttribute.getPropertyValue(KspProperty.IN_OUT))) {
if (required) {
taskDefinitionBuilder.addInRequired(attributeName, domain);
} else {
taskDefinitionBuilder.addInOptional(attributeName, domain);
}
} else {
if (required) {
taskDefinitionBuilder.withOutRequired(attributeName, domain);
} else {
taskDefinitionBuilder.withOutOptional(attributeName, domain);
}
}
}
return taskDefinitionBuilder.build();
}
Aggregations