protected NSDictionary snapshotsGroupedByEntity(NSArray objects, EOObjectStoreCoordinator osc) {
if (objects == null || objects.count() == 0) {
return NSDictionary.EmptyDictionary;
}
NSMutableDictionary result = new NSMutableDictionary();
NSMutableDictionary dbcs = new NSMutableDictionary();
for (Enumeration gids = objects.objectEnumerator(); gids.hasMoreElements();) {
EOGlobalID gid = (EOGlobalID) gids.nextElement();
if (gid instanceof EOKeyGlobalID) {
EOKeyGlobalID globalID = (EOKeyGlobalID) gid;
String entityName = globalID.entityName();
String key = entityName + "/" + System.identityHashCode(osc);
EODatabaseContext dbc = (EODatabaseContext) dbcs.objectForKey(key);
if (dbc == null) {
dbc = ERXEOAccessUtilities.databaseContextForEntityNamed(osc, entityName);
dbcs.setObjectForKey(dbc, key);
}
NSMutableArray snapshotsForEntity = (NSMutableArray) result.objectForKey(entityName);
if (snapshotsForEntity == null) {
snapshotsForEntity = new NSMutableArray();
result.setObjectForKey(snapshotsForEntity, entityName);