Bug 575894 - Format on aggregated column with mapRules produces wrong design
Summary: Format on aggregated column with mapRules produces wrong design
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: 4.5.0   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Birt-Report-inbox@eclipse.org CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-09 03:23 EDT by Dawid Cokan CLA
Modified: 2021-09-09 05:07 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dawid Cokan CLA 2021-09-09 03:23:39 EDT
Hi. 

We are building a system in which we are using a BIRT API to produce a ReportDesign based on metadata user can select in our application. We are using a BIRT 4.5.0

One of our business case is producing a table. In short: given the list of columns we want to produce a ReportDesign representing them. One of feature available is providing a format for numeric column. I want to support a "zero mask", for instance whenever a value to be displayed in cell is 0 instead I want to print "-". I was able to manage it by "mapRules". It works fine but one case.

It doesn't work for formatting an aggregation. When I add mapRules in my grouping cell the BIRT adds additional boundDataColumns instance with incorrect data which fails in runtime. 

To describe in details what I am doing:

1. I add definition of my aggregation in table -> boundDataColumns:

> <structure>
>     <property name="name">MyAggregation</property>
>     <text-property name="displayName">MyAggregation</text-property>
>     <property name="dataType">decimal</property>
>     <simple-property-list name="aggregateOn">
>         <value>GroupColumn</value>
>     </simple-property-list>
>     <property name="aggregateFunction">SUM</property>
>     <list-property name="arguments">
>         <structure>
>             <property name="name">Expression</property>
>             <expression name="value" type="javascript">row["ColumnToSum"]</expression>
>         </structure>
>     </list-property>
> </structure>
2. I add cell to proper group :
> <cell id="8502">
>     <data name="data_column_X" id="8503">
>         <structure name="numberFormat">
>             <property name="pattern">###,##0.00;(###,##0.00)</property>
>         </structure>
>         <list-property name="mapRules">
>             <structure>
>                 <property name="operator">is-null</property>
>                 <text-property name="display">(No data)</text-property>
>             </structure>
>             <structure>
>                 <expression name="testExpr">row["MyAggregation"]</expression>
>                 <property name="operator">eq</property>
>                 <simple-property-list name="value1">
>                     <value>0</value>
>                 </simple-property-list>
>                 <text-property name="display">-</text-property>
>             </structure>
>         </list-property>
>         <property name="resultSetColumn">MyAggregation</property>
>     </data>
> </cell>
3. When I save the rptdesgin (design.saveAs("myReport.rptdesign");)

Expected:

generated rptdesign should consist of data I put

Actual:

BIRT has added the new boundDataColumns instance:

> <structure>
>     <property name="name">MyAggregation_1</property>
>     <expression name="expression">dataSetRow["MyAggregation"]</expression>
>     <simple-property-list name="aggregateOn">
>         <value>GroupColumn</value>
>     </simple-property-list>
> </structure>
Due to existence of above the PDF report generation fails because this:
> <expression name="expression">dataSetRow["MyAggregation"]</expression>

is unknown - my dataset does not have such property. Note that if I remove just added boundDataColumns the generation works perfectly. 

Note: 
I searched through a code and I can see where it happens. System is searching whether there is any boundDataColumn defined for row["MyAggregation"] (because it's defined as testExpression in mapRules) and if not it adds it. I checks whether such computedColum is already defined to avoid duplications however it doesn't based on computedColumn -> name but instead it checks the expression defined in that ComputedColumn. The column representing my aggregation returns row["ColumnToSum"] when I invoke computedColumn.getExpression() and that's why system thinks it needs to add new ComputedColumn