KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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

61     public void setScopeId(Integer JavaDoc v) throws TorqueException
62     {
63     
64                   if (!ObjectUtils.equals(this.scopeId, v))
65               {
66             this.scopeId = 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                         .setScopeId(v);
79             }
80         }
81                                           
82         // update associated IssueTemplateInfo
83
if (collIssueTemplateInfos != null)
84         {
85             for (int i = 0; i < collIssueTemplateInfos.size(); i++)
86             {
87                 ((IssueTemplateInfo) collIssueTemplateInfos.get(i))
88                         .setScopeId(v);
89             }
90         }
91                                           
92         // update associated Report
93
if (collReports != null)
94         {
95             for (int i = 0; i < collReports.size(); i++)
96             {
97                 ((Report) collReports.get(i))
98                         .setScopeId(v);
99             }
100         }
101                       }
102   
103     /**
104      * Get the Name
105      *
106      * @return String
107      */

108     public String JavaDoc getName()
109     {
110         return name;
111     }
112
113                         
114     /**
115      * Set the value of Name
116      *
117      * @param v new value
118      */

119     public void setName(String JavaDoc v)
120     {
121     
122                   if (!ObjectUtils.equals(this.name, v))
123               {
124             this.name = v;
125             setModified(true);
126         }
127     
128           
129               }
130   
131          
132                                 
133             
134     /**
135      * Collection to store aggregation of collQuerys
136      */

137     protected List JavaDoc collQuerys;
138
139     /**
140      * Temporary storage of collQuerys to save a possible db hit in
141      * the event objects are add to the collection, but the
142      * complete collection is never requested.
143      */

144     protected void initQuerys()
145     {
146         if (collQuerys == null)
147         {
148             collQuerys = new ArrayList JavaDoc();
149         }
150     }
151
152             
153     /**
154      * Method called to associate a Query object to this object
155      * through the Query foreign key attribute
156      *
157      * @param l Query
158      * @throws TorqueException
159      */

160     public void addQuery(Query l) throws TorqueException
161     {
162         getQuerys().add(l);
163         l.setScope((Scope)this);
164     }
165
166     /**
167      * The criteria used to select the current contents of collQuerys
168      */

169     private Criteria lastQuerysCriteria = null;
170
171     /**
172      * If this collection has already been initialized, returns
173      * the collection. Otherwise returns the results of
174      * getQuerys(new Criteria())
175      *
176      * @throws TorqueException
177      */

178     public List JavaDoc getQuerys() throws TorqueException
179     {
180         if (collQuerys == null)
181         {
182             collQuerys = getQuerys(new Criteria(10));
183         }
184         return collQuerys;
185     }
186
187     /**
188      * If this collection has already been initialized with
189      * an identical criteria, it returns the collection.
190      * Otherwise if this Scope has previously
191      * been saved, it will retrieve related Querys from storage.
192      * If this Scope is new, it will return
193      * an empty collection or the current collection, the criteria
194      * is ignored on a new object.
195      *
196      * @throws TorqueException
197      */

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

240     public List JavaDoc getQuerys(Connection JavaDoc con) throws TorqueException
241     {
242         if (collQuerys == null)
243         {
244             collQuerys = getQuerys(new Criteria(10),con);
245         }
246         return collQuerys;
247     }
248
249     /**
250      * If this collection has already been initialized with
251      * an identical criteria, it returns the collection.
252      * Otherwise if this Scope has previously
253      * been saved, it will retrieve related Querys from storage.
254      * If this Scope is new, it will return
255      * an empty collection or the current collection, the criteria
256      * is ignored on a new object.
257      * This method takes in the Connection also as input so that
258      * referenced objects can also be obtained using a Connection
259      * that is taken as input
260      */

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

316     protected List JavaDoc getQuerysJoinScarabUserImpl(Criteria criteria)
317         throws TorqueException
318     {
319         if (collQuerys == null)
320         {
321             if (isNew())
322             {
323                collQuerys = new ArrayList JavaDoc();
324             }
325             else
326             {
327                             criteria.add(QueryPeer.SCOPE_ID, getScopeId() );
328                             collQuerys = QueryPeer.doSelectJoinScarabUserImpl(criteria);
329             }
330         }
331         else
332         {
333             // the following code is to determine if a new query is
334
// called for. If the criteria is the same as the last
335
// one, just return the collection.
336

337                             criteria.add(QueryPeer.SCOPE_ID, getScopeId() );
338                         if (!lastQuerysCriteria.equals(criteria))
339             {
340                 collQuerys = QueryPeer.doSelectJoinScarabUserImpl(criteria);
341             }
342         }
343         lastQuerysCriteria = criteria;
344
345         return collQuerys;
346     }
347                   
348                     
349                               
350                                 
351                                                               
352                                         
353                     
354                     
355           
356     /**
357      * If this collection has already been initialized with
358      * an identical criteria, it returns the collection.
359      * Otherwise if this Scope is new, it will return
360      * an empty collection; or if this Scope has previously
361      * been saved, it will retrieve related Querys from storage.
362      *
363      * This method is protected by default in order to keep the public
364      * api reasonable. You can provide public methods for those you
365      * actually need in Scope.
366      */

