KickJava   Java API By Example, From Geeks To Geeks.

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


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     
28   
29 /**
30  * You should not use this class directly. It should not even be
31  * extended all references should be to ActivitySet
32  */

33 public abstract class BaseActivitySet extends BaseObject
34     implements org.apache.fulcrum.intake.Retrievable
35 {
36     /** The Peer class */
37     private static final ActivitySetPeer peer =
38         new ActivitySetPeer();
39
40         
41     /** The value for the activitySetId field */
42     private Long JavaDoc activitySetId;
43       
44     /** The value for the typeId field */
45     private Integer JavaDoc typeId;
46       
47     /** The value for the attachmentId field */
48     private Long JavaDoc attachmentId;
49       
50     /** The value for the createdBy field */
51     private Integer JavaDoc createdBy;
52       
53     /** The value for the createdDate field */
54     private Date JavaDoc createdDate;
55   
56     
57     /**
58      * Get the ActivitySetId
59      *
60      * @return Long
61      */

62     public Long JavaDoc getActivitySetId()
63     {
64         return activitySetId;
65     }
66
67                                               
68     /**
69      * Set the value of ActivitySetId
70      *
71      * @param v new value
72      */

73     public void setActivitySetId(Long JavaDoc v) throws TorqueException
74     {
75     
76                   if (!ObjectUtils.equals(this.activitySetId, v))
77               {
78             this.activitySetId = v;
79             setModified(true);
80         }
81     
82           
83                                   
84         // update associated Activity
85
if (collActivitys != null)
86         {
87             for (int i = 0; i < collActivitys.size(); i++)
88             {
89                 ((Activity) collActivitys.get(i))
90                         .setTransactionId(v);
91             }
92         }
93                                           
94         // update associated Issue
95
if (collIssues != null)
96         {
97             for (int i = 0; i < collIssues.size(); i++)
98             {
99                 ((Issue) collIssues.get(i))
100                         .setCreatedTransId(v);
101             }
102         }
103                       }
104   
105     /**
106      * Get the TypeId
107      *
108      * @return Integer
109      */

110     public Integer JavaDoc getTypeId()
111     {
112         return typeId;
113     }
114
115                               
116     /**
117      * Set the value of TypeId
118      *
119      * @param v new value
120      */

121     public void setTypeId(Integer JavaDoc v) throws TorqueException
122     {
123     
124                   if (!ObjectUtils.equals(this.typeId, v))
125               {
126             this.typeId = v;
127             setModified(true);
128         }
129     
130                                   
131                 if (aActivitySetType != null && !ObjectUtils.equals(aActivitySetType.getTypeId(), v))
132                 {
133             aActivitySetType = null;
134         }
135       
136               }
137   
138     /**
139      * Get the AttachmentId
140      *
141      * @return Long
142      */

143     public Long JavaDoc getAttachmentId()
144     {
145         return attachmentId;
146     }
147
148                               
149     /**
150      * Set the value of AttachmentId
151      *
152      * @param v new value
153      */

154     public void setAttachmentId(Long JavaDoc v) throws TorqueException
155     {
156     
157                   if (!ObjectUtils.equals(this.attachmentId, v))
158               {
159             this.attachmentId = v;
160             setModified(true);
161         }
162     
163                                   
164                 if (aAttachment != null && !ObjectUtils.equals(aAttachment.getAttachmentId(), v))
165                 {
166             aAttachment = null;
167         }
168       
169               }
170   
171     /**
172      * Get the CreatedBy
173      *
174      * @return Integer
175      */

176     public Integer JavaDoc getCreatedBy()
177     {
178         return createdBy;
179     }
180
181                               
182     /**
183      * Set the value of CreatedBy
184      *
185      * @param v new value
186      */

187     public void setCreatedBy(Integer JavaDoc v) throws TorqueException
188     {
189     
190                   if (!ObjectUtils.equals(this.createdBy, v))
191               {
192             this.createdBy = v;
193             setModified(true);
194         }
195     
196                                           
197                 if (aScarabUser != null && !ObjectUtils.equals(aScarabUser.getUserId(), v))
198                 {
199             aScarabUser = null;
200         }
201       
202               }
203   
204     /**
205      * Get the CreatedDate
206      *
207      * @return Date
208      */

209     public Date JavaDoc getCreatedDate()
210     {
211         return createdDate;
212     }
213
214                         
215     /**
216      * Set the value of CreatedDate
217      *
218      * @param v new value
219      */

220     public void setCreatedDate(Date JavaDoc v)
221     {
222     
223                   if (!ObjectUtils.equals(this.createdDate, v))
224               {
225             this.createdDate = v;
226             setModified(true);
227         }
228     
229           
230               }
231   
232       
233             
234                   
235         private ScarabUser aScarabUser;
236
237     /**
238      * Declares an association between this object and a ScarabUser object
239      *
240      * @param v ScarabUser
241      * @throws TorqueException
242      */

243     public void setScarabUser(ScarabUser v) throws TorqueException
244     {
245             if (v == null)
246         {
247                   setCreatedBy((Integer JavaDoc) null);
248               }
249         else
250         {
251             setCreatedBy(v.getUserId());
252         }
253             aScarabUser = v;
254     }
255
256                         
257     /**
258      * Get the associated ScarabUser object
259      *
260      * @return the associated ScarabUser object
261      * @throws TorqueException
262      */

263     public ScarabUser getScarabUser() throws TorqueException
264     {
265         if ( !ObjectUtils.equals(getCreatedBy(), null) )
266         {
267                 return ScarabUserManager.getInstance(SimpleKey.keyFor(getCreatedBy()));
268             }
269         return aScarabUser;
270     }
271
272     /**
273      * Provides convenient way to set a relationship based on a
274      * ObjectKey, for example
275      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
276      *
277          */

278     public void setScarabUserKey(ObjectKey key) throws TorqueException
279     {
280     
281                     setCreatedBy(new Integer JavaDoc(((NumberKey) key).intValue()));
282               }
283   
284         
285                   
286         private ActivitySetType aActivitySetType;
287
288     /**
289      * Declares an association between this object and a ActivitySetType object
290      *
291      * @param v ActivitySetType
292      * @throws TorqueException
293      */

294     public void setActivitySetType(ActivitySetType v) throws TorqueException
295     {
296             if (v == null)
297         {
298                   setTypeId((Integer JavaDoc) null);
299               }
300         else
301         {
302             setTypeId(v.getTypeId());
303         }
304             aActivitySetType = v;
305     }
306
307                         
308     /**
309      * Get the associated ActivitySetType object
310      *
311      * @return the associated ActivitySetType object
312      * @throws TorqueException
313      */

314     public ActivitySetType getActivitySetType() throws TorqueException
315     {
316         if ( !ObjectUtils.equals(getTypeId(), null) )
317         {
318                 return ActivitySetTypeManager.getInstance(SimpleKey.keyFor(getTypeId()));
319             }
320         return aActivitySetType;
321     }
322
323     /**
324      * Provides convenient way to set a relationship based on a
325      * ObjectKey, for example
326      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
327      *
328          */

329     public void setActivitySetTypeKey(ObjectKey key) throws TorqueException
330     {
331     
332                     setTypeId(new Integer JavaDoc(((NumberKey) key).intValue()));
333               }
334   
335         
336                   
337         private Attachment aAttachment;
338
339     /**
340      * Declares an association between this object and a Attachment object
341      *
342      * @param v Attachment
343      * @throws TorqueException
344      */

345     public void setAttachment(Attachment v) throws TorqueException
346     {
347             if (v == null)
348         {
349                   setAttachmentId((Long JavaDoc) null);
350               }
351         else
352         {
353             setAttachmentId(v.getAttachmentId());
354         }
355             aAttachment = v;
356     }
357
358                         
359     /**
360      * Get the associated Attachment object
361      *
362      * @return the associated Attachment object
363      * @throws TorqueException
364      */

365     public Attachment getAttachment() throws TorqueException
366     {
367         if ( !ObjectUtils.equals(getAttachmentId(), null) )
368         {
369                 return AttachmentManager.getInstance(SimpleKey.keyFor(getAttachmentId()));
370             }
371         return aAttachment;
372     }
373
374     /**
375      * Provides convenient way to set a relationship based on a
376      * ObjectKey, for example
377      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
378      *
379          */

380     public void setAttachmentKey(ObjectKey key) throws TorqueException
381     {
382     
383                     setAttachmentId(new Long JavaDoc(((NumberKey) key).longValue()));
384               }
385      
386                                 
387             
388     /**
389      * Collection to store aggregation of collActivitys
390      */

391     protected List JavaDoc collActivitys;
392
393     /**
394      * Temporary storage of collActivitys to save a possible db hit in
395      * the event objects are add to the collection, but the
396      * complete collection is never requested.
397      */

398     protected void initActivitys()
399     {
400         if (collActivitys == null)
401         {
402             collActivitys = new ArrayList JavaDoc();
403         }
404     }
405
406             
407     /**
408      * Method called to associate a Activity object to this object
409      * through the Activity foreign key attribute
410      *
411      * @param l Activity
412      * @throws TorqueException
413      */

414     public void addActivity(Activity l) throws TorqueException
415     {
416         getActivitys().add(l);
417         l.setActivitySet((ActivitySet)this);
418     }
419
420     /**
421      * The criteria used to select the current contents of collActivitys
422      */

423     private Criteria lastActivitysCriteria = null;
424
425     /**
426      * If this collection has already been initialized, returns
427      * the collection. Otherwise returns the results of
428      * getActivitys(new Criteria())
429      *
430      * @throws TorqueException
431      */

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

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

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

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

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

591                             criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() );
592                         if (!lastActivitysCriteria.equals(criteria))
593             {
594                 collActivitys = ActivityPeer.doSelectJoinIssue(criteria);
595             }
596         }
597         lastActivitysCriteria = criteria;
598
599         return collActivitys;
600     }
601                   
602                     
603                     
604                                 
605                                                               
606                                         
607                     
608                     
609           
610     /**
611      * If this collection has already been initialized with
612      * an identical criteria, it returns the collection.
613      * Otherwise if this ActivitySet is new, it will return
614      * an empty collection; or if this ActivitySet has previously
615      * been saved, it will retrieve related Activitys from storage.
616      *
617      * This method is protected by default in order to keep the public
618      * api reasonable. You can provide public methods for those you
619      * actually need in ActivitySet.
620      */

