ERXUnmodeledToManyRelationship< S extends ERXEnterpriseObject, D extends ERXEnterpriseObject > Class Reference

Collaboration diagram for ERXUnmodeledToManyRelationship< S extends ERXEnterpriseObject, D extends ERXEnterpriseObject >:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void addToObjectsRelationship (NSArray< D > objects)
void addToObjectsRelationship (D object)
Integer countObjects ()
void deleteAllObjectsRelationships ()
void deleteObjectRelationship (D object)
 ERXUnmodeledToManyRelationship (S sourceObject, String destinationEntityName, ERXKey< S > reverseRelationshipKey, boolean isDeep)
 ERXUnmodeledToManyRelationship (S sourceObject, String destinationEntityName, ERXKey< S > reverseRelationshipKey)
ERXFetchSpecification< D > fetchSpecificationForObjects ()
NSArray< D > objects (EOQualifier qualifier, NSArray< EOSortOrdering > sortOrderings, boolean fetch)
NSArray< D > objects (EOQualifier qualifier, boolean fetch)
NSArray< D > objects (EOQualifier qualifier)
NSArray< D > objects ()
EOQualifier qualifierForObjects ()
void removeFromObjectsRelationship (NSArray< D > objects)
void removeFromObjectsRelationship (D object)

Private Member Functions

NSArray< StringdestinationEntityNames ()
NSMutableArray< D > insertedObjects ()
NSArray< D > persistedObjects ()

Static Private Member Functions

static NSArray< StringentityHierarchyNamesForEntityNamed (EOEditingContext ec, String rootEntityName)

Private Attributes

NSArray< String_destinationEntityNames
final String destinationEntityName
final boolean isDeep
final ERXKey< S > reverseRelationshipKey
final S sourceObject

Static Private Attributes

static ConcurrentHashMap
< String, NSArray< String > > 
_entityHierarchies = new ConcurrentHashMap<String, NSArray<String>>()


Detailed Description

A class than is composited into an EO to provide common toMany functionality for the case where the toMany cannot be modeled in EOF due to the unusually large size possibilities of the toMany relationship.

This class is for simple to many relationships, has not been tested on flattened toMany relationships having a join table, aka "many-to-many" relationships.

Usage: Lazily create a private instance of this inside an EO passing in the appropriate constructor parameters and then implement cover methods similar to those that would have been available thru the normal Entity templates calling the corresponding methods of this class.

For example, you might do this in an entity named CTMediaTemplate that formerly had a 'messages' relationship to CTMessage but due to the huge size of the toMany impacting performance, the toMany side of the relationship had to be deleted from the EOModel:

private ERXUnmodeledToManyRelationship<CTMediaTemplate, CTMessage> _messagesRelationship;

Lazily initialize the helper class public ERXUnmodeledToManyRelationship<CTMediaTemplate, CTMessage> messagesRelationship() { if (_messagesRelationship == null) { _messagesRelationship = new ERXUnmodeledToManyRelationship<CTMediaTemplate, CTMessage>(this, CTMessage.ENTITY_NAME, CTMessage.XKEY_MEDIA_TEMPLATE); } return _messagesRelationship; }

public Integer countMessages() { return messagesRelationship().countObjects(); }

public EOQualifier qualifierForMessages() { return messagesRelationship().qualifierForObjects(); }

public NSArray<CTMessage> messages() { return messagesRelationship().objects(); }

public ERXFetchSpecification<CTMessage> fetchSpecificationForMessages() { return messagesRelationship().fetchSpecificationForObjects(); }

public NSArray<CTMessage> messages(EOQualifier qualifier) { return messagesRelationship().objects(qualifier); }

public NSArray<CTMessage> messages(EOQualifier qualifier, boolean fetch) { return messagesRelationship().objects(qualifier, null, fetch); }

public NSArray<CTMessage> messages(EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings, boolean fetch) { return messagesRelationship().objects(qualifier, sortOrderings, fetch); }

public void addToMessagesRelationship(CTMessage object) { messagesRelationship().addToObjectsRelationship(object); }

public void removeFromMessagesRelationship(CTMessage object) { messagesRelationship().removeFromObjectsRelationship(object); }

public void deleteMessagesRelationship(CTMessage object) { messagesRelationship().deleteObjectRelationship(object); }

public void deleteAllMessagesRelationships() { messagesRelationship().deleteAllObjectsRelationships(); }

Author:
kieran

Constructor & Destructor Documentation

ERXUnmodeledToManyRelationship ( sourceObject,
String  destinationEntityName,
ERXKey< S >  reverseRelationshipKey 
)

Standard constructor where the destination entity is a single type. Excludes entities that might inherit from the destination entity

Parameters:
sourceObject 
destinationEntityName 
reverseRelationshipKey 

ERXUnmodeledToManyRelationship ( sourceObject,
String  destinationEntityName,
ERXKey< S >  reverseRelationshipKey,
boolean  isDeep 
)

A constructor that allows isDeep to be set to true to handle destination entity that is the super class of an inheritance hierarchy. The inherited entities are included in the methods that return arrays of destination EOEnterpriseObjects.

Parameters:
sourceObject 
destinationEntityName 
reverseRelationshipKey 
isDeep 


Member Function Documentation

void addToObjectsRelationship ( NSArray< D >  objects  ) 

void addToObjectsRelationship ( object  ) 

Integer countObjects (  ) 

Returns:
the total count of objects in the relationship

void deleteAllObjectsRelationships (  ) 

void deleteObjectRelationship ( object  ) 

NSArray<String> destinationEntityNames (  )  [private]

Returns:
the destination entity names. If this is an inheritance hierarchy, the subclass entities of the specified entity are included

static NSArray<String> entityHierarchyNamesForEntityNamed ( EOEditingContext  ec,
String  rootEntityName 
) [static, private]

Parameters:
rootEntityName 
Returns:
a list of all concrete entity names that inherit from rootEntityName, including rootEntityName itself if it is concrete.

ERXFetchSpecification<D> fetchSpecificationForObjects (  ) 

Returns:
the ERXFetchSpecification that fetches the destination toMany objects that have been persisted to the database

NSMutableArray<D> insertedObjects (  )  [private]

Returns:
the array of related instances that are inserted into this editing context, but not yet saved.

NSArray<D> objects ( EOQualifier  qualifier,
NSArray< EOSortOrdering >  sortOrderings,
boolean  fetch 
)

NSArray<D> objects ( EOQualifier  qualifier,
boolean  fetch 
)

NSArray<D> objects ( EOQualifier  qualifier  ) 

NSArray<D> objects (  ) 

Returns:
the related destination objects

NSArray<D> persistedObjects (  )  [private]

Returns:
the fetched pre-existing objects from the database

EOQualifier qualifierForObjects (  ) 

Returns:
the EOQualifier that qualifies the toMany destination objects

void removeFromObjectsRelationship ( NSArray< D >  objects  ) 

void removeFromObjectsRelationship ( object  ) 


Member Data Documentation

NSArray<String> _destinationEntityNames [private]

ConcurrentHashMap<String, NSArray<String> > _entityHierarchies = new ConcurrentHashMap<String, NSArray<String>>() [static, private]

final String destinationEntityName [private]

final boolean isDeep [private]

final ERXKey<S> reverseRelationshipKey [private]

final S sourceObject [private]


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:43:11 2012 for Project Wonder by  doxygen 1.5.8