1 package org.apache.jetspeed.om.security.turbine;
2
3
4 import java.math.BigDecimal;
5 import java.sql.Connection;
6 import java.util.ArrayList;
7 import java.util.Collections;
8 import java.util.Date;
9 import java.util.List;
10
11 import org.apache.commons.lang.ObjectUtils;
12 import org.apache.torque.TorqueException;
13 import org.apache.torque.om.BaseObject;
14 import org.apache.torque.om.ComboKey;
15 import org.apache.torque.om.DateKey;
16 import org.apache.torque.om.NumberKey;
17 import org.apache.torque.om.ObjectKey;
18 import org.apache.torque.om.SimpleKey;
19 import org.apache.torque.om.StringKey;
20 import org.apache.torque.om.Persistent;
21 import org.apache.torque.util.Criteria;
22 import org.apache.torque.util.Transaction;
23
24
25 /***
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 be
31 * extended all references should be to TurbineGroup
32 */
33 public abstract class BaseTurbineGroup extends BaseObject
34 {
35 /*** The Peer class */
36 private static final TurbineGroupPeer peer =
37 new TurbineGroupPeer();
38
39
40 /*** The value for the groupId field */
41 private int groupId;
42
43 /*** The value for the groupName field */
44 private String groupName;
45
46 /*** The value for the objectdata field */
47 private byte[] objectdata;
48
49
50 /***
51 * Get the GroupId
52 * @return int
53 */
54 public int getGroupId()
55 {
56 return groupId;
57 }
58
59
60 /***
61 * Set the value of GroupId
62 */
63 public void setGroupId(int v ) throws TorqueException
64 {
65
66 if (this.groupId != v)
67 {
68 this.groupId = v;
69 setModified(true);
70 }
71
72
73
74
75 if (collTurbineUserGroupRoles != null )
76 {
77 for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
78 {
79 ((TurbineUserGroupRole)collTurbineUserGroupRoles.get(i))
80 .setGroupId(v);
81 }
82 }
83 }
84
85
86 /***
87 * Get the GroupName
88 * @return String
89 */
90 public String getGroupName()
91 {
92 return groupName;
93 }
94
95
96 /***
97 * Set the value of GroupName
98 */
99 public void setGroupName(String v )
100 {
101
102 if (!ObjectUtils.equals(this.groupName, v))
103 {
104 this.groupName = v;
105 setModified(true);
106 }
107
108
109 }
110
111
112 /***
113 * Get the Objectdata
114 * @return byte[]
115 */
116 public byte[] getObjectdata()
117 {
118 return objectdata;
119 }
120
121
122 /***
123 * Set the value of Objectdata
124 */
125 public void setObjectdata(byte[] v )
126 {
127
128 if (!ObjectUtils.equals(this.objectdata, v))
129 {
130 this.objectdata = v;
131 setModified(true);
132 }
133
134
135 }
136
137
138
139
140
141 /***
142 * Collection to store aggregation of collTurbineUserGroupRoles
143 */
144 protected List collTurbineUserGroupRoles;
145
146 /***
147 * Temporary storage of collTurbineUserGroupRoles to save a possible db hit in
148 * the event objects are add to the collection, but the
149 * complete collection is never requested.
150 */
151 protected void initTurbineUserGroupRoles()
152 {
153 if (collTurbineUserGroupRoles == null)
154 {
155 collTurbineUserGroupRoles = new ArrayList();
156 }
157 }
158
159
160 /***
161 * Method called to associate a TurbineUserGroupRole object to this object
162 * through the TurbineUserGroupRole foreign key attribute
163 *
164 * @param TurbineUserGroupRole l
165 */
166 public void addTurbineUserGroupRole(TurbineUserGroupRole l) throws TorqueException
167 {
168 getTurbineUserGroupRoles().add(l);
169 l.setTurbineGroup((TurbineGroup)this);
170 }
171
172 /***
173 * The criteria used to select the current contents of collTurbineUserGroupRoles
174 */
175 private Criteria lastTurbineUserGroupRolesCriteria = null;
176
177 /***
178 * If this collection has already been initialized, returns
179 * the collection. Otherwise returns the results of
180 * getTurbineUserGroupRoles(new Criteria())
181 */
182 public List getTurbineUserGroupRoles() throws TorqueException
183 {
184 if (collTurbineUserGroupRoles == null)
185 {
186 collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10));
187 }
188 return collTurbineUserGroupRoles;
189 }
190
191 /***
192 * If this collection has already been initialized with
193 * an identical criteria, it returns the collection.
194 * Otherwise if this TurbineGroup has previously
195 * been saved, it will retrieve related TurbineUserGroupRoles from storage.
196 * If this TurbineGroup is new, it will return
197 * an empty collection or the current collection, the criteria
198 * is ignored on a new object.
199 */
200 public List getTurbineUserGroupRoles(Criteria criteria) throws TorqueException
201 {
202 if (collTurbineUserGroupRoles == null)
203 {
204 if (isNew())
205 {
206 collTurbineUserGroupRoles = new ArrayList();
207 }
208 else
209 {
210 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
211 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
212 }
213 }
214 else
215 {
216
217 if (!isNew())
218 {
219
220
221
222 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
223 if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
224 {
225 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
226 }
227 }
228 }
229 lastTurbineUserGroupRolesCriteria = criteria;
230
231 return collTurbineUserGroupRoles;
232 }
233
234 /***
235 * If this collection has already been initialized, returns
236 * the collection. Otherwise returns the results of
237 * getTurbineUserGroupRoles(new Criteria(),Connection)
238 * This method takes in the Connection also as input so that
239 * referenced objects can also be obtained using a Connection
240 * that is taken as input
241 */
242 public List getTurbineUserGroupRoles(Connection con) throws TorqueException
243 {
244 if (collTurbineUserGroupRoles == null)
245 {
246 collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10),con);
247 }
248 return collTurbineUserGroupRoles;
249 }
250
251 /***
252 * If this collection has already been initialized with
253 * an identical criteria, it returns the collection.
254 * Otherwise if this TurbineGroup has previously
255 * been saved, it will retrieve related TurbineUserGroupRoles from storage.
256 * If this TurbineGroup is new, it will return
257 * an empty collection or the current collection, the criteria
258 * is ignored on a new object.
259 * This method takes in the Connection also as input so that
260 * referenced objects can also be obtained using a Connection
261 * that is taken as input
262 */
263 public List getTurbineUserGroupRoles(Criteria criteria,Connection con) throws TorqueException
264 {
265 if (collTurbineUserGroupRoles == null)
266 {
267 if (isNew())
268 {
269 collTurbineUserGroupRoles = new ArrayList();
270 }
271 else
272 {
273 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
274 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria,con);
275 }
276 }
277 else
278 {
279
280 if (!isNew())
281 {
282
283
284
285 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
286 if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
287 {
288 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria,con);
289 }
290 }
291 }
292 lastTurbineUserGroupRolesCriteria = criteria;
293
294 return collTurbineUserGroupRoles;
295 }
296
297
298
299
300
301
302
303
304
305
306
307
308 /***
309 * If this collection has already been initialized with
310 * an identical criteria, it returns the collection.
311 * Otherwise if this TurbineGroup is new, it will return
312 * an empty collection; or if this TurbineGroup has previously
313 * been saved, it will retrieve related TurbineUserGroupRoles from storage.
314 *
315 * This method is protected by default in order to keep the public
316 * api reasonable. You can provide public methods for those you
317 * actually need in TurbineGroup.
318 */
319 protected List getTurbineUserGroupRolesJoinTurbineUser(Criteria criteria)
320 throws TorqueException
321 {
322 if (collTurbineUserGroupRoles == null)
323 {
324 if (isNew())
325 {
326 collTurbineUserGroupRoles = new ArrayList();
327 }
328 else
329 {
330 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
331 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
332 }
333 }
334 else
335 {
336
337
338
339 boolean newCriteria = true;
340 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
341 if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
342 {
343 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
344 }
345 }
346 lastTurbineUserGroupRolesCriteria = criteria;
347
348 return collTurbineUserGroupRoles;
349 }
350
351
352
353
354
355
356
357
358
359 /***
360 * If this collection has already been initialized with
361 * an identical criteria, it returns the collection.
362 * Otherwise if this TurbineGroup is new, it will return
363 * an empty collection; or if this TurbineGroup has previously
364 * been saved, it will retrieve related TurbineUserGroupRoles from storage.
365 *
366 * This method is protected by default in order to keep the public
367 * api reasonable. You can provide public methods for those you
368 * actually need in TurbineGroup.
369 */
370 protected List getTurbineUserGroupRolesJoinTurbineGroup(Criteria criteria)
371 throws TorqueException
372 {
373 if (collTurbineUserGroupRoles == null)
374 {
375 if (isNew())
376 {
377 collTurbineUserGroupRoles = new ArrayList();
378 }
379 else
380 {
381 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
382 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
383 }
384 }
385 else
386 {
387
388
389
390 boolean newCriteria = true;
391 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
392 if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
393 {
394 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
395 }
396 }
397 lastTurbineUserGroupRolesCriteria = criteria;
398
399 return collTurbineUserGroupRoles;
400 }
401
402
403
404
405
406
407
408
409
410 /***
411 * If this collection has already been initialized with
412 * an identical criteria, it returns the collection.
413 * Otherwise if this TurbineGroup is new, it will return
414 * an empty collection; or if this TurbineGroup has previously
415 * been saved, it will retrieve related TurbineUserGroupRoles from storage.
416 *
417 * This method is protected by default in order to keep the public
418 * api reasonable. You can provide public methods for those you
419 * actually need in TurbineGroup.
420 */
421 protected List getTurbineUserGroupRolesJoinTurbineRole(Criteria criteria)
422 throws TorqueException
423 {
424 if (collTurbineUserGroupRoles == null)
425 {
426 if (isNew())
427 {
428 collTurbineUserGroupRoles = new ArrayList();
429 }
430 else
431 {
432 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
433 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
434 }
435 }
436 else
437 {
438
439
440
441 boolean newCriteria = true;
442 criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
443 if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
444 {
445 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
446 }
447 }
448 lastTurbineUserGroupRolesCriteria = criteria;
449
450 return collTurbineUserGroupRoles;
451 }
452
453
454
455
456 private static List fieldNames = null;
457
458 /***
459 * Generate a list of field names.
460 */
461 public static synchronized List getFieldNames()
462 {
463 if (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 }
471 return fieldNames;
472 }
473
474 /***
475 * Retrieves a field from the object by name passed in
476 * as a String.
477 */
478 public Object getByName(String name)
479 {
480 if (name.equals("GroupId"))
481 {
482 return new Integer(getGroupId());
483 }
484 if (name.equals("GroupName"))
485 {
486 return getGroupName();
487 }
488 if (name.equals("Objectdata"))
489 {
490 return getObjectdata();
491 }
492 return null;
493 }
494
495 /***
496 * Retrieves a field from the object by name passed in
497 * as a String. The String must be one of the static
498 * Strings defined in this Class' Peer.
499 */
500 public Object getByPeerName(String name)
501 {
502 if (name.equals(TurbineGroupPeer.GROUP_ID ))
503 {
504 return new Integer(getGroupId());
505 }
506 if (name.equals(TurbineGroupPeer.GROUP_NAME ))
507 {
508 return getGroupName();
509 }
510 if (name.equals(TurbineGroupPeer.OBJECTDATA ))
511 {
512 return getObjectdata();
513 }
514 return null;
515 }
516
517 /***
518 * Retrieves a field from the object by Position as specified
519 * in the xml schema. Zero-based.
520 */
521 public Object getByPosition(int pos)
522 {
523 if ( pos == 0 )
524 {
525 return new Integer(getGroupId());
526 }
527 if ( pos == 1 )
528 {
529 return getGroupName();
530 }
531 if ( pos == 2 )
532 {
533 return getObjectdata();
534 }
535 return null;
536 }
537
538 /***
539 * Stores the object in the database. If the object is new,
540 * it inserts it; otherwise an update is performed.
541 */
542 public void save() throws Exception
543 {
544 save(TurbineGroupPeer.getMapBuilder()
545 .getDatabaseMap().getName());
546 }
547
548 /***
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 is
552 * auto-generated conditionally and therefore needs to be
553 * in this file instead of in the super class, BaseObject.
554 */
555 public void save(String dbName) throws TorqueException
556 {
557 Connection con = null;
558 try
559 {
560 con = Transaction.begin(dbName);
561 save(con);
562 Transaction.commit(con);
563 }
564 catch(TorqueException e)
565 {
566 Transaction.safeRollback(con);
567 throw e;
568 }
569 }
570
571 /*** flag to prevent endless save loop, if this object is referenced
572 by another object which falls in this transaction. */
573 private boolean 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 method
577 * is meant to be used as part of a transaction, otherwise use
578 * the save() method and the connection details will be handled
579 * internally
580 */
581 public void save(Connection con) throws TorqueException
582 {
583 if (!alreadyInSave)
584 {
585 alreadyInSave = true;
586
587
588
589
590 if (isModified())
591 {
592 if (isNew())
593 {
594 TurbineGroupPeer.doInsert((TurbineGroup)this, con);
595 setNew(false);
596 }
597 else
598 {
599 TurbineGroupPeer.doUpdate((TurbineGroup)this, con);
600 }
601
602 if (isCacheOnSave())
603 {
604 TurbineGroupManager.putInstance(this);
605 }
606 }
607
608
609 if (collTurbineUserGroupRoles != null )
610 {
611 for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
612 {
613 ((TurbineUserGroupRole)collTurbineUserGroupRoles.get(i)).save(con);
614 }
615 }
616 alreadyInSave = false;
617 }
618 }
619
620 /***
621 * Specify whether to cache the object after saving to the db.
622 * This method returns false
623 */
624 protected boolean isCacheOnSave()
625 {
626 return true;
627 }
628
629
630 /***
631 * Set the PrimaryKey using ObjectKey.
632 *
633 * @param ObjectKey groupId
634 */
635 public void setPrimaryKey(ObjectKey groupId)
636 throws TorqueException {
637 setGroupId(((NumberKey)groupId).intValue());
638 }
639
640 /***
641 * Set the PrimaryKey using a String.
642 */
643 public void setPrimaryKey(String key) throws TorqueException
644 {
645 setGroupId(Integer.parseInt(key));
646 }
647
648
649 /***
650 * returns an id that differentiates this object from others
651 * of its class.
652 */
653 public ObjectKey getPrimaryKey()
654 {
655 return SimpleKey.keyFor(getGroupId());
656 }
657
658
659 /***
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 */
664 public TurbineGroup copy() throws TorqueException
665 {
666 TurbineGroup copyObj = new TurbineGroup();
667 copyObj.setGroupId(groupId);
668 copyObj.setGroupName(groupName);
669 copyObj.setObjectdata(objectdata);
670
671 copyObj.setGroupId(0);
672
673
674
675 List v = getTurbineUserGroupRoles();
676 for (int i = 0; i < v.size(); i++)
677 {
678 TurbineUserGroupRole obj = (TurbineUserGroupRole) v.get(i);
679 copyObj.addTurbineUserGroupRole(obj.copy());
680 }
681 return copyObj;
682 }
683
684 /***
685 * returns a peer instance associated with this om. Since Peer classes
686 * are not to have any instance attributes, this method returns the
687 * same instance for all member of this class. The method could therefore
688 * be static, but this would prevent one from overriding the behavior.
689 */
690 public TurbineGroupPeer getPeer()
691 {
692 return peer;
693 }
694 }