KickJava   Java API By Example, From Geeks To Geeks.

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


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 TurbineGroup
29  */

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

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

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

88     public String JavaDoc getName()
89     {
90         return name;
91     }
92
93                         
94     /**
95      * Set the value of Name
96      *
97      * @param v new value
98      */

99     public void setName(String JavaDoc v)
100     {
101     
102                   if (!ObjectUtils.equals(this.name, v))
103               {
104             this.name = v;
105             setModified(true);
106         }
107     
108           
109               }
110   
111          
112                                 
113             
114     /**
115      * Collection to store aggregation of collTurbineUserGroupRoles
116      */

117     protected List JavaDoc collTurbineUserGroupRoles;
118
119     /**
120      * Temporary storage of collTurbineUserGroupRoles to save a possible db hit in
121      * the event objects are add to the collection, but the
122      * complete collection is never requested.
123      */

124     protected void initTurbineUserGroupRoles()
125     {
126         if (collTurbineUserGroupRoles == null)
127         {
128             collTurbineUserGroupRoles = new ArrayList JavaDoc();
129         }
130     }
131
132     /**
133      * Method called to associate a TurbineUserGroupRole object to this object
134      * through the TurbineUserGroupRole foreign key attribute
135      *
136      * @param l TurbineUserGroupRole
137      * @throws TorqueException
138      */

139     public void addTurbineUserGroupRole(TurbineUserGroupRole l) throws TorqueException
140     {
141         getTurbineUserGroupRoles().add(l);
142         l.setTurbineGroup((TurbineGroup) this);
143     }
144
145     /**
146      * The criteria used to select the current contents of collTurbineUserGroupRoles
147      */

148     private Criteria lastTurbineUserGroupRolesCriteria = null;
149
150     /**
151      * If this collection has already been initialized, returns
152      * the collection. Otherwise returns the results of
153      * getTurbineUserGroupRoles(new Criteria())
154      *
155      * @throws TorqueException
156      */

157     public List JavaDoc getTurbineUserGroupRoles() throws TorqueException
158     {
159         if (collTurbineUserGroupRoles == null)
160         {
161             collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10));
162         }
163         return collTurbineUserGroupRoles;
164     }
165
166     /**
167      * If this collection has already been initialized with
168      * an identical criteria, it returns the collection.
169      * Otherwise if this TurbineGroup has previously
170      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
171      * If this TurbineGroup is new, it will return
172      * an empty collection or the current collection, the criteria
173      * is ignored on a new object.
174      *
175      * @throws TorqueException
176      */

177     public List JavaDoc getTurbineUserGroupRoles(Criteria criteria) throws TorqueException
178     {
179         if (collTurbineUserGroupRoles == null)
180         {
181             if (isNew())
182             {
183                collTurbineUserGroupRoles = new ArrayList JavaDoc();
184             }
185             else
186             {
187                       criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId() );
188                       collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
189             }
190         }
191         else
192         {
193             // criteria has no effect for a new object
194
if (!isNew())
195             {
196                 // the following code is to determine if a new query is
197
// called for. If the criteria is the same as the last
198
// one, just return the collection.
199
criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
200                       if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
201                 {
202                     collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria);
203                 }
204             }
205         }
206         lastTurbineUserGroupRolesCriteria = criteria;
207
208         return collTurbineUserGroupRoles;
209     }
210
211     /**
212      * If this collection has already been initialized, returns
213      * the collection. Otherwise returns the results of
214      * getTurbineUserGroupRoles(new Criteria(),Connection)
215      * This method takes in the Connection also as input so that
216      * referenced objects can also be obtained using a Connection
217      * that is taken as input
218      */

219     public List JavaDoc getTurbineUserGroupRoles(Connection JavaDoc con) throws TorqueException
220     {
221         if (collTurbineUserGroupRoles == null)
222         {
223             collTurbineUserGroupRoles = getTurbineUserGroupRoles(new Criteria(10), con);
224         }
225         return collTurbineUserGroupRoles;
226     }
227
228     /**
229      * If this collection has already been initialized with
230      * an identical criteria, it returns the collection.
231      * Otherwise if this TurbineGroup has previously
232      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
233      * If this TurbineGroup is new, it will return
234      * an empty collection or the current collection, the criteria
235      * is ignored on a new object.
236      * This method takes in the Connection also as input so that
237      * referenced objects can also be obtained using a Connection
238      * that is taken as input
239      */

