Search in sources :

Example 1 with ReportChangeEvent

use of org.activityinfo.client.page.report.ReportChangeEvent in project activityinfo by bedatadriven.

the class DimensionPrunerTest method test.

@Test
public void test() {
    PivotTableReportElement table = new PivotTableReportElement();
    DimensionPruner pruner = new DimensionPruner(eventBus, dispatcher);
    pruner.bind(table);
    table.getFilter().addRestriction(DimensionType.Indicator, NB_MENAGES_INDICATOR_ID);
    table.addColDimension(new Dimension(DimensionType.Indicator));
    eventBus.fireEvent(new ReportChangeEvent(this, table));
    AttributeGroupDimension groupDim = new AttributeGroupDimension(NFI_FUNDING_GROUP_ID);
    table.addColDimension(groupDim);
    eventBus.fireEvent(new ReportChangeEvent(this, table));
    assertTrue(table.getColumnDimensions().contains(groupDim));
    // now remove the indicator and verify that the attribute group has been
    // removed
    table.getFilter().clearRestrictions(DimensionType.Indicator);
    eventBus.fireEvent(new ReportChangeEvent(this, table));
    assertFalse(table.getColumnDimensions().contains(groupDim));
}
Also used : ReportChangeEvent(org.activityinfo.client.page.report.ReportChangeEvent) Dimension(org.activityinfo.shared.report.model.Dimension) AttributeGroupDimension(org.activityinfo.shared.report.model.AttributeGroupDimension) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) AttributeGroupDimension(org.activityinfo.shared.report.model.AttributeGroupDimension) Test(org.junit.Test)

Example 2 with ReportChangeEvent

use of org.activityinfo.client.page.report.ReportChangeEvent in project activityinfo by bedatadriven.

the class DimensionPrunerTest method testMergedAttributes.

@Test
public void testMergedAttributes() {
    PivotTableReportElement table = new PivotTableReportElement();
    DimensionPruner pruner = new DimensionPruner(eventBus, dispatcher);
    pruner.bind(table);
    table.getFilter().addRestriction(DimensionType.Indicator, Arrays.asList(NB_MENAGES_INDICATOR_ID, VOUCHER_INDICATOR_ID));
    table.addColDimension(new Dimension(DimensionType.Indicator));
    eventBus.fireEvent(new ReportChangeEvent(this, table));
    AttributeGroupDimension groupDim = new AttributeGroupDimension(NFI_FUNDING_GROUP_ID);
    table.addColDimension(groupDim);
    eventBus.fireEvent(new ReportChangeEvent(this, table));
    // now remove the first indicator and verify that the attribute group
    // has NOT been removed, because it shares a name with the other attrib group
    table.getFilter().clearRestrictions(DimensionType.Indicator);
    table.getFilter().addRestriction(DimensionType.Indicator, VOUCHER_INDICATOR_ID);
    eventBus.fireEvent(new ReportChangeEvent(this, table));
    assertTrue(table.getColumnDimensions().contains(groupDim));
}
Also used : ReportChangeEvent(org.activityinfo.client.page.report.ReportChangeEvent) Dimension(org.activityinfo.shared.report.model.Dimension) AttributeGroupDimension(org.activityinfo.shared.report.model.AttributeGroupDimension) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) AttributeGroupDimension(org.activityinfo.shared.report.model.AttributeGroupDimension) Test(org.junit.Test)

Aggregations

ReportChangeEvent (org.activityinfo.client.page.report.ReportChangeEvent)2 AttributeGroupDimension (org.activityinfo.shared.report.model.AttributeGroupDimension)2 Dimension (org.activityinfo.shared.report.model.Dimension)2 PivotTableReportElement (org.activityinfo.shared.report.model.PivotTableReportElement)2 Test (org.junit.Test)2