KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > tigris > scarab > om > BaseFrequency


1 package org.tigris.scarab.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.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 Frequency
29  */

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

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

61     public void setFrequencyId(Integer JavaDoc v) throws TorqueException
62     {
63     
64                   if (!ObjectUtils.equals(this.frequencyId, v))
65               {
66             this.frequencyId = v;
67             setModified(true);
68         }
69     
70           
71                                   
72         // update associated Query
73
if (collQuerys != null)
74         {
75             for (int i = 0; i < collQuerys.size(); i++)
76             {
77                 ((Query) collQuerys.get(i))
78                         .setSubscriptionFrequencyId(v);
79             }
80         }
81                                           
82         // update associated RQueryUser
83
if (collRQueryUsers != null)
84         {
85             for (int i = 0; i < collRQueryUsers.size(); i++)
86             {
87                 ((RQueryUser) collRQueryUsers.get(i))
88                         .setSubscriptionFrequency(v);
89             }
90         }
91                       }
92   
93     /**
94      * Get the Name
95      *
96      * @return String
97      */

98     public String JavaDoc getName()
99     {
100         return name;
101     }
102
103                         
104     /**
105      * Set the value of Name
106      *
107      * @param v new value
108      */

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

127     protected List JavaDoc collQuerys;
128
129     /**
130      * Temporary storage of collQuerys to save a possible db hit in
131      * the event objects are add to the collection, but the
132      * complete collection is never requested.
133      */

134     protected void initQuerys()
135     {
136         if (collQuerys == null)
137         {
138             collQuerys = new ArrayList JavaDoc();
139         }
140     }
141
142             
143     /**
144      * Method called to associate a Query object to this object
145      * through the Query foreign key attribute
146      *
147      * @param l Query
148      * @throws TorqueException
149      */

150     public void addQuery(Query l) throws TorqueException
151     {
152         getQuerys().add(l);
153         l.setFrequency((Frequency)this);
154     }
155
156     /**
157      * The criteria used to select the current contents of collQuerys
158      */

159     private Criteria lastQuerysCriteria = null;
160
161     /**
162      * If this collection has already been initialized, returns
163      * the collection. Otherwise returns the results of
164      * getQuerys(new Criteria())
165      *
166      * @throws TorqueException
167      */

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

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

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

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

