KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > transactions > addrbook > DeleteRecord


1 package transactions.addrbook;
2
3 import dinamica.GenericTableManager;
4 import dinamica.IServiceWrapper;
5 import dinamica.Recordset;
6
7 /**
8  * DeleteRecord<br>
9  * Delete record from address book and save log entry
10  * about this event
11  * <br><br>
12  * Creation date: 15/02/2005<br>
13  * http://www.martincordova.com<br>
14  * @author mcordova - dinamica@martincordova.com
15  */

16 public class DeleteRecord extends GenericTableManager implements IServiceWrapper
17 {
18
19     /* (non-Javadoc)
20      * @see dinamica.GenericTransaction#service(dinamica.Recordset)
21      */

22     public int service(Recordset inputParams) throws Throwable JavaDoc
23     {
24         //reuse superclass code
25
return super.service(inputParams);
26     }
27
28     /* (non-Javadoc)
29      * @see dinamica.IServiceWrapper#beforeService(dinamica.Recordset)
30      */

31     public void beforeService(Recordset inputParams) throws Throwable JavaDoc
32     {
33     }
34
35     /* (non-Javadoc)
36      * @see dinamica.IServiceWrapper#afterService(dinamica.Recordset)
37      */

38     public void afterService(Recordset inputParams) throws Throwable JavaDoc
39     {
40
41         //define audit event description
42
String JavaDoc info = "Deleted record with primary key: " + inputParams.getString("id");
43         
44         //create recordset to hold values
45
Recordset rs = new Recordset();
46         rs.append("operation", java.sql.Types.VARCHAR);
47         rs.append("target_table", java.sql.Types.VARCHAR);
48         rs.append("extra_info", java.sql.Types.VARCHAR);
49         
50         //set values
51
rs.addNew();
52         rs.setValue("operation", "DELETE");
53         rs.setValue("target_table", "address_book");
54         rs.setValue("extra_info", info);
55         
56         //format sql
57
String JavaDoc sql = getSQL(getLocalResource("delete-audit.sql"), rs);
58         
59         //save audit log into db
60
getDb().exec(sql);
61         
62     }
63
64 }
65
Popular Tags