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
27
28 /***
29 * This class was autogenerated by Torque on:
30 *
31 * [Mon May 28 10:17:20 EST 2007]
32 *
33 * You should not use this class directly. It should not even be
34 * extended all references should be to TurbineRole
35 */
36 public abstract class BaseTurbineRole extends BaseObject
37 {
38 /*** The Peer class */
39 private static final TurbineRolePeer peer =
40 new TurbineRolePeer();
41
42
43 /*** The value for the roleId field */
44 private int roleId;
45
46 /*** The value for the name field */
47 private String name;
48
49
50 /***
51 * Get the RoleId
52 *
53 * @return int
54 */
55 public int getRoleId()
56 {
57 return roleId;
58 }
59
60
61 /***
62 * Set the value of RoleId
63 *
64 * @param v new value
65 */
66 public void setRoleId(int v) throws TorqueException
67 {
68
69 if (this.roleId != v)
70 {
71 this.roleId = v;
72 setModified(true);
73 }
74
75
76
77
78 if (collTurbineRolePermissions != null)
79 {
80 for (int i = 0; i < collTurbineRolePermissions.size(); i++)
81 {
82 ((TurbineRolePermission) collTurbineRolePermissions.get(i))
83 .setRoleId(v);
84 }
85 }
86
87
88 if (collTurbineUserGroupRoles != null)
89 {
90 for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
91 {
92 ((TurbineUserGroupRole) collTurbineUserGroupRoles.get(i))
93 .setRoleId(v);
94 }
95 }
96 }
97
98 /***
99 * Get the Name
100 *
101 * @return String
102 */
103 public String getName()
104 {
105 return name;
106 }
107
108
109 /***
110 * Set the value of Name
111 *
112 * @param v new value
113 */
114 public void setName(String v)
115 {
116
117 if (!ObjectUtils.equals(this.name, v))
118 {
119 this.name = v;
120 setModified(true);
121 }
122
123
124 }
125
126
127
128
129 /***
130 * Collection to store aggregation of collTurbineRolePermissions
131 */
132 protected List collTurbineRolePermissions;
133
134 /***
135 * Temporary storage of collTurbineRolePermissions to save a possible db hit in
136 * the event objects are add to the collection, but the
137 * complete collection is never requested.
138 */
139 protected void initTurbineRolePermissions()
140 {
141 if (collTurbineRolePermissions == null)
142 {
143 collTurbineRolePermissions = new ArrayList();
144 }
145 }
146
147
148 /***
149 * Method called to associate a TurbineRolePermission object to this object
150 * through the TurbineRolePermission foreign key attribute
151 *
152 * @param l TurbineRolePermission
153 * @throws TorqueException
154 */
155 public void addTurbineRolePermission(TurbineRolePermission l) throws TorqueException
156 {
157 getTurbineRolePermissions().add(l);
158 l.setTurbineRole((TurbineRole) this);
159 }
160
161 /***
162 * The criteria used to select the current contents of collTurbineRolePermissions
163 */
164 private Criteria lastTurbineRolePermissionsCriteria = null;
165
166 /***
167 * If this collection has already been initialized, returns
168 * the collection. Otherwise returns the results of
169 * getTurbineRolePermissions(new Criteria())
170 *
171 * @return the collection of associated objects
172 * @throws TorqueException
173 */
174 public List getTurbineRolePermissions()
175 throws TorqueException
176 {
177 if (collTurbineRolePermissions == null)
178 {
179 collTurbineRolePermissions = getTurbineRolePermissions(new Criteria(10));
180 }
181 return collTurbineRolePermissions;
182 }
183
184 /***
185 * If this collection has already been initialized with
186 * an identical criteria, it returns the collection.
187 * Otherwise if this TurbineRole has previously
188 * been saved, it will retrieve related TurbineRolePermissions from storage.
189 * If this TurbineRole is new, it will return
190 * an empty collection or the current collection, the criteria
191 * is ignored on a new object.
192 *
193 * @throws TorqueException
194 */
195 public List getTurbineRolePermissions(Criteria criteria) throws TorqueException
196 {
197 if (collTurbineRolePermissions == null)
198 {
199 if (isNew())
200 {
201 collTurbineRolePermissions = new ArrayList();
202 }
203 else
204 {
205 criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId() );
206 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria);
207 }
208 }
209 else
210 {
211
212 if (!isNew())
213 {
214
215
216
217 criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
218 if (!lastTurbineRolePermissionsCriteria.equals(criteria))
219 {
220 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria);
221 }
222 }
223 }
224 lastTurbineRolePermissionsCriteria = criteria;
225
226 return collTurbineRolePermissions;
227 }
228
229 /***
230 * If this collection has already been initialized, returns
231 * the collection. Otherwise returns the results of
232 * getTurbineRolePermissions(new Criteria(),Connection)
233 * This method takes in the Connection also as input so that
234 * referenced objects can also be obtained using a Connection
235 * that is taken as input
236 */
237 public List getTurbineRolePermissions(Connection con) throws TorqueException
238 {
239 if (collTurbineRolePermissions == null)
240 {
241 collTurbineRolePermissions = getTurbineRolePermissions(new Criteria(10), con);
242 }
243 return collTurbineRolePermissions;
244 }
245
246 /***
247 * If this collection has already been initialized with
248 * an identical criteria, it returns the collection.
249 * Otherwise if this TurbineRole has previously
250 * been saved, it will retrieve related TurbineRolePermissions from storage.
251 * If this TurbineRole is new, it will return
252 * an empty collection or the current collection, the criteria
253 * is ignored on a new object.
254 * This method takes in the Connection also as input so that
255 * referenced objects can also be obtained using a Connection
256 * that is taken as input
257 */
258 public List getTurbineRolePermissions(Criteria criteria, Connection con)
259 throws TorqueException
260 {
261 if (collTurbineRolePermissions == null)
262 {
263 if (isNew())
264 {
265 collTurbineRolePermissions = new ArrayList();
266 }
267 else
268 {
269 criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
270 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria, con);
271 }
272 }
273 else
274 {
275
276 if (!isNew())
277 {
278
279
280
281 criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
282 if (!lastTurbineRolePermissionsCriteria.equals(criteria))
283 {
284 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria, con);
285 }
286 }
287 }
288 lastTurbineRolePermissionsCriteria = criteria;
289
290 return collTurbineRolePermissions;
291 }
292
293
294
295
296
297
298
299
300
301
302
303 /***
304 * If this collection has already been initialized with
305 * an identical criteria, it returns the collection.
306 * Otherwise if this TurbineRole is new, it will return
307 * an empty collection; or if this TurbineRole has previously
308 * been saved, it will retrieve related TurbineRolePermissions from storage.
309 *
310 * This method is protected by default in order to keep the public
311 * api reasonable. You can provide public methods for those you
312 * actually need in TurbineRole.
313 */
314 protected List getTurbineRolePermissionsJoinTurbineRole(Criteria criteria)
315 throws TorqueException
316 {
317 if (collTurbineRolePermissions == null)
318 {
319 if (isNew())
320 {
321 collTurbineRolePermissions = new ArrayList();
322 }
323 else
324 {
325 criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
326 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbineRole(criteria);
327 }
328 }
329 else
330 {
331
332
333
334 criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
335 if (!lastTurbineRolePermissionsCriteria.equals(criteria))
336 {
337 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbineRole(criteria);
338 }
339 }
340 lastTurbineRolePermissionsCriteria = criteria;
341
342 return collTurbineRolePermissions;
343 }
344
345
346
347
348
349
350
351
352
353 /***
354 * If this collection has already been initialized with
355 * an identical criteria, it returns the collection.
356 * Otherwise if this TurbineRole is new, it will return
357 * an empty collection; or if this TurbineRole has previously
358 * been saved, it will retrieve related TurbineRolePermissions from storage.
359 *
360 * This method is protected by default in order to keep the public
361 * api reasonable. You can provide public methods for those you
362 * actually need in TurbineRole.
363 */
364 protected List getTurbineRolePermissionsJoinTurbinePermission(Criteria criteria)
365 throws TorqueException
366 {
367 if (collTurbineRolePermissions == null)
368 {
369 if (isNew())
370 {
371 collTurbineRolePermissions = new ArrayList();
372 }
373 else
374 {
375 criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
376 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbinePermission(criteria);
377 }
378 }
379 else
380 {
381
382
383
384 criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
385 if (!lastTurbineRolePermissionsCriteria.equals(criteria))
386 {
387 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbinePermission(criteria);
388 }
389 }
390 lastTurbineRolePermissionsCriteria = criteria;
391
392 return collTurbineRolePermissions;
393 }
394
395
396
397
398
399 /***
400 * Collection to store aggregation of collTurbineUserGroupRoles
401 */
402 protected List collTurbineUserGroupRoles;
403
404 /***
405 * Temporary storage of collTurbineUserGroupRoles to save a possible db hit in
406 * the event objects are add to the collection, but the
407 * complete collection is never requested.
408 */
409 protected void initTurbineUserGroupRoles()
410 {
411 if (collTurbineUserGroupRoles == null)
412 {
413 collTurbineUserGroupRoles = new ArrayList();
414 }
415 }
416
417
418 /***
419 * Method called to associate a TurbineUserGroupRole object to this object
420 * through the TurbineUserGroupRole foreign key attribute
421 *
422 * @param l TurbineUserGroupRole
423 * @throws TorqueException
424 */
425 public void addTurbineUserGroupRole(TurbineUserGroupRole l) throws TorqueException
426 {
427 getTurbineUserGroupRoles().add(l);
428 l.setTurbineRole((TurbineRole) this);
429 }
430
431 /***
432 * The criteria used to select the current contents of collTurbineUserGroupRoles
433 */
434 private Criteria lastTurbineUserGroupRolesCriteria = null;
435
436 /***
437 * If this collection has already been initialized, returns
438 * the collection. Otherwise returns the results of
439 * getTurbineUserGroupRoles(new Criteria())
440 *
441 * @return the collection of associated objects
442 * @throws TorqueException
443 */
444 public List getTurbineUserGroupRoles()
445 throws TorqueException
446 {
447 if (collTurbineUserGroupRoles == null)
448 {
449 collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10));
450 }
451 return collTurbineUserGroupRoles;
452 }
453
454 /***
455 * If this collection has already been initialized with
456 * an identical criteria, it returns the collection.
457 * Otherwise if this TurbineRole has previously
458 * been saved, it will retrieve related TurbineUserGroupRoles from storage.
459 * If this TurbineRole is new, it will return
460 * an empty collection or the current collection, the criteria
461 * is ignored on a new object.
462 *
463 * @throws TorqueException
464 */
465 public List getTurbineUserGroupRoles(Criteria criteria) throws TorqueException
466 {
467 if (collTurbineUserGroupRoles == null)
468 {
469 if (isNew())
470 {
471 collTurbineUserGroupRoles = new ArrayList();
472 }
473 else
474 {
475 criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId() );
476 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
477 }
478 }
479 else
480 {
481
482 if (!isNew())
483 {
484
485
486
487 criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
488 if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
489 {
490 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
491 }
492 }
493 }
494 lastTurbineUserGroupRolesCriteria = criteria;
495
496 return collTurbineUserGroupRoles;
497 }
498
499 /***
500 * If this collection has already been initialized, returns
501 * the collection. Otherwise returns the results of
502 * getTurbineUserGroupRoles(new Criteria(),Connection)
503 * This method takes in the Connection also as input so that
504 * referenced objects can also be obtained using a Connection
505 * that is taken as input
506 */
507 public List getTurbineUserGroupRoles(Connection con) throws TorqueException
508 {
509 if (collTurbineUserGroupRoles == null)
510 {
511 collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10), con);
512 }
513 return collTurbineUserGroupRoles;
514 }
515
516 /***
517 * If this collection has already been initialized with
518 * an identical criteria, it returns the collection.
519 * Otherwise if this TurbineRole has previously
520 * been saved, it will retrieve related TurbineUserGroupRoles from storage.
521 * If this TurbineRole is new, it will return
522 * an empty collection or the current collection, the criteria
523 * is ignored on a new object.
524 * This method takes in the Connection also as input so that
525 * referenced objects can also be obtained using a Connection
526 * that is taken as input
527 */
528 public List getTurbineUserGroupRoles(Criteria criteria, Connection con)
529 throws TorqueException
530 {
531 if (collTurbineUserGroupRoles == null)
532 {
533 if (isNew())
534 {
535 collTurbineUserGroupRoles = new ArrayList();
536 }
537 else
538 {
539 criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
540 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria, con);
541 }
542 }
543 else
544 {
545
546 if (!isNew())
547 {
548
549
550
551 criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
552 if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
553 {
554 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria, con);
555 }
556 }
557 }
558 lastTurbineUserGroupRolesCriteria = criteria;
559
560 return collTurbineUserGroupRoles;
561 }
562
563
564
565
566
567
568
569
570
571
572
573 /***
574 * If this collection has already been initialized with
575 * an identical criteria, it returns the collection.
576 * Otherwise if this TurbineRole is new, it will return
577 * an empty collection; or if this TurbineRole has previously
578 * been saved, it will retrieve related TurbineUserGroupRoles from storage.
579 *
580 * This method is protected by default in order to keep the public
581 * api reasonable. You can provide public methods for those you
582 * actually need in TurbineRole.
583 */
584 protected List getTurbineUserGroupRolesJoinTurbineUser(Criteria criteria)
585 throws TorqueException
586 {
587 if (collTurbineUserGroupRoles == null)
588 {
589 if (isNew())
590 {
591 collTurbineUserGroupRoles = new ArrayList();
592 }
593 else
594 {
595 criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
596 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
597 }
598 }
599 else
600 {
601
602
603
604 criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
605 if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
606 {
607 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
608 }
609 }
610 lastTurbineUserGroupRolesCriteria = criteria;
611
612 return collTurbineUserGroupRoles;
613 }
614
615
616
617
618
619
620
621
622
623 /***
624 * If this collection has already been initialized with
625 * an identical criteria, it returns the collection.
626 * Otherwise if this TurbineRole is new, it will return
627 * an empty collection; or if this TurbineRole has previously
628 * been saved, it will retrieve related TurbineUserGroupRoles from storage.
629 *
630 * This method is protected by default in order to keep the public
631 * api reasonable. You can provide public methods for those you
632 * actually need in TurbineRole.
633 */
634 protected List getTurbineUserGroupRolesJoinTurbineGroup(Criteria criteria)
635 throws TorqueException
636 {
637 if (collTurbineUserGroupRoles == null)
638 {
639 if (isNew())
640 {
641 collTurbineUserGroupRoles = new ArrayList();
642 }
643 else
644 {
645 criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
646 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
647 }
648 }
649 else
650 {
651
652
653
654 criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
655 if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
656 {
657 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
658 }
659 }
660 lastTurbineUserGroupRolesCriteria = criteria;
661
662 return collTurbineUserGroupRoles;
663 }
664
665
666
667
668
669
670
671
672
673 /***
674 * If this collection has already been initialized with
675 * an identical criteria, it returns the collection.
676 * Otherwise if this TurbineRole is new, it will return
677 * an empty collection; or if this TurbineRole has previously
678 * been saved, it will retrieve related TurbineUserGroupRoles from storage.
679 *
680 * This method is protected by default in order to keep the public
681 * api reasonable. You can provide public methods for those you
682 * actually need in TurbineRole.
683 */
684 protected List getTurbineUserGroupRolesJoinTurbineRole(Criteria criteria)
685 throws TorqueException
686 {
687 if (collTurbineUserGroupRoles == null)
688 {
689 if (isNew())
690 {
691 collTurbineUserGroupRoles = new ArrayList();
692 }
693 else
694 {
695 criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
696 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
697 }
698 }
699 else
700 {
701
702
703
704 criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
705 if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
706 {
707 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
708 }
709 }
710 lastTurbineUserGroupRolesCriteria = criteria;
711
712 return collTurbineUserGroupRoles;
713 }
714
715
716
717
718 private static List fieldNames = null;
719
720 /***
721 * Generate a list of field names.
722 *
723 * @return a list of field names
724 */
725 public static synchronized List getFieldNames()
726 {
727 if (fieldNames == null)
728 {
729 fieldNames = new ArrayList();
730 fieldNames.add("RoleId");
731 fieldNames.add("Name");
732 fieldNames = Collections.unmodifiableList(fieldNames);
733 }
734 return fieldNames;
735 }
736
737 /***
738 * Retrieves a field from the object by name passed in as a String.
739 *
740 * @param name field name
741 * @return value
742 */
743 public Object getByName(String name)
744 {
745 if (name.equals("RoleId"))
746 {
747 return new Integer(getRoleId());
748 }
749 if (name.equals("Name"))
750 {
751 return getName();
752 }
753 return null;
754 }
755
756 /***
757 * Retrieves a field from the object by name passed in
758 * as a String. The String must be one of the static
759 * Strings defined in this Class' Peer.
760 *
761 * @param name peer name
762 * @return value
763 */
764 public Object getByPeerName(String name)
765 {
766 if (name.equals(TurbineRolePeer.ROLE_ID))
767 {
768 return new Integer(getRoleId());
769 }
770 if (name.equals(TurbineRolePeer.ROLE_NAME))
771 {
772 return getName();
773 }
774 return null;
775 }
776
777 /***
778 * Retrieves a field from the object by Position as specified
779 * in the xml schema. Zero-based.
780 *
781 * @param pos position in xml schema
782 * @return value
783 */
784 public Object getByPosition(int pos)
785 {
786 if (pos == 0)
787 {
788 return new Integer(getRoleId());
789 }
790 if (pos == 1)
791 {
792 return getName();
793 }
794 return null;
795 }
796
797 /***
798 * Stores the object in the database. If the object is new,
799 * it inserts it; otherwise an update is performed.
800 *
801 * @throws Exception
802 */
803 public void save() throws Exception
804 {
805 save(TurbineRolePeer.getMapBuilder()
806 .getDatabaseMap().getName());
807 }
808
809 /***
810 * Stores the object in the database. If the object is new,
811 * it inserts it; otherwise an update is performed.
812 * Note: this code is here because the method body is
813 * auto-generated conditionally and therefore needs to be
814 * in this file instead of in the super class, BaseObject.
815 *
816 * @param dbName
817 * @throws TorqueException
818 */
819 public void save(String dbName) throws TorqueException
820 {
821 Connection con = null;
822 try
823 {
824 con = Transaction.begin(dbName);
825 save(con);
826 Transaction.commit(con);
827 }
828 catch(TorqueException e)
829 {
830 Transaction.safeRollback(con);
831 throw e;
832 }
833 }
834
835 /*** flag to prevent endless save loop, if this object is referenced
836 by another object which falls in this transaction. */
837 private boolean alreadyInSave = false;
838 /***
839 * Stores the object in the database. If the object is new,
840 * it inserts it; otherwise an update is performed. This method
841 * is meant to be used as part of a transaction, otherwise use
842 * the save() method and the connection details will be handled
843 * internally
844 *
845 * @param con
846 * @throws TorqueException
847 */
848 public void save(Connection con) throws TorqueException
849 {
850 if (!alreadyInSave)
851 {
852 alreadyInSave = true;
853
854
855
856
857 if (isModified())
858 {
859 if (isNew())
860 {
861 TurbineRolePeer.doInsert((TurbineRole) this, con);
862 setNew(false);
863 }
864 else
865 {
866 TurbineRolePeer.doUpdate((TurbineRole) this, con);
867 }
868 }
869
870
871 if (collTurbineRolePermissions != null)
872 {
873 for (int i = 0; i < collTurbineRolePermissions.size(); i++)
874 {
875 ((TurbineRolePermission) collTurbineRolePermissions.get(i)).save(con);
876 }
877 }
878
879 if (collTurbineUserGroupRoles != null)
880 {
881 for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
882 {
883 ((TurbineUserGroupRole) collTurbineUserGroupRoles.get(i)).save(con);
884 }
885 }
886 alreadyInSave = false;
887 }
888 }
889
890
891 /***
892 * Set the PrimaryKey using ObjectKey.
893 *
894 * @param key roleId ObjectKey
895 */
896 public void setPrimaryKey(ObjectKey key)
897 throws TorqueException
898 {
899 setRoleId(((NumberKey) key).intValue());
900 }
901
902 /***
903 * Set the PrimaryKey using a String.
904 *
905 * @param key
906 */
907 public void setPrimaryKey(String key) throws TorqueException
908 {
909 setRoleId(Integer.parseInt(key));
910 }
911
912
913 /***
914 * returns an id that differentiates this object from others
915 * of its class.
916 */
917 public ObjectKey getPrimaryKey()
918 {
919 return SimpleKey.keyFor(getRoleId());
920 }
921
922
923 /***
924 * Makes a copy of this object.
925 * It creates a new object filling in the simple attributes.
926 * It then fills all the association collections and sets the
927 * related objects to isNew=true.
928 */
929 public TurbineRole copy() throws TorqueException
930 {
931 return copyInto(new TurbineRole());
932 }
933
934 protected TurbineRole copyInto(TurbineRole copyObj) throws TorqueException
935 {
936 copyObj.setRoleId(roleId);
937 copyObj.setName(name);
938
939 copyObj.setRoleId( 0);
940
941
942
943 List v = getTurbineRolePermissions();
944 if (v != null)
945 {
946 for (int i = 0; i < v.size(); i++)
947 {
948 TurbineRolePermission obj = (TurbineRolePermission) v.get(i);
949 copyObj.addTurbineRolePermission(obj.copy());
950 }
951 }
952 else
953 {
954 copyObj.collTurbineRolePermissions = null;
955 }
956
957
958 v = getTurbineUserGroupRoles();
959 if (v != null)
960 {
961 for (int i = 0; i < v.size(); i++)
962 {
963 TurbineUserGroupRole obj = (TurbineUserGroupRole) v.get(i);
964 copyObj.addTurbineUserGroupRole(obj.copy());
965 }
966 }
967 else
968 {
969 copyObj.collTurbineUserGroupRoles = null;
970 }
971 return copyObj;
972 }
973
974 /***
975 * returns a peer instance associated with this om. Since Peer classes
976 * are not to have any instance attributes, this method returns the
977 * same instance for all member of this class. The method could therefore
978 * be static, but this would prevent one from overriding the behavior.
979 */
980 public TurbineRolePeer getPeer()
981 {
982 return peer;
983 }
984
985
986 public String toString()
987 {
988 StringBuffer str = new StringBuffer();
989 str.append("TurbineRole:\n");
990 str.append("RoleId = ")
991 .append(getRoleId())
992 .append("\n");
993 str.append("Name = ")
994 .append(getName())
995 .append("\n");
996 return(str.toString());
997 }
998 }