367     protected List JavaDoc getQuerysJoinScope(Criteria criteria)
368         throws TorqueException
369     {
370         if (collQuerys == null)
371         {
372             if (isNew())
373             {
374                collQuerys = new ArrayList JavaDoc();
375             }
376             else
377             {
378                             criteria.add(QueryPeer.SCOPE_ID, getScopeId() );
379                             collQuerys = QueryPeer.doSelectJoinScope(criteria);
380             }
381         }
382         else
383         {
384             // the following code is to determine if a new query is
385
// called for. If the criteria is the same as the last
386
// one, just return the collection.
387

388                             criteria.add(QueryPeer.SCOPE_ID, getScopeId() );
389                         if (!lastQuerysCriteria.equals(criteria))
390             {
391                 collQuerys = QueryPeer.doSelectJoinScope(criteria);
392             }
393         }
394         lastQuerysCriteria = criteria;
395
396         return collQuerys;
397     }
398                   
399                     
400                     
401                                 
402                                                               
403                                         
404                     
405                     
406           
407     /**
408      * If this collection has already been initialized with
409      * an identical criteria, it returns the collection.
410      * Otherwise if this Scope is new, it will return
411      * an empty collection; or if this Scope has previously
412      * been saved, it will retrieve related Querys from storage.
413      *
414      * This method is protected by default in order to keep the public
415      * api reasonable. You can provide public methods for those you
416      * actually need in Scope.
417      */

418     protected List JavaDoc getQuerysJoinScarabModule(Criteria criteria)
419         throws TorqueException
420     {
421         if (collQuerys == null)
422         {
423             if (isNew())
424             {
425                collQuerys = new ArrayList JavaDoc();
426             }
427             else
428             {
429                             criteria.add(QueryPeer.SCOPE_ID, getScopeId() );
430                             collQuerys = QueryPeer.doSelectJoinScarabModule(criteria);
431             }
432         }
433         else
434         {
435             // the following code is to determine if a new query is
436
// called for. If the criteria is the same as the last
437
// one, just return the collection.
438

439                             criteria.add(QueryPeer.SCOPE_ID, getScopeId() );
440                         if (!lastQuerysCriteria.equals(criteria))
441             {
442                 collQuerys = QueryPeer.doSelectJoinScarabModule(criteria);
443             }
444         }
445         lastQuerysCriteria = criteria;
446
447         return collQuerys;
448     }
449                   
450                     
451                     
452                                 
453                                                               
454                                         
455                     
456                     
457           
458     /**
459      * If this collection has already been initialized with
460      * an identical criteria, it returns the collection.
461      * Otherwise if this Scope is new, it will return
462      * an empty collection; or if this Scope has previously
463      * been saved, it will retrieve related Querys from storage.
464      *
465      * This method is protected by default in order to keep the public
466      * api reasonable. You can provide public methods for those you
467      * actually need in Scope.
468      */

469     protected List JavaDoc getQuerysJoinIssueType(Criteria criteria)
470         throws TorqueException
471     {
472         if (collQuerys == null)
473         {
474             if (isNew())
475             {
476                collQuerys = new ArrayList JavaDoc();
477             }
478             else
479             {
480                             criteria.add(QueryPeer.SCOPE_ID, getScopeId() );
481                             collQuerys = QueryPeer.doSelectJoinIssueType(criteria);
482             }
483         }
484         else
485         {
486             // the following code is to determine if a new query is
487
// called for. If the criteria is the same as the last
488
// one, just return the collection.
489

490                             criteria.add(QueryPeer.SCOPE_ID, getScopeId() );
491                         if (!lastQuerysCriteria.equals(criteria))
492             {
493                 collQuerys = QueryPeer.doSelectJoinIssueType(criteria);
494             }
495         }
496         lastQuerysCriteria = criteria;
497
498         return collQuerys;
499     }
500                   
501                     
502                     
503                                 
504                                                               
505                                         
506                     
507                     
508           
509     /**
510      * If this collection has already been initialized with
511      * an identical criteria, it returns the collection.
512      * Otherwise if this Scope is new, it will return
513      * an empty collection; or if this Scope has previously
514      * been saved, it will retrieve related Querys from storage.
515      *
516      * This method is protected by default in order to keep the public
517      * api reasonable. You can provide public methods for those you
518      * actually need in Scope.
519      */

