EOEditingContext ec = eo.editingContext();
if(stringValue.charAt(0) == '@') { // computed key
if(stringValue.equals("@new")) {
EOClassDescription cd = EOClassDescription.classDescriptionForEntityName(relationshipEntityName);
EOEnterpriseObject newObject = cd.createInstanceWithEditingContext(eo.editingContext(), null);
ec.insertObject(newObject);
eo.addObjectToBothSidesOfRelationshipWithKey(newObject,key);
} else if(stringValue.startsWith("@threadStorage.")) {
String keyPath = stringValue.substring("@threadStorage.".length());
Object o = ERXThreadStorage.valueForKey(keyPath);
if(keyPath.indexOf(".") > 0) {
keyPath = stringValue.substring(keyPath.indexOf(".")+1);
o = NSKeyValueCodingAdditions.Utility.valueForKeyPath(o, keyPath);
}
if(o != null) {
if(o instanceof EOEnterpriseObject) {
ERXEOControlUtilities.addObjectToObjectOnBothSidesOfRelationshipWithKey((EOEnterpriseObject)o, eo, key);
} else if(o instanceof NSArray) {
NSArray newObjects = (NSArray)o;
for(Enumeration e = newObjects.objectEnumerator(); e.hasMoreElements();) {
ERXEOControlUtilities.addObjectToObjectOnBothSidesOfRelationshipWithKey((EOEnterpriseObject)e.nextElement(), eo, key);
}
} else {
defaultLog.warn("setValueInObject: Object is neither an EO nor an array");
}
}
}
} else {
if (adaptorType == AdaptorNumberType) {
defaultValue = Integer.valueOf(stringValue);
}
EOGlobalID gid = EOKeyGlobalID.globalIDWithEntityName(relationshipEntityName, new Object[] {defaultValue});
EOEnterpriseObject fault = ec.faultForGlobalID(gid,ec);
eo.addObjectToBothSidesOfRelationshipWithKey(fault,key);
}
}