KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > transactions > security > InsertMaster


1 package transactions.security;
2
3 import dinamica.*;
4
5 /**
6  * Insert service record and its associated application roles
7  * <br><br>
8  * Creation date: 5/03/2004<br>
9  * Last Update: 5/03/2004<br>
10  * (c) 2004 Martin Cordova<br>
11  * This code is released under the LGPL license<br>
12  * @author Martin Cordova (dinamica@martincordova.com)
13  * */

14 public class InsertMaster extends GenericTransaction
15 {
16
17     /* (non-Javadoc)
18      * @see dinamica.GenericTransaction#service(dinamica.Recordset)
19      */

20     public int service(Recordset inputParams) throws Throwable JavaDoc
21     {
22
23         int rc = super.service(inputParams);
24                 
25         //get sql template for insert-user
26
String JavaDoc sql = getResource("insert.sql");
27         
28         //generate sql for insert-user
29
sql = this.getSQL(sql, inputParams);
30         
31         //get db connection
32
Db db = getDb();
33         
34         //insert user
35
db.exec(sql);
36
37         //get identity value
38
Recordset rsId = db.get("select @@identity master_id");
39         rsId.next();
40         
41         //insert roles using utility reusable object
42
sql = getResource("insert-roles.sql");
43         sql = this.getSQL(sql, rsId);
44         InsertRoles r = (InsertRoles)getObject("transactions.security.InsertRoles");
45         r.saveRoles(sql);
46         
47         return rc;
48         
49     }
50
51 }
52
Popular Tags