520     protected List JavaDoc getQuerysJoinMITList(Criteria criteria)
521         throws TorqueException
522     {
523         if (collQuerys == null)
524         {
525             if (isNew())
526             {
527                collQuerys = new ArrayList JavaDoc();
528             }
529             else
530             {
531                             criteria.add(QueryPeer.SCOPE_ID, getScopeId() );
532                             collQuerys = QueryPeer.doSelectJoinMITList(criteria);
533             }
534         }
535         else
536         {
537             // the following code is to determine if a new query is
538
// called for. If the criteria is the same as the last
539
// one, just return the collection.
540

541                             criteria.add(QueryPeer.SCOPE_ID, getScopeId() );
542                         if (!lastQuerysCriteria.equals(criteria))
543             {
544                 collQuerys = QueryPeer.doSelectJoinMITList(criteria);
545             }
546         }
547         lastQuerysCriteria = criteria;
548
549         return collQuerys;
550     }
551                   
552                     
553                     
554                                 
555                                                               
556                                         
557                     
558                     
559           
560     /**
561      * If this collection has already been initialized with
562      * an identical criteria, it returns the collection.
563      * Otherwise if this Scope is new, it will return
564      * an empty collection; or if this Scope has previously
565      * been saved, it will retrieve related Querys from storage.
566      *
567      * This method is protected by default in order to keep the public
568      * api reasonable. You can provide public methods for those you
569      * actually need in Scope.
570      */

571     protected List JavaDoc getQuerysJoinFrequency(Criteria criteria)
572         throws TorqueException
573     {
574         if (collQuerys == null)
575         {
576             if (isNew())
577             {
578                collQuerys = new ArrayList JavaDoc();
579             }
580             else
581             {
582                             criteria.add(QueryPeer.SCOPE_ID, getScopeId() );
583                             collQuerys = QueryPeer.doSelectJoinFrequency(criteria);
584             }
585         }
586         else
587         {
588             // the following code is to determine if a new query is
589
// called for. If the criteria is the same as the last
590
// one, just return the collection.
591

592                             criteria.add(QueryPeer.SCOPE_ID, getScopeId() );
593                         if (!lastQuerysCriteria.equals(criteria))
594             {
595                 collQuerys = QueryPeer.doSelectJoinFrequency(criteria);
596             }
597         }
598         lastQuerysCriteria = criteria;
599
600         return collQuerys;
601     }
602                             
603
604
605                           
606             
607     /**
608      * Collection to store aggregation of collIssueTemplateInfos
609      */

610     protected List JavaDoc collIssueTemplateInfos;
611
612     /**
613      * Temporary storage of collIssueTemplateInfos to save a possible db hit in
614      * the event objects are add to the collection, but the
615      * complete collection is never requested.
616      */

617     protected void initIssueTemplateInfos()
618     {
619         if (collIssueTemplateInfos == null)
620         {
621             collIssueTemplateInfos = new ArrayList JavaDoc();
622         }
623     }
624
625             
626     /**
627      * Method called to associate a IssueTemplateInfo object to this object
628      * through the IssueTemplateInfo foreign key attribute
629      *
630      * @param l IssueTemplateInfo
631      * @throws TorqueException
632      */

633     public void addIssueTemplateInfo(IssueTemplateInfo l) throws TorqueException
634     {
635         getIssueTemplateInfos().add(l);
636         l.setScope((Scope)this);
637     }
638
639     /**
640      * The criteria used to select the current contents of collIssueTemplateInfos
641      */

642     private Criteria lastIssueTemplateInfosCriteria = null;
643
644     /**
645      * If this collection has already been initialized, returns
646      * the collection. Otherwise returns the results of
647      * getIssueTemplateInfos(new Criteria())
648      *
649      * @throws TorqueException
650      */

651     public List JavaDoc getIssueTemplateInfos() throws TorqueException
652     {
653         if (collIssueTemplateInfos == null)
654         {
655             collIssueTemplateInfos = getIssueTemplateInfos(new Criteria(10));
656         }
657         return collIssueTemplateInfos;
658     }
659
660     /**
661      * If this collection has already been initialized with
662      * an identical criteria, it returns the collection.
663      * Otherwise if this Scope has previously
664      * been saved, it will retrieve related IssueTemplateInfos from storage.
665      * If this Scope is new, it will return
666      * an empty collection or the current collection, the criteria
667      * is ignored on a new object.
668      *
669      * @throws TorqueException
670      */

671     public List JavaDoc getIssueTemplateInfos(Criteria criteria) throws TorqueException
672     {
673         if (collIssueTemplateInfos == null)
674         {
675             if (isNew())
676             {
677                collIssueTemplateInfos = new ArrayList JavaDoc();
678             }
679             else
680             {
681                       criteria.add(IssueTemplateInfoPeer.SCOPE_ID, getScopeId() );
682                       collIssueTemplateInfos = IssueTemplateInfoPeer.doSelect(criteria);
683             }
684         }
685         else
686         {
687             // criteria has no effect for a new object
688
if (!isNew())
689             {
690                 // the following code is to determine if a new query is
691
// called for. If the criteria is the same as the last
692
// one, just return the collection.
693
criteria.add(IssueTemplateInfoPeer.SCOPE_ID, getScopeId() );
694                       if (!lastIssueTemplateInfosCriteria.equals(criteria))
695                 {
696                     collIssueTemplateInfos = IssueTemplateInfoPeer.doSelect(criteria);
697                 }
698             }
699         }
700         lastIssueTemplateInfosCriteria = criteria;
701
702         return collIssueTemplateInfos;
703     }
704
705     /**
706      * If this collection has already been initialized, returns
707      * the collection. Otherwise returns the results of
708      * getIssueTemplateInfos(new Criteria(),Connection)
709      * This method takes in the Connection also as input so that
710      * referenced objects can also be obtained using a Connection
711      * that is taken as input
712      */