621     protected List JavaDoc getActivitysJoinAttribute(Criteria criteria)
622         throws TorqueException
623     {
624         if (collActivitys == null)
625         {
626             if (isNew())
627             {
628                collActivitys = new ArrayList JavaDoc();
629             }
630             else
631             {
632                             criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() );
633                             collActivitys = ActivityPeer.doSelectJoinAttribute(criteria);
634             }
635         }
636         else
637         {
638             // the following code is to determine if a new query is
639
// called for. If the criteria is the same as the last
640
// one, just return the collection.
641

642                             criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() );
643                         if (!lastActivitysCriteria.equals(criteria))
644             {
645                 collActivitys = ActivityPeer.doSelectJoinAttribute(criteria);
646             }
647         }
648         lastActivitysCriteria = criteria;
649
650         return collActivitys;
651     }
652                   
653                     
654                               
655                                 
656                                                               
657                                         
658                     
659                     
660           
661     /**
662      * If this collection has already been initialized with
663      * an identical criteria, it returns the collection.
664      * Otherwise if this ActivitySet is new, it will return
665      * an empty collection; or if this ActivitySet has previously
666      * been saved, it will retrieve related Activitys from storage.
667      *
668      * This method is protected by default in order to keep the public
669      * api reasonable. You can provide public methods for those you
670      * actually need in ActivitySet.
671      */

