materializing a MaCommitLogRecord

Chris Muller asqueaker at gmail.com
Mon Jun 14 19:01:52 UTC 2010


> Only because a feature requested for my app is "the ability to audit who
> changed what... just in case."  It doesn't need to be an end-user accessible
> feature, and it won't be used often.  Instead of me building something new I
> realized that Magma has these commit records in the db already... so I'm
> thinking I can just do something simple like record which commit numbers a
> user is responsible for and then if I need to I can go back later and
> extract the needed information from that commit.

If this is for Sarb'Ox then I think you made the right choice;
employing the database-level auditing information, rather putting it
in the app.  Plus, your approach not only captures the auditry about
the current state of all objects, but their entire historical updates
as well.  Excellent.

> Nevermind, I figured it out.  I need to use MagmaSession
> newCommitLogSerializer to materialize the graph in a commit record, not the
> serializer from the current session.

Yep, you found it, good hunting.  I don't know whether you'd found the
"Magma Tools" package but, in there, you'll find a tool called
"MagmaBufferController" which materializes CommitPackages in this
manner as well.  With the tool you can essentially browse the
persistent model without materializing any domain instances..

> However... now I'm not really sure what to make of the contents of the
> buffers inside the serialized buffer of the commit package.  I don't see any
> domain objects in there, just an array of oids, the timestamp and something
> else that I can't seem to materialize.

You could:

  mySession serializer independentCopy materializeObject:
theCommitPackage objects.

#materializeObject: is a private method but given your new
requirements and ideas, you would want a nice, small API for accessing
the objects out of a CommitLogRecord in this manner...

But, allow me to suggest that this may not be necessary.  You just
want to see the "contents" of the objects, you aren't as interested in
executing their behaviors, right?

If so, rather than trying to materialize an old portion of the model,
I would try that MagmaBufferController, et al, to do this job.  With
that tool, you get not only the *shape* of the object model, but also
easy-access to type, numeric, and string contents of objects, not to
mention the audit information as well, all from one single object
(MagmaBufferFacade).

Attempting to materialize a single CommitPackage gives you a "portion"
of an old-version of the model.  It can be done, but it's a bit more
work..

 - Chris


More information about the Magma mailing list