KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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

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

92     public String JavaDoc getName()
93     {
94         return name;
95     }
96
97                         
98     /**
99      * Set the value of Name
100      *
101      * @param v new value
102      */

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

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

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

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

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

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

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

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

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

300     protected List JavaDoc getTurbineUserGroupRolesJoinTurbineUser(Criteria criteria)
301         throws TorqueException
302     {
303                     if (collTurbineUserGroupRoles == null)
304         {
305             if (isNew())
306             {
307                collTurbineUserGroupRoles = new ArrayList JavaDoc();
308             }
309             else
310             {
311                               criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
312                               collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
313             }
314         }
315         else
316         {
317             // the following code is to determine if a new query is
318
// called for. If the criteria is the same as the last
319
// one, just return the collection.
320

321                         criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
322                                     if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
323             {
324                 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineUser(criteria);
325             }
326         }
327         lastTurbineUserGroupRolesCriteria = criteria;
328
329         return collTurbineUserGroupRoles;
330                 }
331                   
332                     
333                               
334                                 
335                                                               
336                                         
337                     
338                     
339           
340     /**
341      * If this collection has already been initialized with
342      * an identical criteria, it returns the collection.
343      * Otherwise if this TurbineGroup is new, it will return
344      * an empty collection; or if this TurbineGroup has previously
345      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
346      *
347      * This method is protected by default in order to keep the public
348      * api reasonable. You can provide public methods for those you
349      * actually need in TurbineGroup.
350      */

351     protected List JavaDoc getTurbineUserGroupRolesJoinTurbineGroup(Criteria criteria)
352         throws TorqueException
353     {
354                     if (collTurbineUserGroupRoles == null)
355         {
356             if (isNew())
357             {
358                collTurbineUserGroupRoles = new ArrayList JavaDoc();
359             }
360             else
361             {
362                               criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
363                               collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
364             }
365         }
366         else
367         {
368             // the following code is to determine if a new query is
369
// called for. If the criteria is the same as the last
370
// one, just return the collection.
371

372                         criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
373                                     if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
374             {
375                 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineGroup(criteria);
376             }
377         }
378         lastTurbineUserGroupRolesCriteria = criteria;
379
380         return collTurbineUserGroupRoles;
381                 }
382                   
383                     
384                     
385                                 
386                                                               
387                                         
388                     
389                     
390           
391     /**
392      * If this collection has already been initialized with
393      * an identical criteria, it returns the collection.
394      * Otherwise if this TurbineGroup is new, it will return
395      * an empty collection; or if this TurbineGroup has previously
396      * been saved, it will retrieve related TurbineUserGroupRoles from storage.
397      *
398      * This method is protected by default in order to keep the public
399      * api reasonable. You can provide public methods for those you
400      * actually need in TurbineGroup.
401      */

402     protected List JavaDoc getTurbineUserGroupRolesJoinTurbineRole(Criteria criteria)
403         throws TorqueException
404     {
405                     if (collTurbineUserGroupRoles == null)
406         {
407             if (isNew())
408             {
409                collTurbineUserGroupRoles = new ArrayList JavaDoc();
410             }
411             else
412             {
413                               criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
414                               collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
415             }
416         }
417         else
418         {
419             // the following code is to determine if a new query is
420
// called for. If the criteria is the same as the last
421
// one, just return the collection.
422

423                         criteria.add(TurbineUserGroupRolePeer.GROUP_ID, getGroupId());
424                                     if (!lastTurbineUserGroupRolesCriteria.equals(criteria))
425             {
426                 collTurbineUserGroupRoles = TurbineUserGroupRolePeer.doSelectJoinTurbineRole(criteria);
427             }
428         }
429         lastTurbineUserGroupRolesCriteria = criteria;
430
431         return collTurbineUserGroupRoles;
432                 }
433                             
434
435
436           
437     private static List JavaDoc fieldNames = null;
438
439     /**
440      * Generate a list of field names.
441      *
442      * @return a list of field names
443      */

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

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

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

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

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

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

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

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

608     public void setPrimaryKey(ObjectKey key)
609         throws TorqueException
610     {
611             setGroupId(((NumberKey) key).intValue());
612         }
613
614     /**
615      * Set the PrimaryKey using a String.
616      *
617      * @param key
618      */

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

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

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

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

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

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