Program: 72158
Project: 72158
Buggy source:
/** 
 * Add aggregate bindings of value series for grouping case.
 * @param query
 * @param seriesDefinitions
 * @param innerMostGroupDef
 * @param valueExprMap
 * @param baseSD
 * @throws DataException
 * @throws DataException
 */
protected void addValueSeriesAggregateBindingForGrouping(BaseQueryDefinition query,EList seriesDefinitions,GroupDefinition innerMostGroupDef,Map valueExprMap,SeriesDefinition baseSD) throws ChartException {
  for (Iterator iter=seriesDefinitions.iterator(); iter.hasNext(); ) {
    SeriesDefinition orthSD=(SeriesDefinition)iter.next();
    Series series=orthSD.getDesignTimeSeries();
    List qlist=ChartEngine.instance().getDataSetProcessor(series.getClass()).getDataDefinitionsForGrouping(series);
    for (Iterator iter_datadef=series.getDataDefinition().iterator(); iter_datadef.hasNext(); ) {
      Query qry=(Query)iter_datadef.next();
      String expr=qry.getDefinition();
      if (expr == null || "String_Node_Str".equals(expr)) {
        continue;
      }
      String aggName=ChartUtil.getAggregateFuncExpr(orthSD,baseSD);
      if (aggName == null || "String_Node_Str".equals(aggName)) {
        continue;
      }
      String name=ChartUtil.getValueSeriesFullExpression(expr,orthSD,baseSD);
      if (fNameSet.contains(name)) {
        continue;
      }
      fNameSet.add(name);
      Binding colBinding=new Binding(name);
      colBinding.setDataType(org.eclipse.birt.core.data.DataType.ANY_TYPE);
      if (qlist.contains(qry)) {
        try {
          setBindingExpressionDueToAggregation(colBinding,expr,aggName);
        }
 catch (        DataException e1) {
          throw new ChartException(ChartReportItemPlugin.ID,ChartException.DATA_BINDING,e1);
        }
        if (innerMostGroupDef != null) {
          try {
            colBinding.addAggregateOn(innerMostGroupDef.getName());
          }
 catch (          DataException e) {
            throw new ChartException(ChartReportItemPlugin.ID,ChartException.DATA_BINDING,e);
          }
        }
        colBinding.setAggrFunction(ChartReportItemUtil.convertToDtEAggFunction(aggName));
        IAggregateFunction aFunc=PluginSettings.instance().getAggregateFunction(aggName);
        if (aFunc.getParametersCount() > 0) {
          Object[] parameters=ChartUtil.getAggFunParameters(orthSD,baseSD);
          for (int i=0; i < parameters.length && i < aFunc.getParametersCount(); i++) {
            String param=(String)parameters[i];
            colBinding.addArgument(new ScriptExpression(param));
          }
        }
      }
 else {
        colBinding.setExpression(new ScriptExpression(expr));
      }
      String newExpr=getExpressionForEvaluator(name);
      try {
        query.addBinding(colBinding);
      }
 catch (      DataException e) {
        throw new ChartException(ChartReportItemPlugin.ID,ChartException.DATA_BINDING,e);
      }
      valueExprMap.put(expr,new String[]{name,newExpr});
    }
  }
}

Fixed version (ground truth):
/** 
 * Add aggregate bindings of value series for grouping case.
 * @param query
 * @param seriesDefinitions
 * @param innerMostGroupDef
 * @param valueExprMap
 * @param baseSD
 * @throws DataException
 * @throws DataException
 */
protected void addValueSeriesAggregateBindingForGrouping(BaseQueryDefinition query,EList seriesDefinitions,GroupDefinition innerMostGroupDef,Map valueExprMap,SeriesDefinition baseSD) throws ChartException {
  for (Iterator iter=seriesDefinitions.iterator(); iter.hasNext(); ) {
    SeriesDefinition orthSD=(SeriesDefinition)iter.next();
    Series series=orthSD.getDesignTimeSeries();
    List qlist=ChartEngine.instance().getDataSetProcessor(series.getClass()).getDataDefinitionsForGrouping(series);
    for (Iterator iter_datadef=series.getDataDefinition().iterator(); iter_datadef.hasNext(); ) {
      Query qry=(Query)iter_datadef.next();
      String expr=qry.getDefinition();
      if (expr == null || "String_Node_Str".equals(expr)) {
        continue;
      }
      String aggName=ChartUtil.getAggregateFuncExpr(orthSD,baseSD);
      if (aggName == null || "String_Node_Str".equals(aggName)) {
        continue;
      }
      String name=ChartUtil.getValueSeriesFullExpression(expr,orthSD,baseSD);
      if (fNameSet.contains(name)) {
        continue;
      }
      fNameSet.add(name);
      Binding colBinding=new Binding(name);
      colBinding.setDataType(org.eclipse.birt.core.data.DataType.ANY_TYPE);
      if (qlist.contains(qry)) {
        try {
          colBinding.setExportable(false);
          setBindingExpressionDueToAggregation(colBinding,expr,aggName);
          if (innerMostGroupDef != null) {
            colBinding.addAggregateOn(innerMostGroupDef.getName());
          }
        }
 catch (        DataException e1) {
          throw new ChartException(ChartReportItemPlugin.ID,ChartException.DATA_BINDING,e1);
        }
        colBinding.setAggrFunction(ChartReportItemUtil.convertToDtEAggFunction(aggName));
        IAggregateFunction aFunc=PluginSettings.instance().getAggregateFunction(aggName);
        if (aFunc.getParametersCount() > 0) {
          Object[] parameters=ChartUtil.getAggFunParameters(orthSD,baseSD);
          for (int i=0; i < parameters.length && i < aFunc.getParametersCount(); i++) {
            String param=(String)parameters[i];
            colBinding.addArgument(new ScriptExpression(param));
          }
        }
      }
 else {
        colBinding.setExpression(new ScriptExpression(expr));
      }
      String newExpr=getExpressionForEvaluator(name);
      try {
        query.addBinding(colBinding);
      }
 catch (      DataException e) {
        throw new ChartException(ChartReportItemPlugin.ID,ChartException.DATA_BINDING,e);
      }
      valueExprMap.put(expr,new String[]{name,newExpr});
    }
  }
}