Search in sources :

Example 1 with Domain

use of io.vertigo.dynamo.domain.metamodel.Domain in project vertigo by KleeGroup.

the class CarSearchLoader method getTaskLoadCarList.

private TaskDefinition getTaskLoadCarList(final SearchChunk<Car> searchChunk) {
    final Domain doCarList = definitionSpace.resolve("DO_DT_CAR_DTC", Domain.class);
    final String sql = searchChunk.getAllURIs().stream().map(uri -> uri.getId().toString()).collect(Collectors.joining(", ", "select * from CAR where ID in (", ")"));
    return TaskDefinition.builder("TK_LOAD_ALL_CARS").withEngine(TaskEngineSelect.class).withRequest(sql).withPackageName(TaskEngineSelect.class.getPackage().getName()).withOutRequired("dtc", doCarList).build();
}
Also used : AbstractSqlSearchLoader(io.vertigo.dynamox.search.AbstractSqlSearchLoader) SearchChunk(io.vertigo.dynamo.search.metamodel.SearchChunk) TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) URI(io.vertigo.dynamo.domain.model.URI) DtObjectUtil(io.vertigo.dynamo.domain.util.DtObjectUtil) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) Domain(io.vertigo.dynamo.domain.metamodel.Domain) Task(io.vertigo.dynamo.task.model.Task) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) DtList(io.vertigo.dynamo.domain.model.DtList) SearchIndex(io.vertigo.dynamo.search.model.SearchIndex) Collectors(java.util.stream.Collectors) VTransactionManager(io.vertigo.commons.transaction.VTransactionManager) SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition) Car(io.vertigo.dynamo.search_2_4.data.domain.Car) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Home(io.vertigo.app.Home) List(java.util.List) TaskManager(io.vertigo.dynamo.task.TaskManager) SearchManager(io.vertigo.dynamo.search.SearchManager) TaskEngineSelect(io.vertigo.dynamox.task.TaskEngineSelect) Assertion(io.vertigo.lang.Assertion) Domain(io.vertigo.dynamo.domain.metamodel.Domain)

Example 2 with Domain

use of io.vertigo.dynamo.domain.metamodel.Domain in project vertigo by KleeGroup.

the class SqlDataStorePlugin method count.

/**
 * {@inheritDoc}
 */
@Override
public int count(final DtDefinition dtDefinition) {
    Assertion.checkNotNull(dtDefinition);
    Assertion.checkArgument(dtDefinition.isPersistent(), "DtDefinition is not  persistent");
    // -----
    final String tableName = getTableName(dtDefinition);
    final String taskName = TASK.TK_COUNT + "_" + tableName;
    final Domain countDomain = Domain.builder("DO_COUNT", DataType.Long).build();
    final String request = "select count(*) from " + tableName;
    final TaskDefinition taskDefinition = TaskDefinition.builder(taskName).withEngine(TaskEngineSelect.class).withDataSpace(dataSpace).withRequest(request).withOutRequired("count", countDomain).build();
    final Task task = Task.builder(taskDefinition).build();
    final Long count = taskManager.execute(task).getResult();
    return count.intValue();
}
Also used : TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task) Domain(io.vertigo.dynamo.domain.metamodel.Domain)

Example 3 with Domain

use of io.vertigo.dynamo.domain.metamodel.Domain in project vertigo by KleeGroup.

the class AccountDefinitionProvider method provideDefinitions.

/**
 * {@inheritDoc}
 */
@Override
public List<Definition> provideDefinitions(final DefinitionSpace definitionSpace) {
    final Domain domainAccountId = Domain.builder("DO_X_ACCOUNT_ID", DataType.String).build();
    final Domain domainAccountName = Domain.builder("DO_X_ACCOUNT_NAME", DataType.String).build();
    final Domain domainAccountEmail = Domain.builder("DO_X_ACCOUNT_EMAIL", DataType.String).build();
    final DtDefinition accountDtDefinition = DtDefinition.builder("DT_ACCOUNT").addIdField(ID, "id", domainAccountId).addDataField(DISPLAY_NAME, "displayName", domainAccountName, false, true).addDataField(EMAIL, "email", domainAccountEmail, false, true).withSortField(DISPLAY_NAME).withDisplayField(DISPLAY_NAME).build();
    final DtDefinition accountGroupDtDefinition = DtDefinition.builder("DT_ACCOUNT_GROUP").addIdField(ID, "id", domainAccountId).addDataField(DISPLAY_NAME, "displayName", domainAccountName, false, true).withSortField(DISPLAY_NAME).withDisplayField(DISPLAY_NAME).build();
    return new ListBuilder<Definition>().add(domainAccountId).add(domainAccountName).add(domainAccountEmail).add(accountDtDefinition).add(accountGroupDtDefinition).build();
}
Also used : DtDefinition(io.vertigo.dynamo.domain.metamodel.DtDefinition) ListBuilder(io.vertigo.util.ListBuilder) Domain(io.vertigo.dynamo.domain.metamodel.Domain)

Example 4 with Domain

use of io.vertigo.dynamo.domain.metamodel.Domain 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();
}
Also used : TaskInput(io.vertigo.dynamo.task.proxy.TaskInput) Parameter(java.lang.reflect.Parameter) TaskDefinitionBuilder(io.vertigo.dynamo.task.metamodel.TaskDefinitionBuilder) Domain(io.vertigo.dynamo.domain.metamodel.Domain)

Example 5 with Domain

use of io.vertigo.dynamo.domain.metamodel.Domain in project vertigo by KleeGroup.

the class DomainDynamicRegistry method populateIdDtField.

/**
 * Ajoute une liste de champs d'un certain type à la dtDefinition
 *
 * @param fields List
 */
private static void populateIdDtField(final DefinitionSpace definitionSpace, final DtDefinitionBuilder dtDefinitionBuilder, final List<DslDefinition> fields) {
    for (final DslDefinition field : fields) {
        final Domain domain = definitionSpace.resolve(field.getDefinitionLinkName("domain"), Domain.class);
        // --
        Assertion.checkArgument(field.getPropertyNames().contains(KspProperty.LABEL), "Label est une propriété obligatoire");
        final String label = (String) field.getPropertyValue(KspProperty.LABEL);
        // --
        final String fieldName = field.getName();
        // -----
        dtDefinitionBuilder.addIdField(fieldName, label, domain);
    }
}
Also used : DslDefinition(io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition) Domain(io.vertigo.dynamo.domain.metamodel.Domain)

Aggregations

Domain (io.vertigo.dynamo.domain.metamodel.Domain)26 DefinitionSpace (io.vertigo.core.definition.DefinitionSpace)8 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)7 TaskDefinition (io.vertigo.dynamo.task.metamodel.TaskDefinition)7 Task (io.vertigo.dynamo.task.model.Task)7 TaskEngineSelect (io.vertigo.dynamox.task.TaskEngineSelect)7 Test (org.junit.Test)6 DslDefinition (io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition)5 ArrayList (java.util.ArrayList)4 AutoCloseableApp (io.vertigo.app.AutoCloseableApp)3 AppConfig (io.vertigo.app.config.AppConfig)3 DtList (io.vertigo.dynamo.domain.model.DtList)3 SearchIndexDefinition (io.vertigo.dynamo.search.metamodel.SearchIndexDefinition)3 FormatterDefault (io.vertigo.dynamox.domain.formatter.FormatterDefault)3 Assertion (io.vertigo.lang.Assertion)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Home (io.vertigo.app.Home)2 VTransactionManager (io.vertigo.commons.transaction.VTransactionManager)2 VTransactionWritable (io.vertigo.commons.transaction.VTransactionWritable)2