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