240     public List JavaDoc getTurbineUserGroupRoles(Criteria criteria, Connection JavaDoc con)
241             throws TorqueException
242     {
243         if (collTurbineUserGroupRoles == null)
244         {
245             if (isNew())
246             {
247                collTurbineUserGroupRoles = new ArrayList JavaDoc();
248             }
249             else
250             {
251                        criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
252                        collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria, con);
253              }
254          }
255          else
256          {
257              // criteria has no effect for a new object
258
if (!isNew())
259              {
260                  // the following code is to determine if a new query is
261
// called for. If the criteria is the same as the last
262
// one, just return the collection.
263
criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
264                        if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
265                  {
266                      collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelect(criteria, con);
267                  }
268              }
269          }
270          lastTurbineUserGroupRolesCriteria = criteria;
271
272          return collTurbineUserGroupRoles;
273      }
274
275                               
276               
277                     
278                     
279                                 
280                                                               
281                                         
282                     
283                     
284           
285     /**
286      * If this collection has already been initialized with
287      * an identical criteria, it returns the collection.
288      * Otherwise if this TurbineGroup is new, it will return
289      * an empty collection; or if this TurbineGroup has previously
290      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
291      *
292      * This method is protected by default in order to keep the public
293      * api reasonable. You can provide public methods for those you
294      * actually need in TurbineGroup.
295      */

296     protected List JavaDoc getTurbineUserGroupRolesJoinTurbineUser(Criteria criteria)
297         throws TorqueException
298     {
299         if (collTurbineUserGroupRoles == null)
300         {
301             if (isNew())
302             {
303                collTurbineUserGroupRoles = new ArrayList JavaDoc();
304             }
305             else
306             {
307                             criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
308                             collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
309             }
310         }
311         else
312         {
313             // the following code is to determine if a new query is
314
// called for. If the criteria is the same as the last
315
// one, just return the collection.
316
boolean newCriteria = true;
317                         criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
318                         if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
319             {
320                 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
321             }
322         }
323         lastTurbineUserGroupRolesCriteria = criteria;
324
325         return collTurbineUserGroupRoles;
326     }
327                   
328                     
329                               
330                                 
331                                                               
332                                         
333                     
334                     
335           
336     /**
337      * If this collection has already been initialized with
338      * an identical criteria, it returns the collection.
339      * Otherwise if this TurbineGroup is new, it will return
340      * an empty collection; or if this TurbineGroup has previously
341      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
342      *
343      * This method is protected by default in order to keep the public
344      * api reasonable. You can provide public methods for those you
345      * actually need in TurbineGroup.
346      */

347     protected List JavaDoc getTurbineUserGroupRolesJoinTurbineGroup(Criteria criteria)
348         throws TorqueException
349     {
350         if (collTurbineUserGroupRoles == null)
351         {
352             if (isNew())
353             {
354                collTurbineUserGroupRoles = new ArrayList JavaDoc();
355             }
356             else
357             {
358                             criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
359                             collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
360             }
361         }
362         else
363         {
364             // the following code is to determine if a new query is
365
// called for. If the criteria is the same as the last
366
// one, just return the collection.
367
boolean newCriteria = true;
368                         criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
369                         if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
370             {
371                 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
372             }
373         }
374         lastTurbineUserGroupRolesCriteria = criteria;
375
376         return collTurbineUserGroupRoles;
377     }
378                   
379                     
380                     
381                                 
382                                                               
383                                         
384                     
385                     
386           
387     /**
388      * If this collection has already been initialized with
389      * an identical criteria, it returns the collection.
390      * Otherwise if this TurbineGroup is new, it will return
391      * an empty collection; or if this TurbineGroup has previously
392      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
393      *
394      * This method is protected by default in order to keep the public
395      * api reasonable. You can provide public methods for those you
396      * actually need in TurbineGroup.
397      */

