Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

If I was going to log every change to every object, some typical hints are that if you subclass EOEditingContext, then prior to any saveChanges() operation you can get a list of the inserted/deleted/changed objects (you have to call processRecentChanges() first). If I was designing this, I'd make all my EOF objects have a common superclass/interface that implemented something like:

Panelcode

auditTrailChanged()


auditTrailInsert()


auditTrailDelete()

Then on a class-by-class basis I could decide what to do. That could include inserting additional objects, etc. Like an object could compare itself to its snapshot if it had changed and it could record the old and new values to a generic object that stored AuditTrail(class name, primary key of object, username, timestamp, attribute, old value (string), new value(string)).

In psuedo code:

Panelcode

override saveChanges()


  self.processRecentChanges()


  foreach obj (self.changedObjects)


    obj.auditTrailChanged()


  foreach obj (self.insertedObjects)


    obj.auditTrailChanged()


  foreach obj (self.deletedObjects)


    obj.auditTrailChanged()


  super.saveChanges()

Category:WebObjects