Jon, I am closing in on a solution.. Unfortunantly my biggest criteria has given me my biggest problems! I want to be able to tie the username to the audit record, but I don't want to change how I use the torque objects.. I know that if I have to actually do something to get the username tied to the audit record, I will forget to do that, and end up with audit records with no names...
I have an Admin_Audit table with columns: sql_table update_user update_dtime message In column message is an XML message: <event type="datachange" table="CATEGORIES_ADMIN"> <data> <column col="YahooCategory" old_val="" new_val="34534" /> </data> </event> In this example I updated my column YahooCategory to have 34534 in it. The difficult thing is the username. I have hacked up the torque build templates for the objects to store a username. Basically each object now inherits from AuditObject who inherits from BaseObject. AuditObject has private field auditUserName. All of the retreive and doSelect methods of the object are bounded by calls to tag(). Tag takes the parent objects username and passes it to its children. That way the children each gets it's parents username value. It also populates a hashtable of the original values in the object. Then, if you call save() on either the toplevel object, or any of it's children, then they each know who the user was, what their orginal state was, and in the save method they create an AdminAudit object that saves the username and data changes to the Admin_Audit table. This is all great, except that the very toplevel object in my code needs to be manually populated with the username. So, if I am working with CategoryAdmin objects, I get them out of the Peer, and then do categoryAdmin.tag(myUserName). Then if I do StagingCategory stagingCategory = categoryAdmin.getStagingCategory(), internally the categoryAdmin object tags the stagingCategory object with my user name. What I really wish though was that when I do any database UPDATE/DELETE/INSERT, and when the call reaches BasePeer it could somehow load up a service that would tell it the username of the session, somehow getting data.getUser().getUserName(). This though, i believe is impossible. Which is why I have to provide the username upfront. Some of the things that currently bugs me is that I had to change the torque templates, that makes it much harder to upgrade. And I don't want to put the audit code in my Business Object level because I still want to be able to regenerate all my code. I may add a third layer to put the Audit code in: BaseObject.java BaseCategoryAdmin.java AuditCategoryAdmin.java CategoryAdmin.java Then, all the methods that actually that call the peer will have the tag() code in them. Also, so that I don't have to do code like: CategoryAdmin ca = CategoryAdminPeer.retrieveByPK(numberKey) ca.tag(myUserName) With the potential to forget the ca.tag() call, I might create a big class called OMAuditFactory with methods like CategoryAdmin ca = omAuditFactory.get(NumberKey nk) and CategoryAdmin ca = omAuditFactory.get(Criteria c) Any pointers/or suggestions will be seized on gratefully! Eric Eric -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Monday, December 17, 2001 12:06 PM To: [EMAIL PROTECTED] Subject: RE: How can I get a user's information service? Hi, if you were to specify that records held details of who initially added them to the database, then the relevent user fields would already be part of the om objects. Although this doesn't help in initially filling them in. Perhaps you could write a method that you could pass an om object and a user object into and have it fill in the relevent fields for you. One other consideration would be whether you have a single audit table that records the table, column, old and new values, or whether you have an audit table for every table in the system. I guess this would depend on how often updates are made and how often you may want to re-create a record as it was at a previous point in time. Either way, I would be interested in how you solve this as I am likely going to need this at some point. Up to now I have been able to get away with just using a log file to record any changes. Jon -----Original Message----- From: Pugh, Eric [mailto:[EMAIL PROTECTED]] Sent: 13 December 2001 20:00 To: 'Turbine Users List' Subject: How can I get a user's information service? Hi all, I need to tweak my OM objects. I need to intercept any updates to the database and record in an Audit table the old value and the new value. I am planning on tweaking the Velocity Templates to have my save() method in my objects take care of this. However, the harder part about this assignment is that I need to record the username of the user who is updating the database. I don't want to have to pass a username value into my OM objects. I am hopping that my OM objects can access some sort of service statically who will give me the User object... That way I don't have to think about the fact that all my OM objects are storing audit data into the database.... Eric -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> ---------------------------------------------------------------------------- ------------- DISCLAIMER: This message contains proprietary information some or all of which may be confidential and/or legally privileged. It is for the intended recipient only who may use and apply the information only for the intended purpose. Internet communications are not secure and none of the companies in the British Biotech plc group accepts responsibility for any loss or damage which any person or legal entity may suffer or incur following their reliance on the contents of this message. Any views or opinions presented are only those of the author and not those of British Biotech. If you are not the intended recipient please delete this e-mail and notify the author immediately by calling ++44 (0)1865 748747; do not use, disclose, distribute, copy, print or rely on this e-mail. British Biotech Pharmaceuticals Limited Registered Office: Thames Court, Watlington Road, Oxford, Oxfordshire, OX4 6LY Registered in England and Wales No 1985479 -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
omaudit.zip
Description: Binary data
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
