Search in sources :

Example 6 with BatchResult

use of org.activityinfo.shared.command.result.BatchResult in project activityinfo by bedatadriven.

the class ImporterWizard method finish.

@Override
public void finish(final AsyncCallback<Void> callback) {
    final KeyGenerator keyGenerator = new KeyGenerator();
    int numColums = model.getData().getNumColumns();
    ColumnBinding[] bindings = bindingsArray();
    // do a first pass to match the location
    List<Command> matchBatch = Lists.newArrayList();
    for (ImportRowModel row : model.getData().getRowStore().getModels()) {
        MatchLocation location = new MatchLocation();
        location.setLocationType(model.getActivity().getLocationTypeId());
        for (int i = 0; i != numColums; ++i) {
            bindings[i].bindLocation(row.get(i), location);
        }
        matchBatch.add(location);
    }
    dispatcher.execute(new BatchCommand(matchBatch), new AsyncCallback<BatchResult>() {

        @Override
        public void onFailure(Throwable caught) {
            MessageBox.alert("Match locations failed", "Exception", null);
        }

        @Override
        public void onSuccess(BatchResult result) {
            submitSites((List) result.getResults(), callback);
        }
    });
}
Also used : ColumnBinding(org.activityinfo.client.importer.column.ColumnBinding) BatchResult(org.activityinfo.shared.command.result.BatchResult) MatchLocation(org.activityinfo.shared.command.MatchLocation) Command(org.activityinfo.shared.command.Command) BatchCommand(org.activityinfo.shared.command.BatchCommand) BatchCommand(org.activityinfo.shared.command.BatchCommand) List(java.util.List) KeyGenerator(org.activityinfo.client.local.command.handler.KeyGenerator)

Example 7 with BatchResult

use of org.activityinfo.shared.command.result.BatchResult in project activityinfo by bedatadriven.

the class DbUserEditor method save.

private void save() {
    BatchCommand batch = new BatchCommand();
    for (Record record : store.getModifiedRecords()) {
        batch.add(new UpdateUserPermissions(db.getId(), (UserPermissionDTO) record.getModel()));
    }
    dispatcher.execute(batch, new MaskingAsyncMonitor(this, I18N.CONSTANTS.saving()), new AsyncCallback<BatchResult>() {

        @Override
        public void onFailure(Throwable caught) {
        // handled by monitor
        }

        @Override
        public void onSuccess(BatchResult result) {
            store.commitChanges();
        }
    });
}
Also used : UpdateUserPermissions(org.activityinfo.shared.command.UpdateUserPermissions) MaskingAsyncMonitor(org.activityinfo.client.dispatch.monitor.MaskingAsyncMonitor) BatchCommand(org.activityinfo.shared.command.BatchCommand) Record(com.extjs.gxt.ui.client.store.Record) BatchResult(org.activityinfo.shared.command.result.BatchResult) UserPermissionDTO(org.activityinfo.shared.dto.UserPermissionDTO)

Aggregations

BatchCommand (org.activityinfo.shared.command.BatchCommand)7 BatchResult (org.activityinfo.shared.command.result.BatchResult)7 Command (org.activityinfo.shared.command.Command)4 MaskingAsyncMonitor (org.activityinfo.client.dispatch.monitor.MaskingAsyncMonitor)3 ArrayList (java.util.ArrayList)2 ColumnBinding (org.activityinfo.client.importer.column.ColumnBinding)2 KeyGenerator (org.activityinfo.client.local.command.handler.KeyGenerator)2 GetReportVisibility (org.activityinfo.shared.command.GetReportVisibility)2 GetSchema (org.activityinfo.shared.command.GetSchema)2 CommandResult (org.activityinfo.shared.command.result.CommandResult)2 ReportVisibilityResult (org.activityinfo.shared.command.result.ReportVisibilityResult)2 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)2 Record (com.extjs.gxt.ui.client.store.Record)1 List (java.util.List)1 CreateLocation (org.activityinfo.shared.command.CreateLocation)1 CreateSite (org.activityinfo.shared.command.CreateSite)1 GetReportModel (org.activityinfo.shared.command.GetReportModel)1 MatchLocation (org.activityinfo.shared.command.MatchLocation)1 UpdateUserPermissions (org.activityinfo.shared.command.UpdateUserPermissions)1 LocationDTO (org.activityinfo.shared.dto.LocationDTO)1