Program: 129065
Project: 129065
Buggy source:
public static void addTableForTemCatalogOrSchema(String dbsid,String schema,DatabaseConnection connection,MetadataTable dbtable,IMetadataConnection iMetadataConnection){
  boolean hasSchemaInCatalog=false;
  Catalog c=(Catalog)ConnectionHelper.getPackage(dbsid,connection,Catalog.class);
  Schema s=(Schema)ConnectionHelper.getPackage(schema,connection,Schema.class);
  List<Schema> subschemas=new ArrayList<Schema>();
  if (c != null) {
    subschemas=CatalogHelper.getSchemas(c);
    hasSchemaInCatalog=subschemas.size() > 0;
  }
  if (c != null && s == null && !hasSchemaInCatalog) {
    PackageHelper.addMetadataTable(dbtable,c);
  }
 else   if (s != null && !hasSchemaInCatalog && c == null) {
    PackageHelper.addMetadataTable(dbtable,s);
  }
 else   if (c != null && hasSchemaInCatalog) {
    subschemas=CatalogHelper.getSchemas(c);
    hasSchemaInCatalog=subschemas.size() > 0;
    if (subschemas.size() > 0) {
      for (      Schema current : subschemas) {
        if (current.getName().equals(schema)) {
          s=current;
          break;
        }
      }
      if (s != null) {
        if (s instanceof SchemaImpl) {
          SchemaImpl schemaElement=(SchemaImpl)s;
          EList<ModelElement> ownedElement=schemaElement.getOwnedElement();
          ownedElement.add(dbtable);
        }
      }
 else       if (subschemas.size() > 0) {
        for (int i=0; i < subschemas.size(); i++) {
          SchemaImpl schemaElement=(SchemaImpl)subschemas.get(i);
          EList<ModelElement> ownedElement=schemaElement.getOwnedElement();
          ownedElement.add(dbtable);
        }
      }
    }
  }
 else {
    ProjectNodeHelper.addCatalogOrSchema(iMetadataConnection,connection);
    boolean isAccess=EDatabaseTypeName.ACCESS.getDisplayName().equals(iMetadataConnection.getDbType());
    if (isAccess) {
      addTableForTemCatalogOrSchema(dbsid,connection.getName(),connection,dbtable,iMetadataConnection);
    }
 else {
      addTableForTemCatalogOrSchema(dbsid,schema,connection,dbtable,iMetadataConnection);
    }
  }
}

Fixed version (ground truth):
public static void addTableForTemCatalogOrSchema(String dbsid,String schema,DatabaseConnection connection,MetadataTable dbtable,IMetadataConnection iMetadataConnection){
  boolean hasSchemaInCatalog=false;
  boolean isAccess=EDatabaseTypeName.ACCESS.getDisplayName().equals(iMetadataConnection.getDbType());
  Catalog c=(Catalog)ConnectionHelper.getPackage(dbsid,connection,Catalog.class);
  Schema s=(Schema)ConnectionHelper.getPackage(schema,connection,Schema.class);
  List<Schema> subschemas=new ArrayList<Schema>();
  if (c != null) {
    subschemas=CatalogHelper.getSchemas(c);
    hasSchemaInCatalog=subschemas.size() > 0;
  }
  if (c != null && s == null && !hasSchemaInCatalog) {
    PackageHelper.addMetadataTable(dbtable,c);
  }
 else   if (s != null && !hasSchemaInCatalog && c == null) {
    PackageHelper.addMetadataTable(dbtable,s);
  }
 else   if (c != null && hasSchemaInCatalog) {
    subschemas=CatalogHelper.getSchemas(c);
    hasSchemaInCatalog=subschemas.size() > 0;
    if (subschemas.size() > 0) {
      for (      Schema current : subschemas) {
        if (current.getName().equals(schema)) {
          s=current;
          break;
        }
      }
      if (s != null) {
        if (s instanceof SchemaImpl) {
          SchemaImpl schemaElement=(SchemaImpl)s;
          EList<ModelElement> ownedElement=schemaElement.getOwnedElement();
          ownedElement.add(dbtable);
        }
      }
 else       if (subschemas.size() > 0) {
        for (int i=0; i < subschemas.size(); i++) {
          SchemaImpl schemaElement=(SchemaImpl)subschemas.get(i);
          EList<ModelElement> ownedElement=schemaElement.getOwnedElement();
          ownedElement.add(dbtable);
        }
      }
    }
  }
 else   if (s == null && c == null && !isAccess) {
    fillCatalogAndSchemas(iMetadataConnection,connection);
    addTableForTemCatalogOrSchema(dbsid,schema,connection,dbtable,iMetadataConnection);
  }
 else {
    ProjectNodeHelper.addCatalogOrSchema(iMetadataConnection,connection);
    if (isAccess) {
      addTableForTemCatalogOrSchema(dbsid,connection.getName(),connection,dbtable,iMetadataConnection);
    }
 else {
      addTableForTemCatalogOrSchema(dbsid,schema,connection,dbtable,iMetadataConnection);
    }
  }
}