Skip to content

Commit

Permalink
Got rid of the unref'd primary keys anomaly...didn't make a lot of sense
Browse files Browse the repository at this point in the history
  • Loading branch information
johncurrier committed Jun 7, 2005
1 parent c5ca9df commit 5a413a4
Showing 1 changed file with 4 additions and 33 deletions.
37 changes: 4 additions & 33 deletions src/net/sourceforge/schemaspy/DBAnalyzer.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
package net.sourceforge.schemaspy;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import net.sourceforge.schemaspy.model.ImpliedForeignKeyConstraint;
import net.sourceforge.schemaspy.model.Table;
import net.sourceforge.schemaspy.model.TableColumn;
import net.sourceforge.schemaspy.model.TableIndex;
import java.sql.*;
import java.util.*;
import net.sourceforge.schemaspy.model.*;

public class DBAnalyzer {
public static List getImpliedConstraints(Collection tables) throws SQLException {
Expand Down Expand Up @@ -164,7 +153,7 @@ public static List getTablesWithIncrementingColumnNames(Collection tables) {
String numbers = null;
for (int i = columnName.length() - 1; i > 0; --i) {
if (Character.isDigit(columnName.charAt(i))) {
numbers = String.valueOf(columnName.charAt(i)) + numbers == null ? "" : numbers;
numbers = String.valueOf(columnName.charAt(i)) + (numbers == null ? "" : numbers);
} else {
break;
}
Expand Down Expand Up @@ -207,24 +196,6 @@ public static List getTablesWithOneColumn(Collection tables) {
return sortTablesByName(singleColumnTables);
}

public static List getUnreferencedPrimaryKeys(Collection tables) {
List unreferencedPrimaryKeys = new ArrayList();

Iterator iter = tables.iterator();
while (iter.hasNext()) {
Table table = (Table)iter.next();
Iterator primaryIter = table.getPrimaryColumns().iterator();
while (primaryIter.hasNext()) {
TableColumn column = (TableColumn)primaryIter.next();
if (column.getChildren().isEmpty()) {
unreferencedPrimaryKeys.add(column);
}
}
}

return sortColumnsByTable(unreferencedPrimaryKeys);
}

public static List sortTablesByName(List tables) {
Collections.sort(tables, new Comparator() {
public int compare(Object object1, Object object2) {
Expand Down

0 comments on commit 5a413a4

Please sign in to comment.