Search in sources :

Example 1 with PartnerDTO

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);
}
Also used : PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) Filter(org.activityinfo.shared.command.Filter)

Example 2 with PartnerDTO

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();
                    }
                }
            });
        }
    });
}
Also used : DuplicateCreateResult(org.activityinfo.shared.command.result.DuplicateCreateResult) PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) FormDialogCallback(org.activityinfo.client.page.common.dialog.FormDialogCallback) CreateResult(org.activityinfo.shared.command.result.CreateResult) DuplicateCreateResult(org.activityinfo.shared.command.result.DuplicateCreateResult) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) FormDialogTether(org.activityinfo.client.page.common.dialog.FormDialogTether) AddPartner(org.activityinfo.shared.command.AddPartner)

Example 3 with PartnerDTO

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;
}
Also used : ListStore(com.extjs.gxt.ui.client.store.ListStore) PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout)

Example 4 with PartnerDTO

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));
}
Also used : ProjectDTO(org.activityinfo.shared.dto.ProjectDTO) PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) CreateResult(org.activityinfo.shared.command.result.CreateResult) GregorianCalendar(java.util.GregorianCalendar) SiteDTO(org.activityinfo.shared.dto.SiteDTO) KeyGenerator(org.activityinfo.client.local.command.handler.KeyGenerator) CreateSite(org.activityinfo.shared.command.CreateSite) Test(org.junit.Test)

Example 5 with PartnerDTO

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()));
}
Also used : PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) CreateResult(org.activityinfo.shared.command.result.CreateResult) SiteResult(org.activityinfo.shared.command.result.SiteResult) RemovePartner(org.activityinfo.shared.command.RemovePartner) AddPartner(org.activityinfo.shared.command.AddPartner) SiteDTO(org.activityinfo.shared.dto.SiteDTO) Date(java.util.Date) CreateSite(org.activityinfo.shared.command.CreateSite) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Aggregations

PartnerDTO (org.activityinfo.shared.dto.PartnerDTO)23 CreateResult (org.activityinfo.shared.command.result.CreateResult)8 Test (org.junit.Test)8 ProjectDTO (org.activityinfo.shared.dto.ProjectDTO)6 SiteDTO (org.activityinfo.shared.dto.SiteDTO)6 AddPartner (org.activityinfo.shared.command.AddPartner)5 CreateSite (org.activityinfo.shared.command.CreateSite)4 DuplicateCreateResult (org.activityinfo.shared.command.result.DuplicateCreateResult)4 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)3 GregorianCalendar (java.util.GregorianCalendar)3 FormDialogCallback (org.activityinfo.client.page.common.dialog.FormDialogCallback)3 FormDialogTether (org.activityinfo.client.page.common.dialog.FormDialogTether)3 OnDataSet (org.activityinfo.server.database.OnDataSet)3 GetPartnersDimension (org.activityinfo.shared.command.GetPartnersDimension)3 PartnerResult (org.activityinfo.shared.command.result.PartnerResult)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Set (java.util.Set)2 KeyGenerator (org.activityinfo.client.local.command.handler.KeyGenerator)2