NSMutableSet<NSBundle> bundles = new NSMutableSet<NSBundle>();
bundles.addObject(NSBundle.mainBundle());
bundles.addObjectsFromArray(frameworkBundles);
for (Enumeration<NSBundle> e = bundles.objectEnumerator(); e.hasMoreElements(); ) {
NSBundle nsbundle = e.nextElement();
NSArray<String> paths = nsbundle.resourcePathsForResources("eomodeld", null);
int pathCount = paths.count();
for (int currentPath = 0; currentPath < pathCount; currentPath++) {
String indexPath = paths.objectAtIndex(currentPath);
if(indexPath.endsWith(".eomodeld~/index.eomodeld")) {
// AK: we don't want to use temp files. This is actually an error in the
// builds or it happens when you open and change models from installed frameworks
// but I'm getting so annoyed by this that we just skip the models here
log.info("Not adding model, it's only a temp file: " + indexPath);
continue;
}
String modelPath = NSPathUtilities.stringByDeletingLastPathComponent(indexPath);
String modelName = (NSPathUtilities.stringByDeletingPathExtension(NSPathUtilities.lastPathComponent(modelPath)));
EOModel eomodel = modelNamed(modelName);
if (eomodel == null) {
URL url = nsbundle.pathURLForResourcePath(modelPath);
modelNameURLDictionary.setObjectForKey(url, modelName);
modelNames.addObject(modelName);
}
else if (NSLog.debugLoggingAllowedForLevelAndGroups(1, 32768L)) {
NSLog.debug.appendln("Ignoring model at path \"" + modelPath + "\" because the model group " + this + " already contains the model from the path \"" + eomodel.pathURL() + "\"");