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);
}
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());
}
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));
}
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));
}
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());
}
});
}
}
Aggregations