use of io.vertigo.dynamo.task.model.Task 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.model.Task 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.task.model.Task in project vertigo by KleeGroup.
the class SqlDataStorePlugin method readNullableForUpdate.
/**
* {@inheritDoc}
*/
@Override
public <E extends Entity> E readNullableForUpdate(final DtDefinition dtDefinition, final URI<?> uri) {
final String tableName = getTableName(dtDefinition);
final String taskName = TASK.TK_LOCK + "_" + tableName;
final String requestedFields = getRequestedFields(dtDefinition);
final DtField idField = getIdField(dtDefinition);
final String idFieldName = idField.getName();
final String request = sqlDialect.createSelectForUpdateQuery(tableName, requestedFields, idFieldName);
final TaskDefinition taskDefinition = TaskDefinition.builder(taskName).withEngine(TaskEngineSelect.class).withDataSpace(dataSpace).withRequest(request).addInRequired(idFieldName, idField.getDomain()).withOutOptional("dto", Home.getApp().getDefinitionSpace().resolve(DOMAIN_PREFIX + SEPARATOR + uri.getDefinition().getName() + "_DTO", Domain.class)).build();
final Task task = Task.builder(taskDefinition).addValue(idFieldName, uri.getId()).build();
return taskManager.execute(task).getResult();
}
use of io.vertigo.dynamo.task.model.Task in project vertigo by KleeGroup.
the class SqlDataStorePlugin method put.
/**
* @param entity Objet à persiter
* @param insert Si opération de type insert (update sinon)
*/
private void put(final Entity entity, final boolean insert) {
final DtDefinition dtDefinition = DtObjectUtil.findDtDefinition(entity);
final String tableName = getTableName(dtDefinition);
final String taskName = (insert ? TASK.TK_INSERT : TASK.TK_UPDATE) + "_" + tableName;
final String request = insert ? sqlDialect.createInsertQuery(dtDefinition.getIdField().get().getName(), getDataFields(dtDefinition), sequencePrefix, tableName) : createUpdateQuery(dtDefinition);
final TaskDefinition taskDefinition = TaskDefinition.builder(taskName).withEngine(getTaskEngineClass(insert)).withDataSpace(dataSpace).withRequest(request).addInRequired("DTO", Home.getApp().getDefinitionSpace().resolve(DOMAIN_PREFIX + SEPARATOR + dtDefinition.getName() + "_DTO", Domain.class)).withOutRequired(AbstractTaskEngineSQL.SQL_ROWCOUNT, integerDomain).build();
final Task task = Task.builder(taskDefinition).addValue("DTO", entity).build();
final int sqlRowCount = taskManager.execute(task).getResult();
if (sqlRowCount > 1) {
throw new VSystemException("more than one row has been " + (insert ? "created" : "updated"));
}
if (sqlRowCount == 0) {
throw new VSystemException("no data " + (insert ? "created" : "updated"));
}
}
use of io.vertigo.dynamo.task.model.Task in project vertigo by KleeGroup.
the class AbstractStoreManagerTest method nativeLoadCarList.
protected final DtList<Car> nativeLoadCarList() {
final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
final Domain doCarList = definitionSpace.resolve("DO_DT_CAR_DTC", Domain.class);
final TaskDefinition taskDefinition = TaskDefinition.builder("TK_LOAD_ALL_CARS").withEngine(TaskEngineSelect.class).withRequest("select * from CAR").withOutRequired("dtc", doCarList).build();
final Task task = Task.builder(taskDefinition).build();
return taskManager.execute(task).getResult();
}
Aggregations