use of com.bedatadriven.rebar.sql.client.SqlException in project activityinfo by bedatadriven.
the class LocalDispatcher method executeOffline.
/**
* Begins a new transaction, initializes a new ExecutionContext, and
* executes the root command.
*
* @param command
* @param callback
*/
private <R extends CommandResult> void executeOffline(final Command<R> command, final AsyncCallback<R> callback) {
Log.debug("Executing command " + command + " OFFLINE.");
try {
final Collector<R> commandResult = Collector.newCollector();
database.transaction(new SqlTransactionCallback() {
@Override
public void begin(SqlTransaction tx) {
LocalExecutionContext context = new LocalExecutionContext(auth, tx, registry, commandQueue);
context.execute(command, commandResult);
}
@Override
public void onError(SqlException e) {
Log.error("OFFLINE EXECUTION FAILED: " + command, e);
callback.onFailure(e);
}
@Override
public void onSuccess() {
callback.onSuccess(commandResult.getResult());
}
});
} catch (Exception e) {
callback.onFailure(e);
}
}
Aggregations