Program: 65188
Project: 65188
Buggy source:
/** 
 * Add aggregate bindings of value series for grouping case.
 * @param query
 * @param seriesDefinitions
 * @param innerMostGroupDef
 * @param valueExprMap
 * @param baseSD
 * @throws ChartException
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) 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) {
        if (!bCreateBindingForExpression || exprCodec.isRowBinding(expr,false)) {
          continue;
        }
      }
      String name=ChartUtil.generateBindingNameOfValueSeries(qry,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);
          if (aggName != null) {
            setBindingExpressionDueToAggregation(colBinding,expr,aggName);
            if (innerMostGroupDef != null) {
              colBinding.addAggregateOn(innerGroupName);
            }
            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));
          }
        }
 catch (        DataException e1) {
          throw new ChartException(ChartReportItemPlugin.ID,ChartException.DATA_BINDING,e1);
        }
      }
 else {
        exprCodec.decode(expr);
        colBinding.setExpression(ChartReportItemUtil.adaptExpression(exprCodec,modelAdapter,false));
      }
      String newExpr=getExpressionForEvaluator(name);
      try {
        if (!query.getBindings().containsKey(colBinding.getBindingName())) {
          query.addBinding(colBinding);
          if (ChartUtil.compareVersion(fChartModel.getVersion(),"String_Node_Str") < 0) {
            String bindingName=ChartUtil.generateBindingNameOfValueSeries(qry,orthSD,baseSD,true);
            if (!query.getBindings().containsKey(bindingName) && !fNameSet.contains(bindingName)) {
              IBinding newBinding=new Binding(bindingName,colBinding.getExpression());
              newBinding.setAggrFunction(colBinding.getAggrFunction());
              newBinding.setDataType(colBinding.getDataType());
              newBinding.setDisplayName(colBinding.getDisplayName());
              newBinding.setExportable(colBinding.exportable());
              newBinding.setFilter(colBinding.getFilter());
              newBinding.setTimeFunction(colBinding.getTimeFunction());
              for (              Object o : colBinding.getAggregatOns()) {
                newBinding.getAggregatOns().add(o);
              }
              for (              Object o : colBinding.getArguments()) {
                newBinding.addArgument((IBaseExpression)o);
              }
              query.addBinding(newBinding);
            }
          }
        }
      }
 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 ChartException
 */
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) 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) {
        if (!bCreateBindingForExpression || exprCodec.isRowBinding(expr,false)) {
          continue;
        }
      }
      String name=ChartUtil.generateBindingNameOfValueSeries(qry,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);
          if (aggName != null) {
            setBindingExpressionDueToAggregation(colBinding,expr,aggName);
            if (innerMostGroupDef != null) {
              colBinding.addAggregateOn(innerGroupName);
            }
            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));
          }
        }
 catch (        DataException e1) {
          throw new ChartException(ChartReportItemPlugin.ID,ChartException.DATA_BINDING,e1);
        }
      }
 else {
        exprCodec.decode(expr);
        colBinding.setExpression(ChartReportItemUtil.adaptExpression(exprCodec,modelAdapter,false));
      }
      String newExpr=getExpressionForEvaluator(name);
      try {
        if (!query.getBindings().containsKey(colBinding.getBindingName())) {
          query.addBinding(colBinding);
          if (ChartUtil.compareVersion(fChartModel.getVersion(),"String_Node_Str") < 0) {
            String bindingName=ChartUtil.generateBindingNameOfValueSeries(qry,orthSD,baseSD,true);
            if (!query.getBindings().containsKey(bindingName) && !fNameSet.contains(bindingName)) {
              IBinding newBinding=new Binding(bindingName,colBinding.getExpression());
              newBinding.setAggrFunction(colBinding.getAggrFunction());
              newBinding.setDataType(colBinding.getDataType());
              newBinding.setDisplayName(colBinding.getDisplayName());
              newBinding.setExportable(colBinding.exportable());
              newBinding.setFilter(colBinding.getFilter());
              newBinding.setTimeFunction(colBinding.getTimeFunction());
              for (              Object o : colBinding.getAggregatOns()) {
                newBinding.getAggregatOns().add(o);
              }
              for (              Object o : colBinding.getArguments()) {
                newBinding.addArgument((IBaseExpression)o);
              }
              query.addBinding(newBinding);
            }
          }
        }
      }
 catch (      DataException e) {
        throw new ChartException(ChartReportItemPlugin.ID,ChartException.DATA_BINDING,e);
      }
      valueExprMap.put(expr,new String[]{name,newExpr});
    }
  }
}