Marketcircle    Forums  Hop To Forum Categories  Extending Daylite  Hop To Forums  Creating Plugins    identifying object relationships
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Journeyman
Posted
I'm looking for a way to elegantly find out, given 2 objects, to establish if there is an existing link between them. This method from objectcontext.h seems like it fits the bill (I think)

 // Returns whether the objects are already joined together
- (BOOL)efficientlyCheckJoinForObject:(MCPObject *)obj 
   usingManyToManyRelationshipWithKey:(NSString *)relName 
							 toObject:(MCPObject *)otherObject;
 


But I guess my question would be, how do I identify the manytomany relationship key? I see that there are primary keys etc, but am not sure what I should be looking for. (For my current purposes, object 1 is a contact and object 2 is a timeblock).

And if this isn't the correct approach, I would like to find out the best way to a) find out whether 2 objects are linked, and b) What is the correct way to identify all objects linked to any particular object..

Thank you!
-E
 
Posts: 96 | Location: San Francisco | Registered: June 22, 2006Reply With QuoteEdit or Delete MessageReport This Post
AJ
Marketcircle Team
Picture of AJ
Posted Hide Post
MCPObject is a 'business object' such as a Contact or a Project - MCPObject is not a primary key.

So to find out if a task is linked to a contact, you do this in Objective-C (the f-script syntax would be a bit different):

  
MCPObject *myTask; // assuming this exists
MCPObject *myContact; // assuming this exists
MCPObjectContext *objectContext; // assuming this exists

if ([objectContext efficientlyCheckJoinForObject:myContact 
       usingManyToManyRelationshipWithKey:@"tasks"
       toObject:myTask])
 {
    
    // the objects are already linked, do what you need to do

 }



Check the eomodeld file for what the many-to-many relationship names should be (they are plural such as 'tasks' or 'keywords'). They look a little different than to-one or to-many relationships. Many-to-manies have an 'intermediate' entity (table) and that entity usually has 'join' in the name at the end. Be careful not to confuse a many-to-many with a to-many.

The exception to this is Role and Relationship.

HTH
 
Posts: 824 | Location: Toronto | Registered: May 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
Journeyman
Posted Hide Post
Got it. Another little lightbulb above my head now..

Is there a convenient way to identify all objects linked to a particular object, or is it a matter of running through each object type each time?

Thanks AJ!
 
Posts: 96 | Location: San Francisco | Registered: June 22, 2006Reply With QuoteEdit or Delete MessageReport This Post
AJ
Marketcircle Team
Picture of AJ
Posted Hide Post
In that case, you just have to cycle through them.
 
Posts: 824 | Location: Toronto | Registered: May 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

Marketcircle    Forums  Hop To Forum Categories  Extending Daylite  Hop To Forums  Creating Plugins    identifying object relationships

© Copyright 2006 Marketcircle Inc. All rights reserved.