001: package de.webman.acl.db;
002:
003: import java.sql.SQLException;
004: import com.teamkonzept.db.TKDBManager;
005: import com.teamkonzept.db.TKDBTableData;
006: import com.teamkonzept.db.TKDBVectorData;
007: import com.teamkonzept.db.TKQuery;
008: import com.teamkonzept.lib.TKVector;
009: import de.webman.acl.db.queries.*;
010:
011: /**
012: * $Header: /cvsroot/webman-cms/source/webman/de/webman/acl/db/LoginDBInterface.java,v 1.1 2001/08/20 08:25:08 mischa Exp $
013: *
014: * Database interface for logins.
015: *
016: * @version 0.10
017: * @since 0.10
018: * @author © 2000 Team-Konzept
019: */
020: public class LoginDBInterface extends ObjectDBInterface {
021:
022: // Constants
023:
024: /**
025: * The table name.
026: */
027: public static final String TABLE_NAME = "WM_USER";
028:
029: /**
030: * The primary key name.
031: */
032: public static final String PRIMARY_KEY_NAME = "WM_USER_ID";
033:
034: /**
035: * The dependent key name.
036: */
037: public static final String DEPENDENT_KEY_NAME = "WM_PROFILE_ID";
038:
039: /**
040: * Dependent column name.
041: */
042: public static final String PRIORITY_COLUMN = "PRIORITY";
043:
044: /**
045: * Column name.
046: */
047: public static final String LOGIN_COLUMN = "LOGIN";
048:
049: /**
050: * Column name.
051: */
052: public static final String NAME_COLUMN = "NAME";
053:
054: /**
055: * Column name.
056: */
057: public static final String TYPE_COLUMN = "TYPE";
058:
059: /**
060: * Column value constant.
061: */
062: public static final String TYPE_USER = "U";
063:
064: /**
065: * Column value constant.
066: */
067: public static final String TYPE_PROFILE = "P";
068:
069: /**
070: * Selection class.
071: */
072: public static final Class WM_USER_SELECT_ALL = UserSelectAll.class;
073:
074: /**
075: * Selection class.
076: */
077: public static final Class WM_USER_SELECT_BY_LOGIN = UserSelectByLogin.class;
078:
079: /**
080: * Selection class.
081: */
082: public static final Class WM_USER_SELECT_BY_TYPE = UserSelectByType.class;
083:
084: /**
085: * Selection class.
086: */
087: public static final Class WM_PROFILE_SELECT_BY_USER = ProfileSelectByUser.class;
088:
089: /**
090: * Selection class.
091: */
092: public static final Class WM_PROFILE_SELECT_BY_PROFILE = ProfileSelectByProfile.class;
093:
094: /**
095: * Insertion class.
096: */
097: public static final Class WM_PROFILE_INSERT = ProfileInsert.class;
098:
099: /**
100: * Special update class.
101: */
102: public static final Class WM_PROFILE_UPDATE = ProfileUpdate.class;
103:
104: /**
105: * Singleton instance.
106: */
107: private static final LoginDBInterface INSTANCE = new LoginDBInterface();
108:
109: // Constructors
110:
111: /**
112: * Inhibits instantiation from outside.
113: */
114: private LoginDBInterface() {
115: super (UserInsert.class, UserUpdate.class, UserSelect.class,
116: UserDelete.class, new Class[1], new Class[1],
117: UserDeleteDependent.class);
118: }
119:
120: // Instance
121:
122: /**
123: * Returns the singleton instance of the database interface.
124: *
125: * @return the singleton instance of the database interface.
126: */
127: public static final LoginDBInterface getInstance() {
128: return INSTANCE;
129: }
130:
131: // Method implementations
132:
133: /**
134: * Returns the name of the database table.
135: *
136: * @return the name of the database table.
137: */
138: public final String getTableName() {
139: return TABLE_NAME;
140: }
141:
142: /**
143: * Returns the name of the primary key.
144: *
145: * @return the name of the primary key.
146: */
147: public final String getPrimaryKeyName() {
148: return PRIMARY_KEY_NAME;
149: }
150:
151: /**
152: * Returns the name of the dependent key.
153: *
154: * @return the name of the dependent key.
155: */
156: public final String getDependentKeyName() {
157: return DEPENDENT_KEY_NAME;
158: }
159:
160: /**
161: * Returns the query for selection of all objects.
162: *
163: * @return the query for selection of all objects.
164: */
165: public final Class getSelectAllQuery() {
166: return WM_USER_SELECT_ALL;
167: }
168:
169: /**
170: * Returns the query for selection of all dependent objects.
171: *
172: * @return the query for selection of all dependent objects.
173: */
174: public final Class getSelectDependentQuery() {
175: return WM_PROFILE_SELECT_BY_USER;
176: }
177:
178: /**
179: * Returns the query for insertion of all dependent objects.
180: *
181: * @return the query for insertion of all dependent objects.
182: */
183: public final Class getInsertDependentQuery() {
184: return WM_PROFILE_INSERT;
185: }
186:
187: // Overridden methods
188:
189: public void doPutEntryTables(TKDBVectorData dbData)
190: throws SQLException {
191: // Intercept special case for 'ProfileCollectionDBData'.
192: TKDBTableData data = dbData.getProtoType(null);
193:
194: if (data != null && data instanceof ProfileCollectionDBData) {
195: TKQuery query = TKDBManager.newQuery(((LoginDBData) dbData)
196: .getQuery());
197: TKVector vector = dbData.getVector(null);
198:
199: int index = 0;
200: int size = vector.size();
201:
202: while (index < size) {
203: ((ProfileCollectionDBData) vector.elementAt(index))
204: .insertIntoQuery(query);
205: query.execute();
206: query.close();
207: index++;
208: }
209: } else {
210: super.doPutEntryTables(dbData);
211: }
212: }
213:
214: }
|