EOEnterpriseObject oldValue = (EOEnterpriseObject) rec.valueForKeyPath(keyPath);
handleChange(ec, target, ERCAuditTrailType.UPDATED, keyPath, oldValue, oldValue);
}
protected void handleChange(EOEditingContext ec, EOEnterpriseObject eo, ERCAuditTrailType type, String keyPath, Object oldValue, Object newValue) {
ERXGenericRecord rec = (ERXGenericRecord) eo;
ERCAuditTrail trail = ERCAuditTrail.clazz.auditTrailForObject(ec, eo);
if (trail == null) {
trail = ERCAuditTrail.clazz.createAuditTrailForObject(ec, eo);
}
log.info(trail + " " + type + ": " + rec.permanentGlobalID() + " " + keyPath + " from " + oldValue + " to " + newValue);
if (oldValue instanceof ERXGenericRecord) {
ERXGenericRecord rec1 = (ERXGenericRecord) oldValue;
oldValue = ERXKeyGlobalID.globalIDForGID(rec1.permanentGlobalID()).asString();
}
if (newValue instanceof ERXGenericRecord) {
ERXGenericRecord rec1 = (ERXGenericRecord) newValue;
newValue = ERXKeyGlobalID.globalIDForGID(rec1.permanentGlobalID()).asString();
}
trail.createEntry(type, keyPath, oldValue, newValue);
}