713     public List JavaDoc getIssueTemplateInfos(Connection JavaDoc con) throws TorqueException
714     {
715         if (collIssueTemplateInfos == null)
716         {
717             collIssueTemplateInfos = getIssueTemplateInfos(new Criteria(10),con);
718         }
719         return collIssueTemplateInfos;
720     }
721
722     /**
723      * If this collection has already been initialized with
724      * an identical criteria, it returns the collection.
725      * Otherwise if this Scope has previously
726      * been saved, it will retrieve related IssueTemplateInfos from storage.
727      * If this Scope is new, it will return
728      * an empty collection or the current collection, the criteria
729      * is ignored on a new object.
730      * This method takes in the Connection also as input so that
731      * referenced objects can also be obtained using a Connection
732      * that is taken as input
733      */

734     public List JavaDoc getIssueTemplateInfos(Criteria criteria,Connection JavaDoc con) throws TorqueException
735     {
736         if (collIssueTemplateInfos == null)
737         {
738             if (isNew())
739             {
740                collIssueTemplateInfos = new ArrayList JavaDoc();
741             }
742             else
743             {
744                        criteria.add(IssueTemplateInfoPeer.SCOPE_ID, getScopeId() );
745                        collIssueTemplateInfos = IssueTemplateInfoPeer.doSelect(criteria,con);
746              }
747          }
748          else
749          {
750              // criteria has no effect for a new object
751
if (!isNew())
752              {
753                  // the following code is to determine if a new query is
754
// called for. If the criteria is the same as the last
755
// one, just return the collection.
756
criteria.add(IssueTemplateInfoPeer.SCOPE_ID, getScopeId() );
757                      if (!lastIssueTemplateInfosCriteria.equals(criteria))
758                  {
759                      collIssueTemplateInfos = IssueTemplateInfoPeer.doSelect(criteria,con);
760                  }
761              }
762          }
763          lastIssueTemplateInfosCriteria = criteria;
764
765          return collIssueTemplateInfos;
766      }
767
768                         
769               
770                     
771                     
772                                 
773                                                               
774                                         
775                     
776                     
777           
778     /**
779      * If this collection has already been initialized with
780      * an identical criteria, it returns the collection.
781      * Otherwise if this Scope is new, it will return
782      * an empty collection; or if this Scope has previously
783      * been saved, it will retrieve related IssueTemplateInfos from storage.
784      *
785      * This method is protected by default in order to keep the public
786      * api reasonable. You can provide public methods for those you
787      * actually need in Scope.
788      */

789     protected List JavaDoc getIssueTemplateInfosJoinIssue(Criteria criteria)
790         throws TorqueException
791     {
792         if (collIssueTemplateInfos == null)
793         {
794             if (isNew())
795             {
796                collIssueTemplateInfos = new ArrayList JavaDoc();
797             }
798             else
799             {
800                             criteria.add(IssueTemplateInfoPeer.SCOPE_ID, getScopeId() );
801                             collIssueTemplateInfos = IssueTemplateInfoPeer.doSelectJoinIssue(criteria);
802             }
803         }
804         else
805         {
806             // the following code is to determine if a new query is
807
// called for. If the criteria is the same as the last
808
// one, just return the collection.
809

810                             criteria.add(IssueTemplateInfoPeer.SCOPE_ID, getScopeId() );
811                         if (!lastIssueTemplateInfosCriteria.equals(criteria))
812             {
813                 collIssueTemplateInfos = IssueTemplateInfoPeer.doSelectJoinIssue(criteria);
814             }
815         }
816         lastIssueTemplateInfosCriteria = criteria;
817
818         return collIssueTemplateInfos;
819     }
820                   
821                     
822                               
823                                 
824                                                               
825                                         
826                     
827                     
828           
829     /**
830      * If this collection has already been initialized with
831      * an identical criteria, it returns the collection.
832      * Otherwise if this Scope is new, it will return
833      * an empty collection; or if this Scope has previously
834      * been saved, it will retrieve related IssueTemplateInfos from storage.
835      *
836      * This method is protected by default in order to keep the public
837      * api reasonable. You can provide public methods for those you
838      * actually need in Scope.
839      */

840     protected List JavaDoc getIssueTemplateInfosJoinScope(Criteria criteria)
841         throws TorqueException
842     {
843         if (collIssueTemplateInfos == null)
844         {
845             if (isNew())
846             {
847                collIssueTemplateInfos = new ArrayList JavaDoc();
848             }
849             else
850             {
851                             criteria.add(IssueTemplateInfoPeer.SCOPE_ID, getScopeId() );
852                             collIssueTemplateInfos = IssueTemplateInfoPeer.doSelectJoinScope(criteria);
853             }
854         }
855         else
856         {
857             // the following code is to determine if a new query is
858
// called for. If the criteria is the same as the last
859
// one, just return the collection.
860

861                             criteria.add(IssueTemplateInfoPeer.SCOPE_ID, getScopeId() );
862                         if (!lastIssueTemplateInfosCriteria.equals(criteria))
863             {
864                 collIssueTemplateInfos = IssueTemplateInfoPeer.doSelectJoinScope(criteria);
865             }
866         }
867         lastIssueTemplateInfosCriteria = criteria;
868
869         return collIssueTemplateInfos;
870     }
871                             
872
873
874                           
875             
876     /**
877      * Collection to store aggregation of collReports
878      */

