Program: 139948
Project: 139948
Buggy source:
private boolean createSqlQuery(String dataFilterAsString,Indicator indicator) throws ParseException, AnalysisExecutionException {
  ModelElement analyzedElement=indicator.getAnalyzedElement();
  if (analyzedElement == null) {
    return traceError("String_Node_Str" + indicator.getName());
  }
  TdTable tdTable=SwitchHelpers.TABLE_SWITCH.doSwitch(indicator.getAnalyzedElement());
  if (tdTable == null) {
    return traceError("String_Node_Str" + indicator.getName());
  }
  String tableName=quote(tdTable.getName());
  if (!belongToSameSchemata(tdTable)) {
    StringBuffer buf=new StringBuffer();
    for (    orgomg.cwm.objectmodel.core.Package schema : schemata.values()) {
      buf.append(schema.getName() + "String_Node_Str");
    }
    log.error("String_Node_Str" + tableName + "String_Node_Str"+ buf.toString().trim()+ "String_Node_Str");
    return false;
  }
  String language=dbms().getDbmsName();
  Expression sqlGenericExpression=null;
  IndicatorDefinition indicatorDefinition=indicator.getIndicatorDefinition();
  if (indicatorDefinition == null) {
    return traceError("String_Node_Str" + indicator.getName() + "String_Node_Str");
  }
  sqlGenericExpression=dbms().getSqlExpression(indicatorDefinition);
  final EClass indicatorEclass=indicator.eClass();
  if (sqlGenericExpression == null || sqlGenericExpression.getBody() == null) {
    return traceError("String_Node_Str" + (indicator.getName() != null ? indicator.getName() : indicatorEclass.getName()) + "String_Node_Str"+ ResourceHelper.getUUID(indicatorDefinition)+ "String_Node_Str");
  }
  List<String> whereExpression=new ArrayList<String>();
  if (StringUtils.isNotBlank(dataFilterAsString)) {
    whereExpression.add(dataFilterAsString);
  }
  final EList<JoinElement> joinConditions=indicator.getJoinConditions();
  if (indicatorDefinition instanceof WhereRule) {
    WhereRule wr=(WhereRule)indicatorDefinition;
    whereExpression.add(wr.getWhereExpression());
    if (!wr.getJoins().isEmpty()) {
      for (      JoinElement joinelt : wr.getJoins()) {
        JoinElement joinCopy=(JoinElement)EcoreUtil.copy(joinelt);
        joinConditions.add(joinCopy);
      }
    }
  }
  IndicatorParameters parameters=indicator.getParameters();
  if (parameters != null) {
  }
  String schemaName=getQuotedSchemaName(tdTable);
  String table=quote(tdTable.getName());
  String catalogName=getQuotedCatalogName(tdTable);
  if (catalogName == null && schemaName != null) {
    final TdSchema parentSchema=SchemaHelper.getParentSchema(tdTable);
    final TdCatalog parentCatalog=CatalogHelper.getParentCatalog(parentSchema);
    catalogName=parentCatalog != null ? parentCatalog.getName() : null;
  }
  table=dbms().toQualifiedName(catalogName,schemaName,table);
  String completedSqlString=null;
  String joinclause=(!joinConditions.isEmpty()) ? dbms().createJoinConditionAsString(joinConditions) : "String_Node_Str";
  completedSqlString=dbms().fillGenericQueryWithJoin(sqlGenericExpression.getBody(),tableName,joinclause);
  completedSqlString=addWhereToSqlStringStatement(whereExpression,completedSqlString);
  String finalQuery=completedSqlString;
  Expression instantiateSqlExpression=BooleanExpressionHelper.createExpression(language,finalQuery);
  indicator.setInstantiatedExpression(instantiateSqlExpression);
  return true;
}

Fixed version (ground truth):
private boolean createSqlQuery(String dataFilterAsString,Indicator indicator) throws ParseException, AnalysisExecutionException {
  ModelElement analyzedElement=indicator.getAnalyzedElement();
  if (analyzedElement == null) {
    return traceError("String_Node_Str" + indicator.getName());
  }
  TdTable tdTable=SwitchHelpers.TABLE_SWITCH.doSwitch(indicator.getAnalyzedElement());
  if (tdTable == null) {
    return traceError("String_Node_Str" + indicator.getName());
  }
  String tableName=quote(tdTable.getName());
  if (!belongToSameSchemata(tdTable)) {
    StringBuffer buf=new StringBuffer();
    for (    orgomg.cwm.objectmodel.core.Package schema : schemata.values()) {
      buf.append(schema.getName() + "String_Node_Str");
    }
    log.error("String_Node_Str" + tableName + "String_Node_Str"+ buf.toString().trim()+ "String_Node_Str");
    return false;
  }
  String language=dbms().getDbmsName();
  Expression sqlGenericExpression=null;
  IndicatorDefinition indicatorDefinition=indicator.getIndicatorDefinition();
  if (indicatorDefinition == null) {
    return traceError("String_Node_Str" + indicator.getName() + "String_Node_Str");
  }
  sqlGenericExpression=dbms().getSqlExpression(indicatorDefinition);
  final EClass indicatorEclass=indicator.eClass();
  if (sqlGenericExpression == null || sqlGenericExpression.getBody() == null) {
    return traceError("String_Node_Str" + (indicator.getName() != null ? indicator.getName() : indicatorEclass.getName()) + "String_Node_Str"+ ResourceHelper.getUUID(indicatorDefinition)+ "String_Node_Str");
  }
  List<String> whereExpression=new ArrayList<String>();
  if (StringUtils.isNotBlank(dataFilterAsString)) {
    whereExpression.add(dataFilterAsString);
  }
  final EList<JoinElement> joinConditions=indicator.getJoinConditions();
  if (RulesPackage.eINSTANCE.getWhereRule().equals(indicatorDefinition.eClass())) {
    WhereRule wr=(WhereRule)indicatorDefinition;
    whereExpression.add(wr.getWhereExpression());
    joinConditions.clear();
    if (!wr.getJoins().isEmpty()) {
      for (      JoinElement joinelt : wr.getJoins()) {
        JoinElement joinCopy=(JoinElement)EcoreUtil.copy(joinelt);
        joinConditions.add(joinCopy);
      }
    }
  }
  IndicatorParameters parameters=indicator.getParameters();
  if (parameters != null) {
  }
  String schemaName=getQuotedSchemaName(tdTable);
  String table=quote(tdTable.getName());
  String catalogName=getQuotedCatalogName(tdTable);
  if (catalogName == null && schemaName != null) {
    final TdSchema parentSchema=SchemaHelper.getParentSchema(tdTable);
    final TdCatalog parentCatalog=CatalogHelper.getParentCatalog(parentSchema);
    catalogName=parentCatalog != null ? parentCatalog.getName() : null;
  }
  table=dbms().toQualifiedName(catalogName,schemaName,table);
  String completedSqlString=null;
  String joinclause=(!joinConditions.isEmpty()) ? dbms().createJoinConditionAsString(joinConditions) : "String_Node_Str";
  completedSqlString=dbms().fillGenericQueryWithJoin(sqlGenericExpression.getBody(),tableName,joinclause);
  completedSqlString=addWhereToSqlStringStatement(whereExpression,completedSqlString);
  String finalQuery=completedSqlString;
  Expression instantiateSqlExpression=BooleanExpressionHelper.createExpression(language,finalQuery);
  indicator.setInstantiatedExpression(instantiateSqlExpression);
  return true;
}