KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fulcrum > security > impl > db > entity > BaseTurbineRole


1 package org.apache.fulcrum.security.impl.db.entity;
2
3
4 import java.math.BigDecimal JavaDoc;
5 import java.sql.Connection JavaDoc;
6 import java.util.ArrayList JavaDoc;
7 import java.util.Date JavaDoc;
8 import java.util.Collections JavaDoc;
9 import java.util.List JavaDoc;
10
11 import org.apache.commons.lang.ObjectUtils;
12 import org.apache.fulcrum.intake.Retrievable;
13 import org.apache.torque.TorqueException;
14 import org.apache.torque.om.BaseObject;
15 import org.apache.torque.om.ComboKey;
16 import org.apache.torque.om.DateKey;
17 import org.apache.torque.om.NumberKey;
18 import org.apache.torque.om.ObjectKey;
19 import org.apache.torque.om.SimpleKey;
20 import org.apache.torque.om.StringKey;
21 import org.apache.torque.om.Persistent;
22 import org.apache.torque.util.Criteria;
23 import org.apache.torque.util.Transaction;
24
25
26 /**
27  * You should not use this class directly. It should not even be
28  * extended all references should be to TurbineRole
29  */

30 public abstract class BaseTurbineRole extends BaseObject
31     implements org.apache.fulcrum.intake.Retrievable
32 {
33     /** The Peer class */
34     private static final TurbineRolePeer peer =
35         new TurbineRolePeer();
36
37         
38     /** The value for the roleId field */
39     private Integer JavaDoc roleId;
40       
41     /** The value for the name field */
42     private String JavaDoc name;
43   
44     
45     /**
46      * Get the RoleId
47      *
48      * @return Integer
49      */

50     public Integer JavaDoc getRoleId()
51     {
52         return roleId;
53     }
54
55                                               
56     /**
57      * Set the value of RoleId
58      *
59      * @param v new value
60      */

61     public void setRoleId(Integer JavaDoc v) throws TorqueException
62     {
63     
64                   if (!ObjectUtils.equals(this.roleId, v))
65               {
66             this.roleId = v;
67             setModified(true);
68         }
69     
70           
71                                   
72         // update associated TurbineRolePermission
73
if (collTurbineRolePermissions != null)
74         {
75             for (int i = 0; i < collTurbineRolePermissions.size(); i++)
76             {
77                 ((TurbineRolePermission) collTurbineRolePermissions.get(i))
78                     .setRoleId(v);
79             }
80         }
81                                           
82         // update associated TurbineUserGroupRole
83
if (collTurbineUserGroupRoles != null)
84         {
85             for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
86             {
87                 ((TurbineUserGroupRole) collTurbineUserGroupRoles.get(i))
88                     .setRoleId(v);
89             }
90         }
91                       }
92   
93     /**
94      * Get the Name
95      *
96      * @return String
97      */

98     public String JavaDoc getName()
99     {
100         return name;
101     }
102
103                         
104     /**
105      * Set the value of Name
106      *
107      * @param v new value
108      */

109     public void setName(String JavaDoc v)
110     {
111     
112                   if (!ObjectUtils.equals(this.name, v))
113               {
114             this.name = v;
115             setModified(true);
116         }
117     
118           
119               }
120   
121          
122                                 
123             
124     /**
125      * Collection to store aggregation of collTurbineRolePermissions
126      */

127     protected List JavaDoc collTurbineRolePermissions;
128
129     /**
130      * Temporary storage of collTurbineRolePermissions to save a possible db hit in
131      * the event objects are add to the collection, but the
132      * complete collection is never requested.
133      */

134     protected void initTurbineRolePermissions()
135     {
136         if (collTurbineRolePermissions == null)
137         {
138             collTurbineRolePermissions = new ArrayList JavaDoc();
139         }
140     }
141
142     /**
143      * Method called to associate a TurbineRolePermission object to this object
144      * through the TurbineRolePermission foreign key attribute
145      *
146      * @param l TurbineRolePermission
147      * @throws TorqueException
148      */

149     public void addTurbineRolePermission(TurbineRolePermission l) throws TorqueException
150     {
151         getTurbineRolePermissions().add(l);
152         l.setTurbineRole((TurbineRole) this);
153     }
154
155     /**
156      * The criteria used to select the current contents of collTurbineRolePermissions
157      */

158     private Criteria lastTurbineRolePermissionsCriteria = null;
159
160     /**
161      * If this collection has already been initialized, returns
162      * the collection. Otherwise returns the results of
163      * getTurbineRolePermissions(new Criteria())
164      *
165      * @throws TorqueException
166      */

167     public List JavaDoc getTurbineRolePermissions() throws TorqueException
168     {
169         if (collTurbineRolePermissions == null)
170         {
171             collTurbineRolePermissions = getTurbineRolePermissions(new Criteria(10));
172         }
173         return collTurbineRolePermissions;
174     }
175
176     /**
177      * If this collection has already been initialized with
178      * an identical criteria, it returns the collection.
179      * Otherwise if this TurbineRole has previously
180      * been saved, it will retrieve related TurbineRolePermissions from storage.
181      * If this TurbineRole is new, it will return
182      * an empty collection or the current collection, the criteria
183      * is ignored on a new object.
184      *
185      * @throws TorqueException
186      */

187     public List JavaDoc getTurbineRolePermissions(Criteria criteria) throws TorqueException
188     {
189         if (collTurbineRolePermissions == null)
190         {
191             if (isNew())
192             {
193                collTurbineRolePermissions = new ArrayList JavaDoc();
194             }
195             else
196             {
197                       criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId() );
198                       collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria);
199             }
200         }
201         else
202         {
203             // criteria has no effect for a new object
204
if (!isNew())
205             {
206                 // the following code is to determine if a new query is
207
// called for. If the criteria is the same as the last
208
// one, just return the collection.
209
criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
210                       if (!lastTurbineRolePermissionsCriteria.equals(criteria))
211                 {
212                     collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria);
213                 }
214             }
215         }
216         lastTurbineRolePermissionsCriteria = criteria;
217
218         return collTurbineRolePermissions;
219     }
220
221     /**
222      * If this collection has already been initialized, returns
223      * the collection. Otherwise returns the results of
224      * getTurbineRolePermissions(new Criteria(),Connection)
225      * This method takes in the Connection also as input so that
226      * referenced objects can also be obtained using a Connection
227      * that is taken as input
228      */

