return entities;
}
private void init() {
List dbEntitiesToResolve = collectAllDbEntities();
Digraph pkDependencyGraph = new MapDigraph(MapDigraph.HASHMAP_FACTORY);
indexedDbEntities = new HashMap(dbEntitiesToResolve.size());
for (Iterator i = dbEntitiesToResolve.iterator(); i.hasNext();) {
DbEntity origin = (DbEntity) i.next();
for (Iterator j = origin.getRelationships().iterator(); j.hasNext();) {
DbRelationship relation = (DbRelationship) j.next();
if (relation.isToDependentPK()) {
DbEntity dst = (DbEntity) relation.getTargetEntity();
if (origin.equals(dst)) {
continue;
}
pkDependencyGraph.putArc(origin, dst, Boolean.TRUE);
}
}
}
int index = 0;
for (Iterator i = dbEntitiesToResolve.iterator(); i.hasNext();) {
DbEntity entity = (DbEntity) i.next();
if (!pkDependencyGraph.containsVertex(entity)) {
indexedDbEntities.put(entity, new Integer(index++));
}
}
boolean acyclic = GraphUtils.isAcyclic(pkDependencyGraph);
if (acyclic) {
IndegreeTopologicalSort sorter = new IndegreeTopologicalSort(
pkDependencyGraph);
while (sorter.hasNext())
indexedDbEntities.put(sorter.next(), new Integer(index++));
}
else {
StrongConnection contractor = new StrongConnection(
pkDependencyGraph,
CollectionFactory.ARRAYLIST_FACTORY);
Digraph contractedDigraph = new MapDigraph(MapDigraph.HASHMAP_FACTORY);
contractor.contract(contractedDigraph, CollectionFactory.ARRAYLIST_FACTORY);
IndegreeTopologicalSort sorter = new IndegreeTopologicalSort(
contractedDigraph);
while (sorter.hasNext()) {
Collection component = (Collection) sorter.next();