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;
232425/***26 * This class was autogenerated by Torque on:27 *28 * [Thu Apr 22 23:12:36 EDT 2004]29 *30 * You should not use this class directly. It should not even be31 * extended all references should be to TurbineGroup32 */33publicabstractclassBaseTurbineGroupextends BaseObject
34 {
35/*** The Peer class */36privatestaticfinalTurbineGroupPeer peer =
37newTurbineGroupPeer();
383940/*** The value for the groupId field */41privateint groupId;
4243/*** The value for the groupName field */44private String groupName;
4546/*** The value for the objectdata field */47private byte[] objectdata;
484950/***51 * Get the GroupId52 * @return int53 */54publicint getGroupId()
55 {
56return groupId;
57 }
585960/***61 * Set the value of GroupId62 */63publicvoid setGroupId(int v ) throws TorqueException
64 {
6566if (this.groupId != v)
67 {
68this.groupId = v;
69 setModified(true);
70 }
71727374// update associated TurbineUserGroupRole75if (collTurbineUserGroupRoles != null )
76 {
77for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
78 {
79 ((TurbineUserGroupRole)collTurbineUserGroupRoles.get(i))
80 .setGroupId(v);
81 }
82 }
83 }
848586/***87 * Get the GroupName88 * @return String89 */90public String getGroupName()
91 {
92return groupName;
93 }
949596/***97 * Set the value of GroupName98 */99publicvoid setGroupName(String v )
100 {
101102if (!ObjectUtils.equals(this.groupName, v))
103 {
104this.groupName = v;
105 setModified(true);
106 }
107108109 }
110111112/***113 * Get the Objectdata114 * @return byte[]115 */116public byte[] getObjectdata()
117 {
118return objectdata;
119 }
120121122/***123 * Set the value of Objectdata124 */125publicvoid setObjectdata(byte[] v )
126 {
127128if (!ObjectUtils.equals(this.objectdata, v))
129 {
130this.objectdata = v;
131 setModified(true);
132 }
133134135 }
136137138139140141/***142 * Collection to store aggregation of collTurbineUserGroupRoles143 */144protected List collTurbineUserGroupRoles;
145146/***147 * Temporary storage of collTurbineUserGroupRoles to save a possible db hit in148 * the event objects are add to the collection, but the149 * complete collection is never requested.150 */151protectedvoid initTurbineUserGroupRoles()
152 {
153if (collTurbineUserGroupRoles == null)
154 {
155 collTurbineUserGroupRoles = new ArrayList();
156 }
157 }
158159160/***161 * Method called to associate a TurbineUserGroupRole object to this object162 * through the TurbineUserGroupRole foreign key attribute163 *164 * @param TurbineUserGroupRole l165 */166publicvoid addTurbineUserGroupRole(TurbineUserGroupRole l) throws TorqueException
167 {
168 getTurbineUserGroupRoles().add(l);
169 l.setTurbineGroup((TurbineGroup)this);
170 }
171172/***173 * The criteria used to select the current contents of collTurbineUserGroupRoles174 */175private Criteria lastTurbineUserGroupRolesCriteria = null;
176177/***178 * If this collection has already been initialized, returns179 * the collection. Otherwise returns the results of180 * getTurbineUserGroupRoles(new Criteria())181 */182public List getTurbineUserGroupRoles() throws TorqueException
183 {
184if (collTurbineUserGroupRoles == null)
185 {
186 collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10));
187 }
188return collTurbineUserGroupRoles;
189 }
190191/***192 * If this collection has already been initialized with193 * an identical criteria, it returns the collection.194 * Otherwise if this TurbineGroup has previously195 * been saved, it will retrieve related TurbineUserGroupRoles from storage.196 * If this TurbineGroup is new, it will return197 * an empty collection or the current collection, the criteria198 * is ignored on a new object.199 */200public List getTurbineUserGroupRoles(Criteria criteria) throws TorqueException
201 {
202if (collTurbineUserGroupRoles == null)
203 {
204if (isNew())
205 {
206 collTurbineUserGroupRoles = new ArrayList();
207 }
208else209 {
210 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
211 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
212 }
213 }
214else215 {
216// criteria has no effect for a new object217if (!isNew())
218 {
219// the following code is to determine if a new query is220// called for. If the criteria is the same as the last221// one, just return the collection.222 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
223if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
224 {
225 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
226 }
227 }
228 }
229 lastTurbineUserGroupRolesCriteria = criteria;
230231return collTurbineUserGroupRoles;
232 }
233234/***235 * If this collection has already been initialized, returns236 * the collection. Otherwise returns the results of237 * getTurbineUserGroupRoles(new Criteria(),Connection)238 * This method takes in the Connection also as input so that239 * referenced objects can also be obtained using a Connection240 * that is taken as input241 */242public List getTurbineUserGroupRoles(Connection con) throws TorqueException
243 {
244if (collTurbineUserGroupRoles == null)
245 {
246 collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10),con);
247 }
248return collTurbineUserGroupRoles;
249 }
250251/***252 * If this collection has already been initialized with253 * an identical criteria, it returns the collection.254 * Otherwise if this TurbineGroup has previously255 * been saved, it will retrieve related TurbineUserGroupRoles from storage.256 * If this TurbineGroup is new, it will return257 * an empty collection or the current collection, the criteria258 * is ignored on a new object.259 * This method takes in the Connection also as input so that260 * referenced objects can also be obtained using a Connection261 * that is taken as input262 */263public List getTurbineUserGroupRoles(Criteria criteria,Connection con) throws TorqueException
264 {
265if (collTurbineUserGroupRoles == null)
266 {
267if (isNew())
268 {
269 collTurbineUserGroupRoles = new ArrayList();
270 }
271else272 {
273 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
274 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria,con);
275 }
276 }
277else278 {
279// criteria has no effect for a new object280if (!isNew())
281 {
282// the following code is to determine if a new query is283// called for. If the criteria is the same as the last284// one, just return the collection.285 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
286if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
287 {
288 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria,con);
289 }
290 }
291 }
292 lastTurbineUserGroupRolesCriteria = criteria;
293294return collTurbineUserGroupRoles;
295 }
296297298299300301302303304305306307308/***309 * If this collection has already been initialized with310 * an identical criteria, it returns the collection.311 * Otherwise if this TurbineGroup is new, it will return312 * an empty collection; or if this TurbineGroup has previously313 * been saved, it will retrieve related TurbineUserGroupRoles from storage.314 *315 * This method is protected by default in order to keep the public316 * api reasonable. You can provide public methods for those you317 * actually need in TurbineGroup.318 */319protected List getTurbineUserGroupRolesJoinTurbineUser(Criteria criteria)
320 throws TorqueException
321 {
322if (collTurbineUserGroupRoles == null)
323 {
324if (isNew())
325 {
326 collTurbineUserGroupRoles = new ArrayList();
327 }
328else329 {
330 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
331 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
332 }
333 }
334else335 {
336// the following code is to determine if a new query is337// called for. If the criteria is the same as the last338// one, just return the collection.339boolean newCriteria = true;
340 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
341if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
342 {
343 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
344 }
345 }
346 lastTurbineUserGroupRolesCriteria = criteria;
347348return collTurbineUserGroupRoles;
349 }
350351352353354355356357358359/***360 * If this collection has already been initialized with361 * an identical criteria, it returns the collection.362 * Otherwise if this TurbineGroup is new, it will return363 * an empty collection; or if this TurbineGroup has previously364 * been saved, it will retrieve related TurbineUserGroupRoles from storage.365 *366 * This method is protected by default in order to keep the public367 * api reasonable. You can provide public methods for those you368 * actually need in TurbineGroup.369 */370protected List getTurbineUserGroupRolesJoinTurbineGroup(Criteria criteria)
371 throws TorqueException
372 {
373if (collTurbineUserGroupRoles == null)
374 {
375if (isNew())
376 {
377 collTurbineUserGroupRoles = new ArrayList();
378 }
379else380 {
381 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
382 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
383 }
384 }
385else386 {
387// the following code is to determine if a new query is388// called for. If the criteria is the same as the last389// one, just return the collection.390boolean newCriteria = true;
391 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
392if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
393 {
394 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
395 }
396 }
397 lastTurbineUserGroupRolesCriteria = criteria;
398399return collTurbineUserGroupRoles;
400 }
401402403404405406407408409410/***411 * If this collection has already been initialized with412 * an identical criteria, it returns the collection.413 * Otherwise if this TurbineGroup is new, it will return414 * an empty collection; or if this TurbineGroup has previously415 * been saved, it will retrieve related TurbineUserGroupRoles from storage.416 *417 * This method is protected by default in order to keep the public418 * api reasonable. You can provide public methods for those you419 * actually need in TurbineGroup.420 */421protected List getTurbineUserGroupRolesJoinTurbineRole(Criteria criteria)
422 throws TorqueException
423 {
424if (collTurbineUserGroupRoles == null)
425 {
426if (isNew())
427 {
428 collTurbineUserGroupRoles = new ArrayList();
429 }
430else431 {
432 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
433 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
434 }
435 }
436else437 {
438// the following code is to determine if a new query is439// called for. If the criteria is the same as the last440// one, just return the collection.441boolean newCriteria = true;
442 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
443if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
444 {
445 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
446 }
447 }
448 lastTurbineUserGroupRolesCriteria = criteria;
449450return collTurbineUserGroupRoles;
451 }
452453454455456privatestatic List fieldNames = null;
457458/***459 * Generate a list of field names.460 */461publicstaticsynchronized List getFieldNames()
462 {
463if (fieldNames == null)
464 {
465 fieldNames = new ArrayList();
466 fieldNames.add("GroupId");
467 fieldNames.add("GroupName");
468 fieldNames.add("Objectdata");
469 fieldNames = Collections.unmodifiableList(fieldNames);
470 }
471return fieldNames;
472 }
473474/***475 * Retrieves a field from the object by name passed in476 * as a String.477 */478public Object getByName(String name)
479 {
480if (name.equals("GroupId"))
481 {
482returnnew Integer(getGroupId());
483 }
484if (name.equals("GroupName"))
485 {
486return getGroupName();
487 }
488if (name.equals("Objectdata"))
489 {
490return getObjectdata();
491 }
492returnnull;
493 }
494495/***496 * Retrieves a field from the object by name passed in497 * as a String. The String must be one of the static498 * Strings defined in this Class' Peer.499 */500public Object getByPeerName(String name)
501 {
502if (name.equals(TurbineGroupPeer.GROUP_ID ))
503 {
504returnnew Integer(getGroupId());
505 }
506if (name.equals(TurbineGroupPeer.GROUP_NAME ))
507 {
508return getGroupName();
509 }
510if (name.equals(TurbineGroupPeer.OBJECTDATA ))
511 {
512return getObjectdata();
513 }
514returnnull;
515 }
516517/***518 * Retrieves a field from the object by Position as specified519 * in the xml schema. Zero-based.520 */521public Object getByPosition(int pos)
522 {
523if ( pos == 0 )
524 {
525returnnew Integer(getGroupId());
526 }
527if ( pos == 1 )
528 {
529return getGroupName();
530 }
531if ( pos == 2 )
532 {
533return getObjectdata();
534 }
535returnnull;
536 }
537538/***539 * Stores the object in the database. If the object is new,540 * it inserts it; otherwise an update is performed.541 */542publicvoid save() throws Exception
543 {
544 save(TurbineGroupPeer.getMapBuilder()
545 .getDatabaseMap().getName());
546 }
547548/***549 * Stores the object in the database. If the object is new,550 * it inserts it; otherwise an update is performed.551 * Note: this code is here because the method body is552 * auto-generated conditionally and therefore needs to be553 * in this file instead of in the super class, BaseObject.554 */555publicvoid save(String dbName) throws TorqueException
556 {
557 Connection con = null;
558try559 {
560 con = Transaction.begin(dbName);
561 save(con);
562 Transaction.commit(con);
563 }
564catch(TorqueException e)
565 {
566 Transaction.safeRollback(con);
567throw e;
568 }
569 }
570571/*** flag to prevent endless save loop, if this object is referenced572 by another object which falls in this transaction. */573privateboolean alreadyInSave = false;
574/***575 * Stores the object in the database. If the object is new,576 * it inserts it; otherwise an update is performed. This method577 * is meant to be used as part of a transaction, otherwise use578 * the save() method and the connection details will be handled579 * internally580 */581publicvoid save(Connection con) throws TorqueException
582 {
583if (!alreadyInSave)
584 {
585 alreadyInSave = true;
586587588589// If this object has been modified, then save it to the database.590if (isModified())
591 {
592if (isNew())
593 {
594 TurbineGroupPeer.doInsert((TurbineGroup)this, con);
595 setNew(false);
596 }
597else598 {
599 TurbineGroupPeer.doUpdate((TurbineGroup)this, con);
600 }
601602if (isCacheOnSave())
603 {
604 TurbineGroupManager.putInstance(this);
605 }
606 }
607608609if (collTurbineUserGroupRoles != null )
610 {
611for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
612 {
613 ((TurbineUserGroupRole)collTurbineUserGroupRoles.get(i)).save(con);
614 }
615 }
616 alreadyInSave = false;
617 }
618 }
619620/***621 * Specify whether to cache the object after saving to the db.622 * This method returns false623 */624protectedboolean isCacheOnSave()
625 {
626returntrue;
627 }
628629630/***631 * Set the PrimaryKey using ObjectKey.632 *633 * @param ObjectKey groupId634 */635publicvoid setPrimaryKey(ObjectKey groupId)
636 throws TorqueException {
637 setGroupId(((NumberKey)groupId).intValue());
638 }
639640/***641 * Set the PrimaryKey using a String.642 */643publicvoid setPrimaryKey(String key) throws TorqueException
644 {
645 setGroupId(Integer.parseInt(key));
646 }
647648649/***650 * returns an id that differentiates this object from others651 * of its class.652 */653public ObjectKey getPrimaryKey()
654 {
655return SimpleKey.keyFor(getGroupId());
656 }
657658659/***660 * Makes a copy of this object.661 * It creates a new object filling in the simple attributes.662 * It then fills all the association collections.663 */664publicTurbineGroup copy() throws TorqueException
665 {
666TurbineGroup copyObj = newTurbineGroup();
667 copyObj.setGroupId(groupId);
668 copyObj.setGroupName(groupName);
669 copyObj.setObjectdata(objectdata);
670671 copyObj.setGroupId(0);
672673674675 List v = getTurbineUserGroupRoles();
676for (int i = 0; i < v.size(); i++)
677 {
678TurbineUserGroupRole obj = (TurbineUserGroupRole) v.get(i);
679 copyObj.addTurbineUserGroupRole(obj.copy());
680 }
681return copyObj;
682 }
683684/***685 * returns a peer instance associated with this om. Since Peer classes686 * are not to have any instance attributes, this method returns the687 * same instance for all member of this class. The method could therefore688 * be static, but this would prevent one from overriding the behavior.689 */690publicTurbineGroupPeer getPeer()
691 {
692return peer;
693 }
694 }