Search in sources :

Example 21 with IndicatorDTO

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

the class IndicatorLinkPage method onToggleLink.

protected void onToggleLink() {
    IndicatorDTO source = sourceIndicatorGrid.getSelectedItem();
    IndicatorDTO dest = destIndicatorGrid.getSelectedItem();
    final boolean link = !linkGraph.linked(source, dest);
    linkButton.toggle(link);
    LinkIndicators update = new LinkIndicators();
    update.setLink(link);
    update.setSourceIndicatorId(source.getId());
    update.setDestIndicatorId(dest.getId());
    if (link) {
        linkGraph.link(sourceDatabaseGrid.getSelectedItem(), source, destDatabaseGrid.getSelectedItem(), dest);
    } else {
        linkGraph.unlink(source, dest);
    }
    destDatabaseGrid.setLinked(linkGraph.destDatabases());
    sourceDatabaseGrid.setLinked(linkGraph.sourceDatabases());
    onDatabaseLinksChanged();
    dispatcher.execute(update, new AsyncCallback<VoidResult>() {

        @Override
        public void onFailure(Throwable caught) {
        // TODO Auto-generated method stub
        }

        @Override
        public void onSuccess(VoidResult result) {
            Info.display(I18N.CONSTANTS.saved(), link ? "Link created" : "Link removed");
        }
    });
}
Also used : IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) VoidResult(org.activityinfo.shared.command.result.VoidResult) LinkIndicators(org.activityinfo.shared.command.LinkIndicators)

Example 22 with IndicatorDTO

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

the class IndicatorGridPanel method setDatabase.

public void setDatabase(UserDatabaseDTO db) {
    setHeading(db.getName());
    store.removeAll();
    for (ActivityDTO activity : db.getActivities()) {
        store.add(activity);
        for (IndicatorGroup group : activity.groupIndicators()) {
            if (group.getName() == null) {
                for (IndicatorDTO indicator : group.getIndicators()) {
                    store.add(indicator);
                }
            } else {
                store.add(group);
                for (IndicatorDTO indicator : group.getIndicators()) {
                    store.add(indicator);
                }
            }
        }
    }
}
Also used : IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) IndicatorGroup(org.activityinfo.shared.dto.IndicatorGroup) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO)

Example 23 with IndicatorDTO

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

the class SiteRenderer method renderIndicatorGroup.

private boolean renderIndicatorGroup(StringBuilder html, IndicatorGroup group, SiteDTO site, boolean showEmptyRows) {
    StringBuilder groupHtml = new StringBuilder();
    boolean empty = true;
    if (group.getName() != null) {
        groupHtml.append("<tr><td class='indicatorGroupHeading'>").append(group.getName()).append("</td><td>&nbsp;</td></tr>");
    }
    for (IndicatorDTO indicator : group.getIndicators()) {
        Double value;
        if (indicator.getAggregation() == IndicatorDTO.AGGREGATE_SITE_COUNT) {
            value = 1.0;
        } else {
            value = site.getIndicatorValue(indicator);
        }
        if (showEmptyRows || (value != null && (indicator.getAggregation() != IndicatorDTO.AGGREGATE_SUM || value != 0))) {
            groupHtml.append("<tr><td class='indicatorHeading");
            if (group.getName() != null) {
                groupHtml.append(" indicatorGroupChild");
            }
            groupHtml.append("'>").append(indicator.getName()).append("</td><td class='indicatorValue'>").append(formatValue(indicator, value)).append("</td><td class='indicatorUnits'>").append(indicator.getUnits()).append("</td></tr>");
            empty = false;
        }
    }
    if (showEmptyRows || !empty) {
        html.append(groupHtml.toString());
        return true;
    } else {
        return false;
    }
}
Also used : IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO)

Example 24 with IndicatorDTO

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

the class MapGenerator method toDTOs.

private Set<IndicatorDTO> toDTOs(Collection<Indicator> indicators) {
    Set<IndicatorDTO> indicatorDTOs = new HashSet<IndicatorDTO>();
    for (Indicator indicator : indicators) {
        IndicatorDTO indicatorDTO = new IndicatorDTO();
        indicatorDTO.setId(indicator.getId());
        indicatorDTO.setName(indicator.getName());
        indicatorDTOs.add(indicatorDTO);
    }
    return indicatorDTOs;
}
Also used : IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) Indicator(org.activityinfo.server.database.hibernate.entity.Indicator) HashSet(java.util.HashSet)

Example 25 with IndicatorDTO

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

the class ItextMapRenderer method addIndicatorList.

private void addIndicatorList(MapReportElement element, MapLayer layer, Cell descriptionCell) {
    com.lowagie.text.List list = new List(List.UNORDERED);
    for (int indicatorId : layer.getIndicatorIds()) {
        IndicatorDTO indicator = element.getContent().getIndicatorById(indicatorId);
        list.add(new ListItem(indicator.getName()));
    }
    descriptionCell.add(list);
}
Also used : List(com.lowagie.text.List) IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) List(com.lowagie.text.List) ListItem(com.lowagie.text.ListItem)

Aggregations

IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)28 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)9 AttributeGroupDTO (org.activityinfo.shared.dto.AttributeGroupDTO)7 AttributeDTO (org.activityinfo.shared.dto.AttributeDTO)6 ModelData (com.extjs.gxt.ui.client.data.ModelData)5 Test (org.junit.Test)5 IndicatorGroup (org.activityinfo.shared.dto.IndicatorGroup)4 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)4 GetSchema (org.activityinfo.shared.command.GetSchema)2 AdminLevelDTO (org.activityinfo.shared.dto.AdminLevelDTO)2 UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)2 MapContent (org.activityinfo.shared.report.content.MapContent)2 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)2 FieldBinding (com.extjs.gxt.ui.client.binding.FieldBinding)1 TreeGridDragSource (com.extjs.gxt.ui.client.dnd.TreeGridDragSource)1 TreeGridDropTarget (com.extjs.gxt.ui.client.dnd.TreeGridDropTarget)1 DNDEvent (com.extjs.gxt.ui.client.event.DNDEvent)1 DNDListener (com.extjs.gxt.ui.client.event.DNDListener)1 GridEvent (com.extjs.gxt.ui.client.event.GridEvent)1 TreeStore (com.extjs.gxt.ui.client.store.TreeStore)1