KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > om > security > turbine > BaseTurbineRole


1 package org.apache.jetspeed.om.security.turbine;
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.torque.TorqueException;
13 import org.apache.torque.om.BaseObject;
14 import org.apache.torque.om.ComboKey;
15 import org.apache.torque.om.DateKey;
16 import org.apache.torque.om.NumberKey;
17 import org.apache.torque.om.ObjectKey;
18 import org.apache.torque.om.SimpleKey;
19 import org.apache.torque.om.StringKey;
20 import org.apache.torque.om.Persistent;
21 import org.apache.torque.util.Criteria;
22 import org.apache.torque.util.Transaction;
23
24
25 /**
26  * This class was autogenerated by Torque on:
27  *
28  * [Thu Apr 22 15:30:48 PDT 2004]
29  *
30  * You should not use this class directly. It should not even be
31  * extended all references should be to TurbineRole
32  */

33 public abstract class BaseTurbineRole extends BaseObject
34 {
35     /** The Peer class */
36     private static final TurbineRolePeer peer =
37         new TurbineRolePeer();
38
39       
40     /** The value for the roleId field */
41     private int roleId;
42       
43     /** The value for the roleName field */
44     private String JavaDoc roleName;
45       
46     /** The value for the objectdata field */
47     private byte[] objectdata;
48   
49   
50     /**
51      * Get the RoleId
52      * @return int
53      */

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

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

100     public String JavaDoc getRoleName()
101     {
102         return roleName;
103     }
104
105                         
106     /**
107      * Set the value of RoleName
108      */

109     public void setRoleName(String JavaDoc v )
110     {
111     
112                   if (!ObjectUtils.equals(this.roleName, v))
113               {
114             this.roleName = v;
115             setModified(true);
116         }
117     
118           
119               }
120
121   
122     /**
123      * Get the Objectdata
124      * @return byte[]
125      */

126     public byte[] getObjectdata()
127     {
128         return objectdata;
129     }
130
131                         
132     /**
133      * Set the value of Objectdata
134      */

135     public void setObjectdata(byte[] v )
136     {
137     
138                   if (!ObjectUtils.equals(this.objectdata, v))
139               {
140             this.objectdata = v;
141             setModified(true);
142         }
143     
144           
145               }
146
147   
148          
149                                 
150             
151     /**
152      * Collection to store aggregation of collTurbineRolePermissions
153      */

154     protected List JavaDoc collTurbineRolePermissions;
155
156     /**
157      * Temporary storage of collTurbineRolePermissions to save a possible db hit in
158      * the event objects are add to the collection, but the
159      * complete collection is never requested.
160      */

161     protected void initTurbineRolePermissions()
162     {
163         if (collTurbineRolePermissions == null)
164         {
165             collTurbineRolePermissions = new ArrayList JavaDoc();
166         }
167     }
168
169             
170     /**
171      * Method called to associate a TurbineRolePermission object to this object
172      * through the TurbineRolePermission foreign key attribute
173      *
174      * @param TurbineRolePermission l
175      */

176     public void addTurbineRolePermission(TurbineRolePermission l) throws TorqueException
177     {
178         getTurbineRolePermissions().add(l);
179         l.setTurbineRole((TurbineRole)this);
180     }
181
182     /**
183      * The criteria used to select the current contents of collTurbineRolePermissions
184      */

185     private Criteria lastTurbineRolePermissionsCriteria = null;
186
187     /**
188      * If this collection has already been initialized, returns
189      * the collection. Otherwise returns the results of
190      * getTurbineRolePermissions(new Criteria())
191      */

192     public List JavaDoc getTurbineRolePermissions() throws TorqueException
193     {
194         if (collTurbineRolePermissions == null)
195         {
196             collTurbineRolePermissions = getTurbineRolePermissions(new Criteria(10));
197         }
198         return collTurbineRolePermissions;
199     }
200
201     /**
202      * If this collection has already been initialized with
203      * an identical criteria, it returns the collection.
204      * Otherwise if this TurbineRole has previously
205      * been saved, it will retrieve related TurbineRolePermissions from storage.
206      * If this TurbineRole is new, it will return
207      * an empty collection or the current collection, the criteria
208      * is ignored on a new object.
209      */

210     public List JavaDoc getTurbineRolePermissions(Criteria criteria) throws TorqueException
211     {
212         if (collTurbineRolePermissions == null)
213         {
214             if (isNew())
215             {
216                collTurbineRolePermissions = new ArrayList JavaDoc();
217             }
218             else
219             {
220                       criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId() );
221                       collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria);
222             }
223         }
224         else
225         {
226             // criteria has no effect for a new object
227
if (!isNew())
228             {
229                 // the following code is to determine if a new query is
230
// called for. If the criteria is the same as the last
231
// one, just return the collection.
232
criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId() );
233                       if (!lastTurbineRolePermissionsCriteria.equals(criteria))
234                 {
235                     collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria);
236                 }
237             }
238         }
239         lastTurbineRolePermissionsCriteria = criteria;
240
241         return collTurbineRolePermissions;
242     }
243
244     /**
245      * If this collection has already been initialized, returns
246      * the collection. Otherwise returns the results of
247      * getTurbineRolePermissions(new Criteria(),Connection)
248      * This method takes in the Connection also as input so that
249      * referenced objects can also be obtained using a Connection
250      * that is taken as input
251      */