672     protected List JavaDoc getActivitysJoinActivitySet(Criteria criteria)
673         throws TorqueException
674     {
675         if (collActivitys == null)
676         {
677             if (isNew())
678             {
679                collActivitys = new ArrayList JavaDoc();
680             }
681             else
682             {
683                             criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() );
684                             collActivitys = ActivityPeer.doSelectJoinActivitySet(criteria);
685             }
686         }
687         else
688         {
689             // the following code is to determine if a new query is
690
// called for. If the criteria is the same as the last
691
// one, just return the collection.
692

693                             criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() );
694                         if (!lastActivitysCriteria.equals(criteria))
695             {
696                 collActivitys = ActivityPeer.doSelectJoinActivitySet(criteria);
697             }
698         }
699         lastActivitysCriteria = criteria;
700
701         return collActivitys;
702     }
703                   
704                     
705                     
706                                             
707                                                                           
708                                         
709                     
710                     
711           
712     /**
713      * If this collection has already been initialized with
714      * an identical criteria, it returns the collection.
715      * Otherwise if this ActivitySet is new, it will return
716      * an empty collection; or if this ActivitySet has previously
717      * been saved, it will retrieve related Activitys from storage.
718      *
719      * This method is protected by default in order to keep the public
720      * api reasonable. You can provide public methods for those you
721      * actually need in ActivitySet.
722      */

723     protected List JavaDoc getActivitysJoinScarabUserImplRelatedByOldUserId(Criteria criteria)
724         throws TorqueException
725     {
726         if (collActivitys == null)
727         {
728             if (isNew())
729             {
730                collActivitys = new ArrayList JavaDoc();
731             }
732             else
733             {
734                             criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() );
735                             collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByOldUserId(criteria);
736             }
737         }
738         else
739         {
740             // the following code is to determine if a new query is
741
// called for. If the criteria is the same as the last
742
// one, just return the collection.
743

744                             criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() );
745                         if (!lastActivitysCriteria.equals(criteria))
746             {
747                 collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByOldUserId(criteria);
748             }
749         }
750         lastActivitysCriteria = criteria;
751
752         return collActivitys;
753     }
754                   
755                     
756                     
757                                             
758                                                                           
759                                         
760                     
761                     
762           
763     /**
764      * If this collection has already been initialized with
765      * an identical criteria, it returns the collection.
766      * Otherwise if this ActivitySet is new, it will return
767      * an empty collection; or if this ActivitySet has previously
768      * been saved, it will retrieve related Activitys from storage.
769      *
770      * This method is protected by default in order to keep the public
771      * api reasonable. You can provide public methods for those you
772      * actually need in ActivitySet.
773      */