306     protected List JavaDoc getQuerysJoinScarabUserImpl(Criteria criteria)
307         throws TorqueException
308     {
309         if (collQuerys == null)
310         {
311             if (isNew())
312             {
313                collQuerys = new ArrayList JavaDoc();
314             }
315             else
316             {
317                             criteria.add(QueryPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
318                             collQuerys = QueryPeer.doSelectJoinScarabUserImpl(criteria);
319             }
320         }
321         else
322         {
323             // the following code is to determine if a new query is
324
// called for. If the criteria is the same as the last
325
// one, just return the collection.
326

327                             criteria.add(QueryPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
328                         if (!lastQuerysCriteria.equals(criteria))
329             {
330                 collQuerys = QueryPeer.doSelectJoinScarabUserImpl(criteria);
331             }
332         }
333         lastQuerysCriteria = criteria;
334
335         return collQuerys;
336     }
337                   
338                     
339                     
340                                 
341                                                               
342                                         
343                     
344                     
345           
346     /**
347      * If this collection has already been initialized with
348      * an identical criteria, it returns the collection.
349      * Otherwise if this Frequency is new, it will return
350      * an empty collection; or if this Frequency has previously
351      * been saved, it will retrieve related Querys from storage.
352      *
353      * This method is protected by default in order to keep the public
354      * api reasonable. You can provide public methods for those you
355      * actually need in Frequency.
356      */

357     protected List JavaDoc getQuerysJoinScope(Criteria criteria)
358         throws TorqueException
359     {
360         if (collQuerys == null)
361         {
362             if (isNew())
363             {
364                collQuerys = new ArrayList JavaDoc();
365             }
366             else
367             {
368                             criteria.add(QueryPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
369                             collQuerys = QueryPeer.doSelectJoinScope(criteria);
370             }
371         }
372         else
373         {
374             // the following code is to determine if a new query is
375
// called for. If the criteria is the same as the last
376
// one, just return the collection.
377

378                             criteria.add(QueryPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
379                         if (!lastQuerysCriteria.equals(criteria))
380             {
381                 collQuerys = QueryPeer.doSelectJoinScope(criteria);
382             }
383         }
384         lastQuerysCriteria = criteria;
385
386         return collQuerys;
387     }
388                   
389                     
390                     
391                                 
392                                                               
393                                         
394                     
395                     
396           
397     /**
398      * If this collection has already been initialized with
399      * an identical criteria, it returns the collection.
400      * Otherwise if this Frequency is new, it will return
401      * an empty collection; or if this Frequency has previously
402      * been saved, it will retrieve related Querys from storage.
403      *
404      * This method is protected by default in order to keep the public
405      * api reasonable. You can provide public methods for those you
406      * actually need in Frequency.
407      */

408     protected List JavaDoc getQuerysJoinScarabModule(Criteria criteria)
409         throws TorqueException
410     {
411         if (collQuerys == null)
412         {
413             if (isNew())
414             {
415                collQuerys = new ArrayList JavaDoc();
416             }
417             else
418             {
419                             criteria.add(QueryPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
420                             collQuerys = QueryPeer.doSelectJoinScarabModule(criteria);
421             }
422         }
423         else
424         {
425             // the following code is to determine if a new query is
426
// called for. If the criteria is the same as the last
427
// one, just return the collection.
428

429                             criteria.add(QueryPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
430                         if (!lastQuerysCriteria.equals(criteria))
431             {
432                 collQuerys = QueryPeer.doSelectJoinScarabModule(criteria);
433             }
434         }
435         lastQuerysCriteria = criteria;
436
437         return collQuerys;
438     }
439                   
440                     
441                     
442                                 
443                                                               
444                                         
445                     
446                     
447           
448     /**
449      * If this collection has already been initialized with
450      * an identical criteria, it returns the collection.
451      * Otherwise if this Frequency is new, it will return
452      * an empty collection; or if this Frequency has previously
453      * been saved, it will retrieve related Querys from storage.
454      *
455      * This method is protected by default in order to keep the public
456      * api reasonable. You can provide public methods for those you
457      * actually need in Frequency.
458      */

459     protected List JavaDoc getQuerysJoinIssueType(Criteria criteria)
460         throws TorqueException
461     {
462         if (collQuerys == null)
463         {
464             if (isNew())
465             {
466                collQuerys = new ArrayList JavaDoc();
467             }
468             else
469             {
470                             criteria.add(QueryPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
471                             collQuerys = QueryPeer.doSelectJoinIssueType(criteria);
472             }
473         }
474         else
475         {
476             // the following code is to determine if a new query is
477
// called for. If the criteria is the same as the last
478
// one, just return the collection.
479

480                             criteria.add(QueryPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
481                         if (!lastQuerysCriteria.equals(criteria))
482             {
483                 collQuerys = QueryPeer.doSelectJoinIssueType(criteria);
484             }
485         }
486         lastQuerysCriteria = criteria;
487
488         return collQuerys;
489     }
490                   
491                     
492                     
493                                 
494                                                               
495                                         
496                     
497                     
498           
499     /**
500      * If this collection has already been initialized with
501      * an identical criteria, it returns the collection.
502      * Otherwise if this Frequency is new, it will return
503      * an empty collection; or if this Frequency has previously
504      * been saved, it will retrieve related Querys from storage.
505      *
506      * This method is protected by default in order to keep the public
507      * api reasonable. You can provide public methods for those you
508      * actually need in Frequency.
509      */

510     protected List JavaDoc getQuerysJoinMITList(Criteria criteria)
511         throws TorqueException
512     {
513         if (collQuerys == null)
514         {
515             if (isNew())
516             {
517                collQuerys = new ArrayList JavaDoc();
518             }
519             else
520             {
521                             criteria.add(QueryPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
522                             collQuerys = QueryPeer.doSelectJoinMITList(criteria);
523             }
524         }
525         else
526         {
527             // the following code is to determine if a new query is
528
// called for. If the criteria is the same as the last
529
// one, just return the collection.
530

531                             criteria.add(QueryPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
532                         if (!lastQuerysCriteria.equals(criteria))
533             {
534                 collQuerys = QueryPeer.doSelectJoinMITList(criteria);
535             }
536         }
537         lastQuerysCriteria = criteria;
538
539         return collQuerys;
540     }
541                   
542                     
543                               
544                                 
545                                                               
546                                         
547                     
548                     
549           
550     /**
551      * If this collection has already been initialized with
552      * an identical criteria, it returns the collection.
553      * Otherwise if this Frequency is new, it will return
554      * an empty collection; or if this Frequency has previously
555      * been saved, it will retrieve related Querys from storage.
556      *
557      * This method is protected by default in order to keep the public
558      * api reasonable. You can provide public methods for those you
559      * actually need in Frequency.
560      */

561     protected List JavaDoc getQuerysJoinFrequency(Criteria criteria)
562         throws TorqueException
563     {
564         if (collQuerys == null)
565         {
566             if (isNew())
567             {
568                collQuerys = new ArrayList JavaDoc();
569             }
570             else
571             {
572                             criteria.add(QueryPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
573                             collQuerys = QueryPeer.doSelectJoinFrequency(criteria);
574             }
575         }
576         else
577         {
578             // the following code is to determine if a new query is
579
// called for. If the criteria is the same as the last
580
// one, just return the collection.
581

582                             criteria.add(QueryPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
583                         if (!lastQuerysCriteria.equals(criteria))
584             {
585                 collQuerys = QueryPeer.doSelectJoinFrequency(criteria);
586             }
587         }
588         lastQuerysCriteria = criteria;
589
590         return collQuerys;
591     }
592                             
593
594
595                           
596             
597     /**
598      * Collection to store aggregation of collRQueryUsers
599      */

600     protected List JavaDoc collRQueryUsers;
601
602     /**
603      * Temporary storage of collRQueryUsers to save a possible db hit in
604      * the event objects are add to the collection, but the
605      * complete collection is never requested.
606      */

607     protected void initRQueryUsers()
608     {
609         if (collRQueryUsers == null)
610         {
611             collRQueryUsers = new ArrayList JavaDoc();
612         }
613     }
614
615             
616     /**
617      * Method called to associate a RQueryUser object to this object
618      * through the RQueryUser foreign key attribute
619      *
620      * @param l RQueryUser
621      * @throws TorqueException
622      */

623     public void addRQueryUser(RQueryUser l) throws TorqueException
624     {
625         getRQueryUsers().add(l);
626         l.setFrequency((Frequency)this);
627     }
628
629     /**
630      * The criteria used to select the current contents of collRQueryUsers
631      */

632     private Criteria lastRQueryUsersCriteria = null;
633
634     /**
635      * If this collection has already been initialized, returns
636      * the collection. Otherwise returns the results of
637      * getRQueryUsers(new Criteria())
638      *
639      * @throws TorqueException
640      */

641     public List JavaDoc getRQueryUsers() throws TorqueException
642     {
643         if (collRQueryUsers == null)
644         {
645             collRQueryUsers = getRQueryUsers(new Criteria(10));
646         }
647         return collRQueryUsers;
648     }
649
650     /**
651      * If this collection has already been initialized with
652      * an identical criteria, it returns the collection.
653      * Otherwise if this Frequency has previously
654      * been saved, it will retrieve related RQueryUsers from storage.
655      * If this Frequency is new, it will return
656      * an empty collection or the current collection, the criteria
657      * is ignored on a new object.
658      *
659      * @throws TorqueException
660      */

661     public List JavaDoc getRQueryUsers(Criteria criteria) throws TorqueException
662     {
663         if (collRQueryUsers == null)
664         {
665             if (isNew())
666             {
667                collRQueryUsers = new ArrayList JavaDoc();
668             }
669             else
670             {
671                       criteria.add(RQueryUserPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
672                       collRQueryUsers = RQueryUserPeer.doSelect(criteria);
673             }
674         }
675         else
676         {
677             // criteria has no effect for a new object
678
if (!isNew())
679             {
680                 // the following code is to determine if a new query is
681
// called for. If the criteria is the same as the last
682
// one, just return the collection.
683
criteria.add(RQueryUserPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
684                       if (!lastRQueryUsersCriteria.equals(criteria))
685                 {
686                     collRQueryUsers = RQueryUserPeer.doSelect(criteria);
687                 }
688             }
689         }
690         lastRQueryUsersCriteria = criteria;
691
692         return collRQueryUsers;
693     }
694
695     /**
696      * If this collection has already been initialized, returns
697      * the collection. Otherwise returns the results of
698      * getRQueryUsers(new Criteria(),Connection)
699      * This method takes in the Connection also as input so that
700      * referenced objects can also be obtained using a Connection
701      * that is taken as input
702      */

703     public List JavaDoc getRQueryUsers(Connection JavaDoc con) throws TorqueException
704     {
705         if (collRQueryUsers == null)
706         {
707             collRQueryUsers = getRQueryUsers(new Criteria(10),con);
708         }
709         return collRQueryUsers;
710     }
711
712     /**
713      * If this collection has already been initialized with
714      * an identical criteria, it returns the collection.
715      * Otherwise if this Frequency has previously
716      * been saved, it will retrieve related RQueryUsers from storage.
717      * If this Frequency is new, it will return
718      * an empty collection or the current collection, the criteria
719      * is ignored on a new object.
720      * This method takes in the Connection also as input so that
721      * referenced objects can also be obtained using a Connection
722      * that is taken as input
723      */

724     public List JavaDoc getRQueryUsers(Criteria criteria,Connection JavaDoc con) throws TorqueException
725     {
726         if (collRQueryUsers == null)
727         {
728             if (isNew())
729             {
730                collRQueryUsers = new ArrayList JavaDoc();
731             }
732             else
733             {
734                        criteria.add(RQueryUserPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
735                        collRQueryUsers = RQueryUserPeer.doSelect(criteria,con);
736              }
737          }
738          else
739          {
740              // criteria has no effect for a new object
741
if (!isNew())
742              {
743                  // the following code is to determine if a new query is
744
// called for. If the criteria is the same as the last
745
// one, just return the collection.
746
criteria.add(RQueryUserPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
747                      if (!lastRQueryUsersCriteria.equals(criteria))
748                  {
749                      collRQueryUsers = RQueryUserPeer.doSelect(criteria,con);
750                  }
751              }
752          }
753          lastRQueryUsersCriteria = criteria;
754
755          return collRQueryUsers;
756      }
757
758                               
759               
760                     
761                     
762                                 
763                                                               
764                                         
765                     
766                     
767           
768     /**
769      * If this collection has already been initialized with
770      * an identical criteria, it returns the collection.
771      * Otherwise if this Frequency is new, it will return
772      * an empty collection; or if this Frequency has previously
773      * been saved, it will retrieve related RQueryUsers from storage.
774      *
775      * This method is protected by default in order to keep the public
776      * api reasonable. You can provide public methods for those you
777      * actually need in Frequency.
778      */

779     protected List JavaDoc getRQueryUsersJoinQuery(Criteria criteria)
780         throws TorqueException
781     {
782         if (collRQueryUsers == null)
783         {
784             if (isNew())
785             {
786                collRQueryUsers = new ArrayList JavaDoc();
787             }
788             else
789             {
790                             criteria.add(RQueryUserPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
791                             collRQueryUsers = RQueryUserPeer.doSelectJoinQuery(criteria);
792             }
793         }
794         else
795         {
796             // the following code is to determine if a new query is
797
// called for. If the criteria is the same as the last
798
// one, just return the collection.
799

800                             criteria.add(RQueryUserPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
801                         if (!lastRQueryUsersCriteria.equals(criteria))
802             {
803                 collRQueryUsers = RQueryUserPeer.doSelectJoinQuery(criteria);
804             }
805         }
806         lastRQueryUsersCriteria = criteria;
807
808         return collRQueryUsers;
809     }
810                   
811                     
812                     
813                                 
814                                                               
815                                         
816                     
817                     
818           
819     /**
820      * If this collection has already been initialized with
821      * an identical criteria, it returns the collection.
822      * Otherwise if this Frequency is new, it will return
823      * an empty collection; or if this Frequency has previously
824      * been saved, it will retrieve related RQueryUsers from storage.
825      *
826      * This method is protected by default in order to keep the public
827      * api reasonable. You can provide public methods for those you
828      * actually need in Frequency.
829      */

830     protected List JavaDoc getRQueryUsersJoinScarabUserImpl(Criteria criteria)
831         throws TorqueException
832     {
833         if (collRQueryUsers == null)
834         {
835             if (isNew())
836             {
837                collRQueryUsers = new ArrayList JavaDoc();
838             }
839             else
840             {
841                             criteria.add(RQueryUserPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
842                             collRQueryUsers = RQueryUserPeer.doSelectJoinScarabUserImpl(criteria);
843             }
844         }
845         else
846         {
847             // the following code is to determine if a new query is
848
// called for. If the criteria is the same as the last
849
// one, just return the collection.
850

851                             criteria.add(RQueryUserPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
852                         if (!lastRQueryUsersCriteria.equals(criteria))
853             {
854                 collRQueryUsers = RQueryUserPeer.doSelectJoinScarabUserImpl(criteria);
855             }
856         }
857         lastRQueryUsersCriteria = criteria;
858
859         return collRQueryUsers;
860     }
861                   
862                     
863                               
864                                 
865                                                               
866                                         
867                     
868                     
869           
870     /**
871      * If this collection has already been initialized with
872      * an identical criteria, it returns the collection.
873      * Otherwise if this Frequency is new, it will return
874      * an empty collection; or if this Frequency has previously
875      * been saved, it will retrieve related RQueryUsers from storage.
876      *
877      * This method is protected by default in order to keep the public
878      * api reasonable. You can provide public methods for those you
879      * actually need in Frequency.
880      */

881     protected List JavaDoc getRQueryUsersJoinFrequency(Criteria criteria)
882         throws TorqueException
883     {
884         if (collRQueryUsers == null)
885         {
886             if (isNew())
887             {
888                collRQueryUsers = new ArrayList JavaDoc();
889             }
890             else
891             {
892                             criteria.add(RQueryUserPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
893                             collRQueryUsers = RQueryUserPeer.doSelectJoinFrequency(criteria);
894             }
895         }
896         else
897         {
898             // the following code is to determine if a new query is
899
// called for. If the criteria is the same as the last
900
// one, just return the collection.
901

902                             criteria.add(RQueryUserPeer.SUBSCRIPTION_FREQUENCY_ID, getFrequencyId() );
903                         if (!lastRQueryUsersCriteria.equals(criteria))
904             {
905                 collRQueryUsers = RQueryUserPeer.doSelectJoinFrequency(criteria);
906             }
907         }
908         lastRQueryUsersCriteria = criteria;
909
910         return collRQueryUsers;
911     }
912                             
913
914
915           
916     private static List JavaDoc fieldNames = null;
917
918     /**
919      * Generate a list of field names.
920      *
921      * @return a list of field names
922      */

923     public static synchronized List JavaDoc getFieldNames()
924     {
925         if (fieldNames == null)
926         {
927             fieldNames = new ArrayList JavaDoc();
928               fieldNames.add("FrequencyId");
929               fieldNames.add("Name");
930               fieldNames = Collections.unmodifiableList(fieldNames);
931         }
932         return fieldNames;
933     }
934
935     /**
936      * Retrieves a field from the object by name passed in as a String.
937      *
938      * @param name field name
939      * @return value
940      */

941     public Object JavaDoc getByName(String JavaDoc name)
942     {
943           if (name.equals("FrequencyId"))
944         {
945                 return getFrequencyId();
946             }
947           if (name.equals("Name"))
948         {
949                 return getName();
950             }
951           return null;
952     }
953     
954     /**
955      * Retrieves a field from the object by name passed in
956      * as a String. The String must be one of the static
957      * Strings defined in this Class' Peer.
958      *
959      * @param name peer name
960      * @return value
961      */

962     public Object JavaDoc getByPeerName(String JavaDoc name)
963     {
964           if (name.equals(FrequencyPeer.FREQUENCY_ID))
965         {
966                 return getFrequencyId();
967             }
968           if (name.equals(FrequencyPeer.FREQUENCY_NAME))
969         {
970                 return getName();
971             }
972           return null;
973     }
974
975     /**
976      * Retrieves a field from the object by Position as specified
977      * in the xml schema. Zero-based.
978      *
979      * @param pos position in xml schema
980      * @return value
981      */

982     public Object JavaDoc getByPosition(int pos)
983     {
984             if (pos == 0)
985         {
986                 return getFrequencyId();
987             }
988               if (pos == 1)
989         {
990                 return getName();
991             }
992               return null;
993     }
994      
995     /**
996      * Stores the object in the database. If the object is new,
997      * it inserts it; otherwise an update is performed.
998      *
999      * @throws Exception
1000     */

1001    public void save() throws Exception JavaDoc
1002    {
1003          save(FrequencyPeer.getMapBuilder()
1004                .getDatabaseMap().getName());
1005      }
1006
1007    /**
1008     * Stores the object in the database. If the object is new,
1009     * it inserts it; otherwise an update is performed.
1010       * Note: this code is here because the method body is
1011     * auto-generated conditionally and therefore needs to be
1012     * in this file instead of in the super class, BaseObject.
1013       *
1014     * @param dbName
1015     * @throws TorqueException
1016     */

1017    public void save(String JavaDoc dbName) throws TorqueException
1018    {
1019        Connection JavaDoc con = null;
1020          try
1021        {
1022            con = Transaction.begin(dbName);
1023            save(con);
1024            Transaction.commit(con);
1025        }
1026        catch(TorqueException e)
1027        {
1028            Transaction.safeRollback(con);
1029            throw e;
1030        }
1031      }
1032
1033      /** flag to prevent endless save loop, if this object is referenced
1034        by another object which falls in this transaction. */

1035    private boolean alreadyInSave = false;
1036      /**
1037     * Stores the object in the database. If the object is new,
1038     * it inserts it; otherwise an update is performed. This method
1039     * is meant to be used as part of a transaction, otherwise use
1040     * the save() method and the connection details will be handled
1041     * internally
1042     *
1043     * @param con
1044     * @throws TorqueException
1045     */

1046    public void save(Connection JavaDoc con) throws TorqueException
1047    {
1048          if (!alreadyInSave)
1049        {
1050            alreadyInSave = true;
1051
1052
1053  
1054            // If this object has been modified, then save it to the database.
1055
if (isModified())
1056            {
1057                if (isNew())
1058                {
1059                    FrequencyPeer.doInsert((Frequency)this, con);
1060                    setNew(false);
1061                }
1062                else
1063                {
1064                    FrequencyPeer.doUpdate((Frequency)this, con);
1065                }
1066
1067                      if (isCacheOnSave())
1068                {
1069                    FrequencyManager.putInstance(this);
1070                }
1071              }
1072
1073                                      
1074                            if (collQuerys != null)
1075            {
1076                for (int i = 0; i < collQuerys.size(); i++)
1077                {
1078                    ((Query)collQuerys.get(i)).save(con);
1079                }
1080            }
1081                                          
1082                            if (collRQueryUsers != null)
1083            {
1084                for (int i = 0; i < collRQueryUsers.size(); i++)
1085                {
1086                    ((RQueryUser)collRQueryUsers.get(i)).save(con);
1087                }
1088            }
1089                          alreadyInSave = false;
1090        }
1091      }
1092
1093    /**
1094     * Specify whether to cache the object after saving to the db.
1095     * This method returns false
1096     */

1097    protected boolean isCacheOnSave()
1098    {
1099        return true;
1100    }
1101
1102                        
1103      /**
1104     * Set the PrimaryKey using ObjectKey.
1105     *
1106     * @param frequencyId ObjectKey
1107     */

1108    public void setPrimaryKey(ObjectKey frequencyId)
1109        throws TorqueException {
1110            setFrequencyId(new Integer JavaDoc(((NumberKey)frequencyId).intValue()));
1111        }
1112
1113    /**
1114     * Set the PrimaryKey using a String.
1115     *
1116     * @param key
1117     */

1118    public void setPrimaryKey(String JavaDoc key) throws TorqueException
1119    {
1120            setFrequencyId(new Integer JavaDoc(key));
1121        }
1122
1123  
1124    /**
1125     * returns an id that differentiates this object from others
1126     * of its class.
1127     */

1128    public ObjectKey getPrimaryKey()
1129    {
1130          return SimpleKey.keyFor(getFrequencyId());
1131      }
1132 
1133    /**
1134     * get an id that differentiates this object from others
1135     * of its class.
1136     */

1137    public String JavaDoc getQueryKey()
1138    {
1139        if (getPrimaryKey() == null)
1140        {
1141            return "";
1142        }
1143        else
1144        {
1145            return getPrimaryKey().toString();
1146        }
1147    }
1148
1149    /**
1150     * set an id that differentiates this object from others
1151     * of its class.
1152     */

1153    public void setQueryKey(String JavaDoc key)
1154        throws TorqueException
1155    {
1156        setPrimaryKey(key);
1157    }
1158
1159    /**
1160     * Makes a copy of this object.
1161     * It creates a new object filling in the simple attributes.
1162       * It then fills all the association collections and sets the
1163     * related objects to isNew=true.
1164       */

1165      public Frequency copy() throws TorqueException
1166    {
1167        Frequency copyObj = new Frequency();
1168            copyObj.setFrequencyId(frequencyId);
1169          copyObj.setName(name);
1170  
1171                      copyObj.setFrequencyId((Integer JavaDoc)null);
1172                  
1173                                      
1174                
1175        List JavaDoc v = getQuerys();
1176        for (int i = 0; i < v.size(); i++)
1177        {
1178            Query obj = (Query) v.get(i);
1179            copyObj.addQuery(obj.copy());
1180        }
1181                                                  
1182                
1183        v = getRQueryUsers();
1184        for (int i = 0; i < v.size(); i++)
1185        {
1186            RQueryUser obj = (RQueryUser) v.get(i);
1187            copyObj.addRQueryUser(obj.copy());
1188        }
1189                            return copyObj;
1190    }
1191
1192    /**
1193     * returns a peer instance associated with this om. Since Peer classes
1194     * are not to have any instance attributes, this method returns the
1195     * same instance for all member of this class. The method could therefore
1196     * be static, but this would prevent one from overriding the behavior.
1197     */

1198    public FrequencyPeer getPeer()
1199    {
1200        return peer;
1201    }
1202
1203    public String JavaDoc toString()
1204    {
1205        StringBuffer JavaDoc str = new StringBuffer JavaDoc();
1206        str.append("Frequency:\n");
1207        str.append("FrequencyId = ")
1208               .append(getFrequencyId())
1209             .append("\n");
1210        str.append("Name = ")
1211               .append(getName())
1212             .append("\n");
1213        return(str.toString());
1214    }
1215}
1216
Popular Tags