879     protected List JavaDoc collReports;
880
881     /**
882      * Temporary storage of collReports to save a possible db hit in
883      * the event objects are add to the collection, but the
884      * complete collection is never requested.
885      */

886     protected void initReports()
887     {
888         if (collReports == null)
889         {
890             collReports = new ArrayList JavaDoc();
891         }
892     }
893
894             
895     /**
896      * Method called to associate a Report object to this object
897      * through the Report foreign key attribute
898      *
899      * @param l Report
900      * @throws TorqueException
901      */

902     public void addReport(Report l) throws TorqueException
903     {
904         getReports().add(l);
905         l.setScope((Scope)this);
906     }
907
908     /**
909      * The criteria used to select the current contents of collReports
910      */

911     private Criteria lastReportsCriteria = null;
912
913     /**
914      * If this collection has already been initialized, returns
915      * the collection. Otherwise returns the results of
916      * getReports(new Criteria())
917      *
918      * @throws TorqueException
919      */

920     public List JavaDoc getReports() throws TorqueException
921     {
922         if (collReports == null)
923         {
924             collReports = getReports(new Criteria(10));
925         }
926         return collReports;
927     }
928
929     /**
930      * If this collection has already been initialized with
931      * an identical criteria, it returns the collection.
932      * Otherwise if this Scope has previously
933      * been saved, it will retrieve related Reports from storage.
934      * If this Scope is new, it will return
935      * an empty collection or the current collection, the criteria
936      * is ignored on a new object.
937      *
938      * @throws TorqueException
939      */

940     public List JavaDoc getReports(Criteria criteria) throws TorqueException
941     {
942         if (collReports == null)
943         {
944             if (isNew())
945             {
946                collReports = new ArrayList JavaDoc();
947             }
948             else
949             {
950                       criteria.add(ReportPeer.SCOPE_ID, getScopeId() );
951                       collReports = ReportPeer.doSelect(criteria);
952             }
953         }
954         else
955         {
956             // criteria has no effect for a new object
957
if (!isNew())
958             {
959                 // the following code is to determine if a new query is
960
// called for. If the criteria is the same as the last
961
// one, just return the collection.
962
criteria.add(ReportPeer.SCOPE_ID, getScopeId() );
963                       if (!lastReportsCriteria.equals(criteria))
964                 {
965                     collReports = ReportPeer.doSelect(criteria);
966                 }
967             }
968         }
969         lastReportsCriteria = criteria;
970
971         return collReports;
972     }
973
974     /**
975      * If this collection has already been initialized, returns
976      * the collection. Otherwise returns the results of
977      * getReports(new Criteria(),Connection)
978      * This method takes in the Connection also as input so that
979      * referenced objects can also be obtained using a Connection
980      * that is taken as input
981      */

982     public List JavaDoc getReports(Connection JavaDoc con) throws TorqueException
983     {
984         if (collReports == null)
985         {
986             collReports = getReports(new Criteria(10),con);
987         }
988         return collReports;
989     }
990
991     /**
992      * If this collection has already been initialized with
993      * an identical criteria, it returns the collection.
994      * Otherwise if this Scope has previously
995      * been saved, it will retrieve related Reports from storage.
996      * If this Scope is new, it will return
997      * an empty collection or the current collection, the criteria
998      * is ignored on a new object.
999      * This method takes in the Connection also as input so that
1000     * referenced objects can also be obtained using a Connection
1001     * that is taken as input
1002     */

1003    public List JavaDoc getReports(Criteria criteria,Connection JavaDoc con) throws TorqueException
1004    {
1005        if (collReports == null)
1006        {
1007            if (isNew())
1008            {
1009               collReports = new ArrayList JavaDoc();
1010            }
1011            else
1012            {
1013                       criteria.add(ReportPeer.SCOPE_ID, getScopeId() );
1014                       collReports = ReportPeer.doSelect(criteria,con);
1015             }
1016         }
1017         else
1018         {
1019             // criteria has no effect for a new object
1020
if (!isNew())
1021             {
1022                 // the following code is to determine if a new query is
1023
// called for. If the criteria is the same as the last
1024
// one, just return the collection.
1025
criteria.add(ReportPeer.SCOPE_ID, getScopeId() );
1026                     if (!lastReportsCriteria.equals(criteria))
1027                 {
1028                     collReports = ReportPeer.doSelect(criteria,con);
1029                 }
1030             }
1031         }
1032         lastReportsCriteria = criteria;
1033
1034         return collReports;
1035     }
1036
1037                                    
1038              
1039                    
1040                    
1041                                
1042                                                              
1043                                        
1044                    
1045                    
1046          
1047    /**
1048     * If this collection has already been initialized with
1049     * an identical criteria, it returns the collection.
1050     * Otherwise if this Scope is new, it will return
1051     * an empty collection; or if this Scope has previously
1052     * been saved, it will retrieve related Reports from storage.
1053     *
1054     * This method is protected by default in order to keep the public
1055     * api reasonable. You can provide public methods for those you
1056     * actually need in Scope.
1057     */

