use of io.vertigo.dynamo.task.metamodel.TaskDefinition in project vertigo by KleeGroup.
the class CarSearchLoader method loadCarList.
private DtList<Car> loadCarList(final SearchChunk<Car> searchChunk) {
final TaskDefinition taskLoadCars = getTaskLoadCarList(searchChunk);
final Task task = Task.builder(taskLoadCars).build();
return getTaskManager().execute(task).getResult();
}
use of io.vertigo.dynamo.task.metamodel.TaskDefinition 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.task.metamodel.TaskDefinition in project vertigo by KleeGroup.
the class TaskGeneratorPlugin method builDtDefinitiondMap.
private static Map<DtDefinition, List<TaskDefinition>> builDtDefinitiondMap() {
final Collection<TaskDefinition> taskDefinitions = Home.getApp().getDefinitionSpace().getAll(TaskDefinition.class);
final Map<DtDefinition, List<TaskDefinition>> taskDefinitionsMap = new LinkedHashMap<>();
// ---
// Par défaut, On crée pour chaque DT une liste vide des taches lui étant associées.
final Collection<DtDefinition> dtDefinitions = Home.getApp().getDefinitionSpace().getAll(DtDefinition.class);
for (final DtDefinition dtDefinition : dtDefinitions) {
taskDefinitionsMap.put(dtDefinition, new ArrayList<TaskDefinition>());
}
// ---
for (final TaskDefinition taskDefinition : taskDefinitions) {
final TaskDefinitionModel templateTaskDefinition = new TaskDefinitionModel(taskDefinition);
final DtDefinition dtDefinition = getDtDefinition(templateTaskDefinition);
final boolean dao = dtDefinition != null;
if (dao) {
// Dans le cas d'un DTO ou DTC en sortie on considère que la tache est liée au DAO.
taskDefinitionsMap.get(dtDefinition).add(taskDefinition);
}
}
return taskDefinitionsMap;
}
use of io.vertigo.dynamo.task.metamodel.TaskDefinition 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.TaskDefinition 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();
}
Aggregations