try {
Object rawValue = NSPropertyListSerialization.propertyListFromString(string);
if(rawValue instanceof NSArray) {
int index = 0;
for(Enumeration e = ((NSArray)rawValue).objectEnumerator(); e.hasMoreElements();) {
EOAttribute attribute = pks.objectAtIndex(index++);
Object value = e.nextElement();
if(attribute.adaptorValueType() == EOAttribute.AdaptorDateType && !(value instanceof NSTimestamp)) {
value = new NSTimestampFormatter("%Y-%m-%d %H:%M:%S %Z").parseObject((String)value);
}
value = attribute.validateValue(value);
pk.setObjectForKey(value, attribute.name());
if(pks.count() == 1) {
break;
}
}
} else {
if(rawValue instanceof NSMutableData) {
// AK: wtf!! I got an exception
// java.lang.IllegalArgumentException: Attempt to create an EOGlobalID for the entity "Asset" with a primary key component of type com.webobjects.foundation.NSMutableData instead of type com.webobjects.foundation.NSData!
// so this is a lame attempt to fix it.
rawValue = new NSData((NSMutableData)rawValue);
}
EOAttribute attribute = pks.objectAtIndex(0);
Object value = rawValue;
value = attribute.validateValue(value);
pk.setObjectForKey(value, attribute.name());
}
return pk;
} catch (Exception ex) {
throw new NSForwardException(ex, "Error while parsing primary key: " + string);
}