use of org.activityinfo.shared.dto.PartnerDTO in project activityinfo by bedatadriven.
the class PartnerFilterPanel method clearFilter.
protected void clearFilter() {
for (PartnerDTO partner : listView.getStore().getModels()) {
listView.setChecked(partner, false);
}
value = new Filter();
filterToolBar.setApplyFilterEnabled(false);
filterToolBar.setRemoveFilterEnabled(false);
}
use of org.activityinfo.shared.dto.PartnerDTO in project activityinfo by bedatadriven.
the class DbPartnerEditor method onAdd.
// public void onSelectionChanged(PartnerDTO selectedItem) {
// this.view.setActionEnabled(UIActions.delete, selectedItem != null);
// }
@Override
protected void onAdd() {
final PartnerDTO newPartner = new PartnerDTO();
this.view.showAddDialog(newPartner, new FormDialogCallback() {
@Override
public void onValidated(final FormDialogTether dlg) {
service.execute(new AddPartner(db.getId(), newPartner), dlg, new AsyncCallback<CreateResult>() {
@Override
public void onFailure(Throwable caught) {
Log.debug("DbPartnerEditor caught exception while executing command AddPartner: ", caught);
}
@Override
public void onSuccess(CreateResult result) {
if (result instanceof DuplicateCreateResult) {
Log.debug("DbPartnerEditor tried to add partner '" + newPartner.getName() + "' to database " + db.getId() + " but it already exists");
MessageBox.alert(I18N.CONSTANTS.newPartner(), I18N.CONSTANTS.duplicatePartner(), null);
} else {
Log.debug("DbPartnerEditor added new partner '" + newPartner.getName() + "' to database " + db.getId());
newPartner.setId(result.getNewId());
store.add(newPartner);
eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
dlg.hide();
}
}
});
}
});
}
use of org.activityinfo.shared.dto.PartnerDTO in project activityinfo by bedatadriven.
the class DbPartnerGrid method createGridAndAddToContainer.
@Override
protected Grid<PartnerDTO> createGridAndAddToContainer(Store store) {
grid = new Grid<PartnerDTO>((ListStore) store, createColumnModel());
grid.setAutoExpandColumn("fullName");
grid.setLoadMask(true);
this.setLayout(new FitLayout());
this.add(grid);
return grid;
}
use of org.activityinfo.shared.dto.PartnerDTO in project activityinfo by bedatadriven.
the class CreateSiteTest method testAllAttribsFalse.
@Test
public void testAllAttribsFalse() throws CommandException {
// create a new detached, client model
SiteDTO newSite = new SiteDTO();
newSite.setId(new KeyGenerator().generateInt());
newSite.setActivityId(1);
newSite.setLocationId(1);
newSite.setPartner(new PartnerDTO(1, "Foobar"));
newSite.setDate1((new GregorianCalendar(2008, 12, 1)).getTime());
newSite.setDate2((new GregorianCalendar(2009, 1, 3)).getTime());
newSite.setLocationName("Virunga");
newSite.setAttributeValue(1, false);
newSite.setAttributeValue(2, false);
newSite.setProject(new ProjectDTO(1, "SomeProject"));
// create command
CreateSite cmd = new CreateSite(newSite);
assertThat((Integer) cmd.getProperties().get("locationId"), equalTo(1));
// execute the command
setUser(1);
CreateResult result = execute(cmd);
// let the client know the command has succeeded
newSite.setId(result.getNewId());
// cmd.onCompleted(result);
// try to retrieve what we've created
PagingLoadResult<SiteDTO> loadResult = execute(GetSites.byId(newSite.getId()));
Assert.assertEquals(1, loadResult.getData().size());
SiteDTO secondRead = loadResult.getData().get(0);
// confirm that the changes are there
Assert.assertEquals("site.attribute[2]", false, secondRead.getAttributeValue(1));
Assert.assertEquals("site.attribute[2]", false, secondRead.getAttributeValue(2));
}
use of org.activityinfo.shared.dto.PartnerDTO in project activityinfo by bedatadriven.
the class LocalSiteCreateTest method siteRemovePartnerConflict.
@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void siteRemovePartnerConflict() {
// FIRST U1 adds a new partner
int databaseId = 1;
PartnerDTO iom = new PartnerDTO();
iom.setName("IOM");
CreateResult result = executeRemotely(new AddPartner(databaseId, iom));
iom.setId(result.getNewId());
// Now U2 synchronizes, and adds a new site with this partner
synchronizeFirstTime();
SiteDTO site = new SiteDTO();
site.setId(3343234);
site.setActivityId(1);
site.setPartner(iom);
site.setDate1(new Date());
site.setDate2(new Date());
site.setLocationId(1);
executeLocally(new CreateSite(site));
// At T+3, U2 thinks better, removes IOM
executeRemotely(new RemovePartner(databaseId, iom.getId()));
// At T+4, U1 synchronizes, and IOM is removed, but site remains
synchronize();
// Verify that there is still a label for this partner
SiteResult sites = executeLocally(GetSites.byId(site.getId()));
assertThat(sites.getTotalLength(), equalTo(1));
assertThat(sites.getData().get(0).getName(), equalTo(site.getName()));
}
Aggregations