/** * Create the prototype cache for the given model by walking a search order. * * @param model */ public static void createPrototypes(EOModel model) { // Remove password for logging NSMutableDictionary dict = model.connectionDictionary().mutableClone(); if (dict.objectForKey("password") != null) { dict.setObjectForKey("<deleted for log>", "password"); } log.info("Creating prototypes for model: " + model.name() + "->" + dict); synchronized (_EOGlobalModelLock) { StringBuilder debugInfo = null; if (log.isDebugEnabled()) { debugInfo = new StringBuilder(); debugInfo.append("Model = " + model.name()); } model._prototypesByName = new NSMutableDictionary(); String name = model.name(); NSArray adaptorPrototypes = NSArray.EmptyArray; EOAdaptor adaptor = EOAdaptor.adaptorWithModel(model); try { adaptorPrototypes = adaptor.prototypeAttributes(); } catch (Exception e) { log.error(e, e); } addAttributesToPrototypesCache(model, adaptorPrototypes); NSArray prototypesToHide = attributesFromEntity(model._group.entityNamed("EOPrototypesToHide")); model._prototypesByName.removeObjectsForKeys(namesForAttributes(prototypesToHide)); String plugin = null; if (adaptor instanceof JDBCAdaptor && !model.name().equalsIgnoreCase("erprototypes")) { plugin = (String) model.connectionDictionary().objectForKey("plugin"); if (plugin == null) { plugin = ERXEOAccessUtilities.guessPluginName(model); } // ~ if (plugin == null) if (plugin != null && plugin.toLowerCase().endsWith("plugin")) { plugin = plugin.substring(0, plugin.length() - "plugin".length()); } if (log.isDebugEnabled()) debugInfo.append("; plugin = " + plugin); } addAttributesToPrototypesCache(model, model._group.entityNamed("EOPrototypes")); addAttributesToPrototypesCache( model, model._group.entityNamed("EO" + model.adaptorName() + "Prototypes")); if (log.isDebugEnabled()) debugInfo.append( "; Prototype Entities Searched = EOPrototypes, " + "EO" + model.adaptorName() + "Prototypes"); if (plugin != null) { addAttributesToPrototypesCache( model, model._group.entityNamed("EOJDBC" + plugin + "Prototypes")); if (log.isDebugEnabled()) debugInfo.append(", " + "EOJDBC" + plugin + "Prototypes"); } addAttributesToPrototypesCache(model, model._group.entityNamed("EOCustomPrototypes")); addAttributesToPrototypesCache( model, model._group.entityNamed("EO" + model.adaptorName() + "CustomPrototypes")); if (log.isDebugEnabled()) debugInfo.append( ", EOCustomPrototypes, " + "EO" + model.adaptorName() + "CustomPrototypes"); if (plugin != null) { addAttributesToPrototypesCache( model, model._group.entityNamed("EOJDBC" + plugin + "CustomPrototypes")); if (log.isDebugEnabled()) debugInfo.append(", " + "EOJDBC" + plugin + "CustomPrototypes"); } addAttributesToPrototypesCache(model, model._group.entityNamed("EO" + name + "Prototypes")); addAttributesToPrototypesCache( model, model._group.entityNamed("EO" + model.adaptorName() + name + "Prototypes")); if (log.isDebugEnabled()) debugInfo.append( ", " + "EO" + name + "Prototypes" + ", " + "EO" + model.adaptorName() + name + "Prototypes"); if (plugin != null) { addAttributesToPrototypesCache( model, model._group.entityNamed("EOJDBC" + plugin + name + "Prototypes")); if (log.isDebugEnabled()) debugInfo.append(", " + "EOJDBC" + plugin + name + "Prototypes"); } if (log.isDebugEnabled()) log.debug(debugInfo.toString()); } }