Search in sources :

Example 1 with AdminLevelDTO

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

the class ColumnBindingFactory method forActivity.

public static List<ColumnBinding> forActivity(ActivityDTO activity) {
    List<ColumnBinding> bindings = Lists.newArrayList();
    bindings.add(Ignore.INSTANCE);
    bindings.add(new DateBinding());
    for (AdminLevelDTO level : activity.getAdminLevels()) {
        bindings.add(new AdminBinding(level));
    }
    if (!activity.getLocationType().isAdminLevel()) {
        bindings.add(new LocationNameBinding(activity.getLocationType()));
    }
    for (IndicatorDTO indicator : activity.getIndicators()) {
        bindings.add(new IndicatorBinding(indicator));
    }
    for (AttributeGroupDTO attributeGroup : activity.getAttributeGroups()) {
        bindings.add(new AttributeBinding(attributeGroup));
    }
    bindings.add(new CommentsBinding());
    return bindings;
}
Also used : IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) AttributeGroupDTO(org.activityinfo.shared.dto.AttributeGroupDTO) AdminLevelDTO(org.activityinfo.shared.dto.AdminLevelDTO)

Example 2 with AdminLevelDTO

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

the class AdminColumnRenderer method render.

private Object render(SiteDTO model) {
    StringBuilder qtip = new StringBuilder();
    SafeHtmlBuilder summary = new SafeHtmlBuilder();
    // we use this set to keep track of names that we've added
    // to the summary to avoid duplication that is common between
    // territories, zones de sante, provinces and districts, etc
    seen.clear();
    int summaryLines = 0;
    for (AdminLevelDTO level : levels) {
        AdminEntityDTO entity = model.getAdminEntity(level.getId());
        if (entity != null) {
            String name = entity.getName();
            if (qtip.length() > 0) {
                qtip.append("<br>");
            }
            qtip.append(level.getName()).append(": ").append(name);
            if (summaryLines < 3 && !seen.contains(name)) {
                if (summaryLines > 0) {
                    summary.appendHtmlConstant("<br/>");
                }
                summary.appendEscaped(name);
                seen.add(name);
                summaryLines++;
            }
        }
    }
    // return summary.toSafeHtml().asString();
    return ColumnTemplates.INSTANCE.adminCell(qtip.toString(), summary.toSafeHtml()).asString();
}
Also used : AdminLevelDTO(org.activityinfo.shared.dto.AdminLevelDTO) AdminEntityDTO(org.activityinfo.shared.dto.AdminEntityDTO) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 3 with AdminLevelDTO

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

the class BoundLocationSection method newLocation.

private void newLocation() {
    location = new LocationDTO(location);
    location.setId(new KeyGenerator().generateInt());
    location.setName(leafComboBox.getValue().getName());
    for (AdminLevelDTO level : adminFieldSet.getAdminLevels()) {
        location.setAdminEntity(level.getId(), adminFieldSet.getAdminEntity(level));
    }
}
Also used : AdminLevelDTO(org.activityinfo.shared.dto.AdminLevelDTO) KeyGenerator(org.activityinfo.client.local.command.handler.KeyGenerator) LocationDTO(org.activityinfo.shared.dto.LocationDTO)

Example 4 with AdminLevelDTO

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

the class SiteRenderer method renderLocation.

public String renderLocation(SiteDTO site, ActivityDTO activity) {
    StringBuilder html = new StringBuilder();
    html.append("<table cellspacing='0'>");
    if (!activity.getLocationType().isAdminLevel()) {
        html.append("<tr><td>");
        html.append(activity.getLocationType().getName()).append(": ");
        html.append("</td><td>");
        html.append(site.getLocationName());
        if (!Strings.isNullOrEmpty(site.getLocationAxe())) {
            html.append("<br>").append(site.getLocationAxe());
        }
        html.append("</td></tr>");
    }
    for (AdminLevelDTO level : activity.getAdminLevels()) {
        AdminEntityDTO entity = site.getAdminEntity(level.getId());
        if (entity != null) {
            html.append("<tr><td>");
            html.append(level.getName()).append(":</td><td>");
            html.append(entity.getName());
            html.append("</td></tr>");
        }
    }
    html.append("</table>");
    return html.toString();
}
Also used : AdminLevelDTO(org.activityinfo.shared.dto.AdminLevelDTO) AdminEntityDTO(org.activityinfo.shared.dto.AdminEntityDTO)

Example 5 with AdminLevelDTO

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

the class LocationForm method saveNewLocation.

private void saveNewLocation() {
    if (coordinateFields.validate() && nameField.validate()) {
        LocationDTO newLocation = new LocationDTO();
        newLocation.setId(new KeyGenerator().generateInt());
        newLocation.setLocationTypeId(locationType.getId());
        newLocation.setName(nameField.getValue());
        newLocation.setAxe(axeField.getValue());
        newLocation.setLatitude(coordinateFields.getLatitudeField().getValue());
        newLocation.setLongitude(coordinateFields.getLongitudeField().getValue());
        for (AdminLevelDTO level : adminPresenter.getAdminLevels()) {
            newLocation.setAdminEntity(level.getId(), adminPresenter.getAdminEntity(level));
        }
        newLocationPresenter.accept(newLocation);
    }
}
Also used : AdminLevelDTO(org.activityinfo.shared.dto.AdminLevelDTO) KeyGenerator(org.activityinfo.client.local.command.handler.KeyGenerator) LocationDTO(org.activityinfo.shared.dto.LocationDTO)

Aggregations

AdminLevelDTO (org.activityinfo.shared.dto.AdminLevelDTO)13 AdminEntityDTO (org.activityinfo.shared.dto.AdminEntityDTO)3 RadioGroup (com.extjs.gxt.ui.client.widget.form.RadioGroup)2 KeyGenerator (org.activityinfo.client.local.command.handler.KeyGenerator)2 AttributeGroupDTO (org.activityinfo.shared.dto.AttributeGroupDTO)2 CountryDTO (org.activityinfo.shared.dto.CountryDTO)2 IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)2 LocationDTO (org.activityinfo.shared.dto.LocationDTO)2 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 BaseEvent (com.extjs.gxt.ui.client.event.BaseEvent)1 FieldEvent (com.extjs.gxt.ui.client.event.FieldEvent)1 Radio (com.extjs.gxt.ui.client.widget.form.Radio)1 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 GetSchema (org.activityinfo.shared.command.GetSchema)1 AdminLevelResult (org.activityinfo.shared.command.result.AdminLevelResult)1