Search in sources :

Example 46 with CreateResult

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);
            }
        }
    });
}
Also used : CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) BatchCommand(org.activityinfo.legacy.shared.command.BatchCommand) BatchResult(org.activityinfo.legacy.shared.command.result.BatchResult)

Aggregations

CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)46 Test (org.junit.Test)26 Date (java.util.Date)9 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)7 UpdatePartner (org.activityinfo.legacy.shared.command.UpdatePartner)7 DuplicateCreateResult (org.activityinfo.legacy.shared.command.result.DuplicateCreateResult)7 OnDataSet (org.activityinfo.server.database.OnDataSet)6 CreateSite (org.activityinfo.legacy.shared.command.CreateSite)5 PartnerDTO (org.activityinfo.legacy.shared.model.PartnerDTO)5 CreateEntity (org.activityinfo.legacy.shared.command.CreateEntity)4 SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)4 TargetDTO (org.activityinfo.legacy.shared.model.TargetDTO)4 CuidAdapter.activityFormClass (org.activityinfo.model.legacy.CuidAdapter.activityFormClass)4 ResourceId (org.activityinfo.model.resource.ResourceId)4 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)3 GregorianCalendar (java.util.GregorianCalendar)3 CloneDatabase (org.activityinfo.legacy.shared.command.CloneDatabase)3 ProjectDTO (org.activityinfo.legacy.shared.model.ProjectDTO)3 SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)3 EnumItem (org.activityinfo.model.type.enumerated.EnumItem)3