Search in sources :

Example 6 with GetAdminEntities

use of org.activityinfo.legacy.shared.command.GetAdminEntities in project activityinfo by bedatadriven.

the class AdminFieldSetPresenterTest method setupDispatcher.

@Before
public void setupDispatcher() {
    dispatcher.setResult(new GetAdminEntities(PROVINCE.getId()), PROVINCES);
    dispatcher.setResult(new GetAdminEntities(TERRITOIRE.getId(), NORD_KIVU.getId()), NORD_KIVU_TERRITOIRES);
    dispatcher.setResult(new GetAdminEntities(TERRITOIRE.getId(), SUD_KIVU.getId()), SUD_KIVU_TERRITOIRES);
}
Also used : GetAdminEntities(org.activityinfo.legacy.shared.command.GetAdminEntities) Before(org.junit.Before)

Example 7 with GetAdminEntities

use of org.activityinfo.legacy.shared.command.GetAdminEntities in project activityinfo by bedatadriven.

the class AdminEntityCacheTest method testRootLevelCache.

@Test
public void testRootLevelCache() {
    CacheManager proxyMgr = new CacheManager(new MockEventBus());
    new AdminEntityCache(proxyMgr);
    proxyMgr.notifyListenersOfSuccess(new GetAdminEntities(1), DTOs.getProvinces());
    CacheResult<ListResult<AdminEntityDTO>> proxyResult = proxyMgr.execute(new GetAdminEntities(1));
    Assert.assertTrue(proxyResult.isCouldExecute());
    Assert.assertEquals(2, proxyResult.getResult().getData().size());
}
Also used : ListResult(org.activityinfo.legacy.shared.command.result.ListResult) MockEventBus(org.activityinfo.ui.client.MockEventBus) GetAdminEntities(org.activityinfo.legacy.shared.command.GetAdminEntities) Test(org.junit.Test)

Example 8 with GetAdminEntities

use of org.activityinfo.legacy.shared.command.GetAdminEntities in project activityinfo by bedatadriven.

the class GetAdminEntitiesHandlerTest method testSiteDbQuery.

@Test
public void testSiteDbQuery() {
    GetAdminEntities cmd = new GetAdminEntities();
    cmd.setParentId(GetAdminEntities.ROOT);
    cmd.setFilter(Filter.filter().onDatabase(1));
    AdminEntityResult result = execute(cmd);
    System.out.println(result.getData());
    assertThat(result.getData().size(), equalTo(2));
}
Also used : AdminEntityResult(org.activityinfo.legacy.shared.command.result.AdminEntityResult) GetAdminEntities(org.activityinfo.legacy.shared.command.GetAdminEntities) Test(org.junit.Test)

Example 9 with GetAdminEntities

use of org.activityinfo.legacy.shared.command.GetAdminEntities in project activityinfo by bedatadriven.

the class GetAdminEntitiesHandlerTest method testIdQuery.

@Test
public void testIdQuery() {
    GetAdminEntities cmd = new GetAdminEntities();
    cmd.setEntityIds(Arrays.asList(10, 11));
    AdminEntityResult result = execute(cmd);
    assertThat(result.getData().size(), equalTo(2));
}
Also used : AdminEntityResult(org.activityinfo.legacy.shared.command.result.AdminEntityResult) GetAdminEntities(org.activityinfo.legacy.shared.command.GetAdminEntities) Test(org.junit.Test)

Example 10 with GetAdminEntities

use of org.activityinfo.legacy.shared.command.GetAdminEntities in project activityinfo by bedatadriven.

the class AdminTreeProxy method load.

/**
 * Load nodes in the tree
 *
 * @param parent
 * @param callback
 */
@Override
protected void load(final Object parent, final AsyncCallback<List<AdminEntityDTO>> callback) {
    if (filter == null) {
        callback.onSuccess(new ArrayList<AdminEntityDTO>());
        return;
    }
    if (!hasRestrictions()) {
        callback.onSuccess(new ArrayList<AdminEntityDTO>());
    } else {
        GetAdminEntities request = new GetAdminEntities();
        request.setFilter(filter);
        if (parent == null) {
            request.setParentId(GetAdminEntities.ROOT);
        } else {
            assert parent instanceof AdminEntityDTO : "expecting AdminEntityDTO";
            request.setParentId(((AdminEntityDTO) parent).getId());
        }
        service.execute(request, new AsyncCallback<AdminEntityResult>() {

            @Override
            public void onFailure(Throwable caught) {
                callback.onFailure(caught);
            }

            @Override
            public void onSuccess(AdminEntityResult result) {
                callback.onSuccess(result.getData());
            }
        });
    }
}
Also used : AdminEntityDTO(org.activityinfo.legacy.shared.model.AdminEntityDTO) AdminEntityResult(org.activityinfo.legacy.shared.command.result.AdminEntityResult) GetAdminEntities(org.activityinfo.legacy.shared.command.GetAdminEntities)

Aggregations

GetAdminEntities (org.activityinfo.legacy.shared.command.GetAdminEntities)11 AdminEntityResult (org.activityinfo.legacy.shared.command.result.AdminEntityResult)8 Test (org.junit.Test)7 AdminEntityDTO (org.activityinfo.legacy.shared.model.AdminEntityDTO)3 TreeStore (com.extjs.gxt.ui.client.store.TreeStore)1 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)1 ListResult (org.activityinfo.legacy.shared.command.result.ListResult)1 AdminMarker (org.activityinfo.legacy.shared.reports.content.AdminMarker)1 MockEventBus (org.activityinfo.ui.client.MockEventBus)1 DispatcherStub (org.activityinfo.ui.client.dispatch.DispatcherStub)1 AdminGroupingModel (org.activityinfo.ui.client.page.entry.grouping.AdminGroupingModel)1 Before (org.junit.Before)1