Thanks. This looks useful.
Do you do something similar with the DB connection? I've now got a model in my framework and a model in my application. Some of the entities in the framework are generic and can optionally be subclassed (User); others are unlikely to be subclassed (UserLogEntry).
How do I tell the framework that its entities should be accessed via the connection in the model in my application rather than the one in the framework's own model?
And if a method in the framework fetches and returns an entity, how would it know to return the subclass of the entity defined in the application rather than the generic entity in the framework? (This question probably shows my confusion... I'm sure I'm just thinking about this problem wrong!) On Jul 16, 2008, at 5:09 PM, Jean-François Veillette wrote: Whenever used, we use the notification of model loaded, and at runtime change whatever values needed to be tweeked for the current project. Like changing table name, setting isAbstract (or not), playing with relationship, etc.
Here is a simple case where we define the isAbstract attribute on all the entities of a generic model :
first ... NSNotificationCenter.defaultCenter().addObserver(AProjectControlerClass.class, new NSSelector("modelLoadedNotification", new Class[] { NSNotification.class }), EOModelGroup.ModelAddedNotification, null);
and latter ... public static void modelLoadedNotification(final NSNotification notification) { NSLog.debug.appendln(AProjectControlerClass.class.getName() + " notificationModelCharge..."); EOModel model = (EOModel) notification.object(); if (model.name().equals("AGenericModel")) { NSArray entities = model.entities(); log.info(model); Enumeration enim = entities.objectEnumerator(); while (enim.hasMoreElements()) { EOEntity entity = (EOEntity) enim.nextElement(); log.info(entity); entity.setIsAbstractEntity(true); } } }
- jfv
Le 08-07-16 à 17:32, Chris Meyer a écrit : And what about adding additional relationships specific to the application to the User entity?
Name it GenericUser (or whatever) in the framework. Subclass GenericUser as User in the app model and add whatever you need. Done.
Great! It sounds like I'm on the right track.
So how does WO handle the table name? In the framework, the GenericUser entity will have a table name (and, implicitly, a DB connection). When subclassing/extending the object in the _application_, is the table name and connection in the _framework_ just ignored?
|