use of org.activityinfo.shared.command.BatchCommand in project activityinfo by bedatadriven.
the class ActivityTest method updateSortOrderTest.
@Test
public void updateSortOrderTest() throws Throwable {
/* Update Sort Order */
Map<String, Object> changes1 = new HashMap<String, Object>();
changes1.put("sortOrder", 2);
Map<String, Object> changes2 = new HashMap<String, Object>();
changes2.put("sortOrder", 1);
execute(new BatchCommand(new UpdateEntity("Activity", 1, changes1), new UpdateEntity("Activity", 2, changes2)));
/* Confirm the order is changed */
SchemaDTO schema = execute(new GetSchema());
Assert.assertEquals(2, schema.getDatabaseById(1).getActivities().get(0).getId());
Assert.assertEquals(1, schema.getDatabaseById(1).getActivities().get(1).getId());
}
use of org.activityinfo.shared.command.BatchCommand 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);
}
});
}
use of org.activityinfo.shared.command.BatchCommand 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();
}
});
}
use of org.activityinfo.shared.command.BatchCommand in project activityinfo by bedatadriven.
the class TargetTest method updateTargetNameTest.
@Test
public void updateTargetNameTest() throws Throwable {
Map<String, Object> changes1 = new HashMap<String, Object>();
changes1.put("name", "newNameOfTarget");
execute(new BatchCommand(new UpdateEntity("Target", 1, changes1)));
List<TargetDTO> targets = execute(new GetTargets(db.getId())).getData();
TargetDTO dto = getTargetById(targets, 1);
Assert.assertEquals("newNameOfTarget", dto.getName());
}
Aggregations