On 2012-09-12, at 10:15 AM, Larry Mills-Gahl wrote:

> I have different classes of users that are subclasses of an AppUser

ERXPartials are another option.  More on that soon, I hope.


> and want to use the preferences structure in ERCoreUserInterface. 
> Calling addPreferenceRelationshipToActorEntity on the parent entity doesn't 
> create a relationship for child classes. I took part of the call from 
> ERCoreBusinessLogic and removed the reverse ("pref->user") relationship so 
> that I can call this for all the subclasses I care about. 

I am not sure if you strictly need to copy that relationship to all of the 
subclasses.  EntityModeler does, but EOF might accommodate not having it.

> 
> Two questions. 
> 1) Am I aiming a gun at my foot with my finger on the trigger? (i.e. Am I 
> doing something profoundly stupid here... don't hold back Chuck)

I am not sure.  If it works... it works.


> 2) Simple tests work with this, but is there something lurking in my limited 
> understanding of the nether regions of EOF going to cause problems?

I think the worst that would happen is an exception during saving saying that 
EOF can't find the relationship on some AppUser subclass.  Then you use code 
like below to add it and carry on.


> Here is the lift (without the prefs->user portion of the relationship 
> (because that is already created in the first call to 
> addPreferenceRelationshipToActorEntity)      
> 
> 
> 
>     public void addPreferenceRelationshipToActorEntityOnly(String entityName) 
> {
>       
>         EOEntity actor = EOModelGroup.defaultGroup().entityNamed(entityName);
>         String attributeNameToJoin = (String) 
> actor.primaryKeyAttributeNames().lastObject();
>         EOEntity preference = 
> EOModelGroup.defaultGroup().entityNamed("ERCPreference");
> 
>         EOJoin preferencesJoin = new 
> EOJoin(actor.attributeNamed(attributeNameToJoin), 
> preference.attributeNamed("userID"));
>         EORelationship preferencesRelationship = new EORelationship();
> 
>         preferencesRelationship.setName("preferences");
>         actor.addRelationship(preferencesRelationship);

You may want to do this after the lines below.


>         preferencesRelationship.addJoin(preferencesJoin);
>         preferencesRelationship.setToMany(true);
>         preferencesRelationship.setJoinSemantic(EORelationship.InnerJoin);
>         
> preferencesRelationship.setDeleteRule(EOEntityClassDescription.DeleteRuleCascade);
>     }
> 

Chuck


-- 
Chuck Hill             Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall 
knowledge of WebObjects or who are trying to solve specific problems.    
http://www.global-village.net/gvc/practical_webobjects









 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to