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();
}
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();
}
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();
}
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();
}
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);
}
}
Aggregations