Program: 138212
Project: 138212
Buggy source:
/** 
 * DOC scorreia Comment method "instantiateQuery".
 * @param indicator
 */
private void instantiateQuery(Indicator indicator){
  if (ColumnsetPackage.eINSTANCE.getColumnSetMultiValueIndicator().isSuperTypeOf(indicator.eClass())) {
    ColumnSetMultiValueIndicator colSetMultValIndicator=(ColumnSetMultiValueIndicator)indicator;
    final EList<ModelElement> analyzedColumns=colSetMultValIndicator.getAnalyzedColumns();
    final EList<String> numericFunctions=initializeNumericFunctions(colSetMultValIndicator);
    final EList<String> dateFunctions=initializeDateFunctions(colSetMultValIndicator);
    List<String> nominalColumns=new ArrayList<String>();
    for (    ModelElement column : colSetMultValIndicator.getNominalColumns()) {
      nominalColumns.add(getQuotedColumnName(column));
    }
    List<String> computedColumns=new ArrayList<String>();
    for (    ModelElement column : colSetMultValIndicator.getNumericColumns()) {
      for (      String f : numericFunctions) {
        computedColumns.add(replaceVariablesLow(f,getQuotedColumnName(column)));
      }
    }
    for (    ModelElement column : colSetMultValIndicator.getDateColumns()) {
      for (      String f : dateFunctions) {
        computedColumns.add(replaceVariablesLow(f,getQuotedColumnName(column)));
      }
    }
    computedColumns.add(colSetMultValIndicator.getCountAll());
    String selectItems=createSelect(nominalColumns,computedColumns);
    final Expression sqlGenericExpression=dbms().getSqlExpression(indicator.getIndicatorDefinition());
    String grpByClause=createGroupBy(nominalColumns);
    String tableName=getTableName(analyzedColumns);
    String sqlExpr=dbms().fillGenericQueryWithColumnTableAndAlias(sqlGenericExpression.getBody(),selectItems,tableName,grpByClause);
    String stringDataFilter=AnalysisHelper.getStringDataFilter(cachedAnalysis);
    if (stringDataFilter == null) {
      stringDataFilter=PluginConstant.EMPTY_STRING;
    }
    sqlExpr=dbms().addWhereToStatement(sqlExpr,stringDataFilter);
    indicator.setInstantiatedExpression(BooleanExpressionHelper.createTdExpression(sqlGenericExpression.getLanguage(),sqlExpr));
    if (ColumnsetPackage.eINSTANCE.getSimpleStatIndicator().isSuperTypeOf(indicator.eClass())) {
      SimpleStatIndicator simpleIndicator=(SimpleStatIndicator)indicator;
      String columnsName=createSelect(nominalColumns,new ArrayList<String>());
      for (      Indicator leafIndicator : simpleIndicator.getLeafIndicators()) {
        final Expression leafSqlGenericExpression=dbms().getSqlExpression(leafIndicator.getIndicatorDefinition());
        String leafSqlExpr=dbms().fillGenericQueryWithColumnTableAndAlias(leafSqlGenericExpression.getBody(),columnsName,tableName,grpByClause);
        leafSqlExpr=dbms().addWhereToStatement(leafSqlExpr,stringDataFilter);
        leafIndicator.setInstantiatedExpression(BooleanExpressionHelper.createTdExpression(leafSqlGenericExpression.getLanguage(),leafSqlExpr));
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * DOC scorreia Comment method "instantiateQuery".
 * @param indicator
 */
private void instantiateQuery(Indicator indicator){
  if (ColumnsetPackage.eINSTANCE.getColumnSetMultiValueIndicator().isSuperTypeOf(indicator.eClass())) {
    ColumnSetMultiValueIndicator colSetMultValIndicator=(ColumnSetMultiValueIndicator)indicator;
    final EList<ModelElement> analyzedColumns=colSetMultValIndicator.getAnalyzedColumns();
    final EList<String> numericFunctions=initializeNumericFunctions(colSetMultValIndicator);
    final EList<String> dateFunctions=initializeDateFunctions(colSetMultValIndicator);
    final String caseStr="String_Node_Str";
    if (SupportDBUrlType.EXCEL.getDBKey().equals(dbms().getDbmsName()) && (dateFunctions.contains(caseStr) || numericFunctions.contains(caseStr))) {
      this.errorMessage=Messages.getString("String_Node_Str");
      Display.getDefault().syncExec(new Runnable(){
        public void run(){
          MessageDialog.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),Messages.getString("String_Node_Str"),errorMessage);
          return;
        }
      }
);
    }
    List<String> nominalColumns=new ArrayList<String>();
    for (    ModelElement column : colSetMultValIndicator.getNominalColumns()) {
      nominalColumns.add(getQuotedColumnName(column));
    }
    List<String> computedColumns=new ArrayList<String>();
    for (    ModelElement column : colSetMultValIndicator.getNumericColumns()) {
      for (      String f : numericFunctions) {
        computedColumns.add(replaceVariablesLow(f,getQuotedColumnName(column)));
      }
    }
    for (    ModelElement column : colSetMultValIndicator.getDateColumns()) {
      for (      String f : dateFunctions) {
        computedColumns.add(replaceVariablesLow(f,getQuotedColumnName(column)));
      }
    }
    computedColumns.add(colSetMultValIndicator.getCountAll());
    String selectItems=createSelect(nominalColumns,computedColumns);
    final Expression sqlGenericExpression=dbms().getSqlExpression(indicator.getIndicatorDefinition());
    String grpByClause=createGroupBy(nominalColumns);
    String tableName=getTableName(analyzedColumns);
    String sqlExpr=dbms().fillGenericQueryWithColumnTableAndAlias(sqlGenericExpression.getBody(),selectItems,tableName,grpByClause);
    String stringDataFilter=AnalysisHelper.getStringDataFilter(cachedAnalysis);
    if (stringDataFilter == null) {
      stringDataFilter=PluginConstant.EMPTY_STRING;
    }
    sqlExpr=dbms().addWhereToStatement(sqlExpr,stringDataFilter);
    indicator.setInstantiatedExpression(BooleanExpressionHelper.createTdExpression(sqlGenericExpression.getLanguage(),sqlExpr));
    if (ColumnsetPackage.eINSTANCE.getSimpleStatIndicator().isSuperTypeOf(indicator.eClass())) {
      SimpleStatIndicator simpleIndicator=(SimpleStatIndicator)indicator;
      String columnsName=createSelect(nominalColumns,new ArrayList<String>());
      for (      Indicator leafIndicator : simpleIndicator.getLeafIndicators()) {
        final Expression leafSqlGenericExpression=dbms().getSqlExpression(leafIndicator.getIndicatorDefinition());
        String leafSqlExpr=dbms().fillGenericQueryWithColumnTableAndAlias(leafSqlGenericExpression.getBody(),columnsName,tableName,grpByClause);
        leafSqlExpr=dbms().addWhereToStatement(leafSqlExpr,stringDataFilter);
        leafIndicator.setInstantiatedExpression(BooleanExpressionHelper.createTdExpression(leafSqlGenericExpression.getLanguage(),leafSqlExpr));
      }
    }
  }
}