}
// ENHANCEME: This should support restrictive qualifiers on the root entity
@Override
public EOQualifier schemaBasedQualifierWithRootEntity(EOQualifier eoqualifier, EOEntity eoentity) {
EOKeyValueQualifier eokeyvaluequalifier = (EOKeyValueQualifier)eoqualifier;
String key = eokeyvaluequalifier.key();
EORelationship eorelationship = eoentity._relationshipForPath(key);
if(eorelationship == null) {
if(!(eokeyvaluequalifier instanceof ERXInQualifier)) {
eokeyvaluequalifier = new ERXInQualifier(key, (NSArray) eokeyvaluequalifier.value());
}
return eokeyvaluequalifier;
}
if(eorelationship.isFlattened()) {
eorelationship = ERXEOAccessUtilities.lastRelationship(eorelationship);
}
NSArray joins = eorelationship.joins();
int l = joins.count();
NSMutableArray destinationAttibuteNames = new NSMutableArray(l);
for(int i = l - 1; i >= 0; i--) {
destinationAttibuteNames.addObject(((EOJoin)joins.objectAtIndex(i)).destinationAttribute().name());
}
Object value = eokeyvaluequalifier.value();
Object obj;
if(value == NSKeyValueCoding.NullValue || (value instanceof EOQualifierVariable)) {
NSMutableDictionary mapping = new NSMutableDictionary(l);
for(int j = 0; j < l; j++) {
mapping.setObjectForKey(value, destinationAttibuteNames.objectAtIndex(j));