Search in sources :

Example 1 with ReportChangeEvent

use of org.activityinfo.ui.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, getDispatcher());
    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.ui.client.page.report.ReportChangeEvent) Dimension(org.activityinfo.legacy.shared.reports.model.Dimension) AttributeGroupDimension(org.activityinfo.legacy.shared.reports.model.AttributeGroupDimension) PivotTableReportElement(org.activityinfo.legacy.shared.reports.model.PivotTableReportElement) AttributeGroupDimension(org.activityinfo.legacy.shared.reports.model.AttributeGroupDimension) Test(org.junit.Test)

Example 2 with ReportChangeEvent

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

the class DimensionPrunerTest method test.

// 
// @Before
// public void setupData() {
// 
// ActivityFormDTO dist = new ActivityFormDTO(1, "Distribution");
// IndicatorDTO nbMenages = new IndicatorDTO();
// nbMenages.setId(NB_MENAGES_INDICATOR_ID);
// nbMenages.setName("Nb Menages");
// dist.getIndicators().add(nbMenages);
// 
// AttributeGroupDTO distFunding = new AttributeGroupDTO(NFI_FUNDING_GROUP_ID);
// distFunding.setName("Funding Source");
// dist.getAttributeGroups().add(distFunding);
// 
// 
// ActivityFormDTO fairs = new ActivityFormDTO(2, "Faire");
// 
// AttributeGroupDTO fairFunding = new AttributeGroupDTO(FAIR_FUNDING_GROUP_ID);
// fairFunding.setName("Funding Source");
// fairs.getAttributeGroups().add(fairFunding);
// 
// IndicatorDTO voucherValue = new IndicatorDTO();
// voucherValue.setId(VOUCHER_INDICATOR_ID);
// voucherValue.setName("Voucher Value");
// fairs.getIndicators().add(voucherValue);
// 
// UserDatabaseDTO nfi = new UserDatabaseDTO(1, "NFI");
// nfi.addActivity(dist);
// nfi.addActivity(fairs);
// 
// this.schema = new SchemaDTO();
// schema.getDatabases().add(nfi);
// 
// dispatcher.setResult(GetSchema.class, schema);
// }
@Test
public void test() {
    PivotTableReportElement table = new PivotTableReportElement();
    DimensionPruner pruner = new DimensionPruner(eventBus, getDispatcher());
    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.ui.client.page.report.ReportChangeEvent) Dimension(org.activityinfo.legacy.shared.reports.model.Dimension) AttributeGroupDimension(org.activityinfo.legacy.shared.reports.model.AttributeGroupDimension) PivotTableReportElement(org.activityinfo.legacy.shared.reports.model.PivotTableReportElement) AttributeGroupDimension(org.activityinfo.legacy.shared.reports.model.AttributeGroupDimension) Test(org.junit.Test)

Aggregations

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