protected Map<IERXMigration, ERXModelVersion> _buildDependenciesForModelsNamed(NSArray<String> modelNames, NSArray<String> skipModelNames) {
Map<IERXMigration, ERXModelVersion> migrations = new LinkedHashMap<IERXMigration, ERXModelVersion>();
try {
Map<String, Integer> versions = new HashMap<String, Integer>();
EOModelGroup modelGroup = EOModelGroup.defaultGroup();
Enumeration modelNamesEnum = modelNames.objectEnumerator();
while (modelNamesEnum.hasMoreElements()) {
String modelName = (String) modelNamesEnum.nextElement();
if (!skipModelNames.containsObject(modelName)) {
EOModel model = modelGroup.modelNamed(modelName);
if (model == null) {
throw new IllegalArgumentException("There is no model named '" + modelName + "' in this model group.");
}
_buildDependenciesForModel(model, ERXMigrator.LATEST_VERSION, versions, migrations);
}
}
Set<String> processedModelNames = new HashSet<String>();
Set<String> pendingModelNames = new HashSet<String>(versions.keySet());
while (!pendingModelNames.isEmpty()) {
Iterator<String> modelNamesIter = pendingModelNames.iterator();
while (modelNamesIter.hasNext()) {
String modelName = modelNamesIter.next();
EOModel model = modelGroup.modelNamed(modelName);
Enumeration entitiesEnum = model.entities().objectEnumerator();
while (entitiesEnum.hasMoreElements()) {
EOEntity entity = (EOEntity) entitiesEnum.nextElement();
EOEntity parentEntity = entity.parentEntity();
if (parentEntity != null && !parentEntity.model().equals(model)) {