774     protected List JavaDoc getActivitysJoinScarabUserImplRelatedByNewUserId(Criteria criteria)
775         throws TorqueException
776     {
777         if (collActivitys == null)
778         {
779             if (isNew())
780             {
781                collActivitys = new ArrayList JavaDoc();
782             }
783             else
784             {
785                             criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() );
786                             collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByNewUserId(criteria);
787             }
788         }
789         else
790         {
791             // the following code is to determine if a new query is
792
// called for. If the criteria is the same as the last
793
// one, just return the collection.
794

795                             criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() );
796                         if (!lastActivitysCriteria.equals(criteria))
797             {
798                 collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByNewUserId(criteria);
799             }
800         }
801         lastActivitysCriteria = criteria;
802
803         return collActivitys;
804     }
805                   
806                     
807                     
808                                             
809                                                                           
810                                         
811                     
812                     
813           
814     /**
815      * If this collection has already been initialized with
816      * an identical criteria, it returns the collection.
817      * Otherwise if this ActivitySet is new, it will return
818      * an empty collection; or if this ActivitySet has previously
819      * been saved, it will retrieve related Activitys from storage.
820      *
821      * This method is protected by default in order to keep the public
822      * api reasonable. You can provide public methods for those you
823      * actually need in ActivitySet.
824      */

825     protected List JavaDoc getActivitysJoinAttributeOptionRelatedByOldOptionId(Criteria criteria)
826         throws TorqueException
827     {
828         if (collActivitys == null)
829         {
830             if (isNew())
831             {
832                collActivitys = new ArrayList JavaDoc();
833             }
834             else
835             {
836                             criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() );
837                             collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByOldOptionId(criteria);
838             }
839         }
840         else
841         {
842             // the following code is to determine if a new query is
843
// called for. If the criteria is the same as the last
844
// one, just return the collection.
845

846                             criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() );
847                         if (!lastActivitysCriteria.equals(criteria))
848             {
849                 collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByOldOptionId(criteria);
850             }
851         }
852         lastActivitysCriteria = criteria;
853
854         return collActivitys;
855     }
856                   
857                     
858                     
859                                             
860                                                                           
861                                         
862                     
863                     
864           
865     /**
866      * If this collection has already been initialized with
867      * an identical criteria, it returns the collection.
868      * Otherwise if this ActivitySet is new, it will return
869      * an empty collection; or if this ActivitySet has previously
870      * been saved, it will retrieve related Activitys from storage.
871      *
872      * This method is protected by default in order to keep the public
873      * api reasonable. You can provide public methods for those you
874      * actually need in ActivitySet.
875      */

876     protected List JavaDoc getActivitysJoinAttributeOptionRelatedByNewOptionId(Criteria criteria)
877         throws TorqueException
878     {
879         if (collActivitys == null)
880         {
881             if (isNew())
882             {
883                collActivitys = new ArrayList JavaDoc();
884             }
885             else
886             {
887                             criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() );
888                             collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByNewOptionId(criteria);
889             }
890         }
891         else
892         {
893             // the following code is to determine if a new query is
894
// called for. If the criteria is the same as the last
895
// one, just return the collection.
896

897                             criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() );
898                         if (!lastActivitysCriteria.equals(criteria))
899             {
900                 collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByNewOptionId(criteria);
901             }
902         }
903         lastActivitysCriteria = criteria;
904
905         return collActivitys;
906     }
907                   
908                     
909                     
910                                 
911                                                               
912                                         
913                     
914                     
915           
916     /**
917      * If this collection has already been initialized with
918      * an identical criteria, it returns the collection.
919      * Otherwise if this ActivitySet is new, it will return
920      * an empty collection; or if this ActivitySet has previously
921      * been saved, it will retrieve related Activitys from storage.
922      *
923      * This method is protected by default in order to keep the public
924      * api reasonable. You can provide public methods for those you
925      * actually need in ActivitySet.
926      */

927     protected List JavaDoc getActivitysJoinAttachment(Criteria criteria)
928         throws TorqueException
929     {
930         if (collActivitys == null)
931         {
932             if (isNew())
933             {
934                collActivitys = new ArrayList JavaDoc();
935             }
936             else
937             {
938                             criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() );
939                             collActivitys = ActivityPeer.doSelectJoinAttachment(criteria);
940             }
941         }
942         else
943         {
944             // the following code is to determine if a new query is
945
// called for. If the criteria is the same as the last
946
// one, just return the collection.
947

948                             criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() );
949                         if (!lastActivitysCriteria.equals(criteria))
950             {
951                 collActivitys = ActivityPeer.doSelectJoinAttachment(criteria);
952             }
953         }
954         lastActivitysCriteria = criteria;
955
956         return collActivitys;
957     }
958                   
959                     
960                     
961                                 
962                                                               
963                                         
964                     
965                     
966           
967     /**
968      * If this collection has already been initialized with
969      * an identical criteria, it returns the collection.
970      * Otherwise if this ActivitySet is new, it will return
971      * an empty collection; or if this ActivitySet has previously
972      * been saved, it will retrieve related Activitys from storage.
973      *
974      * This method is protected by default in order to keep the public
975      * api reasonable. You can provide public methods for those you
976      * actually need in ActivitySet.
977      */

