Search in sources :

Example 1 with IndicatorDTO

use of org.activityinfo.legacy.shared.model.IndicatorDTO in project activityinfo by bedatadriven.

the class IndicatorLinkPage method onToggleLink.

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

        @Override
        public void onFailure(Throwable caught) {
            Log.error(caught.getMessage(), caught);
        }

        @Override
        public void onSuccess(VoidResult result) {
            Info.displayText(I18N.CONSTANTS.saved(), isLinked ? I18N.CONSTANTS.linkCreated() : I18N.CONSTANTS.linkRemoved());
        }
    });
}
Also used : IndicatorDTO(org.activityinfo.legacy.shared.model.IndicatorDTO) VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult) LinkIndicators(org.activityinfo.legacy.shared.command.LinkIndicators)

Example 2 with IndicatorDTO

use of org.activityinfo.legacy.shared.model.IndicatorDTO in project activityinfo by bedatadriven.

the class ShareReportDialog method populateGrid.

private void populateGrid(IndicatorResult indicators, ReportVisibilityResult visibility) {
    gridStore.removeAll();
    Map<Integer, ReportVisibilityDTO> databases = Maps.newHashMap();
    for (ReportVisibilityDTO model : visibility.getList()) {
        databases.put(model.getDatabaseId(), model);
    }
    for (IndicatorDTO indicator : indicators.getIndicators()) {
        if (!databases.containsKey(indicator.getDatabaseId())) {
            ReportVisibilityDTO model = new ReportVisibilityDTO();
            model.setDatabaseId(indicator.getDatabaseId());
            model.setDatabaseName(indicator.getDatabaseName());
            databases.put(indicator.getDatabaseId(), model);
        }
    }
    for (ReportVisibilityDTO model : databases.values()) {
        gridStore.add(model);
    }
    if (gridStore.getCount() == 0) {
        MessageBox.alert(I18N.CONSTANTS.share(), I18N.CONSTANTS.emptyReportsCannotBeShared(), new Listener<MessageBoxEvent>() {

            @Override
            public void handleEvent(MessageBoxEvent be) {
                hide();
            }
        });
    }
}
Also used : ReportVisibilityDTO(org.activityinfo.legacy.shared.model.ReportVisibilityDTO) MessageBoxEvent(com.extjs.gxt.ui.client.event.MessageBoxEvent) IndicatorDTO(org.activityinfo.legacy.shared.model.IndicatorDTO)

Example 3 with IndicatorDTO

use of org.activityinfo.legacy.shared.model.IndicatorDTO in project activityinfo by bedatadriven.

the class ItextMapRenderer method addSingleIndicatorDescription.

private void addSingleIndicatorDescription(MapReportElement element, MapLayer layer, Cell descriptionCell) {
    int indicatorId = layer.getIndicatorIds().get(0);
    IndicatorDTO indicator = element.getContent().getIndicatorById(indicatorId);
    if (indicator == null) {
        throw new NullPointerException("indicatorId:" + indicatorId);
    }
    descriptionCell.add(ThemeHelper.filterDescription(indicator.getName()));
}
Also used : IndicatorDTO(org.activityinfo.legacy.shared.model.IndicatorDTO)

Example 4 with IndicatorDTO

use of org.activityinfo.legacy.shared.model.IndicatorDTO in project activityinfo by bedatadriven.

the class GetIndicatorsHandler method createDto.

private IndicatorDTO createDto(SqlResultSetRow rs) {
    IndicatorDTO indicator = new IndicatorDTO();
    indicator.setId(rs.getInt("indicatorId"));
    indicator.setActivityId(rs.getInt("activityId"));
    indicator.setDatabaseId(rs.getInt("databaseId"));
    indicator.setDatabaseName(rs.getString("databaseName"));
    indicator.setName(rs.getString("name"));
    indicator.setTypeId(rs.getString("type"));
    indicator.setExpression(rs.getString("expression"));
    indicator.setRelevanceExpression(rs.getString("skipExpression"));
    indicator.setNameInExpression(rs.getString("nameInExpression"));
    indicator.setCalculatedAutomatically(rs.getBoolean("calculatedAutomatically"));
    indicator.setCategory(rs.getString("category"));
    indicator.setListHeader(rs.getString("listHeader"));
    indicator.setDescription(rs.getString("description"));
    indicator.setAggregation(rs.getInt("aggregation"));
    indicator.setUnits(rs.getString("units"));
    indicator.setMandatory(rs.getBoolean("mandatory"));
    indicator.setVisible(rs.getBoolean("visible"));
    indicator.setSortOrder(rs.getInt("sortOrder"));
    return indicator;
}
Also used : IndicatorDTO(org.activityinfo.legacy.shared.model.IndicatorDTO)