252     public List JavaDoc getTurbineRolePermissions(Connection JavaDoc con) throws TorqueException
253     {
254         if (collTurbineRolePermissions == null)
255         {
256             collTurbineRolePermissions = getTurbineRolePermissions(new Criteria(10),con);
257         }
258         return collTurbineRolePermissions;
259     }
260
261     /**
262      * If this collection has already been initialized with
263      * an identical criteria, it returns the collection.
264      * Otherwise if this TurbineRole has previously
265      * been saved, it will retrieve related TurbineRolePermissions from storage.
266      * If this TurbineRole is new, it will return
267      * an empty collection or the current collection, the criteria
268      * is ignored on a new object.
269      * This method takes in the Connection also as input so that
270      * referenced objects can also be obtained using a Connection
271      * that is taken as input
272      */

273     public List JavaDoc getTurbineRolePermissions(Criteria criteria,Connection JavaDoc con) throws TorqueException
274     {
275         if (collTurbineRolePermissions == null)
276         {
277             if (isNew())
278             {
279                collTurbineRolePermissions = new ArrayList JavaDoc();
280             }
281             else
282             {
283                        criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId() );
284                        collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria,con);
285              }
286          }
287          else
288          {
289              // criteria has no effect for a new object
290
if (!isNew())
291              {
292                  // the following code is to determine if a new query is
293
// called for. If the criteria is the same as the last
294
// one, just return the collection.
295
criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId() );
296                      if (!lastTurbineRolePermissionsCriteria.equals(criteria))
297                  {
298                      collTurbineRolePermissions = TurbineRolePermissionPeer.doSelect(criteria,con);
299                  }
300              }
301          }
302          lastTurbineRolePermissionsCriteria = criteria;
303
304          return collTurbineRolePermissions;
305      }
306
307                         
308
309               
310                     
311                               
312                                 
313                                                               
314                                         
315                     
316                     
317           
318     /**
319      * If this collection has already been initialized with
320      * an identical criteria, it returns the collection.
321      * Otherwise if this TurbineRole is new, it will return
322      * an empty collection; or if this TurbineRole has previously
323      * been saved, it will retrieve related TurbineRolePermissions from storage.
324      *
325      * This method is protected by default in order to keep the public
326      * api reasonable. You can provide public methods for those you
327      * actually need in TurbineRole.
328      */

329     protected List JavaDoc getTurbineRolePermissionsJoinTurbineRole(Criteria criteria)
330         throws TorqueException
331     {
332         if (collTurbineRolePermissions == null)
333         {
334             if (isNew())
335             {
336                collTurbineRolePermissions = new ArrayList JavaDoc();
337             }
338             else
339             {
340                             criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId() );
341                             collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbineRole(criteria);
342             }
343         }
344         else
345         {
346             // the following code is to determine if a new query is
347
// called for. If the criteria is the same as the last
348
// one, just return the collection.
349
boolean newCriteria = true;
350                             criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId() );
351                         if (!lastTurbineRolePermissionsCriteria.equals(criteria))
352             {
353                 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbineRole(criteria);
354             }
355         }
356         lastTurbineRolePermissionsCriteria = criteria;
357
358         return collTurbineRolePermissions;
359     }
360                   
361                     
362                     
363                                 
364                                                               
365                                         
366                     
367                     
368           
369     /**
370      * If this collection has already been initialized with
371      * an identical criteria, it returns the collection.
372      * Otherwise if this TurbineRole is new, it will return
373      * an empty collection; or if this TurbineRole has previously
374      * been saved, it will retrieve related TurbineRolePermissions from storage.
375      *
376      * This method is protected by default in order to keep the public
377      * api reasonable. You can provide public methods for those you
378      * actually need in TurbineRole.
379      */

