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;
232425262728/***29 * This class was autogenerated by Torque on:30 *31 * [Thu Apr 22 23:12:36 EDT 2004]32 *33 * You should not use this class directly. It should not even be34 * extended all references should be to TurbineUserGroupRole35 */36publicabstractclassBaseTurbineUserGroupRoleextends BaseObject
37 {
38/*** The Peer class */39privatestaticfinalTurbineUserGroupRolePeer peer =
40newTurbineUserGroupRolePeer();
414243/*** The value for the userId field */44privateint userId;
4546/*** The value for the groupId field */47privateint groupId;
4849/*** The value for the roleId field */50privateint roleId;
515253/***54 * Get the UserId55 * @return int56 */57publicint getUserId()
58 {
59return userId;
60 }
616263/***64 * Set the value of UserId65 */66publicvoid setUserId(int v ) throws TorqueException
67 {
6869if (this.userId != v)
70 {
71this.userId = v;
72 setModified(true);
73 }
747576if (aTurbineUser != null && !(aTurbineUser.getUserId() == v))
77 {
78 aTurbineUser = null;
79 }
8081 }
828384/***85 * Get the GroupId86 * @return int87 */88publicint getGroupId()
89 {
90return groupId;
91 }
929394/***95 * Set the value of GroupId96 */97publicvoid setGroupId(int v ) throws TorqueException
98 {
99100if (this.groupId != v)
101 {
102this.groupId = v;
103 setModified(true);
104 }
105106107if (aTurbineGroup != null && !(aTurbineGroup.getGroupId() == v))
108 {
109 aTurbineGroup = null;
110 }
111112 }
113114115/***116 * Get the RoleId117 * @return int118 */119publicint getRoleId()
120 {
121return roleId;
122 }
123124125/***126 * Set the value of RoleId127 */128publicvoid setRoleId(int v ) throws TorqueException
129 {
130131if (this.roleId != v)
132 {
133this.roleId = v;
134 setModified(true);
135 }
136137138if (aTurbineRole != null && !(aTurbineRole.getRoleId() == v))
139 {
140 aTurbineRole = null;
141 }
142143 }
144145146147148149privateTurbineUser aTurbineUser;
150151/***152 * Declares an association between this object and a TurbineUser object153 *154 * @param TurbineUser v155 */156publicvoid setTurbineUser(TurbineUser v) throws TorqueException
157 {
158if (v == null)
159 {
160 setUserId(0);
161 }
162else163 {
164 setUserId(v.getUserId());
165 }
166 aTurbineUser = v;
167 }
168169170publicTurbineUser getTurbineUser() throws TorqueException
171 {
172if ( getUserId()>0 )
173 {
174return TurbineUserManager.getInstance(SimpleKey.keyFor(getUserId()));
175 }
176return aTurbineUser;
177 }
178179/***180 * Provides convenient way to set a relationship based on a181 * ObjectKey. e.g.182 * <code>bar.setFooKey(foo.getPrimaryKey())</code>183 *184 */185publicvoid setTurbineUserKey(ObjectKey key) throws TorqueException
186 {
187188 setUserId(((NumberKey) key).intValue());
189 }
190191192193194privateTurbineGroup aTurbineGroup;
195196/***197 * Declares an association between this object and a TurbineGroup object198 *199 * @param TurbineGroup v200 */201publicvoid setTurbineGroup(TurbineGroup v) throws TorqueException
202 {
203if (v == null)
204 {
205 setGroupId(0);
206 }
207else208 {
209 setGroupId(v.getGroupId());
210 }
211 aTurbineGroup = v;
212 }
213214215publicTurbineGroup getTurbineGroup() throws TorqueException
216 {
217if ( getGroupId()>0 )
218 {
219return TurbineGroupManager.getInstance(SimpleKey.keyFor(getGroupId()));
220 }
221return aTurbineGroup;
222 }
223224/***225 * Provides convenient way to set a relationship based on a226 * ObjectKey. e.g.227 * <code>bar.setFooKey(foo.getPrimaryKey())</code>228 *229 */230publicvoid setTurbineGroupKey(ObjectKey key) throws TorqueException
231 {
232233 setGroupId(((NumberKey) key).intValue());
234 }
235236237238239privateTurbineRole aTurbineRole;
240241/***242 * Declares an association between this object and a TurbineRole object243 *244 * @param TurbineRole v245 */246publicvoid setTurbineRole(TurbineRole v) throws TorqueException
247 {
248if (v == null)
249 {
250 setRoleId(0);
251 }
252else253 {
254 setRoleId(v.getRoleId());
255 }
256 aTurbineRole = v;
257 }
258259260publicTurbineRole getTurbineRole() throws TorqueException
261 {
262if ( getRoleId()>0 )
263 {
264return TurbineRoleManager.getInstance(SimpleKey.keyFor(getRoleId()));
265 }
266return aTurbineRole;
267 }
268269/***270 * Provides convenient way to set a relationship based on a271 * ObjectKey. e.g.272 * <code>bar.setFooKey(foo.getPrimaryKey())</code>273 *274 */275publicvoid setTurbineRoleKey(ObjectKey key) throws TorqueException
276 {
277278 setRoleId(((NumberKey) key).intValue());
279 }
280281282283privatestatic List fieldNames = null;
284285/***286 * Generate a list of field names.287 */288publicstaticsynchronized List getFieldNames()
289 {
290if (fieldNames == null)
291 {
292 fieldNames = new ArrayList();
293 fieldNames.add("UserId");
294 fieldNames.add("GroupId");
295 fieldNames.add("RoleId");
296 fieldNames = Collections.unmodifiableList(fieldNames);
297 }
298return fieldNames;
299 }
300301/***302 * Retrieves a field from the object by name passed in303 * as a String.304 */305public Object getByName(String name)
306 {
307if (name.equals("UserId"))
308 {
309returnnew Integer(getUserId());
310 }
311if (name.equals("GroupId"))
312 {
313returnnew Integer(getGroupId());
314 }
315if (name.equals("RoleId"))
316 {
317returnnew Integer(getRoleId());
318 }
319returnnull;
320 }
321322/***323 * Retrieves a field from the object by name passed in324 * as a String. The String must be one of the static325 * Strings defined in this Class' Peer.326 */327public Object getByPeerName(String name)
328 {
329if (name.equals(TurbineUserGroupRolePeer.USER_ID ))
330 {
331returnnew Integer(getUserId());
332 }
333if (name.equals(TurbineUserGroupRolePeer.GROUP_ID ))
334 {
335returnnew Integer(getGroupId());
336 }
337if (name.equals(TurbineUserGroupRolePeer.ROLE_ID ))
338 {
339returnnew Integer(getRoleId());
340 }
341returnnull;
342 }
343344/***345 * Retrieves a field from the object by Position as specified346 * in the xml schema. Zero-based.347 */348public Object getByPosition(int pos)
349 {
350if ( pos == 0 )
351 {
352returnnew Integer(getUserId());
353 }
354if ( pos == 1 )
355 {
356returnnew Integer(getGroupId());
357 }
358if ( pos == 2 )
359 {
360returnnew Integer(getRoleId());
361 }
362returnnull;
363 }
364365/***366 * Stores the object in the database. If the object is new,367 * it inserts it; otherwise an update is performed.368 */369publicvoid save() throws Exception
370 {
371 save(TurbineUserGroupRolePeer.getMapBuilder()
372 .getDatabaseMap().getName());
373 }
374375/***376 * Stores the object in the database. If the object is new,377 * it inserts it; otherwise an update is performed.378 * Note: this code is here because the method body is379 * auto-generated conditionally and therefore needs to be380 * in this file instead of in the super class, BaseObject.381 */382publicvoid save(String dbName) throws TorqueException
383 {
384 Connection con = null;
385try386 {
387 con = Transaction.begin(dbName);
388 save(con);
389 Transaction.commit(con);
390 }
391catch(TorqueException e)
392 {
393 Transaction.safeRollback(con);
394throw e;
395 }
396 }
397398/*** flag to prevent endless save loop, if this object is referenced399 by another object which falls in this transaction. */400privateboolean alreadyInSave = false;
401/***402 * Stores the object in the database. If the object is new,403 * it inserts it; otherwise an update is performed. This method404 * is meant to be used as part of a transaction, otherwise use405 * the save() method and the connection details will be handled406 * internally407 */408publicvoid save(Connection con) throws TorqueException
409 {
410if (!alreadyInSave)
411 {
412 alreadyInSave = true;
413414415416// If this object has been modified, then save it to the database.417if (isModified())
418 {
419if (isNew())
420 {
421 TurbineUserGroupRolePeer.doInsert((TurbineUserGroupRole)this, con);
422 setNew(false);
423 }
424else425 {
426 TurbineUserGroupRolePeer.doUpdate((TurbineUserGroupRole)this, con);
427 }
428429if (isCacheOnSave())
430 {
431 TurbineUserGroupRoleManager.putInstance(this);
432 }
433 }
434435 alreadyInSave = false;
436 }
437 }
438439/***440 * Specify whether to cache the object after saving to the db.441 * This method returns false442 */443protectedboolean isCacheOnSave()
444 {
445returntrue;
446 }
447448449450privatefinal SimpleKey[] pks = new SimpleKey[3];
451privatefinal ComboKey comboPK = new ComboKey(pks);
452/***453 * Set the PrimaryKey with an ObjectKey454 */455publicvoid setPrimaryKey(ObjectKey key) throws TorqueException
456 {
457 SimpleKey[] keys = (SimpleKey[]) key.getValue();
458 SimpleKey tmpKey = null;
459 setUserId(((NumberKey)keys[0]).intValue());
460 setGroupId(((NumberKey)keys[1]).intValue());
461 setRoleId(((NumberKey)keys[2]).intValue());
462 }
463464/***465 * Set the PrimaryKey using SimpleKeys.466 *467 * @param int userId468 * @param int groupId469 * @param int roleId470 */471publicvoid setPrimaryKey( int userId, int groupId, int roleId)
472 throws TorqueException
473 {
474 setUserId(userId);
475 setGroupId(groupId);
476 setRoleId(roleId);
477 }
478479/***480 * Set the PrimaryKey using a String.481 */482publicvoid setPrimaryKey(String key) throws TorqueException
483 {
484 setPrimaryKey(new ComboKey(key));
485 }
486487/***488 * returns an id that differentiates this object from others489 * of its class.490 */491public ObjectKey getPrimaryKey()
492 {
493 pks[0] = SimpleKey.keyFor(getUserId());
494 pks[1] = SimpleKey.keyFor(getGroupId());
495 pks[2] = SimpleKey.keyFor(getRoleId());
496return comboPK;
497 }
498499500/***501 * Makes a copy of this object.502 * It creates a new object filling in the simple attributes.503 * It then fills all the association collections.504 */505publicTurbineUserGroupRole copy() throws TorqueException
506 {
507TurbineUserGroupRole copyObj = newTurbineUserGroupRole();
508 copyObj.setUserId(userId);
509 copyObj.setGroupId(groupId);
510 copyObj.setRoleId(roleId);
511512 copyObj.setUserId(0);
513 copyObj.setGroupId(0);
514 copyObj.setRoleId(0);
515516return copyObj;
517 }
518519/***520 * returns a peer instance associated with this om. Since Peer classes521 * are not to have any instance attributes, this method returns the522 * same instance for all member of this class. The method could therefore523 * be static, but this would prevent one from overriding the behavior.524 */525publicTurbineUserGroupRolePeer getPeer()
526 {
527return peer;
528 }
529 }