978     protected List JavaDoc getActivitysJoinDepend(Criteria criteria)
979         throws TorqueException
980     {
981         if (collActivitys == null)
982         {
983             if (isNew())
984             {
985                collActivitys = new ArrayList JavaDoc();
986             }
987             else
988             {
989                             criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() );
990                             collActivitys = ActivityPeer.doSelectJoinDepend(criteria);
991             }
992         }
993         else
994         {
995             // the following code is to determine if a new query is
996
// called for. If the criteria is the same as the last
997
// one, just return the collection.
998

999                             criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() );
1000                        if (!lastActivitysCriteria.equals(criteria))
1001            {
1002                collActivitys = ActivityPeer.doSelectJoinDepend(criteria);
1003            }
1004        }
1005        lastActivitysCriteria = criteria;
1006
1007        return collActivitys;
1008    }
1009                            
1010
1011
1012                          
1013            
1014    /**
1015     * Collection to store aggregation of collIssues
1016     */

1017    protected List JavaDoc collIssues;
1018
1019    /**
1020     * Temporary storage of collIssues to save a possible db hit in
1021     * the event objects are add to the collection, but the
1022     * complete collection is never requested.
1023     */

1024    protected void initIssues()
1025    {
1026        if (collIssues == null)
1027        {
1028            collIssues = new ArrayList JavaDoc();
1029        }
1030    }
1031
1032            
1033    /**
1034     * Method called to associate a Issue object to this object
1035     * through the Issue foreign key attribute
1036     *
1037     * @param l Issue
1038     * @throws TorqueException
1039     */

1040    public void addIssue(Issue l) throws TorqueException
1041    {
1042        getIssues().add(l);
1043        l.setActivitySet((ActivitySet)this);
1044    }
1045
1046    /**
1047     * The criteria used to select the current contents of collIssues
1048     */

1049    private Criteria lastIssuesCriteria = null;
1050
1051    /**
1052     * If this collection has already been initialized, returns
1053     * the collection. Otherwise returns the results of
1054     * getIssues(new Criteria())
1055     *
1056     * @throws TorqueException
1057     */

1058    public List JavaDoc getIssues() throws TorqueException
1059    {
1060        if (collIssues == null)
1061        {
1062            collIssues = getIssues(new Criteria(10));
1063        }
1064        return collIssues;
1065    }
1066
1067    /**
1068     * If this collection has already been initialized with
1069     * an identical criteria, it returns the collection.
1070     * Otherwise if this ActivitySet has previously
1071     * been saved, it will retrieve related Issues from storage.
1072     * If this ActivitySet is new, it will return
1073     * an empty collection or the current collection, the criteria
1074     * is ignored on a new object.
1075     *
1076     * @throws TorqueException
1077     */

1078    public List JavaDoc getIssues(Criteria criteria) throws TorqueException
1079    {
1080        if (collIssues == null)
1081        {
1082            if (isNew())
1083            {
1084               collIssues = new ArrayList JavaDoc();
1085            }
1086            else
1087            {
1088                      criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() );
1089                      collIssues = IssuePeer.doSelect(criteria);
1090            }
1091        }
1092        else
1093        {
1094            // criteria has no effect for a new object
1095
if (!isNew())
1096            {
1097                // the following code is to determine if a new query is
1098
// called for. If the criteria is the same as the last
1099
// one, just return the collection.
1100
criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() );
1101                      if (!lastIssuesCriteria.equals(criteria))
1102                {
1103                    collIssues = IssuePeer.doSelect(criteria);
1104                }
1105            }
1106        }
1107        lastIssuesCriteria = criteria;
1108
1109        return collIssues;
1110    }
1111
1112    /**
1113     * If this collection has already been initialized, returns
1114     * the collection. Otherwise returns the results of
1115     * getIssues(new Criteria(),Connection)
1116     * This method takes in the Connection also as input so that
1117     * referenced objects can also be obtained using a Connection
1118     * that is taken as input
1119     */

1120    public List JavaDoc getIssues(Connection JavaDoc con) throws TorqueException
1121    {
1122        if (collIssues == null)
1123        {
1124            collIssues = getIssues(new Criteria(10),con);
1125        }
1126        return collIssues;
1127    }
1128
1129    /**
1130     * If this collection has already been initialized with
1131     * an identical criteria, it returns the collection.
1132     * Otherwise if this ActivitySet has previously
1133     * been saved, it will retrieve related Issues from storage.
1134     * If this ActivitySet is new, it will return
1135     * an empty collection or the current collection, the criteria
1136     * is ignored on a new object.
1137     * This method takes in the Connection also as input so that
1138     * referenced objects can also be obtained using a Connection
1139     * that is taken as input
1140     */

