KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > smile > stored > s_editGroupToPub


1 package smile.stored;
2
3 import java.util.*;
4
5 import java.sql.*;
6
7 /**
8  * s_editGroupToPub is an implements the ProcedureInterface and is a sub-class
9  * of StoredProcedure. This class updates or inserts groups associated with
10  * publications in the database.
11  *
12  * Copyright 2002 Smile Les motoristes Internet http://www.smile.fr/ Contact
13  * cofax@smile.fr for further information
14  *
15  * @author Smile Les motoristes Internet
16  *
17  */

18 public class s_editGroupToPub extends StoredProcedure implements ProcedureInterface {
19
20     // proprietes propres a cette stored proc
21
String JavaDoc in_groupID;
22
23     String JavaDoc in_pubID;
24
25     String JavaDoc in_delete;
26
27     String JavaDoc in_ifexists;
28
29     public s_editGroupToPub() {
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 propprietes de l'objet
36
in_groupID = utils.getString(data, "GROUPID", "");
37         in_pubID = utils.getString(data, "PUBID", "");
38         in_delete = utils.getString(data, "DELETE", "");
39         utils.log("in-delete = " + in_delete);
40     }
41
42     public void checkAction() throws SQLException {
43     }
44
45     public void checkParams() throws SQLException {
46     }
47
48     public void executeAction() throws SQLException {
49         StringBuffer JavaDoc v_sbSelect = new StringBuffer JavaDoc();
50         v_sbSelect.append("SELECT count(*) ").append(" FROM tblpermgrouppublication ").append(" WHERE groupID = " + in_groupID).append(
51                 " AND pubID = " + in_pubID);
52
53         in_ifexists = execStatementToValue(v_sbSelect.toString());
54
55         if (in_ifexists.equals("0")) {
56             if (in_delete.equals("0")) {
57                 StringBuffer JavaDoc v_sb = new StringBuffer JavaDoc();
58                 v_sb.append("INSERT INTO tblpermgrouppublication ").append(" VALUES(" + in_groupID + "," + in_pubID + ")");
59
60                 execStatement(v_sb.toString());
61             }
62         }
63
64         else {
65             if (Integer.parseInt(in_ifexists) > 0) {
66                 if (in_delete.equals("1")) {
67                     StringBuffer JavaDoc v_sbDelete = new StringBuffer JavaDoc();
68                     v_sbDelete.append("DELETE FROM tblpermgrouppublication ").append(" WHERE groupID = " + in_groupID).append(" AND pubID = " + in_pubID);
69
70                     execStatement(v_sbDelete.toString());
71
72                 }
73             }
74         }
75         execStatementToRS(queryResultOk);
76     }
77 }
Popular Tags