Project Wonder 5.0

er.extensions.eof
Class ERXEntityOrder

java.lang.Object
  extended by er.extensions.eof.ERXEntityOrder
Direct Known Subclasses:
ERXEntityFKConstraintOrder

public abstract class ERXEntityOrder
extends java.lang.Object

Abstract class defining an ordering of EOEntities that also provides NSComparators to sort entities based on this ordering. The ordering is based on groups of entities with entities within each group having no defined order.

This is implemented by creating a dictionary of entity name to group. Group 1 is entities with no dependencies. Group 2 is entities with dependencies on entities in group 1. Group 3 is entities with dependencies on entities in groups 1 and 2. etc. The dependencies between entities are determined by the abstract NSDictionary dependenciesByEntity().

Author:
chill

Nested Class Summary
static class ERXEntityOrder.EntityDeleteOrderComparator
          NSComparator to sort on the ascending EOEntity group number from ordering.entityOrdering().
static class ERXEntityOrder.EntityInsertOrderComparator
          NSComparator to sort on the descending EOEntity group number from ordering.entityOrdering().
 
Field Summary
protected  com.webobjects.foundation.NSArray allEntities
           
protected  com.webobjects.foundation.NSMutableDictionary groupedEntities
           
 
Constructor Summary
ERXEntityOrder()
          Convenience constructor for implementing classes.
ERXEntityOrder(com.webobjects.eoaccess.EOModelGroup modelGroup)
          Designated constructor for implementing classes.
 
Method Summary
 com.webobjects.foundation.NSArray allEntities()
           
 void createListOfEntities(com.webobjects.eoaccess.EOModelGroup modelGroup)
          Creates list of all entities (ecluding prototype entities) in all models in modelGroup.
protected abstract  com.webobjects.foundation.NSDictionary dependenciesByEntity()
          Processes allEntities() and returns a dictionary keyed on dependencyKeyFor(EOEntity).
protected  java.lang.String dependencyKeyFor(com.webobjects.eoaccess.EOEntity entity)
          This implementation returns entity.name().
protected  com.webobjects.foundation.NSSet dependentEntities(com.webobjects.foundation.NSDictionary dependencies, com.webobjects.eoaccess.EOEntity entity)
           
protected  void generateOrdering()
          Calls dependenciesByEntity() to determine dependencies and processes entities in allEntities() to generate the groupedEntities() dictionary.
 com.webobjects.foundation.NSMutableDictionary groupedEntities()
          Returns dictionary of group numbers (java.lang.Integer) to entity names.
protected  boolean hasDependenciesForEntity(com.webobjects.foundation.NSDictionary dependencies, com.webobjects.eoaccess.EOEntity entity)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

groupedEntities

protected com.webobjects.foundation.NSMutableDictionary groupedEntities

allEntities

protected com.webobjects.foundation.NSArray allEntities
Constructor Detail

ERXEntityOrder

public ERXEntityOrder(com.webobjects.eoaccess.EOModelGroup modelGroup)
Designated constructor for implementing classes.

Parameters:
modelGroup - EOModelGroup to get list of all entities from

ERXEntityOrder

public ERXEntityOrder()
Convenience constructor for implementing classes. Uses EOModelGroup.defaultGroup().

Method Detail

groupedEntities

public com.webobjects.foundation.NSMutableDictionary groupedEntities()
Returns dictionary of group numbers (java.lang.Integer) to entity names. Group 1 is entities with no dependencies. Group 2 is entities with dependencies on entities in group 1. Group 3 is entities with dependencies on entities in groups 1 and 2. etc

Returns:
dictionary of group numbers to entity names

dependenciesByEntity

protected abstract com.webobjects.foundation.NSDictionary dependenciesByEntity()
Processes allEntities() and returns a dictionary keyed on dependencyKeyFor(EOEntity). The keys are usually entity.name() but are not required to be. The value associated with each key is an NSSet of the entity names that have a dependency on the key. This dictionary is used to determine the dependency ordering.

Returns:
a dictionary keyed on dependencyKeyFor(EOEntity)

generateOrdering

protected void generateOrdering()
Calls dependenciesByEntity() to determine dependencies and processes entities in allEntities() to generate the groupedEntities() dictionary.


hasDependenciesForEntity

protected boolean hasDependenciesForEntity(com.webobjects.foundation.NSDictionary dependencies,
                                           com.webobjects.eoaccess.EOEntity entity)
Parameters:
dependencies - dictionary from dependenciesByEntity()
entity - entity to check for dependencies
Returns:
true if groupedEntities() has all the entities named in dependentEntities(dependencies, entity).

dependentEntities

protected com.webobjects.foundation.NSSet dependentEntities(com.webobjects.foundation.NSDictionary dependencies,
                                                            com.webobjects.eoaccess.EOEntity entity)
Parameters:
dependencies - result from dependenciesByEntity()
entity - EOEntity to return dependencies set for
Returns:
set of names of entities that are dependent on entity

dependencyKeyFor

protected java.lang.String dependencyKeyFor(com.webobjects.eoaccess.EOEntity entity)
This implementation returns entity.name().

Parameters:
entity - EOEntity to return key into dependency dictionary for
Returns:
key for entity into dependency dictionary returned by dependenciesByEntity()

createListOfEntities

public void createListOfEntities(com.webobjects.eoaccess.EOModelGroup modelGroup)
Creates list of all entities (ecluding prototype entities) in all models in modelGroup.

Parameters:
modelGroup - EOModelGroup to get list of all entities from

allEntities

public com.webobjects.foundation.NSArray allEntities()
Returns:
list of all entities in all models in the model group

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.