Program: 138899
Project: 138899
Buggy source:
/** 
 * DOC xqliu Comment method "getValidStatement". 2009-10-29 bug 9702
 * @param dataFilterAsString
 * @param indicator
 * @return
 */
public String getValidStatement(String dataFilterAsString,Indicator indicator){
  ModelElement analyzedElement=indicator.getAnalyzedElement();
  if (analyzedElement == null) {
    traceError("String_Node_Str" + indicator.getName());
    return "String_Node_Str";
  }
  NamedColumnSet set=SwitchHelpers.NAMED_COLUMN_SET_SWITCH.doSwitch(indicator.getAnalyzedElement());
  if (set == null) {
    traceError("String_Node_Str" + indicator.getName());
    return "String_Node_Str";
  }
  String setName=quote(set.getName());
  if (!belongToSameSchemata(set)) {
    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" + setName + "String_Node_Str"+ buf.toString().trim()+ "String_Node_Str");
    return "String_Node_Str";
  }
  Expression sqlGenericExpression=null;
  IndicatorDefinition indicatorDefinition=indicator.getIndicatorDefinition();
  if (indicatorDefinition == null) {
    traceError("String_Node_Str" + indicator.getName() + "String_Node_Str");
    return "String_Node_Str";
  }
  sqlGenericExpression=dbms().getSqlExpression(indicatorDefinition);
  final EClass indicatorEclass=indicator.eClass();
  if (sqlGenericExpression == null || sqlGenericExpression.getBody() == null) {
    traceError("String_Node_Str" + (indicator.getName() != null ? indicator.getName() : indicatorEclass.getName()) + "String_Node_Str"+ ResourceHelper.getUUID(indicatorDefinition)+ "String_Node_Str");
    return "String_Node_Str";
  }
  List<String> whereExpression=new ArrayList<String>();
  if (StringUtils.isNotBlank(dataFilterAsString)) {
    whereExpression.add(dataFilterAsString);
  }
  String setAliasA="String_Node_Str";
  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);
        setAliasA="String_Node_Str".equals(setAliasA) ? joinCopy.getTableAliasA() : setAliasA;
      }
    }
  }
  String schemaName=getQuotedSchemaName(set);
  String catalogName=getQuotedCatalogName(set);
  if (catalogName == null && schemaName != null) {
    final Schema parentSchema=SchemaHelper.getParentSchema(set);
    final Catalog parentCatalog=CatalogHelper.getParentCatalog(parentSchema);
    catalogName=parentCatalog != null ? parentCatalog.getName() : null;
  }
  if (dbms().getDbmsName().equals(SupportDBUrlType.SYBASEDEFAULTURL.getLanguage())) {
    schemaName=ColumnSetHelper.getTableOwner(set);
  }
  setName=dbms().toQualifiedName(catalogName,schemaName,setName);
  String completedSqlString=null;
  String joinclause=(!joinConditions.isEmpty()) ? dbms().createJoinConditionAsString(set,joinConditions,catalogName,schemaName) : "String_Node_Str";
  String genericSql=sqlGenericExpression.getBody();
  setAliasA="String_Node_Str".equals(setAliasA) ? "String_Node_Str" : setAliasA + "String_Node_Str";
  genericSql=genericSql.replace("String_Node_Str",setAliasA);
  completedSqlString=dbms().fillGenericQueryWithJoin(genericSql,setName,joinclause);
  try {
    completedSqlString=addWhereToSqlStringStatement(whereExpression,completedSqlString);
  }
 catch (  ParseException e) {
    log.warn(e);
  }
  return completedSqlString;
}

Fixed version (ground truth):
/** 
 * DOC xqliu Comment method "getValidStatement". 2009-10-29 bug 9702
 * @param dataFilterAsString
 * @param indicator
 * @return
 */
public String getValidStatement(String dataFilterAsString,Indicator indicator){
  ModelElement analyzedElement=indicator.getAnalyzedElement();
  if (analyzedElement == null) {
    traceError("String_Node_Str" + indicator.getName());
    return "String_Node_Str";
  }
  NamedColumnSet set=SwitchHelpers.NAMED_COLUMN_SET_SWITCH.doSwitch(indicator.getAnalyzedElement());
  if (set == null) {
    traceError("String_Node_Str" + indicator.getName());
    return "String_Node_Str";
  }
  String setName=quote(set.getName());
  if (!belongToSameSchemata(set)) {
    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" + setName + "String_Node_Str"+ buf.toString().trim()+ "String_Node_Str");
    return "String_Node_Str";
  }
  Expression sqlGenericExpression=null;
  IndicatorDefinition indicatorDefinition=indicator.getIndicatorDefinition();
  if (indicatorDefinition == null) {
    traceError("String_Node_Str" + indicator.getName() + "String_Node_Str");
    return "String_Node_Str";
  }
  sqlGenericExpression=dbms().getSqlExpression(indicatorDefinition);
  final EClass indicatorEclass=indicator.eClass();
  if (sqlGenericExpression == null || sqlGenericExpression.getBody() == null) {
    traceError("String_Node_Str" + (indicator.getName() != null ? indicator.getName() : indicatorEclass.getName()) + "String_Node_Str"+ ResourceHelper.getUUID(indicatorDefinition)+ "String_Node_Str");
    return "String_Node_Str";
  }
  List<String> whereExpression=new ArrayList<String>();
  if (StringUtils.isNotBlank(dataFilterAsString)) {
    whereExpression.add(dataFilterAsString);
  }
  String setAliasA="String_Node_Str";
  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);
        setAliasA="String_Node_Str".equals(setAliasA) ? joinCopy.getTableAliasA() : setAliasA;
      }
    }
  }
  String schemaName=getQuotedSchemaName(set);
  String catalogName=getQuotedCatalogName(set);
  if (catalogName == null && schemaName != null) {
    final Schema parentSchema=SchemaHelper.getParentSchema(set);
    final Catalog parentCatalog=CatalogHelper.getParentCatalog(parentSchema);
    catalogName=parentCatalog != null ? parentCatalog.getName() : null;
  }
  if (ConnectionUtils.isSybaseeDBProducts(dbms().getDbmsName())) {
    schemaName=ColumnSetHelper.getTableOwner(set);
  }
  setName=dbms().toQualifiedName(catalogName,schemaName,setName);
  String completedSqlString=null;
  String joinclause=(!joinConditions.isEmpty()) ? dbms().createJoinConditionAsString(set,joinConditions,catalogName,schemaName) : "String_Node_Str";
  String genericSql=sqlGenericExpression.getBody();
  setAliasA="String_Node_Str".equals(setAliasA) ? "String_Node_Str" : setAliasA + "String_Node_Str";
  genericSql=genericSql.replace("String_Node_Str",setAliasA);
  completedSqlString=dbms().fillGenericQueryWithJoin(genericSql,setName,joinclause);
  try {
    completedSqlString=addWhereToSqlStringStatement(whereExpression,completedSqlString);
  }
 catch (  ParseException e) {
    log.warn(e);
  }
  return completedSqlString;
}