229     public List JavaDoc getTurbineRolePermissions(Connection JavaDoc con) throws TorqueException
230     {
231         if (collTurbineRolePermissions == null)
232         {
233             collTurbineRolePermissions = getTurbineRolePermissions(new Criteria(10), con);
234         }
235         return collTurbineRolePermissions;
236     }
237
238     /**
239      * If this collection has already been initialized with
240      * an identical criteria, it returns the collection.
241      * Otherwise if this TurbineRole has previously
242      * been saved, it will retrieve related TurbineRolePermissions from storage.
243      * If this TurbineRole is new, it will return
244      * an empty collection or the current collection, the criteria
245      * is ignored on a new object.
246      * This method takes in the Connection also as input so that
247      * referenced objects can also be obtained using a Connection
248      * that is taken as input
249      */

250     public List JavaDoc getTurbineRolePermissions(Criteria criteria, Connection JavaDoc con)
251             throws TorqueException
252     {
253         if (collTurbineRolePermissions == null)
254         {
255             if (isNew())
256             {
257                collTurbineRolePermissions = new ArrayList JavaDoc();
258             }
259             else
260             {
261                        criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
262                        collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria, con);
263              }
264          }
265          else
266          {
267              // criteria has no effect for a new object
268
if (!isNew())
269              {
270                  // the following code is to determine if a new query is
271
// called for. If the criteria is the same as the last
272
// one, just return the collection.
273
criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
274                        if (!lastTurbineRolePermissionsCriteria.equals(criteria))
275                  {
276                      collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria, con);
277                  }
278              }
279          }
280          lastTurbineRolePermissionsCriteria = criteria;
281
282          return collTurbineRolePermissions;
283      }
284
285                         
286               
287                     
288                               
289                                 
290                                                               
291                                         
292                     
293                     
294           
295     /**
296      * If this collection has already been initialized with
297      * an identical criteria, it returns the collection.
298      * Otherwise if this TurbineRole is new, it will return
299      * an empty collection; or if this TurbineRole has previously
300      * been saved, it will retrieve related TurbineRolePermissions from storage.
301      *
302      * This method is protected by default in order to keep the public
303      * api reasonable. You can provide public methods for those you
304      * actually need in TurbineRole.
305      */