1141    public List JavaDoc getIssues(Criteria criteria,Connection JavaDoc con) throws TorqueException
1142    {
1143        if (collIssues == null)
1144        {
1145            if (isNew())
1146            {
1147               collIssues = new ArrayList JavaDoc();
1148            }
1149            else
1150            {
1151                       criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() );
1152                       collIssues = IssuePeer.doSelect(criteria,con);
1153             }
1154         }
1155         else
1156         {
1157             // criteria has no effect for a new object
1158
if (!isNew())
1159             {
1160                 // the following code is to determine if a new query is
1161
// called for. If the criteria is the same as the last
1162
// one, just return the collection.
1163
criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() );
1164                     if (!lastIssuesCriteria.equals(criteria))
1165                 {
1166                     collIssues = IssuePeer.doSelect(criteria,con);
1167                 }
1168             }
1169         }
1170         lastIssuesCriteria = criteria;
1171
1172         return collIssues;
1173     }
1174
1175                              
1176              
1177                    
1178                    
1179                                
1180                                                              
1181                                        
1182                    
1183                    
1184          
1185    /**
1186     * If this collection has already been initialized with
1187     * an identical criteria, it returns the collection.
1188     * Otherwise if this ActivitySet is new, it will return
1189     * an empty collection; or if this ActivitySet has previously
1190     * been saved, it will retrieve related Issues from storage.
1191     *
1192     * This method is protected by default in order to keep the public
1193     * api reasonable. You can provide public methods for those you
1194     * actually need in ActivitySet.
1195     */

1196    protected List JavaDoc getIssuesJoinScarabModule(Criteria criteria)
1197        throws TorqueException
1198    {
1199        if (collIssues == null)
1200        {
1201            if (isNew())
1202            {
1203               collIssues = new ArrayList JavaDoc();
1204            }
1205            else
1206            {
1207                            criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() );
1208                            collIssues = IssuePeer.doSelectJoinScarabModule(criteria);
1209            }
1210        }
1211        else
1212        {
1213            // the following code is to determine if a new query is
1214
// called for. If the criteria is the same as the last
1215
// one, just return the collection.
1216

1217                            criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() );
1218                        if (!lastIssuesCriteria.equals(criteria))
1219            {
1220                collIssues = IssuePeer.doSelectJoinScarabModule(criteria);
1221            }
1222        }
1223        lastIssuesCriteria = criteria;
1224
1225        return collIssues;
1226    }
1227                  
1228                    
1229                    
1230                                
1231                                                              
1232                                        
1233                    
1234                    
1235          
1236    /**
1237     * If this collection has already been initialized with
1238     * an identical criteria, it returns the collection.
1239     * Otherwise if this ActivitySet is new, it will return
1240     * an empty collection; or if this ActivitySet has previously
1241     * been saved, it will retrieve related Issues from storage.
1242     *
1243     * This method is protected by default in order to keep the public
1244     * api reasonable. You can provide public methods for those you
1245     * actually need in ActivitySet.
1246     */

1247    protected List JavaDoc getIssuesJoinIssueType(Criteria criteria)
1248        throws TorqueException
1249    {
1250        if (collIssues == null)
1251        {
1252            if (isNew())
1253            {
1254               collIssues = new ArrayList JavaDoc();
1255            }
1256            else
1257            {
1258                            criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() );
1259                            collIssues = IssuePeer.doSelectJoinIssueType(criteria);
1260            }
1261        }
1262        else
1263        {
1264            // the following code is to determine if a new query is
1265
// called for. If the criteria is the same as the last
1266
// one, just return the collection.
1267

1268                            criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() );
1269                        if (!lastIssuesCriteria.equals(criteria))
1270            {
1271                collIssues = IssuePeer.doSelectJoinIssueType(criteria);
1272            }
1273        }
1274        lastIssuesCriteria = criteria;
1275
1276        return collIssues;
1277    }
1278                  
1279                    
1280                              
1281                                
1282                                                              
1283                                        
1284                    
1285                    
1286          
1287    /**
1288     * If this collection has already been initialized with
1289     * an identical criteria, it returns the collection.
1290     * Otherwise if this ActivitySet is new, it will return
1291     * an empty collection; or if this ActivitySet has previously
1292     * been saved, it will retrieve related Issues from storage.
1293     *
1294     * This method is protected by default in order to keep the public
1295     * api reasonable. You can provide public methods for those you
1296     * actually need in ActivitySet.
1297     */

1298    protected List JavaDoc getIssuesJoinActivitySet(Criteria criteria)
1299        throws TorqueException
1300    {
1301        if (collIssues == null)
1302        {
1303            if (isNew())
1304            {
1305               collIssues = new ArrayList JavaDoc();
1306            }
1307            else
1308            {
1309                            criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() );
1310                            collIssues = IssuePeer.doSelectJoinActivitySet(criteria);
1311            }
1312        }
1313        else
1314        {
1315            // the following code is to determine if a new query is
1316
// called for. If the criteria is the same as the last
1317
// one, just return the collection.
1318

1319                            criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() );
1320                        if (!lastIssuesCriteria.equals(criteria))
1321            {
1322                collIssues = IssuePeer.doSelectJoinActivitySet(criteria);
1323            }
1324        }
1325        lastIssuesCriteria = criteria;
1326
1327        return collIssues;
1328    }
1329                            
1330
1331
1332          
1333    private static List JavaDoc fieldNames = null;
1334
1335    /**
1336     * Generate a list of field names.
1337     *
1338     * @return a list of field names
1339     */

