Search in sources :

Example 1 with TaskAttribute

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;
}
Also used : TaskAttribute(io.vertigo.dynamo.task.metamodel.TaskAttribute) TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition)

Example 2 with TaskAttribute

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;
}
Also used : TaskAttribute(io.vertigo.dynamo.task.metamodel.TaskAttribute) TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition)

Example 3 with TaskAttribute

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);
    }
}
Also used : TaskAttribute(io.vertigo.dynamo.task.metamodel.TaskAttribute)

Example 4 with TaskAttribute

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();
    });
}
Also used : TaskAttribute(io.vertigo.dynamo.task.metamodel.TaskAttribute) OptionalInt(java.util.OptionalInt) Collectors(java.util.stream.Collectors) VTransactionManager(io.vertigo.commons.transaction.VTransactionManager) SqlStatementBuilder(io.vertigo.database.sql.statement.SqlStatementBuilder) Inject(javax.inject.Inject) ScriptManager(io.vertigo.commons.script.ScriptManager) SqlDataBaseManager(io.vertigo.database.sql.SqlDataBaseManager) StoreManager(io.vertigo.dynamo.store.StoreManager) SQLException(java.sql.SQLException) List(java.util.List) SqlStatement(io.vertigo.database.sql.statement.SqlStatement) SqlConnection(io.vertigo.database.sql.connection.SqlConnection) Assertion(io.vertigo.lang.Assertion) TaskAttribute(io.vertigo.dynamo.task.metamodel.TaskAttribute)

Example 5 with TaskAttribute

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());
}
Also used : TaskAttribute(io.vertigo.dynamo.task.metamodel.TaskAttribute)

Aggregations

TaskAttribute (io.vertigo.dynamo.task.metamodel.TaskAttribute)9 TaskDefinition (io.vertigo.dynamo.task.metamodel.TaskDefinition)2 List (java.util.List)2 ExpressionParameter (io.vertigo.commons.script.ExpressionParameter)1 ScriptManager (io.vertigo.commons.script.ScriptManager)1 VTransactionManager (io.vertigo.commons.transaction.VTransactionManager)1 SqlDataBaseManager (io.vertigo.database.sql.SqlDataBaseManager)1 SqlConnection (io.vertigo.database.sql.connection.SqlConnection)1 SqlStatement (io.vertigo.database.sql.statement.SqlStatement)1 SqlStatementBuilder (io.vertigo.database.sql.statement.SqlStatementBuilder)1 StoreManager (io.vertigo.dynamo.store.StoreManager)1 Assertion (io.vertigo.lang.Assertion)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 OptionalInt (java.util.OptionalInt)1 Matcher (java.util.regex.Matcher)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1