380     protected List JavaDoc getTurbineRolePermissionsJoinTurbinePermission(Criteria criteria)
381         throws TorqueException
382     {
383         if (collTurbineRolePermissions == null)
384         {
385             if (isNew())
386             {
387                collTurbineRolePermissions = new ArrayList JavaDoc();
388             }
389             else
390             {
391                             criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId() );
392                             collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbinePermission(criteria);
393             }
394         }
395         else
396         {
397             // the following code is to determine if a new query is
398
// called for. If the criteria is the same as the last
399
// one, just return the collection.
400
boolean newCriteria = true;
401                             criteria.add(TurbineRolePermissionPeer.ROLE_ID, getRoleId() );
402                         if (!lastTurbineRolePermissionsCriteria.equals(criteria))
403             {
404                 collTurbineRolePermissions = TurbineRolePermissionPeer.doSelectJoinTurbinePermission(criteria);
405             }
406         }
407         lastTurbineRolePermissionsCriteria = criteria;
408
409         return collTurbineRolePermissions;
410     }
411                             
412
413
414                           
415             
416     /**
417      * Collection to store aggregation of collTurbineUserGroupRoles
418      */

419     protected List JavaDoc collTurbineUserGroupRoles;
420
421     /**
422      * Temporary storage of collTurbineUserGroupRoles to save a possible db hit in
423      * the event objects are add to the collection, but the
424      * complete collection is never requested.
425      */

426     protected void initTurbineUserGroupRoles()
427     {
428         if (collTurbineUserGroupRoles == null)
429         {
430             collTurbineUserGroupRoles = new ArrayList JavaDoc();
431         }
432     }
433
434             
435     /**
436      * Method called to associate a TurbineUserGroupRole object to this object
437      * through the TurbineUserGroupRole foreign key attribute
438      *
439      * @param TurbineUserGroupRole l
440      */

441     public void addTurbineUserGroupRole(TurbineUserGroupRole l) throws TorqueException
442     {
443         getTurbineUserGroupRoles().add(l);
444         l.setTurbineRole((TurbineRole)this);
445     }
446
447     /**
448      * The criteria used to select the current contents of collTurbineUserGroupRoles
449      */

450     private Criteria lastTurbineUserGroupRolesCriteria = null;
451
452     /**
453      * If this collection has already been initialized, returns
454      * the collection. Otherwise returns the results of
455      * getTurbineUserGroupRoles(new Criteria())
456      */

457     public List JavaDoc getTurbineUserGroupRoles() throws TorqueException
458     {
459         if (collTurbineUserGroupRoles == null)
460         {
461             collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10));
462         }
463         return collTurbineUserGroupRoles;
464     }
465
466     /**
467      * If this collection has already been initialized with
468      * an identical criteria, it returns the collection.
469      * Otherwise if this TurbineRole has previously
470      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
471      * If this TurbineRole is new, it will return
472      * an empty collection or the current collection, the criteria
473      * is ignored on a new object.
474      */

475     public List JavaDoc getTurbineUserGroupRoles(Criteria criteria) throws TorqueException
476     {
477         if (collTurbineUserGroupRoles == null)
478         {
479             if (isNew())
480             {
481                collTurbineUserGroupRoles = new ArrayList JavaDoc();
482             }
483             else
484             {
485                       criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId() );
486                       collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
487             }
488         }
489         else
490         {
491             // criteria has no effect for a new object
492
if (!isNew())
493             {
494                 // the following code is to determine if a new query is
495
// called for. If the criteria is the same as the last
496
// one, just return the collection.
497
criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId() );
498                       if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
499                 {
500                     collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
501                 }
502             }
503         }
504         lastTurbineUserGroupRolesCriteria = criteria;
505
506         return collTurbineUserGroupRoles;
507     }
508
509     /**
510      * If this collection has already been initialized, returns
511      * the collection. Otherwise returns the results of
512      * getTurbineUserGroupRoles(new Criteria(),Connection)
513      * This method takes in the Connection also as input so that
514      * referenced objects can also be obtained using a Connection
515      * that is taken as input
516      */

517     public List JavaDoc getTurbineUserGroupRoles(Connection JavaDoc con) throws TorqueException
518     {
519         if (collTurbineUserGroupRoles == null)
520         {
521             collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10),con);
522         }
523         return collTurbineUserGroupRoles;
524     }
525
526     /**
527      * If this collection has already been initialized with
528      * an identical criteria, it returns the collection.
529      * Otherwise if this TurbineRole has previously
530      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
531      * If this TurbineRole is new, it will return
532      * an empty collection or the current collection, the criteria
533      * is ignored on a new object.
534      * This method takes in the Connection also as input so that
535      * referenced objects can also be obtained using a Connection
536      * that is taken as input
537      */

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

