Search in sources :

Example 6 with AdminEntityResult

use of org.activityinfo.legacy.shared.command.result.AdminEntityResult 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 7 with AdminEntityResult

use of org.activityinfo.legacy.shared.command.result.AdminEntityResult 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 8 with AdminEntityResult

use of org.activityinfo.legacy.shared.command.result.AdminEntityResult 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)

Example 9 with AdminEntityResult

use of org.activityinfo.legacy.shared.command.result.AdminEntityResult 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.legacy.shared.model.AdminEntityDTO) AdminMarker(org.activityinfo.legacy.shared.reports.content.AdminMarker) AdminEntityResult(org.activityinfo.legacy.shared.command.result.AdminEntityResult) GetAdminEntities(org.activityinfo.legacy.shared.command.GetAdminEntities)

Aggregations

AdminEntityResult (org.activityinfo.legacy.shared.command.result.AdminEntityResult)9 GetAdminEntities (org.activityinfo.legacy.shared.command.GetAdminEntities)8 Test (org.junit.Test)5 AdminEntityDTO (org.activityinfo.legacy.shared.model.AdminEntityDTO)4 SqlResultCallback (com.bedatadriven.rebar.sql.client.SqlResultCallback)1 SqlResultSet (com.bedatadriven.rebar.sql.client.SqlResultSet)1 SqlResultSetRow (com.bedatadriven.rebar.sql.client.SqlResultSetRow)1 SqlTransaction (com.bedatadriven.rebar.sql.client.SqlTransaction)1 SqlQuery (com.bedatadriven.rebar.sql.client.query.SqlQuery)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Set (java.util.Set)1 Filter (org.activityinfo.legacy.shared.command.Filter)1 AdminMarker (org.activityinfo.legacy.shared.reports.content.AdminMarker)1