398     protected List JavaDoc getTurbineUserGroupRolesJoinTurbineRole(Criteria criteria)
399         throws TorqueException
400     {
401         if (collTurbineUserGroupRoles == null)
402         {
403             if (isNew())
404             {
405                collTurbineUserGroupRoles = new ArrayList JavaDoc();
406             }
407             else
408             {
409                             criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
410                             collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
411             }
412         }
413         else
414         {
415             // the following code is to determine if a new query is
416
// called for. If the criteria is the same as the last
417
// one, just return the collection.
418
boolean newCriteria = true;
419                         criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
420                         if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
421             {
422                 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
423             }
424         }
425         lastTurbineUserGroupRolesCriteria = criteria;
426
427         return collTurbineUserGroupRoles;
428     }
429                             
430
431
432           
433     private static List JavaDoc fieldNames = null;
434
435     /**
436      * Generate a list of field names.
437      *
438      * @return a list of field names
439      */

440     public static synchronized List JavaDoc getFieldNames()
441     {
442         if (fieldNames == null)
443         {
444             fieldNames = new ArrayList JavaDoc();
445               fieldNames.add("GroupId");
446               fieldNames.add("Name");
447               fieldNames = Collections.unmodifiableList(fieldNames);
448         }
449         return fieldNames;
450     }
451
452     /**
453      * Retrieves a field from the object by name passed in as a String.
454      *
455      * @param name field name
456      * @return value
457      */

458     public Object JavaDoc getByName(String JavaDoc name)
459     {
460           if (name.equals("GroupId"))
461         {
462                 return getGroupId();
463             }
464           if (name.equals("Name"))
465         {
466                 return getName();
467             }
468           return null;
469     }
470     
471     /**
472      * Retrieves a field from the object by name passed in
473      * as a String. The String must be one of the static
474      * Strings defined in this Class' Peer.
475      *
476      * @param name peer name
477      * @return value
478      */

479     public Object JavaDoc getByPeerName(String JavaDoc name)
480     {
481           if (name.equals(TurbineGroupPeer.GROUP_ID))
482         {
483                 return getGroupId();
484             }
485           if (name.equals(TurbineGroupPeer.GROUP_NAME))
486         {
487                 return getName();
488             }
489           return null;
490     }
491
492     /**
493      * Retrieves a field from the object by Position as specified
494      * in the xml schema. Zero-based.
495      *
496      * @param pos position in xml schema
497      * @return value
498      */

499     public Object JavaDoc getByPosition(int pos)
500     {
501             if (pos == 0)
502         {
503                 return getGroupId();
504             }
505               if (pos == 1)
506         {
507                 return getName();
508             }
509               return null;
510     }
511      
512     /**
513      * Stores the object in the database. If the object is new,
514      * it inserts it; otherwise an update is performed.
515      *
516      * @throws Exception
517      */

518     public void save() throws Exception JavaDoc
519     {
520           save(TurbineGroupPeer.getMapBuilder()
521                 .getDatabaseMap().getName());
522       }
523
524     /**
525      * Stores the object in the database. If the object is new,
526      * it inserts it; otherwise an update is performed.
527        * Note: this code is here because the method body is
528      * auto-generated conditionally and therefore needs to be
529      * in this file instead of in the super class, BaseObject.
530        *
531      * @param dbName
532      * @throws TorqueException
533      */

534     public void save(String JavaDoc dbName) throws TorqueException
535     {
536         Connection JavaDoc con = null;
537           try
538         {
539             con = Transaction.begin(dbName);
540             save(con);
541             Transaction.commit(con);
542         }
543         catch(TorqueException e)
544         {
545             Transaction.safeRollback(con);
546             throw e;
547         }
548       }
549
550       /** flag to prevent endless save loop, if this object is referenced
551         by another object which falls in this transaction. */

