Program: 101976
Project: 101976
Buggy source:
/** 
 * Create EMF ForeignKey from the supplied RelationalReference
 * @param ref the relational fk object
 * @param baseTable the table parent of the fk
 * @param modelResource the model resource
 * @return the foreign key object
 */
public EObject createForeignKey(RelationalReference ref,BaseTable baseTable,ModelResource modelResource){
  CoreArgCheck.isInstanceOf(RelationalForeignKey.class,ref);
  RelationalForeignKey fkRef=(RelationalForeignKey)ref;
  final ForeignKey foreignKey=FACTORY.createForeignKey();
  foreignKey.setTable(baseTable);
  foreignKey.setName(fkRef.getName());
  foreignKey.setNameInSource(fkRef.getNameInSource());
  foreignKey.setForeignKeyMultiplicity(getMultiplictyKind(fkRef.getForeignKeyMultiplicity()));
  foreignKey.setPrimaryKeyMultiplicity(getMultiplictyKind(fkRef.getPrimaryKeyMultiplicity()));
  final List keyColumns=foreignKey.getColumns();
  for (  RelationalColumn relColumn : fkRef.getColumns()) {
    Column column=getColumn(relColumn.getName(),baseTable);
    if (column != null) {
      keyColumns.add(column);
    }
  }
  BaseTable fkTable=getTable(fkRef.getUniqueKeyTableName(),modelResource);
  String ukRefName=fkRef.getUniqueKeyName();
  if (fkTable != null && ukRefName != null) {
    if (fkTable.getPrimaryKey() != null && fkTable.getPrimaryKey().getName().equalsIgnoreCase(ukRefName)) {
      foreignKey.setUniqueKey(fkTable.getPrimaryKey());
    }
 else     if (fkTable.getUniqueConstraints().isEmpty()) {
      for (      Object key : fkTable.getUniqueConstraints()) {
        String keyName=this.modelEditor.getName((UniqueKey)key);
        if (keyName.equalsIgnoreCase(ukRefName)) {
          foreignKey.setUniqueKey((UniqueKey)key);
        }
      }
    }
  }
  updateDeferredList(fkRef,foreignKey);
  return foreignKey;
}

Fixed version (ground truth):
/** 
 * Create EMF ForeignKey from the supplied RelationalReference
 * @param ref the relational fk object
 * @param baseTable the table parent of the fk
 * @param modelResource the model resource
 * @return the foreign key object
 */
public EObject createForeignKey(RelationalReference ref,BaseTable baseTable,ModelResource modelResource){
  CoreArgCheck.isInstanceOf(RelationalForeignKey.class,ref);
  RelationalForeignKey fkRef=(RelationalForeignKey)ref;
  final ForeignKey foreignKey=FACTORY.createForeignKey();
  foreignKey.setTable(baseTable);
  foreignKey.setName(fkRef.getName());
  foreignKey.setNameInSource(fkRef.getNameInSource());
  foreignKey.setForeignKeyMultiplicity(getMultiplictyKind(fkRef.getForeignKeyMultiplicity()));
  foreignKey.setPrimaryKeyMultiplicity(getMultiplictyKind(fkRef.getPrimaryKeyMultiplicity()));
  final List keyColumns=foreignKey.getColumns();
  for (  RelationalColumn relColumn : fkRef.getColumns()) {
    Column column=getColumn(relColumn.getName(),baseTable);
    if (column != null) {
      keyColumns.add(column);
    }
  }
  BaseTable fkTable=getTable(fkRef.getUniqueKeyTableName(),modelResource);
  String ukRefName=fkRef.getUniqueKeyName();
  if (fkTable != null && ukRefName != null) {
    if (fkTable.getPrimaryKey() != null && fkTable.getPrimaryKey().getName().equalsIgnoreCase(ukRefName)) {
      foreignKey.setUniqueKey(fkTable.getPrimaryKey());
    }
 else     if (fkTable.getUniqueConstraints().isEmpty()) {
      for (      Object key : fkTable.getUniqueConstraints()) {
        String keyName=this.getModelEditor().getName((UniqueKey)key);
        if (keyName.equalsIgnoreCase(ukRefName)) {
          foreignKey.setUniqueKey((UniqueKey)key);
        }
      }
    }
  }
  updateDeferredList(fkRef,foreignKey);
  return foreignKey;
}