Search in sources :

Example 1 with Transactional

use of io.vertigo.commons.transaction.Transactional in project vertigo by KleeGroup.

the class AbstractSqlSearchLoader method loadNextURI.

/**
 * {@inheritDoc}
 */
@Override
@Transactional
protected final List<URI<S>> loadNextURI(final P lastId, final DtDefinition dtDefinition) {
    try (final VTransactionWritable tx = transactionManager.createCurrentTransaction()) {
        final String tableName = getTableName(dtDefinition);
        final String taskName = "TK_SELECT_" + tableName + "_NEXT_SEARCH_CHUNK";
        final DtField idField = dtDefinition.getIdField().get();
        final String idFieldName = idField.getName();
        final String request = getNextIdsSqlQuery(tableName, idFieldName);
        final TaskDefinition taskDefinition = TaskDefinition.builder(taskName).withEngine(TaskEngineSelect.class).withDataSpace(dtDefinition.getDataSpace()).withRequest(request).addInRequired(idFieldName, idField.getDomain()).withOutRequired("dtc", Home.getApp().getDefinitionSpace().resolve(DOMAIN_PREFIX + SEPARATOR + dtDefinition.getName() + "_DTC", Domain.class)).build();
        final Task task = Task.builder(taskDefinition).addValue(idFieldName, lastId).build();
        final DtList<S> resultDtc = taskManager.execute(task).getResult();
        final List<URI<S>> uris = new ArrayList<>(resultDtc.size());
        for (final S dto : resultDtc) {
            uris.add(new URI<S>(dtDefinition, DtObjectUtil.getId(dto)));
        }
        return uris;
    }
}
Also used : TaskDefinition(io.vertigo.dynamo.task.metamodel.TaskDefinition) Task(io.vertigo.dynamo.task.model.Task) TaskEngineSelect(io.vertigo.dynamox.task.TaskEngineSelect) ArrayList(java.util.ArrayList) VTransactionWritable(io.vertigo.commons.transaction.VTransactionWritable) URI(io.vertigo.dynamo.domain.model.URI) DtField(io.vertigo.dynamo.domain.metamodel.DtField) Transactional(io.vertigo.commons.transaction.Transactional)

Aggregations

Transactional (io.vertigo.commons.transaction.Transactional)1 VTransactionWritable (io.vertigo.commons.transaction.VTransactionWritable)1 DtField (io.vertigo.dynamo.domain.metamodel.DtField)1 URI (io.vertigo.dynamo.domain.model.URI)1 TaskDefinition (io.vertigo.dynamo.task.metamodel.TaskDefinition)1 Task (io.vertigo.dynamo.task.model.Task)1 TaskEngineSelect (io.vertigo.dynamox.task.TaskEngineSelect)1 ArrayList (java.util.ArrayList)1