KickJava   Java API By Example, From Geeks To Geeks.

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


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

30 public abstract class BaseTurbineUser extends BaseObject
31     implements org.apache.fulcrum.intake.Retrievable
32 {
33     /** The Peer class */
34     private static final TurbineUserPeer peer =
35         new TurbineUserPeer();
36
37         
38     /** The value for the userId field */
39     private Integer JavaDoc userId;
40       
41     /** The value for the userName field */
42     private String JavaDoc userName;
43       
44     /** The value for the password field */
45     private String JavaDoc password;
46       
47     /** The value for the firstName field */
48     private String JavaDoc firstName;
49       
50     /** The value for the lastName field */
51     private String JavaDoc lastName;
52       
53     /** The value for the email field */
54     private String JavaDoc email;
55       
56     /** The value for the confirmed field */
57     private String JavaDoc confirmed;
58       
59     /** The value for the modified field */
60     private Date JavaDoc modified;
61       
62     /** The value for the createDate field */
63     private Date JavaDoc createDate;
64       
65     /** The value for the lastLogin field */
66     private Date JavaDoc lastLogin;
67       
68     /** The value for the objectdata field */
69     private byte[] objectdata;
70   
71     
72     /**
73      * Get the UserId
74      *
75      * @return Integer
76      */

77     public Integer JavaDoc getUserId()
78     {
79         return userId;
80     }
81
82                                               
83     /**
84      * Set the value of UserId
85      *
86      * @param v new value
87      */

88     public void setUserId(Integer JavaDoc v) throws TorqueException
89     {
90     
91                   if (!ObjectUtils.equals(this.userId, v))
92               {
93             this.userId = v;
94             setModified(true);
95         }
96     
97           
98                                   
99         // update associated TurbineUserGroupRole
100
if (collTurbineUserGroupRoles != null)
101         {
102             for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
103             {
104                 ((TurbineUserGroupRole) collTurbineUserGroupRoles.get(i))
105                     .setUserId(v);
106             }
107         }
108                       }
109   
110     /**
111      * Get the UserName
112      *
113      * @return String
114      */

115     public String JavaDoc getUserName()
116     {
117         return userName;
118     }
119
120                         
121     /**
122      * Set the value of UserName
123      *
124      * @param v new value
125      */

126     public void setUserName(String JavaDoc v)
127     {
128     
129                   if (!ObjectUtils.equals(this.userName, v))
130               {
131             this.userName = v;
132             setModified(true);
133         }
134     
135           
136               }
137   
138     /**
139      * Get the Password
140      *
141      * @return String
142      */

143     public String JavaDoc getPassword()
144     {
145         return password;
146     }
147
148                         
149     /**
150      * Set the value of Password
151      *
152      * @param v new value
153      */

154     public void setPassword(String JavaDoc v)
155     {
156     
157                   if (!ObjectUtils.equals(this.password, v))
158               {
159             this.password = v;
160             setModified(true);
161         }
162     
163           
164               }
165   
166     /**
167      * Get the FirstName
168      *
169      * @return String
170      */

171     public String JavaDoc getFirstName()
172     {
173         return firstName;
174     }
175
176                         
177     /**
178      * Set the value of FirstName
179      *
180      * @param v new value
181      */

182     public void setFirstName(String JavaDoc v)
183     {
184     
185                   if (!ObjectUtils.equals(this.firstName, v))
186               {
187             this.firstName = v;
188             setModified(true);
189         }
190     
191           
192               }
193   
194     /**
195      * Get the LastName
196      *
197      * @return String
198      */

199     public String JavaDoc getLastName()
200     {
201         return lastName;
202     }
203
204                         
205     /**
206      * Set the value of LastName
207      *
208      * @param v new value
209      */

210     public void setLastName(String JavaDoc v)
211     {
212     
213                   if (!ObjectUtils.equals(this.lastName, v))
214               {
215             this.lastName = v;
216             setModified(true);
217         }
218     
219           
220               }
221   
222     /**
223      * Get the Email
224      *
225      * @return String
226      */

227     public String JavaDoc getEmail()
228     {
229         return email;
230     }
231
232                         
233     /**
234      * Set the value of Email
235      *
236      * @param v new value
237      */

238     public void setEmail(String JavaDoc v)
239     {
240     
241                   if (!ObjectUtils.equals(this.email, v))
242               {
243             this.email = v;
244             setModified(true);
245         }
246     
247           
248               }
249   
250     /**
251      * Get the Confirmed
252      *
253      * @return String
254      */

255     public String JavaDoc getConfirmed()
256     {
257         return confirmed;
258     }
259
260                         
261     /**
262      * Set the value of Confirmed
263      *
264      * @param v new value
265      */

266     public void setConfirmed(String JavaDoc v)
267     {
268     
269                   if (!ObjectUtils.equals(this.confirmed, v))
270               {
271             this.confirmed = v;
272             setModified(true);
273         }
274     
275           
276               }
277   
278     /**
279      * Get the Modified
280      *
281      * @return Date
282      */

283     public Date JavaDoc getModified()
284     {
285         return modified;
286     }
287
288                         
289     /**
290      * Set the value of Modified
291      *
292      * @param v new value
293      */

294     public void setModified(Date JavaDoc v)
295     {
296     
297                   if (!ObjectUtils.equals(this.modified, v))
298               {
299             this.modified = v;
300             setModified(true);
301         }
302     
303           
304               }
305   
306     /**
307      * Get the CreateDate
308      *
309      * @return Date
310      */

311     public Date JavaDoc getCreateDate()
312     {
313         return createDate;
314     }
315
316                         
317     /**
318      * Set the value of CreateDate
319      *
320      * @param v new value
321      */

322     public void setCreateDate(Date JavaDoc v)
323     {
324     
325                   if (!ObjectUtils.equals(this.createDate, v))
326               {
327             this.createDate = v;
328             setModified(true);
329         }
330     
331           
332               }
333   
334     /**
335      * Get the LastLogin
336      *
337      * @return Date
338      */

339     public Date JavaDoc getLastLogin()
340     {
341         return lastLogin;
342     }
343
344                         
345     /**
346      * Set the value of LastLogin
347      *
348      * @param v new value
349      */

350     public void setLastLogin(Date JavaDoc v)
351     {
352     
353                   if (!ObjectUtils.equals(this.lastLogin, v))
354               {
355             this.lastLogin = v;
356             setModified(true);
357         }
358     
359           
360               }
361   
362     /**
363      * Get the Objectdata
364      *
365      * @return byte[]
366      */

367     public byte[] getObjectdata()
368     {
369         return objectdata;
370     }
371
372                         
373     /**
374      * Set the value of Objectdata
375      *
376      * @param v new value
377      */

378     public void setObjectdata(byte[] v)
379     {
380     
381                   if (!ObjectUtils.equals(this.objectdata, v))
382               {
383             this.objectdata = v;
384             setModified(true);
385         }
386     
387           
388               }
389   
390          
391                                 
392             
393     /**
394      * Collection to store aggregation of collTurbineUserGroupRoles
395      */

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

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

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

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

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

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

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

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

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

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

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

719     public static synchronized List JavaDoc getFieldNames()
720     {
721         if (fieldNames == null)
722         {
723             fieldNames = new ArrayList JavaDoc();
724               fieldNames.add("UserId");
725               fieldNames.add("UserName");
726               fieldNames.add("Password");
727               fieldNames.add("FirstName");
728               fieldNames.add("LastName");
729               fieldNames.add("Email");
730               fieldNames.add("Confirmed");
731               fieldNames.add("Modified");
732               fieldNames.add("CreateDate");
733               fieldNames.add("LastLogin");
734               fieldNames.add("Objectdata");
735               fieldNames = Collections.unmodifiableList(fieldNames);
736         }
737         return fieldNames;
738     }
739
740     /**
741      * Retrieves a field from the object by name passed in as a String.
742      *
743      * @param name field name
744      * @return value
745      */

746     public Object JavaDoc getByName(String JavaDoc name)
747     {
748           if (name.equals("UserId"))
749         {
750                 return getUserId();
751             }
752           if (name.equals("UserName"))
753         {
754                 return getUserName();
755             }
756           if (name.equals("Password"))
757         {
758                 return getPassword();
759             }
760           if (name.equals("FirstName"))
761         {
762                 return getFirstName();
763             }
764           if (name.equals("LastName"))
765         {
766                 return getLastName();
767             }
768           if (name.equals("Email"))
769         {
770                 return getEmail();
771             }
772           if (name.equals("Confirmed"))
773         {
774                 return getConfirmed();
775             }
776           if (name.equals("Modified"))
777         {
778                 return getModified();
779             }
780           if (name.equals("CreateDate"))
781         {
782                 return getCreateDate();
783             }
784           if (name.equals("LastLogin"))
785         {
786                 return getLastLogin();
787             }
788           if (name.equals("Objectdata"))
789         {
790                 return getObjectdata();
791             }
792           return null;
793     }
794     
795     /**
796      * Retrieves a field from the object by name passed in
797      * as a String. The String must be one of the static
798      * Strings defined in this Class' Peer.
799      *
800      * @param name peer name
801      * @return value
802      */

803     public Object JavaDoc getByPeerName(String JavaDoc name)
804     {
805           if (name.equals(TurbineUserPeer.USER_ID))
806         {
807                 return getUserId();
808             }
809           if (name.equals(TurbineUserPeer.LOGIN_NAME))
810         {
811                 return getUserName();
812             }
813           if (name.equals(TurbineUserPeer.PASSWORD_VALUE))
814         {
815                 return getPassword();
816             }
817           if (name.equals(TurbineUserPeer.FIRST_NAME))
818         {
819                 return getFirstName();
820             }
821           if (name.equals(TurbineUserPeer.LAST_NAME))
822         {
823                 return getLastName();
824             }
825           if (name.equals(TurbineUserPeer.EMAIL))
826         {
827                 return getEmail();
828             }
829           if (name.equals(TurbineUserPeer.CONFIRM_VALUE))
830         {
831                 return getConfirmed();
832             }
833           if (name.equals(TurbineUserPeer.MODIFIED))
834         {
835                 return getModified();
836             }
837           if (name.equals(TurbineUserPeer.CREATED))
838         {
839                 return getCreateDate();
840             }
841           if (name.equals(TurbineUserPeer.LAST_LOGIN))
842         {
843                 return getLastLogin();
844             }
845           if (name.equals(TurbineUserPeer.OBJECTDATA))
846         {
847                 return getObjectdata();
848             }
849           return null;
850     }
851
852     /**
853      * Retrieves a field from the object by Position as specified
854      * in the xml schema. Zero-based.
855      *
856      * @param pos position in xml schema
857      * @return value
858      */

859     public Object JavaDoc getByPosition(int pos)
860     {
861             if (pos == 0)
862         {
863                 return getUserId();
864             }
865               if (pos == 1)
866         {
867                 return getUserName();
868             }
869               if (pos == 2)
870         {
871                 return getPassword();
872             }
873               if (pos == 3)
874         {
875                 return getFirstName();
876             }
877               if (pos == 4)
878         {
879                 return getLastName();
880             }
881               if (pos == 5)
882         {
883                 return getEmail();
884             }
885               if (pos == 6)
886         {
887                 return getConfirmed();
888             }
889               if (pos == 7)
890         {
891                 return getModified();
892             }
893               if (pos == 8)
894         {
895                 return getCreateDate();
896             }
897               if (pos == 9)
898         {
899                 return getLastLogin();
900             }
901               if (pos == 10)
902         {
903                 return getObjectdata();
904             }
905               return null;
906     }
907      
908     /**
909      * Stores the object in the database. If the object is new,
910      * it inserts it; otherwise an update is performed.
911      *
912      * @throws Exception
913      */

914     public void save() throws Exception JavaDoc
915     {
916           save(TurbineUserPeer.getMapBuilder()
917                 .getDatabaseMap().getName());
918       }
919
920     /**
921      * Stores the object in the database. If the object is new,
922      * it inserts it; otherwise an update is performed.
923        * Note: this code is here because the method body is
924      * auto-generated conditionally and therefore needs to be
925      * in this file instead of in the super class, BaseObject.
926        *
927      * @param dbName
928      * @throws TorqueException
929      */

930     public void save(String JavaDoc dbName) throws TorqueException
931     {
932         Connection JavaDoc con = null;
933           try
934         {
935             con = Transaction.begin(dbName);
936             save(con);
937             Transaction.commit(con);
938         }
939         catch(TorqueException e)
940         {
941             Transaction.safeRollback(con);
942             throw e;
943         }
944       }
945
946       /** flag to prevent endless save loop, if this object is referenced
947         by another object which falls in this transaction. */

948     private boolean alreadyInSave = false;
949       /**
950      * Stores the object in the database. If the object is new,
951      * it inserts it; otherwise an update is performed. This method
952      * is meant to be used as part of a transaction, otherwise use
953      * the save() method and the connection details will be handled
954      * internally
955      *
956      * @param con
957      * @throws TorqueException
958      */

959     public void save(Connection JavaDoc con) throws TorqueException
960     {
961           if (!alreadyInSave)
962         {
963             alreadyInSave = true;
964
965
966   
967             // If this object has been modified, then save it to the database.
968
if (isModified())
969             {
970                 if (isNew())
971                 {
972                     TurbineUserPeer.doInsert((TurbineUser) this, con);
973                     setNew(false);
974                 }
975                 else
976                 {
977                     TurbineUserPeer.doUpdate((TurbineUser) this, con);
978                 }
979             }
980
981                                       
982                 
983             if (collTurbineUserGroupRoles != null)
984             {
985                 for (int i = 0; i < collTurbineUserGroupRoles.size(); i++)
986                 {
987                     ((TurbineUserGroupRole) collTurbineUserGroupRoles.get(i)).save(con);
988                 }
989             }
990                           alreadyInSave = false;
991         }
992       }
993
994
995                           
996       /**
997      * Set the PrimaryKey using ObjectKey.
998      *
999      * @param userId ObjectKey
1000     */

1001    public void setPrimaryKey(ObjectKey key)
1002        throws TorqueException
1003    {
1004            setUserId(new Integer JavaDoc(((NumberKey) key).intValue()));
1005        }
1006
1007    /**
1008     * Set the PrimaryKey using a String.
1009     *
1010     * @param key
1011     */

1012    public void setPrimaryKey(String JavaDoc key) throws TorqueException
1013    {
1014            setUserId(new Integer JavaDoc(key));
1015        }
1016
1017  
1018    /**
1019     * returns an id that differentiates this object from others
1020     * of its class.
1021     */

1022    public ObjectKey getPrimaryKey()
1023    {
1024          return SimpleKey.keyFor(getUserId());
1025      }
1026
1027 
1028    /**
1029     * get an id that differentiates this object from others
1030     * of its class.
1031     */

1032    public String JavaDoc getQueryKey()
1033    {
1034        if (getPrimaryKey() == null)
1035        {
1036            return "";
1037        }
1038        else
1039        {
1040            return getPrimaryKey().toString();
1041        }
1042    }
1043
1044    /**
1045     * set an id that differentiates this object from others
1046     * of its class.
1047     */

1048    public void setQueryKey(String JavaDoc key)
1049        throws TorqueException
1050    {
1051        setPrimaryKey(key);
1052    }
1053
1054    /**
1055     * Makes a copy of this object.
1056     * It creates a new object filling in the simple attributes.
1057       * It then fills all the association collections and sets the
1058     * related objects to isNew=true.
1059       */

1060      public TurbineUser copy() throws TorqueException
1061    {
1062        return copyInto(new TurbineUser());
1063    }
1064  
1065    protected TurbineUser copyInto(TurbineUser copyObj) throws TorqueException
1066    {
1067          copyObj.setUserId(userId);
1068          copyObj.setUserName(userName);
1069          copyObj.setPassword(password);
1070          copyObj.setFirstName(firstName);
1071          copyObj.setLastName(lastName);
1072          copyObj.setEmail(email);
1073          copyObj.setConfirmed(confirmed);
1074          copyObj.setModified(modified);
1075          copyObj.setCreateDate(createDate);
1076          copyObj.setLastLogin(lastLogin);
1077          copyObj.setObjectdata(objectdata);
1078  
1079                    copyObj.setUserId((Integer JavaDoc)null);
1080                                                                        
1081                                      
1082                
1083        List JavaDoc v = getTurbineUserGroupRoles();
1084        for (int i = 0; i < v.size(); i++)
1085        {
1086            TurbineUserGroupRole obj = (TurbineUserGroupRole) v.get(i);
1087            copyObj.addTurbineUserGroupRole(obj.copy());
1088        }
1089                    
1090        return copyObj;
1091    }
1092
1093    /**
1094     * returns a peer instance associated with this om. Since Peer classes
1095     * are not to have any instance attributes, this method returns the
1096     * same instance for all member of this class. The method could therefore
1097     * be static, but this would prevent one from overriding the behavior.
1098     */

1099    public TurbineUserPeer getPeer()
1100    {
1101        return peer;
1102    }
1103
1104    public String JavaDoc toString()
1105    {
1106        StringBuffer JavaDoc str = new StringBuffer JavaDoc();
1107        str.append("TurbineUser:\n");
1108        str.append("UserId = ")
1109           .append(getUserId())
1110           .append("\n");
1111        str.append("UserName = ")
1112           .append(getUserName())
1113           .append("\n");
1114        str.append("Password = ")
1115           .append(getPassword())
1116           .append("\n");
1117        str.append("FirstName = ")
1118           .append(getFirstName())
1119           .append("\n");
1120        str.append("LastName = ")
1121           .append(getLastName())
1122           .append("\n");
1123        str.append("Email = ")
1124           .append(getEmail())
1125           .append("\n");
1126        str.append("Confirmed = ")
1127           .append(getConfirmed())
1128           .append("\n");
1129        str.append("Modified = ")
1130           .append(getModified())
1131           .append("\n");
1132        str.append("CreateDate = ")
1133           .append(getCreateDate())
1134           .append("\n");
1135        str.append("LastLogin = ")
1136           .append(getLastLogin())
1137           .append("\n");
1138        str.append("Objectdata = ")
1139           .append(getObjectdata())
1140           .append("\n");
1141        return(str.toString());
1142    }
1143}
1144
Popular Tags