• 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: Newbie vs Many-To-Many (0 win-1 win)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Newbie vs Many-To-Many (0 win-1 win)


  • Subject: Re: Newbie vs Many-To-Many (0 win-1 win)
  • From: Art Isbell <email@hidden>
  • Date: Sun, 2 Mar 2003 10:53:58 -1000

On Sunday, March 2, 2003, at 06:33  AM, Riccardo De Menna wrote:

I've done my homework... after studying carefully what you told me and
the documentation on EORelationshipManager I came to the conclusion
that what I'm trying to do is not exactly what
addObjectToBothSidesOfRelationshipWithKey() and the others are meant
for.

You may mean "EORelationshipManipulation".

The problem is that my Contact profile also allows to reassign the
Contact to a different Client. The user is not bound to the original
relationship and thus, only adding or removing the object is not
sufficient since the original owner has to be notified as well.
I mean that I need to remove the relationship from the old Client and
add it to the new one.

I'm not familiar with the Web user interface you're using to move a contact from client1 to client2, but theoretically, you should be able to do so by merely sending client1 a removeObjectFromBothSidesOfRelationshipWithKey(contactToMove, contactKey), where "contactKey" might be "contact" if Client has a to-one relationship with Contact or "contacts" if the relationship is to-many. Then you would sent client2 an addObjectToBothSidesOfRelationshipWithKey(contactToMove, contactKey) message.



I've used the
EOEditingContext.currentEventSnapshotForObject which works great.
Obviously you have to call this stuff before updating the
editingContext.

Step 1: get the snapshot with all the old values of the record that
needs updating
Step 2: determine changed keys and intersect with relationship keys
Step 3: cycle trough all to-one relationships by removing the record
from the old relationship and adding to the new one
Step 4: cycle trough all the to-many relationship by removing the
record from all the previous owners and adding to the new ones

I don't understand the need for such a complex algorithm, but then I don't understand what you need to accomplish. The above algorithm would work only if objects have already been updated, but it's not clear to me what updates have already occurred before this algorithm is invoked.


I've named the method
updateObjectForBothSidesOfRelationshipWithKey(EOGenericRecord
objectToUpdate, String relationshipToUpdate) since it basically
performs exactly the same thing that the add and remove do but with the
addition that it cleans old relationships.

removeObjectFromBothSidesOfRelationshipWithKey() will remove objects ("clean old relationships"?) but you're not using this method for some reason. removeObjectFromPropertyWithKey() ignores any inverse relationship with could leave your in-memory object graph inconsistent if inverse relationships exist.


I wrote my first
line in Java just 4 days ago and I'm still not very proficient with the
documentation.

Congratulations on your Java coding and your ferreting out the EOF and Foundation methods that you've used correctly. You might also consider NSSet to create the intersection of changed and relationship keys. Moving between NSArray and NSSet is easy.


Art
http://homepage.mac.com/aisbell/
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Newbie vs Many-To-Many (0 win-1 win) (From: Riccardo De Menna <email@hidden>)

  • Prev by Date: Re: Multiple Row update
  • Next by Date: Many problems for Many To Many Relationships across Databases
  • Previous by thread: Re: Newbie vs Many-To-Many (0 win-1 win)
  • Next by thread: Multiple Row update
  • Index(es):
    • Date
    • Thread