KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > acl > db > LoginDBInterface


1 package de.webman.acl.db;
2
3 import java.sql.SQLException JavaDoc;
4 import com.teamkonzept.db.TKDBManager;
5 import com.teamkonzept.db.TKDBTableData;
6 import com.teamkonzept.db.TKDBVectorData;
7 import com.teamkonzept.db.TKQuery;
8 import com.teamkonzept.lib.TKVector;
9 import de.webman.acl.db.queries.*;
10
11 /**
12  * $Header: /cvsroot/webman-cms/source/webman/de/webman/acl/db/LoginDBInterface.java,v 1.1 2001/08/20 08:25:08 mischa Exp $
13  *
14  * Database interface for logins.
15  *
16  * @version 0.10
17  * @since 0.10
18  * @author © 2000 Team-Konzept
19  */

20 public class LoginDBInterface
21     extends ObjectDBInterface
22 {
23
24     // Constants
25

26     /**
27      * The table name.
28      */

29     public static final String JavaDoc TABLE_NAME = "WM_USER";
30
31     /**
32      * The primary key name.
33      */

34     public static final String JavaDoc PRIMARY_KEY_NAME = "WM_USER_ID";
35
36     /**
37      * The dependent key name.
38      */

39     public static final String JavaDoc DEPENDENT_KEY_NAME = "WM_PROFILE_ID";
40
41     /**
42      * Dependent column name.
43      */

44     public static final String JavaDoc PRIORITY_COLUMN = "PRIORITY";
45
46     /**
47      * Column name.
48      */

49     public static final String JavaDoc LOGIN_COLUMN = "LOGIN";
50
51     /**
52      * Column name.
53      */

54     public static final String JavaDoc NAME_COLUMN = "NAME";
55
56     /**
57      * Column name.
58      */

59     public static final String JavaDoc TYPE_COLUMN = "TYPE";
60
61     /**
62      * Column value constant.
63      */

64     public static final String JavaDoc TYPE_USER = "U";
65
66     /**
67      * Column value constant.
68      */

69     public static final String JavaDoc TYPE_PROFILE = "P";
70
71     /**
72      * Selection class.
73      */

74     public static final Class JavaDoc WM_USER_SELECT_ALL = UserSelectAll.class;
75
76     /**
77      * Selection class.
78      */

79     public static final Class JavaDoc WM_USER_SELECT_BY_LOGIN = UserSelectByLogin.class;
80
81     /**
82      * Selection class.
83      */

84     public static final Class JavaDoc WM_USER_SELECT_BY_TYPE = UserSelectByType.class;
85
86     /**
87      * Selection class.
88      */

89     public static final Class JavaDoc WM_PROFILE_SELECT_BY_USER = ProfileSelectByUser.class;
90
91     /**
92      * Selection class.
93      */

94     public static final Class JavaDoc WM_PROFILE_SELECT_BY_PROFILE = ProfileSelectByProfile.class;
95
96     /**
97      * Insertion class.
98      */

99     public static final Class JavaDoc WM_PROFILE_INSERT = ProfileInsert.class;
100
101     /**
102      * Special update class.
103      */

104     public static final Class JavaDoc WM_PROFILE_UPDATE = ProfileUpdate.class;
105
106     /**
107      * Singleton instance.
108      */

109     private static final LoginDBInterface INSTANCE = new LoginDBInterface();
110
111
112     // Constructors
113

114     /**
115      * Inhibits instantiation from outside.
116      */

117     private LoginDBInterface ()
118     {
119         super(UserInsert.class,
120               UserUpdate.class,
121               UserSelect.class,
122               UserDelete.class,
123               new Class JavaDoc[1],
124               new Class JavaDoc[1],
125               UserDeleteDependent.class);
126     }
127
128
129     // Instance
130

131     /**
132      * Returns the singleton instance of the database interface.
133      *
134      * @return the singleton instance of the database interface.
135      */

136     public static final LoginDBInterface getInstance ()
137     {
138         return INSTANCE;
139     }
140
141
142     // Method implementations
143

144     /**
145      * Returns the name of the database table.
146      *
147      * @return the name of the database table.
148      */

149     public final String JavaDoc getTableName ()
150     {
151         return TABLE_NAME;
152     }
153
154     /**
155      * Returns the name of the primary key.
156      *
157      * @return the name of the primary key.
158      */

159     public final String JavaDoc getPrimaryKeyName ()
160     {
161         return PRIMARY_KEY_NAME;
162     }
163
164     /**
165      * Returns the name of the dependent key.
166      *
167      * @return the name of the dependent key.
168      */

169     public final String JavaDoc getDependentKeyName ()
170     {
171         return DEPENDENT_KEY_NAME;
172     }
173
174     /**
175      * Returns the query for selection of all objects.
176      *
177      * @return the query for selection of all objects.
178      */

179     public final Class JavaDoc getSelectAllQuery ()
180     {
181         return WM_USER_SELECT_ALL;
182     }
183
184     /**
185      * Returns the query for selection of all dependent objects.
186      *
187      * @return the query for selection of all dependent objects.
188      */

189     public final Class JavaDoc getSelectDependentQuery ()
190     {
191         return WM_PROFILE_SELECT_BY_USER;
192     }
193
194     /**
195      * Returns the query for insertion of all dependent objects.
196      *
197      * @return the query for insertion of all dependent objects.
198      */

199     public final Class JavaDoc getInsertDependentQuery ()
200     {
201         return WM_PROFILE_INSERT;
202     }
203
204
205     // Overridden methods
206

207     public void doPutEntryTables (TKDBVectorData dbData)
208         throws SQLException JavaDoc
209     {
210         // Intercept special case for 'ProfileCollectionDBData'.
211
TKDBTableData data = dbData.getProtoType(null);
212
213         if (data != null &&
214             data instanceof ProfileCollectionDBData)
215         {
216             TKQuery query = TKDBManager.newQuery(((LoginDBData) dbData).getQuery());
217             TKVector vector = dbData.getVector(null);
218
219             int index = 0;
220             int size = vector.size();
221
222             while (index < size)
223             {
224                 ((ProfileCollectionDBData) vector.elementAt(index)).insertIntoQuery(query);
225                 query.execute();
226                 query.close();
227                 index++;
228             }
229         }
230         else
231         {
232             super.doPutEntryTables(dbData);
233         }
234     }
235
236 }
237
Popular Tags