nus-yam/ex-repair huggingface dataset:
Program: 139293
Project: 139293
Buggy source:
/** 
 * Method "fillListOfCatalogs" gets the list of catalogs only when the list is empty. When the list is not empty, no call is executed to the connection.
 * @param connection
 * @param catalogNames the list of catalogs of the given connection
 * @throws SQLException
 */
private static void fillListOfCatalogs(Connection connection,List<String> catalogNames) throws SQLException {
  if (catalogNames.isEmpty()) {
    ResultSet catalogSet=null;
    DatabaseMetaData connectionMetadata=getConnectionMetadata(connection);
    if (connectionMetadata.getDatabaseProductName() != null && connectionMetadata.getDatabaseProductName().toLowerCase().indexOf(DatabaseConstant.ODBC_ORACLE_PRODUCT_NAME) < 0) {
      catalogSet=connectionMetadata.getCatalogs();
    }
    try {
      if (catalogSet != null) {
        while (catalogSet.next()) {
          String catalogName=catalogSet.getString(MetaDataConstants.TABLE_CAT.name());
          if (catalogName != null || !"String_Node_Str".equals(catalogName)) {
            catalogNames.add(catalogName);
          }
        }
      }
    }
 catch (    SQLException e) {
      log.warn("String_Node_Str",e);
    }
 finally {
      if (catalogSet != null) {
        catalogSet.close();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Method "fillListOfCatalogs" gets the list of catalogs only when the list is empty. When the list is not empty, no call is executed to the connection.
 * @param connection
 * @param catalogNames the list of catalogs of the given connection
 * @throws SQLException
 */
private static void fillListOfCatalogs(Connection connection,List<String> catalogNames) throws SQLException {
  if (catalogNames.isEmpty()) {
    ResultSet catalogSet=null;
    if (!(ConnectionUtils.isOdbcOracle(connection) || ConnectionUtils.isOdbcIngres(connection))) {
      catalogSet=getConnectionMetadata(connection).getCatalogs();
    }
    try {
      if (catalogSet != null) {
        while (catalogSet.next()) {
          String catalogName=catalogSet.getString(MetaDataConstants.TABLE_CAT.name());
          if (catalogName != null || !"String_Node_Str".equals(catalogName)) {
            catalogNames.add(catalogName);
          }
        }
      }
    }
 catch (    SQLException e) {
      log.warn("String_Node_Str",e);
    }
 finally {
      if (catalogSet != null) {
        catalogSet.close();
      }
    }
  }
}
Program: 139295
Project: 139295
Buggy source:
/** 
 * Method "changeCatalog".
 * @param catalogName unquoted catalog's name
 * @param connection
 * @throws SQLException
 */
protected boolean changeCatalog(String catalogName,Connection connection){
  try {
    if (!ConnectionUtils.isOdbcMssql(connection)) {
      connection.setCatalog(catalogName);
    }
    return true;
  }
 catch (  RuntimeException e) {
    return traceError("String_Node_Str" + catalogName + "String_Node_Str"+ e.getMessage());
  }
catch (  SQLException e) {
    return traceError("String_Node_Str" + catalogName + "String_Node_Str"+ e.getMessage());
  }
}

Fixed version (ground truth):
/** 
 * Method "changeCatalog".
 * @param catalogName unquoted catalog's name
 * @param connection
 * @throws SQLException
 */
protected boolean changeCatalog(String catalogName,Connection connection){
  try {
    if (!(ConnectionUtils.isOdbcMssql(connection) || ConnectionUtils.isOdbcOracle(connection))) {
      connection.setCatalog(catalogName);
    }
    return true;
  }
 catch (  RuntimeException e) {
    return traceError("String_Node_Str" + catalogName + "String_Node_Str"+ e.getMessage());
  }
catch (  SQLException e) {
    return traceError("String_Node_Str" + catalogName + "String_Node_Str"+ e.getMessage());
  }
}
Program: 139296
Project: 139296
Buggy source:
private void setPercentUIEnable(){
  IEditorPart editor=CorePlugin.getDefault().getCurrentActiveEditor();
  AbstractMetadataFormPage masterPage=null;
  boolean tableMasterPage=false;
  boolean columnSetMasterPage=false;
  AnalysisEditor anaEditor=null;
  if (editor != null) {
    anaEditor=(AnalysisEditor)editor;
    Object temp=anaEditor.getMasterPage();
    if (temp != null) {
      tableMasterPage=temp instanceof TableMasterDetailsPage;
      columnSetMasterPage=temp instanceof ColumnSetMasterPage;
      if (tableMasterPage) {
        masterPage=(TableMasterDetailsPage)temp;
      }
 else       if (columnSetMasterPage) {
        masterPage=(ColumnSetMasterPage)temp;
      }
 else {
        masterPage=(ColumnMasterDetailsPage)temp;
      }
    }
  }
  if (masterPage != null) {
    Analysis ana;
    if (tableMasterPage) {
      ana=((TableMasterDetailsPage)masterPage).getAnalysisHandler().getAnalysis();
    }
 else     if (columnSetMasterPage) {
      ana=((ColumnSetMasterPage)masterPage).getColumnSetAnalysisHandler().getAnalysis();
    }
 else {
      ana=((ColumnMasterDetailsPage)masterPage).getAnalysisHandler().getAnalysis();
    }
    isContainRowCount=AnalysisHelper.containsRowCount(ana);
  }
  pLowerText.setEnabled(isContainRowCount);
  pHigherText.setEnabled(isContainRowCount);
}

Fixed version (ground truth):
private void setPercentUIEnable(){
  IEditorPart editor=CorePlugin.getDefault().getCurrentActiveEditor();
  AbstractMetadataFormPage masterPage=null;
  boolean tableMasterPage=false;
  boolean columnSetMasterPage=false;
  boolean columnCorrelationMasterPage=false;
  AnalysisEditor anaEditor=null;
  if (editor != null) {
    anaEditor=(AnalysisEditor)editor;
    Object temp=anaEditor.getMasterPage();
    if (temp != null) {
      tableMasterPage=temp instanceof TableMasterDetailsPage;
      columnSetMasterPage=temp instanceof ColumnSetMasterPage;
      columnCorrelationMasterPage=temp instanceof ColumnCorrelationNominalAndIntervalMasterPage;
      if (tableMasterPage) {
        masterPage=(TableMasterDetailsPage)temp;
      }
 else       if (columnSetMasterPage) {
        masterPage=(ColumnSetMasterPage)temp;
      }
 else       if (columnCorrelationMasterPage) {
        masterPage=(ColumnCorrelationNominalAndIntervalMasterPage)temp;
      }
 else {
        masterPage=(ColumnMasterDetailsPage)temp;
      }
    }
  }
  if (masterPage != null) {
    Analysis ana;
    if (tableMasterPage) {
      ana=((TableMasterDetailsPage)masterPage).getAnalysisHandler().getAnalysis();
    }
 else     if (columnSetMasterPage) {
      ana=((ColumnSetMasterPage)masterPage).getColumnSetAnalysisHandler().getAnalysis();
    }
 else     if (columnCorrelationMasterPage) {
      ana=((ColumnCorrelationNominalAndIntervalMasterPage)masterPage).getColumnCorrelationAnalysisHandler().getAnalysis();
    }
 else {
      ana=((ColumnMasterDetailsPage)masterPage).getAnalysisHandler().getAnalysis();
    }
    isContainRowCount=AnalysisHelper.containsRowCount(ana);
  }
  pLowerText.setEnabled(isContainRowCount);
  pHigherText.setEnabled(isContainRowCount);
}
Program: 139297
Project: 139297
Buggy source:
/** 
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated NOT
 */
public Double getMean(){
  Long c=getCount() - getNullCount();
  if (c.compareTo(0L) == 0) {
    throw new RuntimeException("String_Node_Str");
  }
  Double sum=null;
  try {
    sum=Double.valueOf(getSumStr());
  }
 catch (  Exception e) {
    return Double.NaN;
  }
  if (sum == null) {
    throw new RuntimeException("String_Node_Str");
  }
  return sum / c;
}

Fixed version (ground truth):
/** 
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated NOT
 */
public Double getMean(){
  Long c=getCount();
  if (c.compareTo(0L) == 0) {
    throw new RuntimeException("String_Node_Str");
  }
  Double sum=null;
  try {
    sum=Double.valueOf(getSumStr());
  }
 catch (  Exception e) {
    return Double.NaN;
  }
  if (sum == null) {
    throw new RuntimeException("String_Node_Str");
  }
  return sum / c;
}
Program: 139298
Project: 139298
Buggy source:
@Override protected ReturnCode canRun(){
  ModelElementIndicator[] modelElementIndicators=treeViewer.getModelElementIndicator();
  if (modelElementIndicators == null || modelElementIndicators.length == 0) {
    return new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str"),false);
  }
  for (  ModelElementIndicator modelElementIndicator : modelElementIndicators) {
    if (modelElementIndicator.getIndicators().length == 0) {
      return new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str"),false);
    }
  }
  return new ReturnCode(true);
}

Fixed version (ground truth):
@Override protected ReturnCode canRun(){
  ReturnCode checkMdmExecutionEngine=checkMdmExecutionEngine();
  if (!checkMdmExecutionEngine.isOk()) {
    return checkMdmExecutionEngine;
  }
  ModelElementIndicator[] modelElementIndicators=treeViewer.getModelElementIndicator();
  if (modelElementIndicators == null || modelElementIndicators.length == 0) {
    return new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str"),false);
  }
  for (  ModelElementIndicator modelElementIndicator : modelElementIndicators) {
    if (modelElementIndicator.getIndicators().length == 0) {
      return new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str"),false);
    }
  }
  return new ReturnCode(true);
}
Program: 139299
Project: 139299
Buggy source:
@Override protected ReturnCode canSave(){
  ModelElementIndicator[] modelElementIndicators=treeViewer.getModelElementIndicator();
  if (modelElementIndicators != null && modelElementIndicators.length != 0) {
    analysis.getContext().setConnection(ModelElementIndicatorHelper.getTdDataProvider(modelElementIndicators[0]));
  }
  if (analysisHandler.isMdmConnection() && ExecutionLanguage.JAVA.getLiteral().equals(this.execLang)) {
    return new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str"),false);
  }
  List<ModelElement> analyzedElement=new ArrayList<ModelElement>();
  for (  ModelElementIndicator modelElementIndicator : treeViewer.getModelElementIndicator()) {
    analyzedElement.add(modelElementIndicator.getModelElement());
  }
  if (!analyzedElement.isEmpty()) {
    if (!ModelElementHelper.isFromSameConnection(analyzedElement)) {
      return new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str"),false);
    }
    if (!ModelElementHelper.isFromSameTable(analyzedElement) && !"String_Node_Str".equals(dataFilterComp.getDataFilterString())) {
      return new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str"),false);
    }
  }
  return new ReturnCode(true);
}

Fixed version (ground truth):
@Override protected ReturnCode canSave(){
  ReturnCode checkMdmExecutionEngine=checkMdmExecutionEngine();
  if (!checkMdmExecutionEngine.isOk()) {
    return checkMdmExecutionEngine;
  }
  List<ModelElement> analyzedElement=new ArrayList<ModelElement>();
  for (  ModelElementIndicator modelElementIndicator : treeViewer.getModelElementIndicator()) {
    analyzedElement.add(modelElementIndicator.getModelElement());
  }
  if (!analyzedElement.isEmpty()) {
    if (!ModelElementHelper.isFromSameConnection(analyzedElement)) {
      return new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str"),false);
    }
    if (!ModelElementHelper.isFromSameTable(analyzedElement) && !"String_Node_Str".equals(dataFilterComp.getDataFilterString())) {
      return new ReturnCode(DefaultMessagesImpl.getString("String_Node_Str"),false);
    }
  }
  return new ReturnCode(true);
}
Program: 139300
Project: 139300
Buggy source:
public static IFolderNode[] getFolderNodes(EObject eObject){
  IFolderNode[] folderNodes=catalogFolderNodeMap.get(eObject);
  if (folderNodes != null) {
    return folderNodes;
  }
 else   if (SwitchHelpers.CATALOG_SWITCH.doSwitch(eObject) != null) {
    return createTableViewNodes(eObject);
  }
 else   if (SwitchHelpers.SCHEMA_SWITCH.doSwitch(eObject) != null) {
    return createTableViewNodes(eObject);
  }
 else   if (SwitchHelpers.TABLE_SWITCH.doSwitch(eObject) != null) {
    return createColumFolderNodes(eObject);
  }
 else   if (SwitchHelpers.VIEW_SWITCH.doSwitch(eObject) != null) {
    return createColumFolderNodes(eObject);
  }
  return folderNodes;
}

Fixed version (ground truth):
public static IFolderNode[] getFolderNodes(EObject eObject){
  IFolderNode[] folderNodes=catalogFolderNodeMap.get(eObject);
  if (folderNodes != null) {
    return folderNodes;
  }
 else   if (SwitchHelpers.CATALOG_SWITCH.doSwitch(eObject) != null) {
    return createTableViewNodes(eObject);
  }
 else   if (SwitchHelpers.SCHEMA_SWITCH.doSwitch(eObject) != null) {
    return createTableViewNodes(eObject);
  }
 else   if (SwitchHelpers.TABLE_SWITCH.doSwitch(eObject) != null) {
    return createColumFolderNodes(eObject);
  }
 else   if (SwitchHelpers.VIEW_SWITCH.doSwitch(eObject) != null) {
    return createColumFolderNodes(eObject);
  }
  return folderNodes == null ? new IFolderNode[]{} : folderNodes;
}
Program: 139301
Project: 139301
Buggy source:
public boolean hasChildren(Object element){
  if (element instanceof EObject) {
    EObject eobject=(EObject)element;
    if (SwitchHelpers.XMLELEMENT_SWITCH.doSwitch(eobject) != null) {
      return DqRepositoryViewService.hasChildren((TdXMLElement)element);
    }
    if (SwitchHelpers.COLUMN_SWITCH.doSwitch(eobject) != null) {
      return false;
    }
    if (eobject instanceof IndicatorDefinition) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
public boolean hasChildren(Object element){
  if (element instanceof EObject) {
    EObject eobject=(EObject)element;
    if (SwitchHelpers.XMLELEMENT_SWITCH.doSwitch(eobject) != null) {
      return DqRepositoryViewService.hasChildren((TdXMLElement)element);
    }
    return checkLeaf(eobject);
  }
  return true;
}
Program: 139302
Project: 139302
Buggy source:
@Override public boolean storeSqlResults(List<Object[]> objects){
  if (!checkResults(objects,2)) {
    return false;
  }
  String s=String.valueOf(objects.get(0)[0]);
  String c=String.valueOf(objects.get(0)[1]);
  this.setSumStr(s);
  this.setCount(Long.valueOf(c));
  return true;
}

Fixed version (ground truth):
@Override public boolean storeSqlResults(List<Object[]> objects){
  if (!checkResults(objects,2)) {
    return false;
  }
  String s=String.valueOf(objects.get(0)[0]);
  String c=String.valueOf(objects.get(0)[1]);
  if (!NumberUtils.isNumber(s)) {
    s="String_Node_Str";
  }
  if (!NumberUtils.isNumber(c)) {
    c="String_Node_Str";
  }
  this.setSumStr(s);
  this.setCount(Long.valueOf(c));
  return true;
}
Program: 139303
Project: 139303
Buggy source:
/** 
 * yyi 2009-11-30 10187 check schema is exist in DB
 * @param catName
 * @return
 */
public boolean checkSchema(TdSchema schema){
  EObject container=schema.eContainer();
  if (container != null) {
    TdCatalog catalog=SwitchHelpers.CATALOG_SWITCH.doSwitch(container);
    if (catalog != null) {
      try {
        connection.setCatalog(catalog.getName());
        DatabaseContentRetriever.getCatalogs(connection);
        List<TdSchema> schemas=connection.getMetaData().getDriverName().equals(DatabaseConstant.MSSQL_DRIVER_NAME_JDBC2_0) ? DatabaseContentRetriever.getMSSQLSchemas(connection).get(catalog.getName()) : DatabaseContentRetriever.getSchemas(connection).get(catalog.getName());
        for (        TdSchema tdSchema : schemas) {
          if (tdSchema.getName().equals(schema.getName()))           return true;
        }
        return false;
      }
 catch (      SQLException e) {
        log.error(e);
      }
    }
  }
  return checkSchemaByName(schema.getName());
}

Fixed version (ground truth):
/** 
 * yyi 2009-11-30 10187 check schema is exist in DB
 * @param catName
 * @return
 */
public boolean checkSchema(TdSchema schema){
  EObject container=schema.eContainer();
  if (container != null) {
    TdCatalog catalog=SwitchHelpers.CATALOG_SWITCH.doSwitch(container);
    if (catalog != null) {
      try {
        connection.setCatalog(catalog.getName());
        DatabaseContentRetriever.getCatalogs(connection);
        List<TdSchema> schemas=null;
        if (connection.getMetaData().getDriverName().equals(DatabaseConstant.MSSQL_DRIVER_NAME_JDBC2_0)) {
          schemas=DatabaseContentRetriever.getMSSQLSchemas(connection).get(catalog.getName());
        }
 else         if (ConnectionUtils.isPostgresql(connection)) {
          schemas=DatabaseContentRetriever.getSchemas(connection).get(null);
        }
 else {
          schemas=DatabaseContentRetriever.getSchemas(connection).get(catalog.getName());
        }
        if (schemas != null) {
          for (          TdSchema tdSchema : schemas) {
            if (tdSchema.getName().equals(schema.getName()))             return true;
          }
        }
        return false;
      }
 catch (      SQLException e) {
        log.error(e);
      }
    }
  }
  return checkSchemaByName(schema.getName());
}
Program: 139305
Project: 139305
Buggy source:
/** 
 * DOC xqliu Comment method "storeSqlResultsMatching".
 * @param objects
 * @return
 */
public boolean storeSqlResultsMatching(List<Object[]> objects){
  if (!checkResults(objects,2)) {
    return false;
  }
  Long match=Long.valueOf(String.valueOf(objects.get(0)[0]));
  Long total=Long.valueOf(String.valueOf(objects.get(0)[1]));
  if (match != null) {
    this.setMatchingValueCount(match);
  }
  if (total != null) {
    this.setCount(total);
  }
  if (total != null && match != null) {
    this.setNotMatchingValueCount(total - match);
  }
  return true;
}

Fixed version (ground truth):
/** 
 * DOC xqliu Comment method "storeSqlResultsMatching".
 * @param objects
 * @return
 */
private boolean storeSqlResultsMatching(List<Object[]> objects){
  if (!checkResults(objects,2)) {
    return false;
  }
  Long match=Long.valueOf(String.valueOf(objects.get(0)[0]));
  Long total=Long.valueOf(String.valueOf(objects.get(0)[1]));
  if (match != null) {
    this.setMatchingValueCount(match);
  }
  if (total != null) {
    this.setCount(total);
  }
  if (total != null && match != null) {
    this.setNotMatchingValueCount(total - match);
  }
  return true;
}
Program: 139306
Project: 139306
Buggy source:
/** 
 * DOC xqliu Comment method "storeSqlResultsFrequency".
 * @param objects
 * @return
 */
public boolean storeSqlResultsFrequency(List<Object[]> objects){
  int nbColumns=2;
  if (hasDateGrainParameter()) {
    DateGrain dategrain=getParameters().getDateParameters().getDateAggregationType();
switch (dategrain) {
case DAY:
      nbColumns++;
case WEEK:
    nbColumns++;
case MONTH:
  nbColumns++;
case QUARTER:
nbColumns++;
case YEAR:
break;
default :
break;
}
}
if (objects.isEmpty()) {
if (log.isInfoEnabled()) {
log.info("String_Node_Str" + "String_Node_Str");
}
this.setValueToFreq(new HashMap<Object,Long>());
return true;
}
if (!checkResults(objects,nbColumns)) {
return false;
}
HashMap<Object,Long> mapVal2Freq=new HashMap<Object,Long>();
boolean debug=log.isDebugEnabled();
StringBuffer matrix=debug ? new StringBuffer() : null;
for (Object[] value2freq : objects) {
if (value2freq.length != nbColumns) {
log.error("String_Node_Str");
return false;
}
Object value=getValueFields(value2freq);
Long freq=Long.valueOf(String.valueOf(value2freq[nbColumns - 1]));
mapVal2Freq.put(value,freq);
if (debug) {
matrix.append("String_Node_Str").append("String_Node_Str").append(value).append("String_Node_Str").append("String_Node_Str").append(freq);
}
}
if (debug) {
log.debug(matrix);
}
this.setValueToFreq(mapVal2Freq);
return true;
}

Fixed version (ground truth):
/** 
 * DOC xqliu Comment method "storeSqlResultsFrequency".
 * @param objects
 * @return
 */
private boolean storeSqlResultsFrequency(List<Object[]> objects){
  int nbColumns=2;
  if (hasDateGrainParameter()) {
    DateGrain dategrain=getParameters().getDateParameters().getDateAggregationType();
switch (dategrain) {
case DAY:
      nbColumns++;
case WEEK:
    nbColumns++;
case MONTH:
  nbColumns++;
case QUARTER:
nbColumns++;
case YEAR:
break;
default :
break;
}
}
if (objects.isEmpty()) {
if (log.isInfoEnabled()) {
log.info("String_Node_Str" + "String_Node_Str");
}
this.setValueToFreq(new HashMap<Object,Long>());
return true;
}
if (!checkResults(objects,nbColumns)) {
return false;
}
HashMap<Object,Long> mapVal2Freq=new HashMap<Object,Long>();
boolean debug=log.isDebugEnabled();
StringBuffer matrix=debug ? new StringBuffer() : null;
for (Object[] value2freq : objects) {
if (value2freq.length != nbColumns) {
log.error("String_Node_Str");
return false;
}
Object value=getValueFields(value2freq);
Long freq=Long.valueOf(String.valueOf(value2freq[nbColumns - 1]));
mapVal2Freq.put(value,freq);
if (debug) {
matrix.append("String_Node_Str").append("String_Node_Str").append(value).append("String_Node_Str").append("String_Node_Str").append(freq);
}
}
if (debug) {
log.debug(matrix);
}
this.setValueToFreq(mapVal2Freq);
return true;
}
Program: 139307
Project: 139307
Buggy source:
/** 
 * DOC xqliu Comment method "storeSqlResultsRowCount".
 * @param objects
 * @return
 */
public boolean storeSqlResultsRowCount(List<Object[]> objects){
  if (!checkResults(objects,1)) {
    return false;
  }
  Long c=Long.valueOf(String.valueOf(objects.get(0)[0]));
  this.setUserCount(c);
  return true;
}

Fixed version (ground truth):
/** 
 * DOC xqliu Comment method "storeSqlResultsRowCount".
 * @param objects
 * @return
 */
private boolean storeSqlResultsRowCount(List<Object[]> objects){
  if (!checkResults(objects,1)) {
    return false;
  }
  Long c=Long.valueOf(String.valueOf(objects.get(0)[0]));
  this.setUserCount(c);
  return true;
}
Program: 139308
Project: 139308
Buggy source:
/** 
 * yyi 2009-11-30 10187 check schema is exist in DB
 * @param catName
 * @return
 */
public boolean checkSchema(TdSchema schema){
  TdCatalog catalog=SwitchHelpers.CATALOG_SWITCH.doSwitch(schema.eContainer());
  if (catalog != null) {
    try {
      connection.setCatalog(catalog.getName());
      DatabaseContentRetriever.getCatalogs(connection);
      List<TdSchema> schemas=connection.getMetaData().getDriverName().equals(DatabaseConstant.MSSQL_DRIVER_NAME_JDBC2_0) ? DatabaseContentRetriever.getMSSQLSchemas(connection).get(catalog.getName()) : DatabaseContentRetriever.getSchemas(connection).get(catalog.getName());
      for (      TdSchema tdSchema : schemas) {
        if (tdSchema.getName().equals(schema.getName()))         return true;
      }
      return false;
    }
 catch (    SQLException e) {
      log.error(e);
    }
  }
  return checkSchemaByName(schema.getName());
}

Fixed version (ground truth):
/** 
 * yyi 2009-11-30 10187 check schema is exist in DB
 * @param catName
 * @return
 */
public boolean checkSchema(TdSchema schema){
  EObject container=schema.eContainer();
  if (container != null) {
    TdCatalog catalog=SwitchHelpers.CATALOG_SWITCH.doSwitch(container);
    if (catalog != null) {
      try {
        connection.setCatalog(catalog.getName());
        DatabaseContentRetriever.getCatalogs(connection);
        List<TdSchema> schemas=connection.getMetaData().getDriverName().equals(DatabaseConstant.MSSQL_DRIVER_NAME_JDBC2_0) ? DatabaseContentRetriever.getMSSQLSchemas(connection).get(catalog.getName()) : DatabaseContentRetriever.getSchemas(connection).get(catalog.getName());
        for (        TdSchema tdSchema : schemas) {
          if (tdSchema.getName().equals(schema.getName()))           return true;
        }
        return false;
      }
 catch (      SQLException e) {
        log.error(e);
      }
    }
  }
  return checkSchemaByName(schema.getName());
}
Program: 139309
Project: 139309
Buggy source:
@Override protected ReturnCode executeSqlQuery(String sqlStatement) throws SQLException {
  ReturnCode ok=new ReturnCode(true);
  DataProvider dataProvider=this.getDataManager();
  if (this.elementToIndicators.values().isEmpty()) {
    String msg="String_Node_Str";
    log.error(msg);
    ok.setReturnCode(msg,false);
    return ok;
  }
  Indicator[] indics=this.getAllIndicators();
  if (indics.length == 0) {
    String msg="String_Node_Str" + dataProvider;
    log.error(msg);
    ok.setReturnCode(msg,false);
    return ok;
  }
  for (  Indicator indicator : indics) {
    SchemaIndicator schemaIndicator=DataqualitySwitchHelper.SCHEMA_SWITCH.doSwitch(indicator);
    if (schemaIndicator == null) {
      continue;
    }
    TdSchema schema=(TdSchema)schemaIndicator.getAnalyzedElement();
    String catName=schema.getName();
    if (!checkSchema(schema)) {
      ok.setReturnCode(Messages.getString("String_Node_Str",catName),false);
      return ok;
    }
    TdCatalog catalog=SwitchHelpers.CATALOG_SWITCH.doSwitch(schema.eContainer());
    if (catalog != null) {
      catName=catalog.getName();
    }
    connection.setCatalog(catName);
    evalSchemaIndicLow(null,schemaIndicator,null,schema,ok);
  }
  return ok;
}

Fixed version (ground truth):
@Override protected ReturnCode executeSqlQuery(String sqlStatement) throws SQLException {
  ReturnCode ok=new ReturnCode(true);
  DataProvider dataProvider=this.getDataManager();
  if (this.elementToIndicators.values().isEmpty()) {
    String msg="String_Node_Str";
    log.error(msg);
    ok.setReturnCode(msg,false);
    return ok;
  }
  Indicator[] indics=this.getAllIndicators();
  if (indics.length == 0) {
    String msg="String_Node_Str" + dataProvider;
    log.error(msg);
    ok.setReturnCode(msg,false);
    return ok;
  }
  for (  Indicator indicator : indics) {
    SchemaIndicator schemaIndicator=DataqualitySwitchHelper.SCHEMA_SWITCH.doSwitch(indicator);
    if (schemaIndicator == null) {
      continue;
    }
    TdSchema schema=(TdSchema)schemaIndicator.getAnalyzedElement();
    String catName=schema.getName();
    if (!checkSchema(schema)) {
      ok.setReturnCode(Messages.getString("String_Node_Str",catName),false);
      return ok;
    }
    EObject container=schema.eContainer();
    if (container != null) {
      TdCatalog catalog=SwitchHelpers.CATALOG_SWITCH.doSwitch(container);
      if (catalog != null) {
        catName=catalog.getName();
      }
    }
    connection.setCatalog(catName);
    evalSchemaIndicLow(null,schemaIndicator,null,schema,ok);
  }
  return ok;
}
Program: 139310
Project: 139310
Buggy source:
/** 
 * DOC xqliu Comment method "getRowsStatement".
 * @param valid
 * @return
 */
private String getRowsStatement(boolean valid){
  String dataFilterClause=this.getDataFilterClause();
  Indicator indicator2=this.indicator;
  TableAnalysisSqlExecutor tasExecutor=new TableAnalysisSqlExecutor();
  tasExecutor.setCachedAnalysis(this.analysis);
  if (valid) {
    return tasExecutor.getValidStatement(dataFilterClause,indicator2);
  }
 else {
    String non=valid ? "String_Node_Str" : "String_Node_Str";
    NamedColumnSet set=(NamedColumnSet)indicator2.getAnalyzedElement();
    String whereClause=((WhereRule)indicator2.getIndicatorDefinition()).getWhereExpression();
    return "String_Node_Str" + getFullyQualifiedTableName(set) + dbmsLanguage.where()+ non+ "String_Node_Str"+ whereClause+ "String_Node_Str";
  }
}

Fixed version (ground truth):
/** 
 * DOC xqliu Comment method "getRowsStatement".
 * @param valid
 * @return
 */
private String getRowsStatement(boolean valid){
  String dataFilterClause=this.getDataFilterClause();
  Indicator indicator2=this.indicator;
  TableAnalysisSqlExecutor tasExecutor=new TableAnalysisSqlExecutor();
  tasExecutor.setCachedAnalysis(this.analysis);
  if (valid) {
    return tasExecutor.getValidStatement(dataFilterClause,indicator2);
  }
 else {
    NamedColumnSet set=(NamedColumnSet)indicator2.getAnalyzedElement();
    String whereClause=((WhereRule)indicator2.getIndicatorDefinition()).getWhereExpression();
    return "String_Node_Str" + getFullyQualifiedTableName(set) + dbmsLanguage.where()+ dbmsLanguage.not()+ "String_Node_Str"+ whereClause+ "String_Node_Str"+ andDataFilterClause();
  }
}
Program: 139311
Project: 139311
Buggy source:
/** 
 * return Column or TdXMLElement analysis executor. ADD xqliu bug 10238 2009-12-24
 * @param analysis
 * @param executionEngine
 * @return
 */
private static AnalysisExecutor getModelElementAnalysisExecutor(Analysis analysis,ExecutionLanguage executionEngine){
  TypedReturnCode<TdProviderConnection> rc=DataProviderHelper.getTdProviderConnection((DataProvider)analysis.getContext().getConnection());
  boolean mdm=ConnectionUtils.isMdmConnection(rc.getObject());
  boolean sql=ExecutionLanguage.SQL.equals(executionEngine);
  if (mdm) {
    return sql ? new MdmAnalysisSqlExecutor() : new MdmAnalysisExecutor();
  }
 else {
    if (analysis != null) {
      try {
        TypedReturnCode<Connection> connection=getConnection(analysis);
        if (connection.isOk()) {
          if (ConnectionUtils.isOdbcConnection(connection.getObject())) {
            ConnectionUtils.closeConnection(connection.getObject());
            return new ColumnAnalysisExecutor();
          }
        }
 else {
          ConnectionUtils.closeConnection(connection.getObject());
          log.error(connection.getMessage());
        }
      }
 catch (      SQLException e) {
        e.printStackTrace();
      }
    }
    return sql ? new ColumnAnalysisSqlExecutor() : new ColumnAnalysisExecutor();
  }
}

Fixed version (ground truth):
/** 
 * return Column or TdXMLElement analysis executor. ADD xqliu bug 10238 2009-12-24
 * @param analysis
 * @param executionEngine
 * @return
 */
private static AnalysisExecutor getModelElementAnalysisExecutor(Analysis analysis,ExecutionLanguage executionEngine){
  TypedReturnCode<TdProviderConnection> rc=DataProviderHelper.getTdProviderConnection((DataProvider)analysis.getContext().getConnection());
  boolean mdm=ConnectionUtils.isMdmConnection(rc.getObject());
  boolean sql=ExecutionLanguage.SQL.equals(executionEngine);
  if (mdm) {
    return sql ? new MdmAnalysisSqlExecutor() : new MdmAnalysisExecutor();
  }
 else {
    return sql ? new ColumnAnalysisSqlExecutor() : new ColumnAnalysisExecutor();
  }
}
Program: 139312
Project: 139312
Buggy source:
@Override protected ReturnCode executeSqlQuery(String sqlStatement) throws SQLException {
  ReturnCode ok=new ReturnCode(true);
  DataProvider dataProvider=this.getDataManager();
  if (this.elementToIndicators.values().isEmpty()) {
    String msg="String_Node_Str";
    log.error(msg);
    ok.setReturnCode(msg,false);
    return ok;
  }
  Indicator[] indics=this.getAllIndicators();
  if (indics.length == 0) {
    String msg="String_Node_Str" + dataProvider;
    log.error(msg);
    ok.setReturnCode(msg,false);
    return ok;
  }
  for (  Indicator indicator : indics) {
    SchemaIndicator schemaIndicator=DataqualitySwitchHelper.SCHEMA_SWITCH.doSwitch(indicator);
    if (schemaIndicator == null) {
      continue;
    }
    TdSchema schema=(TdSchema)schemaIndicator.getAnalyzedElement();
    String catName=schema.getName();
    if (!checkSchema(catName)) {
      ok.setReturnCode(Messages.getString("String_Node_Str",catName),false);
      return ok;
    }
    connection.setCatalog(catName);
    evalSchemaIndicLow(null,schemaIndicator,null,schema,ok);
  }
  return ok;
}

Fixed version (ground truth):
@Override protected ReturnCode executeSqlQuery(String sqlStatement) throws SQLException {
  ReturnCode ok=new ReturnCode(true);
  DataProvider dataProvider=this.getDataManager();
  if (this.elementToIndicators.values().isEmpty()) {
    String msg="String_Node_Str";
    log.error(msg);
    ok.setReturnCode(msg,false);
    return ok;
  }
  Indicator[] indics=this.getAllIndicators();
  if (indics.length == 0) {
    String msg="String_Node_Str" + dataProvider;
    log.error(msg);
    ok.setReturnCode(msg,false);
    return ok;
  }
  for (  Indicator indicator : indics) {
    SchemaIndicator schemaIndicator=DataqualitySwitchHelper.SCHEMA_SWITCH.doSwitch(indicator);
    if (schemaIndicator == null) {
      continue;
    }
    TdSchema schema=(TdSchema)schemaIndicator.getAnalyzedElement();
    String catName=schema.getName();
    TdCatalog catalog=SwitchHelpers.CATALOG_SWITCH.doSwitch(schema.eContainer());
    if (catalog != null) {
      catName=catalog.getName();
    }
    if (!checkSchema(catName)) {
      ok.setReturnCode(Messages.getString("String_Node_Str",catName),false);
      return ok;
    }
    connection.setCatalog(catName);
    evalSchemaIndicLow(null,schemaIndicator,null,schema,ok);
  }
  return ok;
}
Program: 139313
Project: 139313
Buggy source:
/** 
 * DOC scorreia Comment method "getTableName".
 * @param analyzedColumns
 * @return the quoted table name
 */
private String getTableName(final EList<Column> analyzedColumns){
  ColumnSet columnSetOwner=ColumnHelper.getColumnSetOwner(analyzedColumns.get(0));
  String tableName=columnSetOwner.getName();
  Package pack=ColumnSetHelper.getParentCatalogOrSchema(columnSetOwner);
  if (pack == null) {
    log.error("String_Node_Str" + tableName);
  }
 else {
    this.catalogOrSchema=pack.getName();
  }
  return quote(tableName);
}

Fixed version (ground truth):
/** 
 * DOC scorreia Comment method "getTableName".
 * @param analyzedColumns
 * @return the quoted table name
 */
private String getTableName(final EList<Column> analyzedColumns){
  ColumnSet columnSetOwner=ColumnHelper.getColumnSetOwner(analyzedColumns.get(0));
  String tableName=columnSetOwner.getName();
  Package pack=ColumnSetHelper.getParentCatalogOrSchema(columnSetOwner);
  if (pack == null) {
    log.error("String_Node_Str" + tableName);
  }
 else {
    this.catalogOrSchema=pack.getName();
  }
  String schemaName=getQuotedSchemaName(columnSetOwner);
  String catalogName=getQuotedCatalogName(columnSetOwner);
  if (catalogName == null && schemaName != null) {
    final TdSchema parentSchema=SchemaHelper.getParentSchema(columnSetOwner);
    final TdCatalog parentCatalog=CatalogHelper.getParentCatalog(parentSchema);
    catalogName=parentCatalog != null ? parentCatalog.getName() : null;
  }
  return dbms().toQualifiedName(catalogName,schemaName,tableName);
}
Program: 139315
Project: 139315
Buggy source:
/** 
 */
public void openColumnsSelectionDialog(){
  List<Column> columnList=treeViewer.getColumnSetMultiValueList();
  if (columnList == null) {
    columnList=new ArrayList<Column>();
  }
  ColumnsSelectionDialog dialog=new ColumnsSelectionDialog(this,null,DefaultMessagesImpl.getString("String_Node_Str"),columnList,DefaultMessagesImpl.getString("String_Node_Str"));
  if (dialog.open() == Window.OK) {
    Object[] columns=dialog.getResult();
    treeViewer.setInput(columns);
    return;
  }
}

Fixed version (ground truth):
/** 
 */
public void openColumnsSelectionDialog(){
  List<Column> columnList=treeViewer.getColumnSetMultiValueList();
  if (columnList == null) {
    columnList=new ArrayList<Column>();
  }
  ColumnsSelectionDialog dialog=new ColumnsSelectionDialog(this,null,DefaultMessagesImpl.getString("String_Node_Str"),columnList,DefaultMessagesImpl.getString("String_Node_Str"));
  if (dialog.open() == Window.OK) {
    Object[] columns=dialog.getResult();
    treeViewer.setInput(columns);
    indicatorsViewer.setInput(simpleStatIndicator);
    return;
  }
}
Program: 139316
Project: 139316
Buggy source:
@Override public void mouseDown(MouseEvent e){
  deleteColumnItems(column);
  removeItemBranch(treeItem);
}

Fixed version (ground truth):
@Override public void mouseDown(MouseEvent e){
  deleteColumnItems(column);
  removeItemBranch(treeItem);
  updateBindConnection(masterPage,tree);
}
Program: 139319
Project: 139319
Buggy source:
/** 
 * @param parent
 */
private Tree createTree(Composite parent){
  final Tree newTree=new Tree(parent,SWT.MULTI | SWT.BORDER);
  GridDataFactory.fillDefaults().align(SWT.FILL,SWT.FILL).grab(true,true).applyTo(newTree);
  newTree.setHeaderVisible(true);
  TreeColumn column1=new TreeColumn(newTree,SWT.CENTER);
  column1.setWidth(190);
  column1.setText(DefaultMessagesImpl.getString("String_Node_Str"));
  TreeColumn column2=new TreeColumn(newTree,SWT.CENTER);
  column2.setWidth(80);
  column2.setText(DefaultMessagesImpl.getString("String_Node_Str"));
  parent.layout();
  createTreeMenu(newTree,false);
  AbstractAnalysisActionHandler actionHandler=new AbstractAnalysisActionHandler(parent){
    @Override protected void handleRemove(){
      removeSelectedElements(newTree);
    }
  }
;
  parent.setData(AbstractMetadataFormPage.ACTION_HANDLER,actionHandler);
  addSourceDND(newTree);
  addTargetDND(newTree);
  addTreeListener(newTree);
  return newTree;
}

Fixed version (ground truth):
/** 
 * @param parent
 */
private Tree createTree(Composite parent){
  final Tree newTree=new Tree(parent,SWT.MULTI | SWT.BORDER);
  GridDataFactory.fillDefaults().align(SWT.FILL,SWT.FILL).grab(true,true).applyTo(newTree);
  newTree.setHeaderVisible(true);
  TreeColumn column1=new TreeColumn(newTree,SWT.CENTER);
  column1.setWidth(190);
  column1.setText(DefaultMessagesImpl.getString("String_Node_Str"));
  TreeColumn column2=new TreeColumn(newTree,SWT.CENTER);
  column2.setWidth(80);
  column2.setText(DefaultMessagesImpl.getString("String_Node_Str"));
  parent.layout();
  createTreeMenu(newTree,false);
  AbstractAnalysisActionHandler actionHandler=new AbstractAnalysisActionHandler(parent){
    @Override protected void handleRemove(){
      removeSelectedElements(newTree);
      updateBindConnection(masterPage,tree);
    }
  }
;
  parent.setData(AbstractMetadataFormPage.ACTION_HANDLER,actionHandler);
  addSourceDND(newTree);
  addTargetDND(newTree);
  addTreeListener(newTree);
  return newTree;
}
Program: 139320
Project: 139320
Buggy source:
@Override protected void handleRemove(){
  removeSelectedElements(newTree);
}

Fixed version (ground truth):
@Override protected void handleRemove(){
  removeSelectedElements(newTree);
  updateBindConnection(masterPage,tree);
}
Program: 139321
Project: 139321
Buggy source:
public static Package getCatalogOrSchema(EObject element){
  if (element == null) {
    return null;
  }
  TdCatalog res=SwitchHelpers.CATALOG_SWITCH.doSwitch(element);
  if (res != null) {
    return res;
  }
  return SwitchHelpers.SCHEMA_SWITCH.doSwitch(element);
}

Fixed version (ground truth):
public static Package getCatalogOrSchema(EObject element){
  if (element == null) {
    return null;
  }
  EObject eContainer=element.eContainer();
  if (eContainer != null) {
    return getCatalogOrSchema(eContainer);
  }
  TdCatalog res=SwitchHelpers.CATALOG_SWITCH.doSwitch(element);
  if (res != null) {
    return res;
  }
  return SwitchHelpers.SCHEMA_SWITCH.doSwitch(element);
}
Program: 139323
Project: 139323
Buggy source:
public boolean execute(){
  IFile talendDefinitionFile=DefinitionHandler.getTalendDefinitionFile();
  if (talendDefinitionFile.exists()) {
    try {
    }
 catch (    Exception e) {
      log.error(e,e);
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
public boolean execute(){
  IFile talendDefinitionFile=DefinitionHandler.getTalendDefinitionFile();
  if (talendDefinitionFile.exists()) {
    try {
      talendDefinitionFile.delete(true,null);
      IFolder librariesFolder=ResourceManager.getLibrariesFolder();
      DefinitionHandler.getInstance().copyDefinitionsIntoFolder(librariesFolder);
    }
 catch (    Exception e) {
      log.error(e,e);
      return false;
    }
  }
  return true;
}
Program: 139325
Project: 139325
Buggy source:
private static boolean checkQuotes(String[] values){
  for (  String value : values) {
    if (!value.matches("String_Node_Str"))     return false;
  }
  return true;
}

Fixed version (ground truth):
private static boolean checkQuotes(String[] values){
  for (  String value : values) {
    if (!checkQuotationMarks(value))     return false;
  }
  return true;
}
Program: 139327
Project: 139327
Buggy source:
@Override public boolean canDrop(ModelElement modelElement){
  return false;
}

Fixed version (ground truth):
@Override public boolean canDrop(ModelElement modelElement){
  List<TdColumn> existColumns=new ArrayList<TdColumn>();
  for (  Column columnFromMultiValueList : this.getColumnSetMultiValueList()) {
    existColumns.add((TdColumn)columnFromMultiValueList);
  }
  if (existColumns.contains(modelElement)) {
    return false;
  }
  return true;
}
Program: 139328
Project: 139328
Buggy source:
@Override public void dropModelElements(List<? extends ModelElement> modelElements,int index){
}

Fixed version (ground truth):
@Override public void dropModelElements(List<? extends ModelElement> modelElements,int index){
  List<Column> columns=new ArrayList<Column>();
  for (  ModelElement element : modelElements) {
    TdColumn column=SwitchHelpers.COLUMN_SWITCH.doSwitch(element);
    if (column != null) {
      columns.add(column);
    }
  }
  this.addElements(columns,index);
}
Program: 139329
Project: 139329
Buggy source:
@Override public boolean canDrop(ModelElement modelElement){
  return false;
}

Fixed version (ground truth):
@Override public boolean canDrop(ModelElement modelElement){
  List<TdColumn> existColumns=new ArrayList<TdColumn>();
  for (  Column columnFromMultiValueList : this.getColumnSetMultiValueList()) {
    existColumns.add((TdColumn)columnFromMultiValueList);
  }
  if (existColumns.contains(modelElement)) {
    return false;
  }
  return true;
}
Program: 139330
Project: 139330
Buggy source:
@Override public void dropModelElements(List<? extends ModelElement> modelElements,int index){
}

Fixed version (ground truth):
@Override public void dropModelElements(List<? extends ModelElement> modelElements,int index){
  List<Column> columns=new ArrayList<Column>();
  for (  ModelElement element : modelElements) {
    TdColumn column=SwitchHelpers.COLUMN_SWITCH.doSwitch(element);
    if (column != null) {
      columns.add(column);
    }
  }
  this.addElements(columns,index);
}
Program: 139331
Project: 139331
Buggy source:
@Override public boolean canDrop(Column column){
  return false;
}

Fixed version (ground truth):
@Override public boolean canDrop(ModelElement modelElement){
  List<ModelElement> existModelElements=new ArrayList<ModelElement>();
  for (  ModelElementIndicator modelElementIndicator : this.getModelElementIndicator()) {
    existModelElements.add(modelElementIndicator.getModelElement());
  }
  if (existModelElements.contains(modelElement)) {
    return false;
  }
  if (modelElement instanceof TdXMLElement) {
    return XmlElementHelper.isLeafNode((TdXMLElement)modelElement);
  }
  return true;
}
Program: 139332
Project: 139332
Buggy source:
@Override public boolean canDrop(ModelElement modelElement){
  return false;
}

Fixed version (ground truth):
@Override public boolean canDrop(ModelElement modelElement){
  return true;
}
Program: 139333
Project: 139333
Buggy source:
@Override public void dropModelElements(List<? extends ModelElement> modelElements,int index){
}

Fixed version (ground truth):
@Override public void dropModelElements(List<? extends ModelElement> modelElements,int index){
  List<Column> columns=new ArrayList<Column>();
  for (  ModelElement element : modelElements) {
    TdColumn column=SwitchHelpers.COLUMN_SWITCH.doSwitch(element);
    if (column != null) {
      columns.add(column);
    }
  }
  JoinElementColumnDialog joinElementColumnDialog=new JoinElementColumnDialog(null);
  if (joinElementColumnDialog.open() == Window.OK) {
    JoinElement join=(JoinElement)this.myTableViewer.getElementAt(index);
    if (join == null) {
      join=this.addJoinElement();
    }
    if (join != null) {
      boolean dirty=false;
      for (      Column column : columns) {
        if (column != null) {
          if (!updateColumnSetPackage(column)) {
            break;
          }
          if (COLUMN_A.equals(joinElementColumnDialog.getAb())) {
            join.setColA(column);
            join.setColumnAliasA(column.getName());
            join.setTableAliasA(ColumnHelper.getColumnSetFullName(column));
            dirty=true;
          }
 else {
            join.setColB(column);
            join.setColumnAliasB(column.getName());
            join.setTableAliasB(ColumnHelper.getColumnSetFullName(column));
            dirty=true;
          }
        }
      }
      if (dirty) {
        this.masterPage.setDirty(true);
        this.myTableViewer.update(join,null);
      }
    }
  }
}
Program: 139335
Project: 139335
Buggy source:
/** 
 * yyi 2009-11-30 10187 check schema is exist in DB
 * @param catName
 * @return
 */
public boolean checkSchema(TdSchema schema){
  TdCatalog catalog=SwitchHelpers.CATALOG_SWITCH.doSwitch(schema.eContainer());
  if (catalog != null) {
    try {
      connection.setCatalog(catalog.getName());
      List<TdSchema> schemas=DatabaseContentRetriever.getSchemas(connection).get(catalog.getName());
      for (      TdSchema tdSchema : schemas) {
        if (tdSchema.getName().equals(schema.getName()))         return true;
      }
      return false;
    }
 catch (    SQLException e) {
      log.error(e);
    }
  }
  return checkSchemaByName(schema.getName());
}

Fixed version (ground truth):
/** 
 * yyi 2009-11-30 10187 check schema is exist in DB
 * @param catName
 * @return
 */
public boolean checkSchema(TdSchema schema){
  TdCatalog catalog=SwitchHelpers.CATALOG_SWITCH.doSwitch(schema.eContainer());
  if (catalog != null) {
    try {
      connection.setCatalog(catalog.getName());
      DatabaseContentRetriever.getCatalogs(connection);
      List<TdSchema> schemas=connection.getMetaData().getDriverName().equals(DatabaseConstant.MSSQL_DRIVER_NAME_JDBC2_0) ? DatabaseContentRetriever.getMSSQLSchemas(connection).get(catalog.getName()) : DatabaseContentRetriever.getSchemas(connection).get(catalog.getName());
      for (      TdSchema tdSchema : schemas) {
        if (tdSchema.getName().equals(schema.getName()))         return true;
      }
      return false;
    }
 catch (    SQLException e) {
      log.error(e);
    }
  }
  return checkSchemaByName(schema.getName());
}
Program: 139336
Project: 139336
Buggy source:
public Map<String,String> getQueryMap(){
  Map<String,String> map=new HashMap<String,String>();
switch (this.indicatorEnum) {
case RowCountIndicatorEnum:
case NullCountIndicatorEnum:
case BlankCountIndicatorEnum:
case DefValueCountIndicatorEnum:
    map.put(MENU_VIEW_ROWS,getRowsStatement());
  break;
case UniqueIndicatorEnum:
map.put(MENU_VIEW_ROWS,getRowsStatementWithSubQuery());
map.put(MENU_VIEW_VALUES,getValuesStatement(this.columnName));
break;
case DistinctCountIndicatorEnum:
map.put(MENU_VIEW_VALUES,getDistinctValuesStatement(this.columnName));
break;
case DuplicateCountIndicatorEnum:
map.put(MENU_VIEW_ROWS,getRowsStatementWithSubQuery());
map.put(MENU_VIEW_VALUES,getValuesStatement(this.columnName));
break;
default :
}
return map;
}

Fixed version (ground truth):
public Map<String,String> getQueryMap(){
  Map<String,String> map=new HashMap<String,String>();
  if (!isXml()) {
switch (this.indicatorEnum) {
case RowCountIndicatorEnum:
case NullCountIndicatorEnum:
case BlankCountIndicatorEnum:
case DefValueCountIndicatorEnum:
      map.put(MENU_VIEW_ROWS,getRowsStatement());
    break;
case UniqueIndicatorEnum:
  map.put(MENU_VIEW_ROWS,getRowsStatementWithSubQuery());
map.put(MENU_VIEW_VALUES,getValuesStatement(this.columnName));
break;
case DistinctCountIndicatorEnum:
map.put(MENU_VIEW_VALUES,getDistinctValuesStatement(this.columnName));
break;
case DuplicateCountIndicatorEnum:
map.put(MENU_VIEW_ROWS,getRowsStatementWithSubQuery());
map.put(MENU_VIEW_VALUES,getValuesStatement(this.columnName));
break;
default :
}
}
return map;
}
Program: 139338
Project: 139338
Buggy source:
/** 
 * yyi 2009-11-30 10187 check schema is exist in DB
 * @param catName
 * @return
 */
public boolean checkSchema(String catName){
  if (0 == schemasName.size()) {
    Collection<TdSchema> schemas=new CatalogBuilder(connection).getSchemata();
    for (    TdSchema ts : schemas) {
      schemasName.add(ts.getName());
    }
  }
  if (!schemasName.contains(catName)) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * yyi 2009-11-30 10187 check schema is exist in DB
 * @param catName
 * @return
 */
public boolean checkSchema(TdSchema schema){
  TdCatalog catalog=SwitchHelpers.CATALOG_SWITCH.doSwitch(schema.eContainer());
  if (catalog != null) {
    try {
      connection.setCatalog(catalog.getName());
      List<TdSchema> schemas=DatabaseContentRetriever.getSchemas(connection).get(catalog.getName());
      for (      TdSchema tdSchema : schemas) {
        if (tdSchema.getName().equals(schema.getName()))         return true;
      }
      return false;
    }
 catch (    SQLException e) {
      log.error(e);
    }
  }
  return checkSchemaByName(schema.getName());
}