552     private boolean alreadyInSave = false;
553       /**
554      * Stores the object in the database. If the object is new,
555      * it inserts it; otherwise an update is performed. This method
556      * is meant to be used as part of a transaction, otherwise use
557      * the save() method and the connection details will be handled
558      * internally
559      *
560      * @param con
561      * @throws TorqueException
562      */

563     public void save(Connection JavaDoc con) throws TorqueException
564     {
565           if (!alreadyInSave)
566         {
567             alreadyInSave = true;
568
569
570   
571             // If this object has been modified, then save it to the database.
572
if (isModified())
573             {
574                 if (isNew())
575                 {
576                     TurbineGroupPeer.doInsert((TurbineGroup) this, con);
577                     setNew(false);
578                 }
579                 else
580                 {
581                     TurbineGroupPeer.doUpdate((TurbineGroup) this, con);
582                 }
583             }
584
585                                       
586                 
587             if (collTurbineUserGroupRoles != null)
588             {
589                 for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
590                 {
591                     ((TurbineUserGroupRole) collTurbineUserGroupRoles.get(i)).save(con);
592                 }
593             }
594                           alreadyInSave = false;
595         }
596       }
597
598
599                           
600       /**
601      * Set the PrimaryKey using ObjectKey.
602      *
603      * @param groupId ObjectKey
604      */

605     public void setPrimaryKey(ObjectKey key)
606         throws TorqueException
607     {
608             setGroupId(new Integer JavaDoc(((NumberKey) key).intValue()));
609         }
610
611     /**
612      * Set the PrimaryKey using a String.
613      *
614      * @param key
615      */

616     public void setPrimaryKey(String JavaDoc key) throws TorqueException
617     {
618             setGroupId(new Integer JavaDoc(key));
619         }
620
621   
622     /**
623      * returns an id that differentiates this object from others
624      * of its class.
625      */

626     public ObjectKey getPrimaryKey()
627     {
628           return SimpleKey.keyFor(getGroupId());
629       }
630
631  
632     /**
633      * get an id that differentiates this object from others
634      * of its class.
635      */

636     public String JavaDoc getQueryKey()
637     {
638         if (getPrimaryKey() == null)
639         {
640             return "";
641         }
642         else
643         {
644             return getPrimaryKey().toString();
645         }
646     }
647
648     /**
649      * set an id that differentiates this object from others
650      * of its class.
651      */

652     public void setQueryKey(String JavaDoc key)
653         throws TorqueException
654     {
655         setPrimaryKey(key);
656     }
657
658     /**
659      * Makes a copy of this object.
660      * It creates a new object filling in the simple attributes.
661        * It then fills all the association collections and sets the
662      * related objects to isNew=true.
663        */

664       public TurbineGroup copy() throws TorqueException
665     {
666         return copyInto(new TurbineGroup());
667     }
668   
669     protected TurbineGroup copyInto(TurbineGroup copyObj) throws TorqueException
670     {
671           copyObj.setGroupId(groupId);
672           copyObj.setName(name);
673   
674                     copyObj.setGroupId((Integer JavaDoc)null);
675                   
676                                       
677                 
678         List JavaDoc v = getTurbineUserGroupRoles();
679         for (int i = 0; i < v.size(); i++)
680         {
681             TurbineUserGroupRole obj = (TurbineUserGroupRole) v.get(i);
682             copyObj.addTurbineUserGroupRole(obj.copy());
683         }
684                     
685         return copyObj;
686     }
687
688     /**
689      * returns a peer instance associated with this om. Since Peer classes
690      * are not to have any instance attributes, this method returns the
691      * same instance for all member of this class. The method could therefore
692      * be static, but this would prevent one from overriding the behavior.
693      */

694     public TurbineGroupPeer getPeer()
695     {
696         return peer;
697     }
698
699     public String JavaDoc toString()
700     {
701         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
702         str.append("TurbineGroup:\n");
703         str.append("GroupId = ")
704            .append(getGroupId())
705            .append("\n");
706         str.append("Name = ")
707            .append(getName())
708            .append("\n");
709         return(str.toString());
710     }
711 }
712
Popular Tags