1packageorg.apache.jetspeed.om.security.turbine;
234import java.math.BigDecimal;
5import java.sql.Connection;
6import java.util.ArrayList;
7import java.util.Collections;
8import java.util.Date;
9import java.util.List;
1011import org.apache.commons.lang.ObjectUtils;
12import org.apache.torque.TorqueException;
13import org.apache.torque.om.BaseObject;
14import org.apache.torque.om.ComboKey;
15import org.apache.torque.om.DateKey;
16import org.apache.torque.om.NumberKey;
17import org.apache.torque.om.ObjectKey;
18import org.apache.torque.om.SimpleKey;
19import org.apache.torque.om.StringKey;
20import org.apache.torque.om.Persistent;
21import org.apache.torque.util.Criteria;
22import org.apache.torque.util.Transaction;
2324252627/***28 * This class was autogenerated by Torque on:29 *30 * [Thu Apr 22 23:12:36 EDT 2004]31 *32 * You should not use this class directly. It should not even be33 * extended all references should be to TurbineRolePermission34 */35publicabstractclassBaseTurbineRolePermissionextends BaseObject
36 {
37/*** The Peer class */38privatestaticfinalTurbineRolePermissionPeer peer =
39newTurbineRolePermissionPeer();
404142/*** The value for the roleId field */43privateint roleId;
4445/*** The value for the permissionId field */46privateint permissionId;
474849/***50 * Get the RoleId51 * @return int52 */53publicint getRoleId()
54 {
55return roleId;
56 }
575859/***60 * Set the value of RoleId61 */62publicvoid setRoleId(int v ) throws TorqueException
63 {
6465if (this.roleId != v)
66 {
67this.roleId = v;
68 setModified(true);
69 }
707172if (aTurbineRole != null && !(aTurbineRole.getRoleId() == v))
73 {
74 aTurbineRole = null;
75 }
7677 }
787980/***81 * Get the PermissionId82 * @return int83 */84publicint getPermissionId()
85 {
86return permissionId;
87 }
888990/***91 * Set the value of PermissionId92 */93publicvoid setPermissionId(int v ) throws TorqueException
94 {
9596if (this.permissionId != v)
97 {
98this.permissionId = v;
99 setModified(true);
100 }
101102103if (aTurbinePermission != null && !(aTurbinePermission.getPermissionId() == v))
104 {
105 aTurbinePermission = null;
106 }
107108 }
109110111112113114privateTurbineRole aTurbineRole;
115116/***117 * Declares an association between this object and a TurbineRole object118 *119 * @param TurbineRole v120 */121publicvoid setTurbineRole(TurbineRole v) throws TorqueException
122 {
123if (v == null)
124 {
125 setRoleId(0);
126 }
127else128 {
129 setRoleId(v.getRoleId());
130 }
131 aTurbineRole = v;
132 }
133134135publicTurbineRole getTurbineRole() throws TorqueException
136 {
137if ( getRoleId()>0 )
138 {
139return TurbineRoleManager.getInstance(SimpleKey.keyFor(getRoleId()));
140 }
141return aTurbineRole;
142 }
143144/***145 * Provides convenient way to set a relationship based on a146 * ObjectKey. e.g.147 * <code>bar.setFooKey(foo.getPrimaryKey())</code>148 *149 */150publicvoid setTurbineRoleKey(ObjectKey key) throws TorqueException
151 {
152153 setRoleId(((NumberKey) key).intValue());
154 }
155156157158159privateTurbinePermission aTurbinePermission;
160161/***162 * Declares an association between this object and a TurbinePermission object163 *164 * @param TurbinePermission v165 */166publicvoid setTurbinePermission(TurbinePermission v) throws TorqueException
167 {
168if (v == null)
169 {
170 setPermissionId(0);
171 }
172else173 {
174 setPermissionId(v.getPermissionId());
175 }
176 aTurbinePermission = v;
177 }
178179180publicTurbinePermission getTurbinePermission() throws TorqueException
181 {
182if ( getPermissionId()>0 )
183 {
184return TurbinePermissionManager.getInstance(SimpleKey.keyFor(getPermissionId()));
185 }
186return aTurbinePermission;
187 }
188189/***190 * Provides convenient way to set a relationship based on a191 * ObjectKey. e.g.192 * <code>bar.setFooKey(foo.getPrimaryKey())</code>193 *194 */195publicvoid setTurbinePermissionKey(ObjectKey key) throws TorqueException
196 {
197198 setPermissionId(((NumberKey) key).intValue());
199 }
200201202203privatestatic List fieldNames = null;
204205/***206 * Generate a list of field names.207 */208publicstaticsynchronized List getFieldNames()
209 {
210if (fieldNames == null)
211 {
212 fieldNames = new ArrayList();
213 fieldNames.add("RoleId");
214 fieldNames.add("PermissionId");
215 fieldNames = Collections.unmodifiableList(fieldNames);
216 }
217return fieldNames;
218 }
219220/***221 * Retrieves a field from the object by name passed in222 * as a String.223 */224public Object getByName(String name)
225 {
226if (name.equals("RoleId"))
227 {
228returnnew Integer(getRoleId());
229 }
230if (name.equals("PermissionId"))
231 {
232returnnew Integer(getPermissionId());
233 }
234returnnull;
235 }
236237/***238 * Retrieves a field from the object by name passed in239 * as a String. The String must be one of the static240 * Strings defined in this Class' Peer.241 */242public Object getByPeerName(String name)
243 {
244if (name.equals(TurbineRolePermissionPeer.ROLE_ID ))
245 {
246returnnew Integer(getRoleId());
247 }
248if (name.equals(TurbineRolePermissionPeer.PERMISSION_ID ))
249 {
250returnnew Integer(getPermissionId());
251 }
252returnnull;
253 }
254255/***256 * Retrieves a field from the object by Position as specified257 * in the xml schema. Zero-based.258 */259public Object getByPosition(int pos)
260 {
261if ( pos == 0 )
262 {
263returnnew Integer(getRoleId());
264 }
265if ( pos == 1 )
266 {
267returnnew Integer(getPermissionId());
268 }
269returnnull;
270 }
271272/***273 * Stores the object in the database. If the object is new,274 * it inserts it; otherwise an update is performed.275 */276publicvoid save() throws Exception
277 {
278 save(TurbineRolePermissionPeer.getMapBuilder()
279 .getDatabaseMap().getName());
280 }
281282/***283 * Stores the object in the database. If the object is new,284 * it inserts it; otherwise an update is performed.285 * Note: this code is here because the method body is286 * auto-generated conditionally and therefore needs to be287 * in this file instead of in the super class, BaseObject.288 */289publicvoid save(String dbName) throws TorqueException
290 {
291 Connection con = null;
292try293 {
294 con = Transaction.begin(dbName);
295 save(con);
296 Transaction.commit(con);
297 }
298catch(TorqueException e)
299 {
300 Transaction.safeRollback(con);
301throw e;
302 }
303 }
304305/*** flag to prevent endless save loop, if this object is referenced306 by another object which falls in this transaction. */307privateboolean alreadyInSave = false;
308/***309 * Stores the object in the database. If the object is new,310 * it inserts it; otherwise an update is performed. This method311 * is meant to be used as part of a transaction, otherwise use312 * the save() method and the connection details will be handled313 * internally314 */315publicvoid save(Connection con) throws TorqueException
316 {
317if (!alreadyInSave)
318 {
319 alreadyInSave = true;
320321322323// If this object has been modified, then save it to the database.324if (isModified())
325 {
326if (isNew())
327 {
328 TurbineRolePermissionPeer.doInsert((TurbineRolePermission)this, con);
329 setNew(false);
330 }
331else332 {
333 TurbineRolePermissionPeer.doUpdate((TurbineRolePermission)this, con);
334 }
335336if (isCacheOnSave())
337 {
338 TurbineRolePermissionManager.putInstance(this);
339 }
340 }
341342 alreadyInSave = false;
343 }
344 }
345346/***347 * Specify whether to cache the object after saving to the db.348 * This method returns false349 */350protectedboolean isCacheOnSave()
351 {
352returntrue;
353 }
354355356357privatefinal SimpleKey[] pks = new SimpleKey[2];
358privatefinal ComboKey comboPK = new ComboKey(pks);
359/***360 * Set the PrimaryKey with an ObjectKey361 */362publicvoid setPrimaryKey(ObjectKey key) throws TorqueException
363 {
364 SimpleKey[] keys = (SimpleKey[]) key.getValue();
365 SimpleKey tmpKey = null;
366 setRoleId(((NumberKey)keys[0]).intValue());
367 setPermissionId(((NumberKey)keys[1]).intValue());
368 }
369370/***371 * Set the PrimaryKey using SimpleKeys.372 *373 * @param int roleId374 * @param int permissionId375 */376publicvoid setPrimaryKey( int roleId, int permissionId)
377 throws TorqueException
378 {
379 setRoleId(roleId);
380 setPermissionId(permissionId);
381 }
382383/***384 * Set the PrimaryKey using a String.385 */386publicvoid setPrimaryKey(String key) throws TorqueException
387 {
388 setPrimaryKey(new ComboKey(key));
389 }
390391/***392 * returns an id that differentiates this object from others393 * of its class.394 */395public ObjectKey getPrimaryKey()
396 {
397 pks[0] = SimpleKey.keyFor(getRoleId());
398 pks[1] = SimpleKey.keyFor(getPermissionId());
399return comboPK;
400 }
401402403/***404 * Makes a copy of this object.405 * It creates a new object filling in the simple attributes.406 * It then fills all the association collections.407 */408publicTurbineRolePermission copy() throws TorqueException
409 {
410TurbineRolePermission copyObj = newTurbineRolePermission();
411 copyObj.setRoleId(roleId);
412 copyObj.setPermissionId(permissionId);
413414 copyObj.setRoleId(0);
415 copyObj.setPermissionId(0);
416417return copyObj;
418 }
419420/***421 * returns a peer instance associated with this om. Since Peer classes422 * are not to have any instance attributes, this method returns the423 * same instance for all member of this class. The method could therefore424 * be static, but this would prevent one from overriding the behavior.425 */426publicTurbineRolePermissionPeer getPeer()
427 {
428return peer;
429 }
430 }