1058    protected List JavaDoc getReportsJoinIssueType(Criteria criteria)
1059        throws TorqueException
1060    {
1061        if (collReports == null)
1062        {
1063            if (isNew())
1064            {
1065               collReports = new ArrayList JavaDoc();
1066            }
1067            else
1068            {
1069                            criteria.add(ReportPeer.SCOPE_ID, getScopeId() );
1070                            collReports = ReportPeer.doSelectJoinIssueType(criteria);
1071            }
1072        }
1073        else
1074        {
1075            // the following code is to determine if a new query is
1076
// called for. If the criteria is the same as the last
1077
// one, just return the collection.
1078

1079                            criteria.add(ReportPeer.SCOPE_ID, getScopeId() );
1080                        if (!lastReportsCriteria.equals(criteria))
1081            {
1082                collReports = ReportPeer.doSelectJoinIssueType(criteria);
1083            }
1084        }
1085        lastReportsCriteria = criteria;
1086
1087        return collReports;
1088    }
1089                  
1090                    
1091                    
1092                                
1093                                                              
1094                                        
1095                    
1096                    
1097          
1098    /**
1099     * If this collection has already been initialized with
1100     * an identical criteria, it returns the collection.
1101     * Otherwise if this Scope is new, it will return
1102     * an empty collection; or if this Scope has previously
1103     * been saved, it will retrieve related Reports from storage.
1104     *
1105     * This method is protected by default in order to keep the public
1106     * api reasonable. You can provide public methods for those you
1107     * actually need in Scope.
1108     */

1109    protected List JavaDoc getReportsJoinScarabUserImpl(Criteria criteria)
1110        throws TorqueException
1111    {
1112        if (collReports == null)
1113        {
1114            if (isNew())
1115            {
1116               collReports = new ArrayList JavaDoc();
1117            }
1118            else
1119            {
1120                            criteria.add(ReportPeer.SCOPE_ID, getScopeId() );
1121                            collReports = ReportPeer.doSelectJoinScarabUserImpl(criteria);
1122            }
1123        }
1124        else
1125        {
1126            // the following code is to determine if a new query is
1127
// called for. If the criteria is the same as the last
1128
// one, just return the collection.
1129

1130                            criteria.add(ReportPeer.SCOPE_ID, getScopeId() );
1131                        if (!lastReportsCriteria.equals(criteria))
1132            {
1133                collReports = ReportPeer.doSelectJoinScarabUserImpl(criteria);
1134            }
1135        }
1136        lastReportsCriteria = criteria;
1137
1138        return collReports;
1139    }
1140                  
1141                    
1142                    
1143                                
1144                                                              
1145                                        
1146                    
1147                    
1148          
1149    /**
1150     * If this collection has already been initialized with
1151     * an identical criteria, it returns the collection.
1152     * Otherwise if this Scope is new, it will return
1153     * an empty collection; or if this Scope has previously
1154     * been saved, it will retrieve related Reports from storage.
1155     *
1156     * This method is protected by default in order to keep the public
1157     * api reasonable. You can provide public methods for those you
1158     * actually need in Scope.
1159     */

1160    protected List JavaDoc getReportsJoinScarabModule(Criteria criteria)
1161        throws TorqueException
1162    {
1163        if (collReports == null)
1164        {
1165            if (isNew())
1166            {
1167               collReports = new ArrayList JavaDoc();
1168            }
1169            else
1170            {
1171                            criteria.add(ReportPeer.SCOPE_ID, getScopeId() );
1172                            collReports = ReportPeer.doSelectJoinScarabModule(criteria);
1173            }
1174        }
1175        else
1176        {
1177            // the following code is to determine if a new query is
1178
// called for. If the criteria is the same as the last
1179
// one, just return the collection.
1180

1181                            criteria.add(ReportPeer.SCOPE_ID, getScopeId() );
1182                        if (!lastReportsCriteria.equals(criteria))
1183            {
1184                collReports = ReportPeer.doSelectJoinScarabModule(criteria);
1185            }
1186        }
1187        lastReportsCriteria = criteria;
1188
1189        return collReports;
1190    }
1191                  
1192                    
1193                              
1194                                
1195                                                              
1196                                        
1197                    
1198                    
1199          
1200    /**
1201     * If this collection has already been initialized with
1202     * an identical criteria, it returns the collection.
1203     * Otherwise if this Scope is new, it will return
1204     * an empty collection; or if this Scope has previously
1205     * been saved, it will retrieve related Reports from storage.
1206     *
1207     * This method is protected by default in order to keep the public
1208     * api reasonable. You can provide public methods for those you
1209     * actually need in Scope.
1210     */

