Search in sources :

Example 16 with AdminEntityDTO

use of org.activityinfo.shared.dto.AdminEntityDTO 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 17 with AdminEntityDTO

use of org.activityinfo.shared.dto.AdminEntityDTO in project activityinfo by bedatadriven.

the class BoundLocationSection method isDirty.

private boolean isDirty() {
    for (AdminLevelDTO level : adminFieldSet.getAdminLevels()) {
        AdminEntityDTO original = location.getAdminEntity(level.getId());
        AdminEntityDTO current = adminFieldSet.getAdminEntity(level);
        if (current == null && original != null) {
            return true;
        }
        if (current != null && original == null) {
            return true;
        }
        if (current.getId() != original.getId()) {
            return true;
        }
    }
    return false;
}
Also used : AdminLevelDTO(org.activityinfo.shared.dto.AdminLevelDTO) AdminEntityDTO(org.activityinfo.shared.dto.AdminEntityDTO)

Example 18 with AdminEntityDTO

use of org.activityinfo.shared.dto.AdminEntityDTO in project activityinfo by bedatadriven.

the class SiteExporter method createDataRows.

private void createDataRows(ActivityDTO activity, Filter filter, Sheet sheet) {
    int rowIndex = 2;
    for (SiteDTO site : querySites(activity, filter)) {
        Row row = sheet.createRow(rowIndex++);
        int column = 0;
        createCell(row, column++, site.getDate1());
        createCell(row, column++, site.getDate2());
        createCell(row, column++, site.getPartnerName());
        createCell(row, column++, site.getLocationName());
        createCell(row, column++, site.getLocationAxe());
        for (Integer indicatorId : indicators) {
            createIndicatorValueCell(row, column++, site.getIndicatorValue(indicatorId));
        }
        for (Integer attribId : attributes) {
            Boolean value = site.getAttributeValue(attribId);
            if (value != null) {
                Cell valueCell = createCell(row, column, value);
                valueCell.setCellStyle(attribValueStyle);
            }
            column++;
        }
        for (Integer levelId : levels) {
            AdminEntityDTO entity = site.getAdminEntity(levelId);
            if (entity != null) {
                createCell(row, column, "");
                createCell(row, column + 1, entity.getName());
            }
            column += 2;
        }
        if (site.hasLatLong()) {
            createCoordCell(row, column, site.getLongitude());
            createCoordCell(row, column + 1, site.getLatitude());
        }
        column += 2;
        if (!Strings.isNullOrEmpty(site.getComments())) {
            createCell(row, column, site.getComments());
        }
        column++;
    }
}
Also used : AdminEntityDTO(org.activityinfo.shared.dto.AdminEntityDTO) SiteDTO(org.activityinfo.shared.dto.SiteDTO) Row(org.apache.poi.ss.usermodel.Row) Cell(org.apache.poi.ss.usermodel.Cell)

Example 19 with AdminEntityDTO

use of org.activityinfo.shared.dto.AdminEntityDTO 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 20 with AdminEntityDTO

use of org.activityinfo.shared.dto.AdminEntityDTO in project activityinfo by bedatadriven.

the class AdminFieldSetPresenterTest method expectSelections.

private void expectSelections(Collection<AdminEntityDTO> values) {
    resetToDefault(selectionListener);
    for (AdminEntityDTO entity : values) {
        selectionListener.handleEvent(eq(new AdminLevelSelectionEvent(entity.getLevelId(), entity)));
    }
    replay(selectionListener);
}
Also used : AdminEntityDTO(org.activityinfo.shared.dto.AdminEntityDTO)

Aggregations

AdminEntityDTO (org.activityinfo.shared.dto.AdminEntityDTO)21 ArrayList (java.util.ArrayList)4 AdminEntityResult (org.activityinfo.shared.command.result.AdminEntityResult)4 SqlResultCallback (com.bedatadriven.rebar.sql.client.SqlResultCallback)3 SqlResultSet (com.bedatadriven.rebar.sql.client.SqlResultSet)3 SqlResultSetRow (com.bedatadriven.rebar.sql.client.SqlResultSetRow)3 SqlTransaction (com.bedatadriven.rebar.sql.client.SqlTransaction)3 GetAdminEntities (org.activityinfo.shared.command.GetAdminEntities)3 AdminLevelDTO (org.activityinfo.shared.dto.AdminLevelDTO)3 SiteDTO (org.activityinfo.shared.dto.SiteDTO)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 AdminEntity (org.activityinfo.server.database.hibernate.entity.AdminEntity)2 AdminLevel (org.activityinfo.server.database.hibernate.entity.AdminLevel)2 Filter (org.activityinfo.shared.command.Filter)2 LocationDTO (org.activityinfo.shared.dto.LocationDTO)2 SqlQuery (com.bedatadriven.rebar.sql.client.query.SqlQuery)1 LabelField (com.extjs.gxt.ui.client.widget.form.LabelField)1 FitLayout (com.extjs.gxt.ui.client.widget.layout.FitLayout)1 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1