use of org.activityinfo.legacy.shared.command.result.BatchResult in project activityinfo by bedatadriven.
the class DispatcherStub method execute.
@Override
public <T extends CommandResult> void execute(Command<T> command, AsyncCallback<T> callback) {
if (command instanceof BatchCommand) {
BatchCommand batch = (BatchCommand) command;
List<CommandResult> results = new ArrayList<CommandResult>();
for (Command batchCmd : batch.getCommands()) {
results.add(findResult(batchCmd));
}
callback.onSuccess((T) new BatchResult(results));
} else {
callback.onSuccess((T) findResult(command));
}
}
use of org.activityinfo.legacy.shared.command.result.BatchResult in project activityinfo by bedatadriven.
the class SchemaImporterV2 method persistBatch.
private void persistBatch(final Iterator<List<? extends EntityDTO>> batchIterator) {
BatchCommand batchCommand = new BatchCommand();
final List<? extends EntityDTO> batch = batchIterator.next();
for (EntityDTO entity : batch) {
batchCommand.add(create(entity));
}
listener.submittingBatch(batchNumber++, batchCount);
dispatcher.execute(batchCommand, new AsyncCallback<BatchResult>() {
@Override
public void onFailure(Throwable caught) {
callback.onFailure(caught);
}
@Override
public void onSuccess(BatchResult result) {
for (int i = 0; i != result.getResults().size(); ++i) {
CreateResult createResult = result.getResult(i);
batch.get(i).set("id", createResult.getNewId());
}
if (batchIterator.hasNext()) {
persistBatch(batchIterator);
} else {
callback.onSuccess(null);
}
}
});
}
Aggregations