use of org.activityinfo.legacy.shared.command.result.CreateResult in project activityinfo by bedatadriven.
the class DbProjectEditor method onAdd.
@Override
protected void onAdd() {
final ProjectDTO newProject = new ProjectDTO();
this.view.showAddDialog(newProject, new FormDialogCallback() {
@Override
public void onValidated(final FormDialogTether dlg) {
service.execute(new AddProject(db.getId(), newProject), dlg, new AsyncCallback<CreateResult>() {
@Override
public void onFailure(Throwable caught) {
MessageBox.alert(I18N.CONSTANTS.error(), I18N.CONSTANTS.errorOnServer(), null);
}
@Override
public void onSuccess(CreateResult result) {
newProject.setId(result.getNewId());
store.add(newProject);
db.getProjects().add(newProject);
eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
dlg.hide();
}
});
}
});
}
use of org.activityinfo.legacy.shared.command.result.CreateResult in project activityinfo by bedatadriven.
the class LocalSchemaChangeTest method createAttributes.
@Test
public void createAttributes() throws Exception {
Map<String, Object> attributeGroup = Maps.newHashMap();
attributeGroup.put("name", "New Indicator");
attributeGroup.put("activityId", 2);
attributeGroup.put("multipleAllowed", true);
attributeGroup.put("mandatory", true);
CreateResult createResult = assertChangeIsSynchronized(2, new CreateEntity(AttributeGroupDTO.ENTITY_NAME, attributeGroup));
Map<String, Object> attribute = Maps.newHashMap();
attribute.put("name", "New Attribute");
attribute.put("attributeGroupId", createResult.getNewId());
assertChangeIsSynchronized(2, new CreateEntity(AttributeDTO.ENTITY_NAME, attribute));
}
use of org.activityinfo.legacy.shared.command.result.CreateResult in project activityinfo by bedatadriven.
the class LocalSiteCreateTest method createNew.
@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void createNew() {
synchronize();
// create a new detached, client model
SiteDTO newSite = SiteDTOs.newSite();
LocationDTO location = LocationDTOs.newLocation();
executeLocally(new CreateLocation(location));
newSite.setLocation(location);
// create command
CreateSite cmd = new CreateSite(newSite);
// execute the command
CreateResult result = executeLocally(cmd);
// let the client know the command has succeeded
newSite.setId(result.getNewId());
// try to retrieve what we've created FROM OUR CLIENT SIDE DATABASE
SiteResult loadResult = executeLocally(GetSites.byId(newSite.getId()));
Assert.assertEquals(1, loadResult.getData().size());
SiteDTO secondRead = loadResult.getData().get(0);
// confirm that the changes are there
SiteDTOs.validateNewSite(secondRead);
newRequest();
// now Sync with the server
synchronize();
// Confirm that paging works client side
GetSites pagingRequest = new GetSites();
pagingRequest.setLimit(1);
executeLocally(pagingRequest);
}
use of org.activityinfo.legacy.shared.command.result.CreateResult in project activityinfo by bedatadriven.
the class PartnerTest method testAddNewPartner.
@Test
public void testAddNewPartner() throws Exception {
PartnerDTO newPartner = new PartnerDTO();
newPartner.setName("VDE");
newPartner.setFullName("Vision d'Espoir");
CreateResult cr = execute(new UpdatePartner(1, newPartner));
SchemaDTO schema = execute(new GetSchema());
PartnerDTO partner = schema.getDatabaseById(1).getPartnerById(cr.getNewId());
Assert.assertNotNull(partner);
Assert.assertEquals("VDE", partner.getName());
Assert.assertEquals("Vision d'Espoir", partner.getFullName());
}
use of org.activityinfo.legacy.shared.command.result.CreateResult in project activityinfo by bedatadriven.
the class PartnerTest method testAddDuplicatePartner.
public void testAddDuplicatePartner() throws Exception {
PartnerDTO newPartner = new PartnerDTO();
newPartner.setName("NRC");
newPartner.setFullName("Norweigen Refugee Committe");
CreateResult cr = execute(new UpdatePartner(1, newPartner));
Assert.assertTrue(cr instanceof DuplicateCreateResult);
}
Aggregations