306     protected List JavaDoc getTurbineRolePermissionsJoinTurbineRole(Criteria criteria)
307         throws TorqueException
308     {
309         if (collTurbineRolePermissions == null)
310         {
311             if (isNew())
312             {
313                collTurbineRolePermissions = new ArrayList JavaDoc();
314             }
315             else
316             {
317                             criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
318                             collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbineRole(criteria);
319             }
320         }
321         else
322         {
323             // the following code is to determine if a new query is
324
// called for. If the criteria is the same as the last
325
// one, just return the collection.
326
boolean newCriteria = true;
327                         criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
328                         if (!lastTurbineRolePermissionsCriteria.equals(criteria))
329             {
330                 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbineRole(criteria);
331             }
332         }
333         lastTurbineRolePermissionsCriteria = criteria;
334
335         return collTurbineRolePermissions;
336     }
337                   
338                     
339                     
340                                 
341                                                               
342                                         
343                     
344                     
345           
346     /**
347      * If this collection has already been initialized with
348      * an identical criteria, it returns the collection.
349      * Otherwise if this TurbineRole is new, it will return
350      * an empty collection; or if this TurbineRole has previously
351      * been saved, it will retrieve related TurbineRolePermissions from storage.
352      *
353      * This method is protected by default in order to keep the public
354      * api reasonable. You can provide public methods for those you
355      * actually need in TurbineRole.
356      */

357     protected List JavaDoc getTurbineRolePermissionsJoinTurbinePermission(Criteria criteria)
358         throws TorqueException
359     {
360         if (collTurbineRolePermissions == null)
361         {
362             if (isNew())
363             {
364                collTurbineRolePermissions = new ArrayList JavaDoc();
365             }
366             else
367             {
368                             criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
369                             collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbinePermission(criteria);
370             }
371         }
372         else
373         {
374             // the following code is to determine if a new query is
375
// called for. If the criteria is the same as the last
376
// one, just return the collection.
377
boolean newCriteria = true;
378                         criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
379                         if (!lastTurbineRolePermissionsCriteria.equals(criteria))
380             {
381                 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbinePermission(criteria);
382             }
383         }
384         lastTurbineRolePermissionsCriteria = criteria;
385
386         return collTurbineRolePermissions;
387     }
388                             
389
390
391                           
392             
393     /**
394      * Collection to store aggregation of collTurbineUserGroupRoles
395      */

396     protected List JavaDoc collTurbineUserGroupRoles;
397
398     /**
399      * Temporary storage of collTurbineUserGroupRoles to save a possible db hit in
400      * the event objects are add to the collection, but the
401      * complete collection is never requested.
402      */

403     protected void initTurbineUserGroupRoles()
404     {
405         if (collTurbineUserGroupRoles == null)
406         {
407             collTurbineUserGroupRoles = new ArrayList JavaDoc();
408         }
409     }
410
411     /**
412      * Method called to associate a TurbineUserGroupRole object to this object
413      * through the TurbineUserGroupRole foreign key attribute
414      *
415      * @param l TurbineUserGroupRole
416      * @throws TorqueException
417      */

418     public void addTurbineUserGroupRole(TurbineUserGroupRole l) throws TorqueException
419     {
420         getTurbineUserGroupRoles().add(l);
421         l.setTurbineRole((TurbineRole) this);
422     }
423
424     /**
425      * The criteria used to select the current contents of collTurbineUserGroupRoles
426      */

427     private Criteria lastTurbineUserGroupRolesCriteria = null;
428
429     /**
430      * If this collection has already been initialized, returns
431      * the collection. Otherwise returns the results of
432      * getTurbineUserGroupRoles(new Criteria())
433      *
434      * @throws TorqueException
435      */

436     public List JavaDoc getTurbineUserGroupRoles() throws TorqueException
437     {
438         if (collTurbineUserGroupRoles == null)
439         {
440             collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10));
441         }
442         return collTurbineUserGroupRoles;
443     }
444
445     /**
446      * If this collection has already been initialized with
447      * an identical criteria, it returns the collection.
448      * Otherwise if this TurbineRole has previously
449      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
450      * If this TurbineRole is new, it will return
451      * an empty collection or the current collection, the criteria
452      * is ignored on a new object.
453      *
454      * @throws TorqueException
455      */

456     public List JavaDoc getTurbineUserGroupRoles(Criteria criteria) throws TorqueException
457     {
458         if (collTurbineUserGroupRoles == null)
459         {
460             if (isNew())
461             {
462                collTurbineUserGroupRoles = new ArrayList JavaDoc();
463             }
464             else
465             {
466                       criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId() );
467                       collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
468             }
469         }
470         else
471         {
472             // criteria has no effect for a new object
473
if (!isNew())
474             {
475                 // the following code is to determine if a new query is
476
// called for. If the criteria is the same as the last
477
// one, just return the collection.
478
criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
479                       if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
480                 {
481                     collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
482                 }
483             }
484         }
485         lastTurbineUserGroupRolesCriteria = criteria;
486
487         return collTurbineUserGroupRoles;
488     }
489
490     /**
491      * If this collection has already been initialized, returns
492      * the collection. Otherwise returns the results of
493      * getTurbineUserGroupRoles(new Criteria(),Connection)
494      * This method takes in the Connection also as input so that
495      * referenced objects can also be obtained using a Connection
496      * that is taken as input
497      */

498     public List JavaDoc getTurbineUserGroupRoles(Connection JavaDoc con) throws TorqueException
499     {
500         if (collTurbineUserGroupRoles == null)
501         {
502             collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10), con);
503         }
504         return collTurbineUserGroupRoles;
505     }
506
507     /**
508      * If this collection has already been initialized with
509      * an identical criteria, it returns the collection.
510      * Otherwise if this TurbineRole has previously
511      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
512      * If this TurbineRole is new, it will return
513      * an empty collection or the current collection, the criteria
514      * is ignored on a new object.
515      * This method takes in the Connection also as input so that
516      * referenced objects can also be obtained using a Connection
517      * that is taken as input
518      */

519     public List JavaDoc getTurbineUserGroupRoles(Criteria criteria, Connection JavaDoc con)
520             throws TorqueException
521     {
522         if (collTurbineUserGroupRoles == null)
523         {
524             if (isNew())
525             {
526                collTurbineUserGroupRoles = new ArrayList JavaDoc();
527             }
528             else
529             {
530                        criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
531                        collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria, con);
532              }
533          }
534          else
535          {
536              // criteria has no effect for a new object
537
if (!isNew())
538              {
539                  // the following code is to determine if a new query is
540
// called for. If the criteria is the same as the last
541
// one, just return the collection.
542
criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
543                        if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
544                  {
545                      collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria, con);
546                  }
547              }
548          }
549          lastTurbineUserGroupRolesCriteria = criteria;
550
551          return collTurbineUserGroupRoles;
552      }
553
554                               
555               
556                     
557                     
558                                 
559                                                               
560                                         
561                     
562                     
563           
564     /**
565      * If this collection has already been initialized with
566      * an identical criteria, it returns the collection.
567      * Otherwise if this TurbineRole is new, it will return
568      * an empty collection; or if this TurbineRole has previously
569      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
570      *
571      * This method is protected by default in order to keep the public
572      * api reasonable. You can provide public methods for those you
573      * actually need in TurbineRole.
574      */

575     protected List JavaDoc getTurbineUserGroupRolesJoinTurbineUser(Criteria criteria)
576         throws TorqueException
577     {
578         if (collTurbineUserGroupRoles == null)
579         {
580             if (isNew())
581             {
582                collTurbineUserGroupRoles = new ArrayList JavaDoc();
583             }
584             else
585             {
586                             criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
587                             collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
588             }
589         }
590         else
591         {
592             // the following code is to determine if a new query is
593
// called for. If the criteria is the same as the last
594
// one, just return the collection.
595
boolean newCriteria = true;
596                         criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
597                         if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
598             {
599                 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
600             }
601         }
602         lastTurbineUserGroupRolesCriteria = criteria;
603
604         return collTurbineUserGroupRoles;
605     }
606                   
607                     
608                     
609                                 
610                                                               
611                                         
612                     
613                     
614           
615     /**
616      * If this collection has already been initialized with
617      * an identical criteria, it returns the collection.
618      * Otherwise if this TurbineRole is new, it will return
619      * an empty collection; or if this TurbineRole has previously
620      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
621      *
622      * This method is protected by default in order to keep the public
623      * api reasonable. You can provide public methods for those you
624      * actually need in TurbineRole.
625      */

626     protected List JavaDoc getTurbineUserGroupRolesJoinTurbineGroup(Criteria criteria)
627         throws TorqueException
628     {
629         if (collTurbineUserGroupRoles == null)
630         {
631             if (isNew())
632             {
633                collTurbineUserGroupRoles = new ArrayList JavaDoc();
634             }
635             else
636             {
637                             criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
638                             collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
639             }
640         }
641         else
642         {
643             // the following code is to determine if a new query is
644
// called for. If the criteria is the same as the last
645
// one, just return the collection.
646
boolean newCriteria = true;
647                         criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
648                         if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
649             {
650                 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
651             }
652         }
653         lastTurbineUserGroupRolesCriteria = criteria;
654
655         return collTurbineUserGroupRoles;
656     }
657                   
658                     
659                               
660                                 
661                                                               
662                                         
663                     
664                     
665           
666     /**
667      * If this collection has already been initialized with
668      * an identical criteria, it returns the collection.
669      * Otherwise if this TurbineRole is new, it will return
670      * an empty collection; or if this TurbineRole has previously
671      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
672      *
673      * This method is protected by default in order to keep the public
674      * api reasonable. You can provide public methods for those you
675      * actually need in TurbineRole.
676      */

677     protected List JavaDoc getTurbineUserGroupRolesJoinTurbineRole(Criteria criteria)
678         throws TorqueException
679     {
680         if (collTurbineUserGroupRoles == null)
681         {
682             if (isNew())
683             {
684                collTurbineUserGroupRoles = new ArrayList JavaDoc();
685             }
686             else
687             {
688                             criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
689                             collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
690             }
691         }
692         else
693         {
694             // the following code is to determine if a new query is
695
// called for. If the criteria is the same as the last
696
// one, just return the collection.
697
boolean newCriteria = true;
698                         criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
699                         if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
700             {
701                 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
702             }
703         }
704         lastTurbineUserGroupRolesCriteria = criteria;
705
706         return collTurbineUserGroupRoles;
707     }
708                             
709
710
711           
712     private static List JavaDoc fieldNames = null;
713
714     /**
715      * Generate a list of field names.
716      *
717      * @return a list of field names
718      */

719     public static synchronized List JavaDoc getFieldNames()
720     {
721         if (fieldNames == null)
722         {
723             fieldNames = new ArrayList JavaDoc();
724               fieldNames.add("RoleId");
725               fieldNames.add("Name");
726               fieldNames = Collections.unmodifiableList(fieldNames);
727         }
728         return fieldNames;
729     }
730
731     /**
732      * Retrieves a field from the object by name passed in as a String.
733      *
734      * @param name field name
735      * @return value
736      */

737     public Object JavaDoc getByName(String JavaDoc name)
738     {
739           if (name.equals("RoleId"))
740         {
741                 return getRoleId();
742             }
743           if (name.equals("Name"))
744         {
745                 return getName();
746             }
747           return null;
748     }
749     
750     /**
751      * Retrieves a field from the object by name passed in
752      * as a String. The String must be one of the static
753      * Strings defined in this Class' Peer.
754      *
755      * @param name peer name
756      * @return value
757      */

758     public Object JavaDoc getByPeerName(String JavaDoc name)
759     {
760           if (name.equals(TurbineRolePeer.ROLE_ID))
761         {
762                 return getRoleId();
763             }
764           if (name.equals(TurbineRolePeer.ROLE_NAME))
765         {
766                 return getName();
767             }
768           return null;
769     }
770
771     /**
772      * Retrieves a field from the object by Position as specified
773      * in the xml schema. Zero-based.
774      *
775      * @param pos position in xml schema
776      * @return value
777      */

778     public Object JavaDoc getByPosition(int pos)
779     {
780             if (pos == 0)
781         {
782                 return getRoleId();
783             }
784               if (pos == 1)
785         {
786                 return getName();
787             }
788               return null;
789     }
790      
791     /**
792      * Stores the object in the database. If the object is new,
793      * it inserts it; otherwise an update is performed.
794      *
795      * @throws Exception
796      */

797     public void save() throws Exception JavaDoc
798     {
799           save(TurbineRolePeer.getMapBuilder()
800                 .getDatabaseMap().getName());
801       }
802
803     /**
804      * Stores the object in the database. If the object is new,
805      * it inserts it; otherwise an update is performed.
806        * Note: this code is here because the method body is
807      * auto-generated conditionally and therefore needs to be
808      * in this file instead of in the super class, BaseObject.
809        *
810      * @param dbName
811      * @throws TorqueException
812      */

813     public void save(String JavaDoc dbName) throws TorqueException
814     {
815         Connection JavaDoc con = null;
816           try
817         {
818             con = Transaction.begin(dbName);
819             save(con);
820             Transaction.commit(con);
821         }
822         catch(TorqueException e)
823         {
824             Transaction.safeRollback(con);
825             throw e;
826         }
827       }
828
829       /** flag to prevent endless save loop, if this object is referenced
830         by another object which falls in this transaction. */

831     private boolean alreadyInSave = false;
832       /**
833      * Stores the object in the database. If the object is new,
834      * it inserts it; otherwise an update is performed. This method
835      * is meant to be used as part of a transaction, otherwise use
836      * the save() method and the connection details will be handled
837      * internally
838      *
839      * @param con
840      * @throws TorqueException
841      */

842     public void save(Connection JavaDoc con) throws TorqueException
843     {
844           if (!alreadyInSave)
845         {
846             alreadyInSave = true;
847
848
849   
850             // If this object has been modified, then save it to the database.
851
if (isModified())
852             {
853                 if (isNew())
854                 {
855                     TurbineRolePeer.doInsert((TurbineRole) this, con);
856                     setNew(false);
857                 }
858                 else
859                 {
860                     TurbineRolePeer.doUpdate((TurbineRole) this, con);
861                 }
862             }
863
864                                       
865                 
866             if (collTurbineRolePermissions != null)
867             {
868                 for (int i = 0; i < collTurbineRolePermissions.size(); i++)
869                 {
870                     ((TurbineRolePermission) collTurbineRolePermissions.get(i)).save(con);
871                 }
872             }
873                                           
874                 
875             if (collTurbineUserGroupRoles != null)
876             {
877                 for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
878                 {
879                     ((TurbineUserGroupRole) collTurbineUserGroupRoles.get(i)).save(con);
880                 }
881             }
882                           alreadyInSave = false;
883         }
884       }
885
886
887                           
888       /**
889      * Set the PrimaryKey using ObjectKey.
890      *
891      * @param roleId ObjectKey
892      */

893     public void setPrimaryKey(ObjectKey key)
894         throws TorqueException
895     {
896             setRoleId(new Integer JavaDoc(((NumberKey) key).intValue()));
897         }
898
899     /**
900      * Set the PrimaryKey using a String.
901      *
902      * @param key
903      */

904     public void setPrimaryKey(String JavaDoc key) throws TorqueException
905     {
906             setRoleId(new Integer JavaDoc(key));
907         }
908
909   
910     /**
911      * returns an id that differentiates this object from others
912      * of its class.
913      */

914     public ObjectKey getPrimaryKey()
915     {
916           return SimpleKey.keyFor(getRoleId());
917       }
918
919  
920     /**
921      * get an id that differentiates this object from others
922      * of its class.
923      */

924     public String JavaDoc getQueryKey()
925     {
926         if (getPrimaryKey() == null)
927         {
928             return "";
929         }
930         else
931         {
932             return getPrimaryKey().toString();
933         }
934     }
935
936     /**
937      * set an id that differentiates this object from others
938      * of its class.
939      */

940     public void setQueryKey(String JavaDoc key)
941         throws TorqueException
942     {
943         setPrimaryKey(key);
944     }
945
946     /**
947      * Makes a copy of this object.
948      * It creates a new object filling in the simple attributes.
949        * It then fills all the association collections and sets the
950      * related objects to isNew=true.
951        */

952       public TurbineRole copy() throws TorqueException
953     {
954         return copyInto(new TurbineRole());
955     }
956   
957     protected TurbineRole copyInto(TurbineRole copyObj) throws TorqueException
958     {
959           copyObj.setRoleId(roleId);
960           copyObj.setName(name);
961   
962                     copyObj.setRoleId((Integer JavaDoc)null);
963                   
964                                       
965                 
966         List JavaDoc v = getTurbineRolePermissions();
967         for (int i = 0; i < v.size(); i++)
968         {
969             TurbineRolePermission obj = (TurbineRolePermission) v.get(i);
970             copyObj.addTurbineRolePermission(obj.copy());
971         }
972                                                   
973                 
974         v = getTurbineUserGroupRoles();
975         for (int i = 0; i < v.size(); i++)
976         {
977             TurbineUserGroupRole obj = (TurbineUserGroupRole) v.get(i);
978             copyObj.addTurbineUserGroupRole(obj.copy());
979         }
980                     
981         return copyObj;
982     }
983
984     /**
985      * returns a peer instance associated with this om. Since Peer classes
986      * are not to have any instance attributes, this method returns the
987      * same instance for all member of this class. The method could therefore
988      * be static, but this would prevent one from overriding the behavior.
989      */

990     public TurbineRolePeer getPeer()
991     {
992         return peer;
993     }
994
995     public String JavaDoc toString()
996     {
997         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
998         str.append("TurbineRole:\n");
999         str.append("RoleId = ")
1000           .append(getRoleId())
1001           .append("\n");
1002        str.append("Name = ")
1003           .append(getName())
1004           .append("\n");
1005        return(str.toString());
1006    }
1007}
1008
Popular Tags