Search in sources :

Example 6 with GetAdminEntities

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

the class GetAdminEntitiesHandlerTest method testRootLevelQuery.

@Test
public void testRootLevelQuery() throws Exception {
    GetAdminEntities cmd = new GetAdminEntities(PROVINCE);
    AdminEntityResult result = execute(cmd);
    assertThat(result.getData().size(), equalTo(4));
}
Also used : AdminEntityResult(org.activityinfo.shared.command.result.AdminEntityResult) GetAdminEntities(org.activityinfo.shared.command.GetAdminEntities) Test(org.junit.Test)

Example 7 with GetAdminEntities

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

the class SyncIntegrationTest method testGetAdminEntities.

@Test
@OnDataSet("/dbunit/sites-simple1.db.xml")
public void testGetAdminEntities() throws SQLException, InterruptedException {
    synchronizeFirstTime();
    executeLocally(new GetAdminEntities(1));
}
Also used : GetAdminEntities(org.activityinfo.shared.command.GetAdminEntities) OnDataSet(org.activityinfo.server.database.OnDataSet) Test(org.junit.Test)

Example 8 with GetAdminEntities

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

the class AdminTreeProxy method load.

@Override
public void load(DataReader<List<AdminEntityDTO>> dataReader, final Object parent, final AsyncCallback<List<AdminEntityDTO>> callback) {
    if (filter == null) {
        callback.onSuccess(new ArrayList<AdminEntityDTO>());
        return;
    }
    service.execute(new GetSchema(), new AsyncCallback<SchemaDTO>() {

        @Override
        public void onFailure(Throwable caught) {
            GWT.log("Failed to load admin entities", caught);
        }

        @Override
        public void onSuccess(SchemaDTO schema) {
            final Set<CountryDTO> countries = findCountries(schema);
            if (CollectionUtil.isEmpty(countries)) {
                callback.onSuccess(new ArrayList<AdminEntityDTO>());
                return;
            }
            initLevelsWithChildren(countries);
            GetAdminEntities request = new GetAdminEntities(toIdSet(countries), filter);
            if (parent != null) {
                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) {
                    prepareData(countries, result.getData());
                    callback.onSuccess(result.getData());
                }
            });
        }
    });
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) AdminEntityDTO(org.activityinfo.shared.dto.AdminEntityDTO) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) AdminEntityResult(org.activityinfo.shared.command.result.AdminEntityResult) ArrayList(java.util.ArrayList) GetAdminEntities(org.activityinfo.shared.command.GetAdminEntities) GetSchema(org.activityinfo.shared.command.GetSchema) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO)

Example 9 with GetAdminEntities

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

the class PolygonLayerGenerator method queryBounds.

private void queryBounds(DispatcherSync dispatcher, Filter layerFilter) {
    GetAdminEntities query = new GetAdminEntities();
    query.setLevelId(layer.getAdminLevelId());
    AdminEntityResult entities = dispatcher.execute(query);
    for (AdminEntityDTO entity : entities.getData()) {
        if (entity.hasBounds()) {
            AdminMarker marker = new AdminMarker(entity);
            overlay.addPolygon(marker);
        }
    }
}
Also used : AdminEntityDTO(org.activityinfo.shared.dto.AdminEntityDTO) AdminMarker(org.activityinfo.shared.report.content.AdminMarker) AdminEntityResult(org.activityinfo.shared.command.result.AdminEntityResult) GetAdminEntities(org.activityinfo.shared.command.GetAdminEntities)

Example 10 with GetAdminEntities

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

the class SiteAdminTreeLoaderTest method load.

@Test
public void load() {
    DispatcherStub dispatcher = new DispatcherStub();
    dispatcher.setResult(new GetSchema(), DTOs.PEAR.SCHEMA);
    dispatcher.setResult(new GetAdminEntities(1), DTOs.PROVINCES);
    SiteAdminTreeLoader loader = new SiteAdminTreeLoader(dispatcher, new AdminGroupingModel(1));
    new TreeStore<ModelData>(loader);
    loader.load();
}
Also used : AdminGroupingModel(org.activityinfo.client.page.entry.grouping.AdminGroupingModel) TreeStore(com.extjs.gxt.ui.client.store.TreeStore) DispatcherStub(org.activityinfo.client.dispatch.DispatcherStub) GetAdminEntities(org.activityinfo.shared.command.GetAdminEntities) GetSchema(org.activityinfo.shared.command.GetSchema) Test(org.junit.Test)

Aggregations

GetAdminEntities (org.activityinfo.shared.command.GetAdminEntities)10 AdminEntityResult (org.activityinfo.shared.command.result.AdminEntityResult)6 Test (org.junit.Test)6 AdminEntityDTO (org.activityinfo.shared.dto.AdminEntityDTO)3 GetSchema (org.activityinfo.shared.command.GetSchema)2 TreeStore (com.extjs.gxt.ui.client.store.TreeStore)1 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 MockEventBus (org.activityinfo.client.MockEventBus)1 DispatcherStub (org.activityinfo.client.dispatch.DispatcherStub)1 AdminGroupingModel (org.activityinfo.client.page.entry.grouping.AdminGroupingModel)1 OnDataSet (org.activityinfo.server.database.OnDataSet)1 ListResult (org.activityinfo.shared.command.result.ListResult)1 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)1 AdminMarker (org.activityinfo.shared.report.content.AdminMarker)1 Before (org.junit.Before)1