Program: 130018
Project: 130018
Buggy source:
/** 
 * ldong Comment method "getExistCheckedTable".
 * @param tableNode
 * @return
 */
private TableNode getExistCheckedTable(TableNode tableNode){
  if (tableNode != null && tableNode.getType() == TableNode.TABLE) {
    EList<ModelElement> ownedElement=null;
    List<TableNode> tableNodes=getTableNodeInfo();
    TableNode parent=tableNode.getParent();
    int type=parent.getType();
    if (type == TableNode.CATALOG) {
      for (      TableNode catalogNode : tableNodes) {
        if (catalogNode.getType() == type) {
          if (!catalogNode.getValue().equals(parent.getValue())) {
            if (catalogNode.getCatalog() != null) {
              ownedElement=catalogNode.getCatalog().getOwnedElement();
              for (              ModelElement m : ownedElement) {
                if (m instanceof MetadataTable) {
                  String label=((MetadataTable)m).getLabel();
                  if (label.equals(tableNode.getValue())) {
                    if (((CatalogImpl)m.eContainer()).getName().equals(catalogNode.getValue())) {
                      return transferTableToTableNode((MetadataTable)m,catalogNode);
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
 else     if (type == TableNode.SCHEMA) {
      TableNode p=parent.getParent();
      if (p == null) {
        for (        TableNode schemaNode : tableNodes) {
          if (schemaNode.getType() == type) {
            if (!schemaNode.getValue().equals(parent.getValue())) {
              if (schemaNode.getSchema() != null) {
                ownedElement=schemaNode.getSchema().getOwnedElement();
                for (                ModelElement m : ownedElement) {
                  if (m instanceof MetadataTable) {
                    String label=((MetadataTable)m).getLabel();
                    if (label.equals(tableNode.getValue())) {
                      if (((SchemaImpl)m.eContainer()).getName().equals(schemaNode.getValue())) {
                        return transferTableToTableNode((MetadataTable)m,schemaNode);
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
 else {
        for (        TableNode catalogNode : tableNodes) {
          if (catalogNode.getType() == TableNode.CATALOG) {
            if (catalogNode.getCatalog() != null) {
              if (catalogNode.getValue().equals(p.getValue())) {
                List<Schema> schemas=CatalogHelper.getSchemas(catalogNode.getCatalog());
                for (                Schema schs : schemas) {
                  ownedElement=schs.getOwnedElement();
                  for (                  ModelElement m : ownedElement) {
                    if (m instanceof MetadataTable) {
                      String label=((MetadataTable)m).getLabel();
                      if (label.equals(tableNode.getValue())) {
                        List<TableNode> schemaNodeList=catalogNode.getChildren();
                        for (                        TableNode parentSchema : schemaNodeList) {
                          if (((SchemaImpl)m.eContainer()).getName().equals(parentSchema.getValue()) && !parentSchema.getValue().equals(parent.getValue())) {
                            return transferTableToTableNode((MetadataTable)m,parentSchema);
                          }
                        }
                      }
                    }
                  }
                }
              }
 else {
                List<Schema> schemas=CatalogHelper.getSchemas(catalogNode.getCatalog());
                for (                Schema schs : schemas) {
                  ownedElement=schs.getOwnedElement();
                  for (                  ModelElement m : ownedElement) {
                    if (m instanceof MetadataTable) {
                      String label=((MetadataTable)m).getLabel();
                      if (label.equals(tableNode.getValue())) {
                        List<TableNode> schemaNodeList=catalogNode.getChildren();
                        for (                        TableNode parentSchema : schemaNodeList) {
                          if (((SchemaImpl)m.eContainer()).getName().equals(parentSchema.getValue())) {
                            return transferTableToTableNode((MetadataTable)m,parentSchema);
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * ldong Comment method "getExistCheckedTable".
 * @param tableNode
 * @return
 */
private TableNode getExistCheckedTable(TableNode tableNode){
  if (tableNode != null && tableNode.getType() == TableNode.TABLE) {
    EList<ModelElement> ownedElement=null;
    List<TableNode> tableNodes=getTableNodeInfo();
    TableNode parent=tableNode.getParent();
    if (parent != null) {
      int type=parent.getType();
      if (type == TableNode.CATALOG) {
        for (        TableNode catalogNode : tableNodes) {
          if (catalogNode.getType() == type) {
            if (!catalogNode.getValue().equals(parent.getValue())) {
              if (catalogNode.getCatalog() != null) {
                ownedElement=catalogNode.getCatalog().getOwnedElement();
                for (                ModelElement m : ownedElement) {
                  if (m instanceof MetadataTable) {
                    String label=((MetadataTable)m).getLabel();
                    if (label.equals(tableNode.getValue())) {
                      if (((CatalogImpl)m.eContainer()).getName().equals(catalogNode.getValue())) {
                        return transferTableToTableNode((MetadataTable)m,catalogNode);
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
 else       if (type == TableNode.SCHEMA) {
        TableNode p=parent.getParent();
        if (p == null) {
          for (          TableNode schemaNode : tableNodes) {
            if (schemaNode.getType() == type) {
              if (!schemaNode.getValue().equals(parent.getValue())) {
                if (schemaNode.getSchema() != null) {
                  ownedElement=schemaNode.getSchema().getOwnedElement();
                  for (                  ModelElement m : ownedElement) {
                    if (m instanceof MetadataTable) {
                      String label=((MetadataTable)m).getLabel();
                      if (label.equals(tableNode.getValue())) {
                        if (((SchemaImpl)m.eContainer()).getName().equals(schemaNode.getValue())) {
                          return transferTableToTableNode((MetadataTable)m,schemaNode);
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
 else {
          for (          TableNode catalogNode : tableNodes) {
            if (catalogNode.getType() == TableNode.CATALOG) {
              if (catalogNode.getCatalog() != null) {
                if (catalogNode.getValue().equals(p.getValue())) {
                  List<Schema> schemas=CatalogHelper.getSchemas(catalogNode.getCatalog());
                  for (                  Schema schs : schemas) {
                    ownedElement=schs.getOwnedElement();
                    for (                    ModelElement m : ownedElement) {
                      if (m instanceof MetadataTable) {
                        String label=((MetadataTable)m).getLabel();
                        if (label.equals(tableNode.getValue())) {
                          List<TableNode> schemaNodeList=catalogNode.getChildren();
                          for (                          TableNode parentSchema : schemaNodeList) {
                            if (((SchemaImpl)m.eContainer()).getName().equals(parentSchema.getValue()) && !parentSchema.getValue().equals(parent.getValue())) {
                              return transferTableToTableNode((MetadataTable)m,parentSchema);
                            }
                          }
                        }
                      }
                    }
                  }
                }
 else {
                  List<Schema> schemas=CatalogHelper.getSchemas(catalogNode.getCatalog());
                  for (                  Schema schs : schemas) {
                    ownedElement=schs.getOwnedElement();
                    for (                    ModelElement m : ownedElement) {
                      if (m instanceof MetadataTable) {
                        String label=((MetadataTable)m).getLabel();
                        if (label.equals(tableNode.getValue())) {
                          List<TableNode> schemaNodeList=catalogNode.getChildren();
                          for (                          TableNode parentSchema : schemaNodeList) {
                            if (((SchemaImpl)m.eContainer()).getName().equals(parentSchema.getValue())) {
                              return transferTableToTableNode((MetadataTable)m,parentSchema);
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
 else {
    for (    Object obj : ConnectionHelper.getTables(getConnection())) {
      if (obj == null) {
        continue;
      }
      MetadataTable table=(MetadataTable)obj;
      if (table.getLabel().equals(tableNode.getValue())) {
        return transferTableToTableNode(table,null);
      }
    }
  }
  return null;
}