use of io.vertigo.dynamo.task.metamodel.TaskAttribute in project vertigo by KleeGroup.
the class DomainMetricsProvider method countTaskDependencies.
private static double countTaskDependencies(final Domain domain) {
Assertion.checkNotNull(domain);
// ---
int count = 0;
for (final TaskDefinition taskDefinition : Home.getApp().getDefinitionSpace().getAll(TaskDefinition.class)) {
for (final TaskAttribute taskAttribute : taskDefinition.getInAttributes()) {
if (domain.equals(taskAttribute.getDomain())) {
count++;
}
}
if (taskDefinition.getOutAttributeOption().isPresent()) {
if (domain.equals(taskDefinition.getOutAttributeOption().get().getDomain())) {
count++;
}
}
}
return count;
}
use of io.vertigo.dynamo.task.metamodel.TaskAttribute in project vertigo by KleeGroup.
the class DomainMetricsProvider method countTaskDependencies.
private static double countTaskDependencies(final DtDefinition dtDefinition) {
int count = 0;
for (final TaskDefinition taskDefinition : Home.getApp().getDefinitionSpace().getAll(TaskDefinition.class)) {
for (final TaskAttribute taskAttribute : taskDefinition.getInAttributes()) {
count += count(dtDefinition, taskAttribute);
}
if (taskDefinition.getOutAttributeOption().isPresent()) {
final TaskAttribute taskAttribute = taskDefinition.getOutAttributeOption().get();
count += count(dtDefinition, taskAttribute);
}
}
return count;
}
use of io.vertigo.dynamo.task.metamodel.TaskAttribute in project vertigo by KleeGroup.
the class Task method checkValues.
private void checkValues() {
for (final TaskAttribute taskAttribute : taskDefinition.getInAttributes()) {
// on ne prend que les attributes correspondant au mode.
// We check all attributes
final Object value = inTaskAttributes.get(taskAttribute);
taskAttribute.checkAttribute(value);
}
}
use of io.vertigo.dynamo.task.metamodel.TaskAttribute in project vertigo by KleeGroup.
the class TaskEngineProcBatch method setNamedParameters.
@Override
protected void setNamedParameters(final SqlStatementBuilder sqlStatementBuilder) {
final List<TaskAttribute> potentialBatchAttributes = getTaskDefinition().getInAttributes().stream().filter(// multiple
inAttribute -> inAttribute.getDomain().isMultiple()).collect(Collectors.toList());
Assertion.checkState(potentialBatchAttributes.size() == 1, "For batch a single List param is required");
final TaskAttribute listAttribute = potentialBatchAttributes.get(0);
final List<TaskAttribute> otherAttributes = getTaskDefinition().getInAttributes().stream().filter(// not multiple
inAttribute -> !inAttribute.getDomain().isMultiple()).collect(Collectors.toList());
// ---
final List<?> list = getValue(listAttribute.getName());
list.forEach(object -> {
// we bind the parameter of the batch
sqlStatementBuilder.bind(listAttribute.getName(), listAttribute.getDomain().getJavaClass(), object);
// we add all the "constant" parameters
otherAttributes.forEach(otherAttribute -> sqlStatementBuilder.bind(otherAttribute.getName(), otherAttribute.getDomain().getJavaClass(), getValue(otherAttribute.getName())));
sqlStatementBuilder.nextLine();
});
}
use of io.vertigo.dynamo.task.metamodel.TaskAttribute in project vertigo by KleeGroup.
the class TaskEngineSelect method doExecute.
/**
* {@inheritDoc}
*/
@Override
protected OptionalInt doExecute(final SqlStatement sqlStatement, final SqlConnection connection) throws SQLException {
final TaskAttribute outAttribute = getOutTaskAttribute();
final List<?> result;
final Integer limit = outAttribute.getDomain().isMultiple() ? null : 1;
result = getDataBaseManager().executeQuery(sqlStatement, outAttribute.getDomain().getJavaClass(), limit, connection);
switch(outAttribute.getDomain().getScope()) {
case DATA_OBJECT:
if (outAttribute.getDomain().isMultiple()) {
final DtList<?> dtList = result.stream().map(DtObject.class::cast).collect(VCollectors.toDtList(outAttribute.getDomain().getDtDefinition()));
setResult(dtList);
} else {
Assertion.checkState(result.size() <= 1, "Limit exceeded");
setResult(result.isEmpty() ? null : result.get(0));
}
break;
case PRIMITIVE:
case VALUE_OBJECT:
if (outAttribute.getDomain().isMultiple()) {
setResult(result);
} else {
Assertion.checkState(result.size() <= 1, "Limit exceeded");
setResult(result.isEmpty() ? null : result.get(0));
}
break;
default:
throw new IllegalStateException();
}
return OptionalInt.of(result.size());
}
Aggregations