use of org.activityinfo.legacy.shared.command.result.CreateResult 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