use of org.activityinfo.legacy.shared.command.UpdateEntity in project activityinfo by bedatadriven.
the class DbTargetEditor method onEdit.
@Override
protected void onEdit(final TargetDTO dto) {
this.view.showAddDialog(dto, db, true, new FormDialogCallback() {
@Override
public void onValidated(final FormDialogTether dlg) {
final Record record = store.getRecord(dto);
service.execute(new UpdateEntity(dto, getChangedProperties(record)), dlg, new AsyncCallback<VoidResult>() {
@Override
public void onFailure(Throwable caught) {
Log.error("Failed to edit target. " + caught.getMessage(), caught);
}
@Override
public void onSuccess(VoidResult result) {
if (record.get("partnerId") != null) {
PartnerDTO partner = db.getPartnerById((Integer) record.get("partnerId"));
dto.setPartner(partner);
} else {
dto.setPartner(null);
}
if (record.get("projectId") != null) {
ProjectDTO project = db.getProjectById((Integer) record.get("projectId"));
dto.setProject(project);
} else {
dto.setProject(null);
}
store.commitChanges();
eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
dlg.hide();
}
});
}
});
}
use of org.activityinfo.legacy.shared.command.UpdateEntity in project activityinfo by bedatadriven.
the class AttributeGroupTest method testUpdate.
@Test
public void testUpdate() throws Exception {
// change the name of an entity group
ActivityFormDTO activity = execute(new GetActivityForm(1));
AttributeGroupDTO group = activity.getAttributeGroups().get(0);
group.setName("Foobar");
Map<String, Object> changes = new HashMap<String, Object>();
changes.put("name", group.getName());
execute(new UpdateEntity(group, changes));
// reload data
activity = execute(new GetActivityForm(1));
// verify the property has been duly changed
assertThat(activity.getAttributeGroups().get(0).getName(), equalTo(group.getName()));
}
use of org.activityinfo.legacy.shared.command.UpdateEntity in project activityinfo by bedatadriven.
the class UpdateSiteTest method testUpdateLockedPeriod.
@Test
public void testUpdateLockedPeriod() throws CommandException {
Map<String, Object> changes = new HashMap<String, Object>();
changes.put("enabled", false);
execute(new UpdateEntity("LockedPeriod", 1, changes));
// assure that the change has been effected
LockedPeriod lockedPeriod = em.find(LockedPeriod.class, 1);
Assert.assertEquals("enabled", false, lockedPeriod.isEnabled());
}
use of org.activityinfo.legacy.shared.command.UpdateEntity in project activityinfo by bedatadriven.
the class LockedPeriodTest method createTest.
@Test
public void createTest() throws CommandException {
setUser(1);
LockedPeriodDTO dto = new LockedPeriodDTO();
dto.setName("my name");
dto.setFromDate(new LocalDate(2011, 1, 1));
dto.setToDate(new LocalDate(2011, 1, 31));
dto.setEnabled(true);
CreateLockedPeriod create = new CreateLockedPeriod(dto);
create.setDatabaseId(1);
CreateResult result = execute(create);
Map<String, Object> changes = Maps.newHashMap();
changes.put("toDate", new LocalDate(2011, 2, 28));
execute(new UpdateEntity("LockedPeriod", result.getNewId(), changes));
}
use of org.activityinfo.legacy.shared.command.UpdateEntity in project activityinfo by bedatadriven.
the class DbListPresenter method update.
private void update(UserDatabaseDTO db, final FormDialogImpl dialog) {
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("name", db.getName());
properties.put("fullName", db.getFullName());
properties.put("countryId", db.getCountry().getId());
dispatcher.execute(new UpdateEntity(db.getEntityName(), db.getId(), properties), new SuccessCallback<VoidResult>() {
@Override
public void onSuccess(VoidResult arg0) {
eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
loader.load();
dialog.hide();
}
});
}
Aggregations