KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > smile > stored > s_editUserToSection


1 package smile.stored;
2
3 import java.util.*;
4 import java.sql.*;
5
6 /**
7  * s_editUserToSection is an implements the ProcedureInterface and is a
8  * sub-class of StoredProcedure. This class updates or delete rights on sections
9  * for users in the database.
10  *
11  * Copyright 2003 Cofax
12  *
13  * @author Badr Chentouf
14  */

15
16 public class s_editUserToSection extends StoredProcedure implements ProcedureInterface {
17
18     // proprietes propres a cette stored proc
19
String JavaDoc in_userID;
20
21     String JavaDoc in_mappingCode;
22
23     String JavaDoc ifexists;
24
25     String JavaDoc in_director;
26
27     String JavaDoc ifnoneed;
28
29     public s_editUserToSection() {
30     }
31
32     public void init(HashMap initData, Connection con) {
33         // on initialise le hashmap de donnees et la connection de l'objet
34
super.init(initData, con);
35         // on initialise les proprietes de l'objet
36
in_userID = utils.getString(data, "USERID", "");
37         in_mappingCode = utils.getString(data, "MAPPINGCODE", "");
38         in_director = utils.getString(data, "DIRECTOR", "");
39         action = utils.getString(data, "ACTION", "");
40     }
41
42     public void checkAction() throws SQLException {
43         String JavaDoc qry = "SELECT count(0) as nb FROM tblpermusersection WHERE userID=" + in_userID + " AND mappingCode=" + in_mappingCode;
44         ifexists = execStatementToValue(qry);
45         close();
46     }
47
48     public void checkParams() throws SQLException {
49     }
50
51     public void executeAction() throws SQLException {
52         if (ifexists.equals("0")) {
53             if (action.equals("1")) {
54                 StringBuffer JavaDoc v_sb = new StringBuffer JavaDoc();
55                 v_sb.append("INSERT into tblpermusersection ").append(" values ('" + in_userID + "', '" + in_mappingCode + "', '" + in_director + "')");
56
57                 execStatement(v_sb.toString());
58             }
59             if (action.equals("2")) {
60                 StringBuffer JavaDoc v_sb = new StringBuffer JavaDoc();
61                 v_sb.append("INSERT into tblpermusersection ").append(" values ('" + in_userID + "', '" + in_mappingCode + "', '" + in_director + "')");
62
63                 execStatement(v_sb.toString());
64             }
65         } else if (ifexists.equals("1")) {
66             if (action.equals("0")) {
67                 StringBuffer JavaDoc v_sb = new StringBuffer JavaDoc();
68                 v_sb.append("DELETE FROM tblpermusersection ").append(" WHERE userID = " + in_userID + " ").append(" AND mappingCode = " + in_mappingCode);
69
70                 execStatement(v_sb.toString());
71             }
72             if ((action.equals("2")) || (action.equals("1"))) {
73                 StringBuffer JavaDoc v_sb = new StringBuffer JavaDoc();
74                 v_sb.append("UPDATE tblpermusersection ").append(" SET manager = " + in_director + " ").append(" WHERE userID = " + in_userID + " ").append(
75                         " AND mappingCode = " + in_mappingCode);
76
77                 execStatement(v_sb.toString());
78             }
79
80         }
81         execStatementToRS(queryResultOk);
82     }
83 }
Popular Tags