Re: Question about reusing model entities
Re: Question about reusing model entities
- Subject: Re: Question about reusing model entities
- From: Jean-François Veillette <email@hidden>
- Date: Wed, 16 Jul 2008 20:09:31 -0400
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?
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden