KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > campware > cream > om > BaseTurbineRole


1 package org.campware.cream.om;
2
3
4 import java.math.BigDecimal JavaDoc;
5 import java.sql.Connection JavaDoc;
6 import java.util.ArrayList JavaDoc;
7 import java.util.Collections JavaDoc;
8 import java.util.Date JavaDoc;
9 import java.util.List JavaDoc;
10
11 import org.apache.commons.lang.ObjectUtils;
12 import org.apache.turbine.om.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  * This class was autogenerated by Torque on:
28  *
29  * [Wed May 04 09:10:56 CEST 2005]
30  *
31  * You should not use this class directly. It should not even be
32  * extended all references should be to TurbineRole
33  */

34 public abstract class BaseTurbineRole extends BaseObject
35     implements org.apache.turbine.om.Retrievable
36 {
37     /** The Peer class */
38     private static final TurbineRolePeer peer =
39         new TurbineRolePeer();
40
41         
42     /** The value for the roleId field */
43     private int roleId;
44       
45     /** The value for the name field */
46     private String JavaDoc name;
47   
48     
49     /**
50      * Get the RoleId
51      *
52      * @return int
53      */

54     public int getRoleId()
55     {
56         return roleId;
57     }
58
59                                               
60     /**
61      * Set the value of RoleId
62      *
63      * @param v new value
64      */

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

102     public String JavaDoc getName()
103     {
104         return name;
105     }
106
107                         
108     /**
109      * Set the value of Name
110      *
111      * @param v new value
112      */

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

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

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

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

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

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

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

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

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

310     protected List JavaDoc getTurbineRolePermissionsJoinTurbineRole(Criteria criteria)
311         throws TorqueException
312     {
313                     if (collTurbineRolePermissions == null)
314         {
315             if (isNew())
316             {
317                collTurbineRolePermissions = new ArrayList JavaDoc();
318             }
319             else
320             {
321                               criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
322                               collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbineRole(criteria);
323             }
324         }
325         else
326         {
327             // the following code is to determine if a new query is
328
// called for. If the criteria is the same as the last
329
// one, just return the collection.
330

331                         criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
332                                     if (!lastTurbineRolePermissionsCriteria.equals(criteria))
333             {
334                 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbineRole(criteria);
335             }
336         }
337         lastTurbineRolePermissionsCriteria = criteria;
338
339         return collTurbineRolePermissions;
340                 }
341                   
342                     
343                     
344                                 
345                                                               
346                                         
347                     
348                     
349           
350     /**
351      * If this collection has already been initialized with
352      * an identical criteria, it returns the collection.
353      * Otherwise if this TurbineRole is new, it will return
354      * an empty collection; or if this TurbineRole has previously
355      * been saved, it will retrieve related TurbineRolePermissions from storage.
356      *
357      * This method is protected by default in order to keep the public
358      * api reasonable. You can provide public methods for those you
359      * actually need in TurbineRole.
360      */

361     protected List JavaDoc getTurbineRolePermissionsJoinTurbinePermission(Criteria criteria)
362         throws TorqueException
363     {
364                     if (collTurbineRolePermissions == null)
365         {
366             if (isNew())
367             {
368                collTurbineRolePermissions = new ArrayList JavaDoc();
369             }
370             else
371             {
372                               criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
373                               collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbinePermission(criteria);
374             }
375         }
376         else
377         {
378             // the following code is to determine if a new query is
379
// called for. If the criteria is the same as the last
380
// one, just return the collection.
381

382                         criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId());
383                                     if (!lastTurbineRolePermissionsCriteria.equals(criteria))
384             {
385                 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbinePermission(criteria);
386             }
387         }
388         lastTurbineRolePermissionsCriteria = criteria;
389
390         return collTurbineRolePermissions;
391                 }
392                             
393
394
395                           
396             
397           /**
398      * Collection to store aggregation of collTurbineUserGroupRoles
399      */

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

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

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

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

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

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

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

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

579     protected List JavaDoc getTurbineUserGroupRolesJoinTurbineUser(Criteria criteria)
580         throws TorqueException
581     {
582                     if (collTurbineUserGroupRoles == null)
583         {
584             if (isNew())
585             {
586                collTurbineUserGroupRoles = new ArrayList JavaDoc();
587             }
588             else
589             {
590                               criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
591                               collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
592             }
593         }
594         else
595         {
596             // the following code is to determine if a new query is
597
// called for. If the criteria is the same as the last
598
// one, just return the collection.
599

600                         criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
601                                     if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
602             {
603                 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
604             }
605         }
606         lastTurbineUserGroupRolesCriteria = criteria;
607
608         return collTurbineUserGroupRoles;
609                 }
610                   
611                     
612                     
613                                 
614                                                               
615                                         
616                     
617                     
618           
619     /**
620      * If this collection has already been initialized with
621      * an identical criteria, it returns the collection.
622      * Otherwise if this TurbineRole is new, it will return
623      * an empty collection; or if this TurbineRole has previously
624      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
625      *
626      * This method is protected by default in order to keep the public
627      * api reasonable. You can provide public methods for those you
628      * actually need in TurbineRole.
629      */

630     protected List JavaDoc getTurbineUserGroupRolesJoinTurbineGroup(Criteria criteria)
631         throws TorqueException
632     {
633                     if (collTurbineUserGroupRoles == null)
634         {
635             if (isNew())
636             {
637                collTurbineUserGroupRoles = new ArrayList JavaDoc();
638             }
639             else
640             {
641                               criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
642                               collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
643             }
644         }
645         else
646         {
647             // the following code is to determine if a new query is
648
// called for. If the criteria is the same as the last
649
// one, just return the collection.
650

651                         criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
652                                     if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
653             {
654                 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
655             }
656         }
657         lastTurbineUserGroupRolesCriteria = criteria;
658
659         return collTurbineUserGroupRoles;
660                 }
661                   
662                     
663                               
664                                 
665                                                               
666                                         
667                     
668                     
669           
670     /**
671      * If this collection has already been initialized with
672      * an identical criteria, it returns the collection.
673      * Otherwise if this TurbineRole is new, it will return
674      * an empty collection; or if this TurbineRole has previously
675      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
676      *
677      * This method is protected by default in order to keep the public
678      * api reasonable. You can provide public methods for those you
679      * actually need in TurbineRole.
680      */

681     protected List JavaDoc getTurbineUserGroupRolesJoinTurbineRole(Criteria criteria)
682         throws TorqueException
683     {
684                     if (collTurbineUserGroupRoles == null)
685         {
686             if (isNew())
687             {
688                collTurbineUserGroupRoles = new ArrayList JavaDoc();
689             }
690             else
691             {
692                               criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
693                               collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
694             }
695         }
696         else
697         {
698             // the following code is to determine if a new query is
699
// called for. If the criteria is the same as the last
700
// one, just return the collection.
701

702                         criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId());
703                                     if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
704             {
705                 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
706             }
707         }
708         lastTurbineUserGroupRolesCriteria = criteria;
709
710         return collTurbineUserGroupRoles;
711                 }
712                             
713
714
715           
716     private static List JavaDoc fieldNames = null;
717
718     /**
719      * Generate a list of field names.
720      *
721      * @return a list of field names
722      */

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

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

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

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

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

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

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

846     public void save(Connection JavaDoc con) throws TorqueException
847     {
848           if (!alreadyInSave)
849         {
850             alreadyInSave = true;
851
852
853   
854             // If this object has been modified, then save it to the database.
855
if (isModified())
856             {
857                 if (isNew())
858                 {
859                     TurbineRolePeer.doInsert((TurbineRole) this, con);
860                     setNew(false);
861                 }
862                 else
863                 {
864                     TurbineRolePeer.doUpdate((TurbineRole) this, con);
865                 }
866             }
867
868                                       
869                 
870                     if (collTurbineRolePermissions != null)
871             {
872                 for (int i = 0; i < collTurbineRolePermissions.size(); i++)
873                 {
874                     ((TurbineRolePermission) collTurbineRolePermissions.get(i)).save(con);
875                 }
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 JavaDoc 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      * get an id that differentiates this object from others
924      * of its class.
925      */

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

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

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

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