594     protected List JavaDoc getTurbineUserGroupRolesJoinTurbineUser(Criteria criteria)
595         throws TorqueException
596     {
597         if (collTurbineUserGroupRoles == null)
598         {
599             if (isNew())
600             {
601                collTurbineUserGroupRoles = new ArrayList JavaDoc();
602             }
603             else
604             {
605                             criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId() );
606                             collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
607             }
608         }
609         else
610         {
611             // the following code is to determine if a new query is
612
// called for. If the criteria is the same as the last
613
// one, just return the collection.
614
boolean newCriteria = true;
615                             criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId() );
616                         if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
617             {
618                 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
619             }
620         }
621         lastTurbineUserGroupRolesCriteria = criteria;
622
623         return collTurbineUserGroupRoles;
624     }
625                   
626                     
627                     
628                                 
629                                                               
630                                         
631                     
632                     
633           
634     /**
635      * If this collection has already been initialized with
636      * an identical criteria, it returns the collection.
637      * Otherwise if this TurbineRole is new, it will return
638      * an empty collection; or if this TurbineRole has previously
639      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
640      *
641      * This method is protected by default in order to keep the public
642      * api reasonable. You can provide public methods for those you
643      * actually need in TurbineRole.
644      */

645     protected List JavaDoc getTurbineUserGroupRolesJoinTurbineGroup(Criteria criteria)
646         throws TorqueException
647     {
648         if (collTurbineUserGroupRoles == null)
649         {
650             if (isNew())
651             {
652                collTurbineUserGroupRoles = new ArrayList JavaDoc();
653             }
654             else
655             {
656                             criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId() );
657                             collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
658             }
659         }
660         else
661         {
662             // the following code is to determine if a new query is
663
// called for. If the criteria is the same as the last
664
// one, just return the collection.
665
boolean newCriteria = true;
666                             criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId() );
667                         if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
668             {
669                 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
670             }
671         }
672         lastTurbineUserGroupRolesCriteria = criteria;
673
674         return collTurbineUserGroupRoles;
675     }
676                   
677                     
678                               
679                                 
680                                                               
681                                         
682                     
683                     
684           
685     /**
686      * If this collection has already been initialized with
687      * an identical criteria, it returns the collection.
688      * Otherwise if this TurbineRole is new, it will return
689      * an empty collection; or if this TurbineRole has previously
690      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
691      *
692      * This method is protected by default in order to keep the public
693      * api reasonable. You can provide public methods for those you
694      * actually need in TurbineRole.
695      */

696     protected List JavaDoc getTurbineUserGroupRolesJoinTurbineRole(Criteria criteria)
697         throws TorqueException
698     {
699         if (collTurbineUserGroupRoles == null)
700         {
701             if (isNew())
702             {
703                collTurbineUserGroupRoles = new ArrayList JavaDoc();
704             }
705             else
706             {
707                             criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId() );
708                             collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
709             }
710         }
711         else
712         {
713             // the following code is to determine if a new query is
714
// called for. If the criteria is the same as the last
715
// one, just return the collection.
716
boolean newCriteria = true;
717                             criteria.add(TurbineUserGroupRolePeer.ROLE_ID, getRoleId() );
718                         if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
719             {
720                 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
721             }
722         }
723         lastTurbineUserGroupRolesCriteria = criteria;
724
725         return collTurbineUserGroupRoles;
726     }
727                             
728
729
730           
731     private static List JavaDoc fieldNames = null;
732
733     /**
734      * Generate a list of field names.
735      */

736     public static synchronized List JavaDoc getFieldNames()
737     {
738         if (fieldNames == null)
739         {
740             fieldNames = new ArrayList JavaDoc();
741               fieldNames.add("RoleId");
742               fieldNames.add("RoleName");
743               fieldNames.add("Objectdata");
744               fieldNames = Collections.unmodifiableList(fieldNames);
745         }
746         return fieldNames;
747     }
748
749     /**
750      * Retrieves a field from the object by name passed in
751      * as a String.
752      */

753     public Object JavaDoc getByName(String JavaDoc name)
754     {
755           if (name.equals("RoleId"))
756         {
757                 return new Integer JavaDoc(getRoleId());
758             }
759           if (name.equals("RoleName"))
760         {
761                 return getRoleName();
762             }
763           if (name.equals("Objectdata"))
764         {
765                 return getObjectdata();
766             }
767           return null;
768     }
769     
770     /**
771      * Retrieves a field from the object by name passed in
772      * as a String. The String must be one of the static
773      * Strings defined in this Class' Peer.
774      */