Example 5 with IndicatorDTO

use of org.activityinfo.legacy.shared.model.IndicatorDTO in project activityinfo by bedatadriven.

the class SiteRendererTest method multipleGroupsRender.

@Test
public void multipleGroupsRender() {
    IndicatorDTO indicator1 = new IndicatorDTO();
    indicator1.setId(1);
    indicator1.setAggregation(IndicatorDTO.AGGREGATE_SUM);
    indicator1.setName("First indicator");
    indicator1.setCategory("First group");
    IndicatorDTO indicator2 = new IndicatorDTO();
    indicator2.setAggregation(IndicatorDTO.AGGREGATE_SUM);
    indicator2.setId(2);
    indicator2.setName("Second indicator");
    indicator2.setCategory("Second group");
    IndicatorDTO indicator3 = new IndicatorDTO();
    indicator3.setAggregation(IndicatorDTO.AGGREGATE_SUM);
    indicator3.setType(FieldTypeClass.NARRATIVE);
    indicator3.setId(3);
    indicator3.setName("Third indicator");
    indicator3.setCategory("Second group");
    ActivityFormDTO activity = new ActivityFormDTO();
    activity.setId(1);
    activity.getIndicators().add(indicator1);
    activity.getIndicators().add(indicator2);
    activity.getIndicators().add(indicator3);
    SiteDTO site = new SiteDTO();
    site.setIndicatorValue(1, 1000d);
    site.setIndicatorValue(2, 2000d);
    site.setIndicatorValue(3, "Some help but not a huge amount.\nHowever there was " + "some other information that I'd like to present in " + "second paragraph.");
    String html = siteRenderer.renderSite(site, activity, true);
    System.out.println(html);
    assertTrue(html.contains(indicator1.getName()));
    assertTrue(html.contains(indicator2.getName()));
    assertTrue(html.contains(indicator3.getName()));
}
Also used : IndicatorDTO(org.activityinfo.legacy.shared.model.IndicatorDTO) ActivityFormDTO(org.activityinfo.legacy.shared.model.ActivityFormDTO) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO) Test(org.junit.Test)

Aggregations

IndicatorDTO (org.activityinfo.legacy.shared.model.IndicatorDTO)14 Test (org.junit.Test)3 LayoutContainer (com.extjs.gxt.ui.client.widget.LayoutContainer)2 Text (com.extjs.gxt.ui.client.widget.Text)2 TextField (com.extjs.gxt.ui.client.widget.form.TextField)2 MessageBoxEvent (com.extjs.gxt.ui.client.event.MessageBoxEvent)1 Field (com.extjs.gxt.ui.client.widget.form.Field)1 NumberField (com.extjs.gxt.ui.client.widget.form.NumberField)1 HBoxLayout (com.extjs.gxt.ui.client.widget.layout.HBoxLayout)1 TableData (com.extjs.gxt.ui.client.widget.layout.TableData)1 TableLayout (com.extjs.gxt.ui.client.widget.layout.TableLayout)1 ToolTipConfig (com.extjs.gxt.ui.client.widget.tips.ToolTipConfig)1 Color (com.google.code.appengine.awt.Color)1 com.lowagie.text (com.lowagie.text)1 FileOutputStream (java.io.FileOutputStream)1 List (java.util.List)1 LinkIndicators (org.activityinfo.legacy.shared.command.LinkIndicators)1 VoidResult (org.activityinfo.legacy.shared.command.result.VoidResult)1 ActivityFormDTO (org.activityinfo.legacy.shared.model.ActivityFormDTO)1 ReportVisibilityDTO (org.activityinfo.legacy.shared.model.ReportVisibilityDTO)1