boolean nodep = false;
boolean firstrun = true;
final Set<ColumnFkInfo> fks = t.getForeignKeys();
final Iterator<ColumnFkInfo> iter = fks.iterator();
while (iter.hasNext()) {
final ColumnFkInfo fk = iter.next();
Logger.debug("[resolveDep] FK -> %s: %s", fk.getPkTable(), resolved.containsKey(fk.getPkTable()));
if (!resolved.containsKey(fk.getPkTable())) {
final Table inner = unresolved.get(fk.getPkTable());
// if there's yet a cycle with the two tables inner following t
// then proceed to the next FK and ignore this potential cycle
if (duplicateCycle(t, inner)) {
continue;
}
if (cyclePath != null && cyclePath.contains(inner)) {
cyclePath.add(t);
// create a new list for the detected cycle to add to the
// cyclicDeps, the former one (cyclePath) is used further on
final List<Table> cycle = new ArrayList<Table>(cyclePath);
cycle.add(inner);
if (_cyclicDependencies == null) {
_cyclicDependencies = new HashSet<List<Table>>();
}
Logger.debug("[resolveDep] +++ Putting cyclePath: %s", cycle);
_cyclicDependencies.add(cycle);
continue;
} else {
if (cyclePath == null) {
Logger.debug("[resolveDep] Starting cyclePath with: %s", t);
cyclePath = new ArrayList<Table>();
}
cyclePath.add(t);
}
resolveDep(inner, cyclePath, resolved, unresolved);
if (resolved.containsKey(fk.getPkTable())) {
nodep = (firstrun || nodep);
firstrun = false;
}
} else {
nodep = (firstrun || nodep);