775     public Object JavaDoc getByPeerName(String JavaDoc name)
776     {
777           if (name.equals(TurbineRolePeer.ROLE_ID ))
778         {
779                 return new Integer JavaDoc(getRoleId());
780             }
781           if (name.equals(TurbineRolePeer.ROLE_NAME ))
782         {
783                 return getRoleName();
784             }
785           if (name.equals(TurbineRolePeer.OBJECTDATA ))
786         {
787                 return getObjectdata();
788             }
789           return null;
790     }
791
792     /**
793      * Retrieves a field from the object by Position as specified
794      * in the xml schema. Zero-based.
795      */

796     public Object JavaDoc getByPosition(int pos)
797     {
798             if ( pos == 0 )
799         {
800                 return new Integer JavaDoc(getRoleId());
801             }
802               if ( pos == 1 )
803         {
804                 return getRoleName();
805             }
806               if ( pos == 2 )
807         {
808                 return getObjectdata();
809             }
810               return null;
811     }
812      
813     /**
814      * Stores the object in the database. If the object is new,
815      * it inserts it; otherwise an update is performed.
816      */

817     public void save() throws Exception JavaDoc
818     {
819           save(TurbineRolePeer.getMapBuilder()
820                 .getDatabaseMap().getName());
821       }
822
823     /**
824      * Stores the object in the database. If the object is new,
825      * it inserts it; otherwise an update is performed.
826        * Note: this code is here because the method body is
827      * auto-generated conditionally and therefore needs to be
828      * in this file instead of in the super class, BaseObject.
829        */

830     public void save(String JavaDoc dbName) throws TorqueException
831     {
832         Connection JavaDoc con = null;
833           try
834         {
835             con = Transaction.begin(dbName);
836             save(con);
837             Transaction.commit(con);
838         }
839         catch(TorqueException e)
840         {
841             Transaction.safeRollback(con);
842             throw e;
843         }
844       }
845
846       /** flag to prevent endless save loop, if this object is referenced
847         by another object which falls in this transaction. */

848     private boolean alreadyInSave = false;
849       /**
850      * Stores the object in the database. If the object is new,
851      * it inserts it; otherwise an update is performed. This method
852      * is meant to be used as part of a transaction, otherwise use
853      * the save() method and the connection details will be handled
854      * internally
855      */

856     public void save(Connection JavaDoc con) throws TorqueException
857     {
858           if (!alreadyInSave)
859         {
860             alreadyInSave = true;
861
862
863   
864             // If this object has been modified, then save it to the database.
865
if (isModified())
866             {
867                 if (isNew())
868                 {
869                     TurbineRolePeer.doInsert((TurbineRole)this, con);
870                     setNew(false);
871                 }
872                 else
873                 {
874                     TurbineRolePeer.doUpdate((TurbineRole)this, con);
875                 }
876
877                       if (isCacheOnSave())
878                 {
879                     TurbineRoleManager.putInstance(this);
880                 }
881               }
882
883                                       
884                             if (collTurbineRolePermissions != null )
885             {
886                 for (int i = 0; i < collTurbineRolePermissions.size(); i++)
887                 {
888                     ((TurbineRolePermission)collTurbineRolePermissions.get(i)).save(con);
889                 }
890             }
891                                           
892                             if (collTurbineUserGroupRoles != null )
893             {
894                 for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
895                 {
896                     ((TurbineUserGroupRole)collTurbineUserGroupRoles.get(i)).save(con);
897                 }
898             }
899                           alreadyInSave = false;
900         }
901       }
902
903     /**
904      * Specify whether to cache the object after saving to the db.
905      * This method returns false
906      */

907     protected boolean isCacheOnSave()
908     {
909         return true;
910     }
911
912                         
913       /**
914      * Set the PrimaryKey using ObjectKey.
915      *
916      * @param ObjectKey roleId
917      */

918     public void setPrimaryKey(ObjectKey roleId)
919         throws TorqueException {
920             setRoleId(((NumberKey)roleId).intValue());
921         }
922
923     /**
924      * Set the PrimaryKey using a String.
925      */

926     public void setPrimaryKey(String JavaDoc key) throws TorqueException
927     {
928             setRoleId(Integer.parseInt(key));
929         }
930
931   
932     /**
933      * returns an id that differentiates this object from others
934      * of its class.
935      */

936     public ObjectKey getPrimaryKey()
937     {
938           return SimpleKey.keyFor(getRoleId());
939       }
940  
941
942     /**
943      * Makes a copy of this object.
944      * It creates a new object filling in the simple attributes.
945        * It then fills all the association collections.
946        */

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

981     public TurbineRolePeer getPeer()
982     {
983         return peer;
984     }
985 }
986
Popular Tags