1340    public static synchronized List JavaDoc getFieldNames()
1341    {
1342        if (fieldNames == null)
1343        {
1344            fieldNames = new ArrayList JavaDoc();
1345              fieldNames.add("ActivitySetId");
1346              fieldNames.add("TypeId");
1347              fieldNames.add("AttachmentId");
1348              fieldNames.add("CreatedBy");
1349              fieldNames.add("CreatedDate");
1350              fieldNames = Collections.unmodifiableList(fieldNames);
1351        }
1352        return fieldNames;
1353    }
1354
1355    /**
1356     * Retrieves a field from the object by name passed in as a String.
1357     *
1358     * @param name field name
1359     * @return value
1360     */

1361    public Object JavaDoc getByName(String JavaDoc name)
1362    {
1363          if (name.equals("ActivitySetId"))
1364        {
1365                return getActivitySetId();
1366            }
1367          if (name.equals("TypeId"))
1368        {
1369                return getTypeId();
1370            }
1371          if (name.equals("AttachmentId"))
1372        {
1373                return getAttachmentId();
1374            }
1375          if (name.equals("CreatedBy"))
1376        {
1377                return getCreatedBy();
1378            }
1379          if (name.equals("CreatedDate"))
1380        {
1381                return getCreatedDate();
1382            }
1383          return null;
1384    }
1385    
1386    /**
1387     * Retrieves a field from the object by name passed in
1388     * as a String. The String must be one of the static
1389     * Strings defined in this Class' Peer.
1390     *
1391     * @param name peer name
1392     * @return value
1393     */

1394    public Object JavaDoc getByPeerName(String JavaDoc name)
1395    {
1396          if (name.equals(ActivitySetPeer.TRANSACTION_ID))
1397        {
1398                return getActivitySetId();
1399            }
1400          if (name.equals(ActivitySetPeer.TYPE_ID))
1401        {
1402                return getTypeId();
1403            }
1404          if (name.equals(ActivitySetPeer.ATTACHMENT_ID))
1405        {
1406                return getAttachmentId();
1407            }
1408          if (name.equals(ActivitySetPeer.CREATED_BY))
1409        {
1410                return getCreatedBy();
1411            }
1412          if (name.equals(ActivitySetPeer.CREATED_DATE))
1413        {
1414                return getCreatedDate();
1415            }
1416          return null;
1417    }
1418
1419    /**
1420     * Retrieves a field from the object by Position as specified
1421     * in the xml schema. Zero-based.
1422     *
1423     * @param pos position in xml schema
1424     * @return value
1425     */

1426    public Object JavaDoc getByPosition(int pos)
1427    {
1428            if (pos == 0)
1429        {
1430                return getActivitySetId();
1431            }
1432              if (pos == 1)
1433        {
1434                return getTypeId();
1435            }
1436              if (pos == 2)
1437        {
1438                return getAttachmentId();
1439            }
1440              if (pos == 3)
1441        {
1442                return getCreatedBy();
1443            }
1444              if (pos == 4)
1445        {
1446                return getCreatedDate();
1447            }
1448              return null;
1449    }
1450     
1451    /**
1452     * Stores the object in the database. If the object is new,
1453     * it inserts it; otherwise an update is performed.
1454     *
1455     * @throws Exception
1456     */

1457    public void save() throws Exception JavaDoc
1458    {
1459          save(ActivitySetPeer.getMapBuilder()
1460                .getDatabaseMap().getName());
1461      }
1462
1463    /**
1464     * Stores the object in the database. If the object is new,
1465     * it inserts it; otherwise an update is performed.
1466       * Note: this code is here because the method body is
1467     * auto-generated conditionally and therefore needs to be
1468     * in this file instead of in the super class, BaseObject.
1469       *
1470     * @param dbName
1471     * @throws TorqueException
1472     */

1473    public void save(String JavaDoc dbName) throws TorqueException
1474    {
1475        Connection JavaDoc con = null;
1476          try
1477        {
1478            con = Transaction.begin(dbName);
1479            save(con);
1480            Transaction.commit(con);
1481        }
1482        catch(TorqueException e)
1483        {
1484            Transaction.safeRollback(con);
1485            throw e;
1486        }
1487      }
1488
1489      /** flag to prevent endless save loop, if this object is referenced
1490        by another object which falls in this transaction. */

1491    private boolean alreadyInSave = false;
1492      /**
1493     * Stores the object in the database. If the object is new,
1494     * it inserts it; otherwise an update is performed. This method
1495     * is meant to be used as part of a transaction, otherwise use
1496     * the save() method and the connection details will be handled
1497     * internally
1498     *
1499     * @param con
1500     * @throws TorqueException
1501     */

