• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: ERCPreferences on subclasses of ERCoreUserInterface object
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ERCPreferences on subclasses of ERCoreUserInterface object


  • Subject: Re: ERCPreferences on subclasses of ERCoreUserInterface object
  • From: Chuck Hill <email@hidden>
  • Date: Wed, 12 Sep 2012 14:48:23 -0700

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@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Rewrite WO app URL
  • Next by Date: Re: WOWorkerThread deadlocks
  • Previous by thread: Re: ERPDFGeneration with FOP and examples
  • Next by thread: ERDList.CreateObjectDelegate
  • Index(es):
    • Date
    • Thread