EORelationship relationship = ERXUtilities.relationshipWithObjectAndKeyPath((EOEnterpriseObject)_source, _localRelationshipKey()); if(relationship!=null) { destinationEntity = relationship.destinationEntity();
anEditingContext = ((EOEnterpriseObject)_source).editingContext(); } if (anEditingContext == null) { anEditingContext = session().defaultEditingContext() ; }  if(anEntityName != null) { anEntityName = _localSourceEntityName(); EOEntity anEntity = EOUtilities.entityNamed(anEditingContext, anEntityName); if (anEntity == null) { throw new IllegalStateException("<" + getClass().getName() + " could not find entity named " + anEntityName + ">");
    protected EOEntity destinationEntity() {        String anEntityName = _localSourceEntityName();        // FIXME (msanchez, 08/00, 2520053): use modelGroup on ObjectStoreCoordinator of our editingContext        EOModelGroup aModelGroup = EOModelGroup.defaultGroup();        EOEntity anEntity = aModelGroup.entityNamed(anEntityName);        if (anEntity == null) {            throw new IllegalStateException("<" + getClass().getName() + " could not find entity named " + anEntityName + ">");        }        EOEntity destinationEntity = null;        Object _source = _localSourceObject();        if (_source instanceof EOEnterpriseObject) {            EORelationship relationship = ERXUtilities.relationshipWithObjectAndKeyPath((EOEnterpriseObject)_source,                                                                                        _localRelationshipKey());            if(relationship!=null) {                destinationEntity = relationship.destinationEntity();            }        }        if (destinationEntity == null) {            destinationEntity = entityWithEntityAndKeyPath(anEntity, _localRelationshipKey());        }        return destinationEntity;    }