1502    public void save(Connection JavaDoc con) throws TorqueException
1503    {
1504          if (!alreadyInSave)
1505        {
1506            alreadyInSave = true;
1507
1508
1509  
1510            // If this object has been modified, then save it to the database.
1511
if (isModified())
1512            {
1513                if (isNew())
1514                {
1515                    ActivitySetPeer.doInsert((ActivitySet)this, con);
1516                    setNew(false);
1517                }
1518                else
1519                {
1520                    ActivitySetPeer.doUpdate((ActivitySet)this, con);
1521                }
1522
1523                      if (isCacheOnSave())
1524                {
1525                    ActivitySetManager.putInstance(this);
1526                }
1527              }
1528
1529                                      
1530                            if (collActivitys != null)
1531            {
1532                for (int i = 0; i < collActivitys.size(); i++)
1533                {
1534                    ((Activity)collActivitys.get(i)).save(con);
1535                }
1536            }
1537                                          
1538                            if (collIssues != null)
1539            {
1540                for (int i = 0; i < collIssues.size(); i++)
1541                {
1542                    ((Issue)collIssues.get(i)).save(con);
1543                }
1544            }
1545                          alreadyInSave = false;
1546        }
1547      }
1548
1549    /**
1550     * Specify whether to cache the object after saving to the db.
1551     * This method returns false
1552     */

1553    protected boolean isCacheOnSave()
1554    {
1555        return true;
1556    }
1557
1558                        
1559      /**
1560     * Set the PrimaryKey using ObjectKey.
1561     *
1562     * @param activitySetId ObjectKey
1563     */

1564    public void setPrimaryKey(ObjectKey activitySetId)
1565        throws TorqueException {
1566            setActivitySetId(new Long JavaDoc(((NumberKey)activitySetId).longValue()));
1567        }
1568
1569    /**
1570     * Set the PrimaryKey using a String.
1571     *
1572     * @param key
1573     */

1574    public void setPrimaryKey(String JavaDoc key) throws TorqueException
1575    {
1576            setActivitySetId(new Long JavaDoc(key));
1577        }
1578
1579  
1580    /**
1581     * returns an id that differentiates this object from others
1582     * of its class.
1583     */

1584    public ObjectKey getPrimaryKey()
1585    {
1586          return SimpleKey.keyFor(getActivitySetId());
1587      }
1588 
1589    /**
1590     * get an id that differentiates this object from others
1591     * of its class.
1592     */

1593    public String JavaDoc getQueryKey()
1594    {
1595        if (getPrimaryKey() == null)
1596        {
1597            return "";
1598        }
1599        else
1600        {
1601            return getPrimaryKey().toString();
1602        }
1603    }
1604
1605    /**
1606     * set an id that differentiates this object from others
1607     * of its class.
1608     */

1609    public void setQueryKey(String JavaDoc key)
1610        throws TorqueException
1611    {
1612        setPrimaryKey(key);
1613    }
1614
1615    /**
1616     * Makes a copy of this object.
1617     * It creates a new object filling in the simple attributes.
1618       * It then fills all the association collections and sets the
1619     * related objects to isNew=true.
1620       */

1621      public ActivitySet copy() throws TorqueException
1622    {
1623        ActivitySet copyObj = new ActivitySet();
1624            copyObj.setActivitySetId(activitySetId);
1625          copyObj.setTypeId(typeId);
1626          copyObj.setAttachmentId(attachmentId);
1627          copyObj.setCreatedBy(createdBy);
1628          copyObj.setCreatedDate(createdDate);
1629  
1630                      copyObj.setActivitySetId((Long JavaDoc)null);
1631                                    
1632                                      
1633                
1634        List JavaDoc v = getActivitys();
1635        for (int i = 0; i < v.size(); i++)
1636        {
1637            Activity obj = (Activity) v.get(i);
1638            copyObj.addActivity(obj.copy());
1639        }
1640                                                  
1641                
1642        v = getIssues();
1643        for (int i = 0; i < v.size(); i++)
1644        {
1645            Issue obj = (Issue) v.get(i);
1646            copyObj.addIssue(obj.copy());
1647        }
1648                            return copyObj;
1649    }
1650
1651    /**
1652     * returns a peer instance associated with this om. Since Peer classes
1653     * are not to have any instance attributes, this method returns the
1654     * same instance for all member of this class. The method could therefore
1655     * be static, but this would prevent one from overriding the behavior.
1656     */

1657    public ActivitySetPeer getPeer()
1658    {
1659        return peer;
1660    }
1661
1662    public String JavaDoc toString()
1663    {
1664        StringBuffer JavaDoc str = new StringBuffer JavaDoc();
1665        str.append("ActivitySet:\n");
1666        str.append("ActivitySetId = ")
1667               .append(getActivitySetId())
1668             .append("\n");
1669        str.append("TypeId = ")
1670               .append(getTypeId())
1671             .append("\n");
1672        str.append("AttachmentId = ")
1673               .append(getAttachmentId())
1674             .append("\n");
1675        str.append("CreatedBy = ")
1676               .append(getCreatedBy())
1677             .append("\n");
1678        str.append("CreatedDate = ")
1679               .append(getCreatedDate())
1680             .append("\n");
1681        return(str.toString());
1682    }
1683}
1684
Popular Tags