1211    protected List JavaDoc getReportsJoinScope(Criteria criteria)
1212        throws TorqueException
1213    {
1214        if (collReports == null)
1215        {
1216            if (isNew())
1217            {
1218               collReports = new ArrayList JavaDoc();
1219            }
1220            else
1221            {
1222                            criteria.add(ReportPeer.SCOPE_ID, getScopeId() );
1223                            collReports = ReportPeer.doSelectJoinScope(criteria);
1224            }
1225        }
1226        else
1227        {
1228            // the following code is to determine if a new query is
1229
// called for. If the criteria is the same as the last
1230
// one, just return the collection.
1231

1232                            criteria.add(ReportPeer.SCOPE_ID, getScopeId() );
1233                        if (!lastReportsCriteria.equals(criteria))
1234            {
1235                collReports = ReportPeer.doSelectJoinScope(criteria);
1236            }
1237        }
1238        lastReportsCriteria = criteria;
1239
1240        return collReports;
1241    }
1242                            
1243
1244
1245          
1246    private static List JavaDoc fieldNames = null;
1247
1248    /**
1249     * Generate a list of field names.
1250     *
1251     * @return a list of field names
1252     */

1253    public static synchronized List JavaDoc getFieldNames()
1254    {
1255        if (fieldNames == null)
1256        {
1257            fieldNames = new ArrayList JavaDoc();
1258              fieldNames.add("ScopeId");
1259              fieldNames.add("Name");
1260              fieldNames = Collections.unmodifiableList(fieldNames);
1261        }
1262        return fieldNames;
1263    }
1264
1265    /**
1266     * Retrieves a field from the object by name passed in as a String.
1267     *
1268     * @param name field name
1269     * @return value
1270     */

1271    public Object JavaDoc getByName(String JavaDoc name)
1272    {
1273          if (name.equals("ScopeId"))
1274        {
1275                return getScopeId();
1276            }
1277          if (name.equals("Name"))
1278        {
1279                return getName();
1280            }
1281          return null;
1282    }
1283    
1284    /**
1285     * Retrieves a field from the object by name passed in
1286     * as a String. The String must be one of the static
1287     * Strings defined in this Class' Peer.
1288     *
1289     * @param name peer name
1290     * @return value
1291     */

1292    public Object JavaDoc getByPeerName(String JavaDoc name)
1293    {
1294          if (name.equals(ScopePeer.SCOPE_ID))
1295        {
1296                return getScopeId();
1297            }
1298          if (name.equals(ScopePeer.SCOPE_NAME))
1299        {
1300                return getName();
1301            }
1302          return null;
1303    }
1304
1305    /**
1306     * Retrieves a field from the object by Position as specified
1307     * in the xml schema. Zero-based.
1308     *
1309     * @param pos position in xml schema
1310     * @return value
1311     */

1312    public Object JavaDoc getByPosition(int pos)
1313    {
1314            if (pos == 0)
1315        {
1316                return getScopeId();
1317            }
1318              if (pos == 1)
1319        {
1320                return getName();
1321            }
1322              return null;
1323    }
1324     
1325    /**
1326     * Stores the object in the database. If the object is new,
1327     * it inserts it; otherwise an update is performed.
1328     *
1329     * @throws Exception
1330     */

1331    public void save() throws Exception JavaDoc
1332    {
1333          save(ScopePeer.getMapBuilder()
1334                .getDatabaseMap().getName());
1335      }
1336
1337    /**
1338     * Stores the object in the database. If the object is new,
1339     * it inserts it; otherwise an update is performed.
1340       * Note: this code is here because the method body is
1341     * auto-generated conditionally and therefore needs to be
1342     * in this file instead of in the super class, BaseObject.
1343       *
1344     * @param dbName
1345     * @throws TorqueException
1346     */

1347    public void save(String JavaDoc dbName) throws TorqueException
1348    {
1349        Connection JavaDoc con = null;
1350          try
1351        {
1352            con = Transaction.begin(dbName);
1353            save(con);
1354            Transaction.commit(con);
1355        }
1356        catch(TorqueException e)
1357        {
1358            Transaction.safeRollback(con);
1359            throw e;
1360        }
1361      }
1362
1363      /** flag to prevent endless save loop, if this object is referenced
1364        by another object which falls in this transaction. */

1365    private boolean alreadyInSave = false;
1366      /**
1367     * Stores the object in the database. If the object is new,
1368     * it inserts it; otherwise an update is performed. This method
1369     * is meant to be used as part of a transaction, otherwise use
1370     * the save() method and the connection details will be handled
1371     * internally
1372     *
1373     * @param con
1374     * @throws TorqueException
1375     */

