Program: 65187
Project: 65187
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<SeriesDefinition> seriesDefinitions,GroupDefinition innerMostGroupDef,Map<String,String[]> valueExprMap,SeriesDefinition baseSD) throws ChartException {
  for (  SeriesDefinition orthSD : seriesDefinitions) {
    Series series=orthSD.getDesignTimeSeries();
    List<Query> qlist=ChartEngine.instance().getDataSetProcessor(series.getClass()).getDataDefinitionsForGrouping(series);
    for (    Query qry : series.getDataDefinition()) {
      String expr=qry.getDefinition();
      if (expr == null || "String_Node_Str".equals(expr)) {
        continue;
      }
      String aggName=ChartUtil.getAggregateFuncExpr(orthSD,baseSD,qry);
      if (aggName == null || "String_Node_Str".equals(aggName)) {
        continue;
      }
      String name=ChartUtil.generateBindingNameOfValueSeries(qry,orthSD,baseSD);
      if (fNameSet.contains(name)) {
        query.getBindings().remove(name);
      }
      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) {
          String[] parameters=ChartUtil.getAggFunParameters(orthSD,baseSD,qry);
          for (int i=0; i < parameters.length && i < aFunc.getParametersCount(); i++) {
            String param=parameters[i];
            colBinding.addArgument(new ScriptExpression(param));
          }
        }
      }
 else {
        exprCodec.decode(expr);
        colBinding.setExpression(ChartReportItemUtil.adaptExpression(exprCodec,modelAdapter,false));
      }
      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[]{expr,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<SeriesDefinition> seriesDefinitions,GroupDefinition innerMostGroupDef,Map<String,String[]> valueExprMap,SeriesDefinition baseSD) throws ChartException {
  for (  SeriesDefinition orthSD : seriesDefinitions) {
    Series series=orthSD.getDesignTimeSeries();
    List<Query> qlist=ChartEngine.instance().getDataSetProcessor(series.getClass()).getDataDefinitionsForGrouping(series);
    for (    Query qry : series.getDataDefinition()) {
      String expr=qry.getDefinition();
      if (expr == null || "String_Node_Str".equals(expr) || isDataBinding(expr)) {
        continue;
      }
      String aggName=ChartUtil.getAggregateFuncExpr(orthSD,baseSD,qry);
      if (aggName == null || "String_Node_Str".equals(aggName)) {
        continue;
      }
      String name=ChartUtil.generateBindingNameOfValueSeries(qry,orthSD,baseSD);
      if (fNameSet.contains(name)) {
        query.getBindings().remove(name);
      }
      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) {
          String[] parameters=ChartUtil.getAggFunParameters(orthSD,baseSD,qry);
          for (int i=0; i < parameters.length && i < aFunc.getParametersCount(); i++) {
            String param=parameters[i];
            colBinding.addArgument(new ScriptExpression(param));
          }
        }
      }
 else {
        exprCodec.decode(expr);
        colBinding.setExpression(ChartReportItemUtil.adaptExpression(exprCodec,modelAdapter,false));
      }
      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[]{expr,newExpr});
    }
  }
}