1376    public void save(Connection JavaDoc con) throws TorqueException
1377    {
1378          if (!alreadyInSave)
1379        {
1380            alreadyInSave = true;
1381
1382
1383  
1384            // If this object has been modified, then save it to the database.
1385
if (isModified())
1386            {
1387                if (isNew())
1388                {
1389                    ScopePeer.doInsert((Scope)this, con);
1390                    setNew(false);
1391                }
1392                else
1393                {
1394                    ScopePeer.doUpdate((Scope)this, con);
1395                }
1396
1397                      if (isCacheOnSave())
1398                {
1399                    ScopeManager.putInstance(this);
1400                }
1401              }
1402
1403                                      
1404                            if (collQuerys != null)
1405            {
1406                for (int i = 0; i < collQuerys.size(); i++)
1407                {
1408                    ((Query)collQuerys.get(i)).save(con);
1409                }
1410            }
1411                                          
1412                            if (collIssueTemplateInfos != null)
1413            {
1414                for (int i = 0; i < collIssueTemplateInfos.size(); i++)
1415                {
1416                    ((IssueTemplateInfo)collIssueTemplateInfos.get(i)).save(con);
1417                }
1418            }
1419                                          
1420                            if (collReports != null)
1421            {
1422                for (int i = 0; i < collReports.size(); i++)
1423                {
1424                    ((Report)collReports.get(i)).save(con);
1425                }
1426            }
1427                          alreadyInSave = false;
1428        }
1429      }
1430
1431    /**
1432     * Specify whether to cache the object after saving to the db.
1433     * This method returns false
1434     */

1435    protected boolean isCacheOnSave()
1436    {
1437        return true;
1438    }
1439
1440                        
1441      /**
1442     * Set the PrimaryKey using ObjectKey.
1443     *
1444     * @param scopeId ObjectKey
1445     */

1446    public void setPrimaryKey(ObjectKey scopeId)
1447        throws TorqueException {
1448            setScopeId(new Integer JavaDoc(((NumberKey)scopeId).intValue()));
1449        }
1450
1451    /**
1452     * Set the PrimaryKey using a String.
1453     *
1454     * @param key
1455     */

1456    public void setPrimaryKey(String JavaDoc key) throws TorqueException
1457    {
1458            setScopeId(new Integer JavaDoc(key));
1459        }
1460
1461  
1462    /**
1463     * returns an id that differentiates this object from others
1464     * of its class.
1465     */

1466    public ObjectKey getPrimaryKey()
1467    {
1468          return SimpleKey.keyFor(getScopeId());
1469      }
1470 
1471    /**
1472     * get an id that differentiates this object from others
1473     * of its class.
1474     */

1475    public String JavaDoc getQueryKey()
1476    {
1477        if (getPrimaryKey() == null)
1478        {
1479            return "";
1480        }
1481        else
1482        {
1483            return getPrimaryKey().toString();
1484        }
1485    }
1486
1487    /**
1488     * set an id that differentiates this object from others
1489     * of its class.
1490     */

1491    public void setQueryKey(String JavaDoc key)
1492        throws TorqueException
1493    {
1494        setPrimaryKey(key);
1495    }
1496
1497    /**
1498     * Makes a copy of this object.
1499     * It creates a new object filling in the simple attributes.
1500       * It then fills all the association collections and sets the
1501     * related objects to isNew=true.
1502       */

1503      public Scope copy() throws TorqueException
1504    {
1505        Scope copyObj = new Scope();
1506            copyObj.setScopeId(scopeId);
1507          copyObj.setName(name);
1508  
1509                      copyObj.setScopeId((Integer JavaDoc)null);
1510                  
1511                                      
1512                
1513        List JavaDoc v = getQuerys();
1514        for (int i = 0; i < v.size(); i++)
1515        {
1516            Query obj = (Query) v.get(i);
1517            copyObj.addQuery(obj.copy());
1518        }
1519                                                  
1520                
1521        v = getIssueTemplateInfos();
1522        for (int i = 0; i < v.size(); i++)
1523        {
1524            IssueTemplateInfo obj = (IssueTemplateInfo) v.get(i);
1525            copyObj.addIssueTemplateInfo(obj.copy());
1526        }
1527                                                  
1528                
1529        v = getReports();
1530        for (int i = 0; i < v.size(); i++)
1531        {
1532            Report obj = (Report) v.get(i);
1533            copyObj.addReport(obj.copy());
1534        }
1535                            return copyObj;
1536    }
1537
1538    /**
1539     * returns a peer instance associated with this om. Since Peer classes
1540     * are not to have any instance attributes, this method returns the
1541     * same instance for all member of this class. The method could therefore
1542     * be static, but this would prevent one from overriding the behavior.
1543     */

1544    public ScopePeer getPeer()
1545    {
1546        return peer;
1547    }
1548
1549    public String JavaDoc toString()
1550    {
1551        StringBuffer JavaDoc str = new StringBuffer JavaDoc();
1552        str.append("Scope:\n");
1553        str.append("ScopeId = ")
1554               .append(getScopeId())
1555             .append("\n");
1556        str.append("Name = ")
1557               .append(getName())
1558             .append("\n");
1559        return(str.toString());
1560    }
1561}
1562
Popular Tags