KickJava   Java API By Example, From Geeks To Geeks.

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


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 Depend
32  */

33 public abstract class BaseDepend extends BaseObject
34     implements org.apache.fulcrum.intake.Retrievable
35 {
36     /** The Peer class */
37     private static final DependPeer peer =
38         new DependPeer();
39
40         
41     /** The value for the dependId field */
42     private Integer JavaDoc dependId;
43       
44     /** The value for the observedId field */
45     private Long JavaDoc observedId;
46       
47     /** The value for the observerId field */
48     private Long JavaDoc observerId;
49       
50     /** The value for the typeId field */
51     private Integer JavaDoc typeId;
52                                                                 
53     /** The value for the deleted field */
54     private boolean deleted = false;
55   
56     
57     /**
58      * Get the DependId
59      *
60      * @return Integer
61      */

62     public Integer JavaDoc getDependId()
63     {
64         return dependId;
65     }
66
67                                               
68     /**
69      * Set the value of DependId
70      *
71      * @param v new value
72      */

73     public void setDependId(Integer JavaDoc v) throws TorqueException
74     {
75     
76                   if (!ObjectUtils.equals(this.dependId, v))
77               {
78             this.dependId = 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                         .setDependId(v);
91             }
92         }
93                       }
94   
95     /**
96      * Get the ObservedId
97      *
98      * @return Long
99      */

100     public Long JavaDoc getObservedId()
101     {
102         return observedId;
103     }
104
105                               
106     /**
107      * Set the value of ObservedId
108      *
109      * @param v new value
110      */

111     public void setObservedId(Long JavaDoc v) throws TorqueException
112     {
113     
114                   if (!ObjectUtils.equals(this.observedId, v))
115               {
116             this.observedId = v;
117             setModified(true);
118         }
119     
120                                                                           
121                 if (aIssueRelatedByObservedId != null && !ObjectUtils.equals(aIssueRelatedByObservedId.getIssueId(), v))
122                 {
123             aIssueRelatedByObservedId = null;
124         }
125       
126               }
127   
128     /**
129      * Get the ObserverId
130      *
131      * @return Long
132      */

133     public Long JavaDoc getObserverId()
134     {
135         return observerId;
136     }
137
138                               
139     /**
140      * Set the value of ObserverId
141      *
142      * @param v new value
143      */

144     public void setObserverId(Long JavaDoc v) throws TorqueException
145     {
146     
147                   if (!ObjectUtils.equals(this.observerId, v))
148               {
149             this.observerId = v;
150             setModified(true);
151         }
152     
153                                                                           
154                 if (aIssueRelatedByObserverId != null && !ObjectUtils.equals(aIssueRelatedByObserverId.getIssueId(), v))
155                 {
156             aIssueRelatedByObserverId = null;
157         }
158       
159               }
160   
161     /**
162      * Get the TypeId
163      *
164      * @return Integer
165      */

166     public Integer JavaDoc getTypeId()
167     {
168         return typeId;
169     }
170
171                               
172     /**
173      * Set the value of TypeId
174      *
175      * @param v new value
176      */

177     public void setTypeId(Integer JavaDoc v) throws TorqueException
178     {
179     
180                   if (!ObjectUtils.equals(this.typeId, v))
181               {
182             this.typeId = v;
183             setModified(true);
184         }
185     
186                                   
187                 if (aDependType != null && !ObjectUtils.equals(aDependType.getDependTypeId(), v))
188                 {
189             aDependType = null;
190         }
191       
192               }
193   
194     /**
195      * Get the Deleted
196      *
197      * @return boolean
198      */

199     public boolean getDeleted()
200     {
201         return deleted;
202     }
203
204                         
205     /**
206      * Set the value of Deleted
207      *
208      * @param v new value
209      */

210     public void setDeleted(boolean v)
211     {
212     
213                   if (this.deleted != v)
214               {
215             this.deleted = v;
216             setModified(true);
217         }
218     
219           
220               }
221   
222       
223         
224                         
225             private Issue aIssueRelatedByObservedId;
226
227     /**
228      * Declares an association between this object and a Issue object
229      *
230      * @param v Issue
231      * @throws TorqueException
232      */

233     public void setIssueRelatedByObservedId(Issue v) throws TorqueException
234     {
235             if (v == null)
236         {
237                   setObservedId((Long JavaDoc) null);
238               }
239         else
240         {
241             setObservedId(v.getIssueId());
242         }
243             aIssueRelatedByObservedId = v;
244     }
245
246                         
247     /**
248      * Get the associated Issue object
249      *
250      * @return the associated Issue object
251      * @throws TorqueException
252      */

253     public Issue getIssueRelatedByObservedId() throws TorqueException
254     {
255         if ( !ObjectUtils.equals(getObservedId(), null) )
256         {
257                 return IssueManager.getInstance(SimpleKey.keyFor(getObservedId()));
258             }
259         return aIssueRelatedByObservedId;
260     }
261
262     /**
263      * Provides convenient way to set a relationship based on a
264      * ObjectKey, for example
265      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
266      *
267          */

268     public void setIssueRelatedByObservedIdKey(ObjectKey key) throws TorqueException
269     {
270     
271                     setObservedId(new Long JavaDoc(((NumberKey) key).longValue()));
272               }
273   
274         
275                         
276             private Issue aIssueRelatedByObserverId;
277
278     /**
279      * Declares an association between this object and a Issue object
280      *
281      * @param v Issue
282      * @throws TorqueException
283      */

284     public void setIssueRelatedByObserverId(Issue v) throws TorqueException
285     {
286             if (v == null)
287         {
288                   setObserverId((Long JavaDoc) null);
289               }
290         else
291         {
292             setObserverId(v.getIssueId());
293         }
294             aIssueRelatedByObserverId = v;
295     }
296
297                         
298     /**
299      * Get the associated Issue object
300      *
301      * @return the associated Issue object
302      * @throws TorqueException
303      */

304     public Issue getIssueRelatedByObserverId() throws TorqueException
305     {
306         if ( !ObjectUtils.equals(getObserverId(), null) )
307         {
308                 return IssueManager.getInstance(SimpleKey.keyFor(getObserverId()));
309             }
310         return aIssueRelatedByObserverId;
311     }
312
313     /**
314      * Provides convenient way to set a relationship based on a
315      * ObjectKey, for example
316      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
317      *
318          */

319     public void setIssueRelatedByObserverIdKey(ObjectKey key) throws TorqueException
320     {
321     
322                     setObserverId(new Long JavaDoc(((NumberKey) key).longValue()));
323               }
324   
325         
326                   
327         private DependType aDependType;
328
329     /**
330      * Declares an association between this object and a DependType object
331      *
332      * @param v DependType
333      * @throws TorqueException
334      */

335     public void setDependType(DependType v) throws TorqueException
336     {
337             if (v == null)
338         {
339                   setTypeId((Integer JavaDoc) null);
340               }
341         else
342         {
343             setTypeId(v.getDependTypeId());
344         }
345             aDependType = v;
346     }
347
348                         
349     /**
350      * Get the associated DependType object
351      *
352      * @return the associated DependType object
353      * @throws TorqueException
354      */

355     public DependType getDependType() throws TorqueException
356     {
357         if ( !ObjectUtils.equals(getTypeId(), null) )
358         {
359                 return DependTypeManager.getInstance(SimpleKey.keyFor(getTypeId()));
360             }
361         return aDependType;
362     }
363
364     /**
365      * Provides convenient way to set a relationship based on a
366      * ObjectKey, for example
367      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
368      *
369          */

370     public void setDependTypeKey(ObjectKey key) throws TorqueException
371     {
372     
373                     setTypeId(new Integer JavaDoc(((NumberKey) key).intValue()));
374               }
375      
376                                 
377             
378     /**
379      * Collection to store aggregation of collActivitys
380      */

381     protected List JavaDoc collActivitys;
382
383     /**
384      * Temporary storage of collActivitys to save a possible db hit in
385      * the event objects are add to the collection, but the
386      * complete collection is never requested.
387      */

388     protected void initActivitys()
389     {
390         if (collActivitys == null)
391         {
392             collActivitys = new ArrayList JavaDoc();
393         }
394     }
395
396             
397     /**
398      * Method called to associate a Activity object to this object
399      * through the Activity foreign key attribute
400      *
401      * @param l Activity
402      * @throws TorqueException
403      */

404     public void addActivity(Activity l) throws TorqueException
405     {
406         getActivitys().add(l);
407         l.setDepend((Depend)this);
408     }
409
410     /**
411      * The criteria used to select the current contents of collActivitys
412      */

413     private Criteria lastActivitysCriteria = null;
414
415     /**
416      * If this collection has already been initialized, returns
417      * the collection. Otherwise returns the results of
418      * getActivitys(new Criteria())
419      *
420      * @throws TorqueException
421      */

422     public List JavaDoc getActivitys() throws TorqueException
423     {
424         if (collActivitys == null)
425         {
426             collActivitys = getActivitys(new Criteria(10));
427         }
428         return collActivitys;
429     }
430
431     /**
432      * If this collection has already been initialized with
433      * an identical criteria, it returns the collection.
434      * Otherwise if this Depend has previously
435      * been saved, it will retrieve related Activitys from storage.
436      * If this Depend is new, it will return
437      * an empty collection or the current collection, the criteria
438      * is ignored on a new object.
439      *
440      * @throws TorqueException
441      */

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

484     public List JavaDoc getActivitys(Connection JavaDoc con) throws TorqueException
485     {
486         if (collActivitys == null)
487         {
488             collActivitys = getActivitys(new Criteria(10),con);
489         }
490         return collActivitys;
491     }
492
493     /**
494      * If this collection has already been initialized with
495      * an identical criteria, it returns the collection.
496      * Otherwise if this Depend has previously
497      * been saved, it will retrieve related Activitys from storage.
498      * If this Depend is new, it will return
499      * an empty collection or the current collection, the criteria
500      * is ignored on a new object.
501      * This method takes in the Connection also as input so that
502      * referenced objects can also be obtained using a Connection
503      * that is taken as input
504      */

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

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

581                             criteria.add(ActivityPeer.DEPEND_ID, getDependId() );
582                         if (!lastActivitysCriteria.equals(criteria))
583             {
584                 collActivitys = ActivityPeer.doSelectJoinIssue(criteria);
585             }
586         }
587         lastActivitysCriteria = criteria;
588
589         return collActivitys;
590     }
591                   
592                     
593                     
594                                 
595                                                               
596                                         
597                     
598                     
599           
600     /**
601      * If this collection has already been initialized with
602      * an identical criteria, it returns the collection.
603      * Otherwise if this Depend is new, it will return
604      * an empty collection; or if this Depend has previously
605      * been saved, it will retrieve related Activitys from storage.
606      *
607      * This method is protected by default in order to keep the public
608      * api reasonable. You can provide public methods for those you
609      * actually need in Depend.
610      */

611     protected List JavaDoc getActivitysJoinAttribute(Criteria criteria)
612         throws TorqueException
613     {
614         if (collActivitys == null)
615         {
616             if (isNew())
617             {
618                collActivitys = new ArrayList JavaDoc();
619             }
620             else
621             {
622                             criteria.add(ActivityPeer.DEPEND_ID, getDependId() );
623                             collActivitys = ActivityPeer.doSelectJoinAttribute(criteria);
624             }
625         }
626         else
627         {
628             // the following code is to determine if a new query is
629
// called for. If the criteria is the same as the last
630
// one, just return the collection.
631

632                             criteria.add(ActivityPeer.DEPEND_ID, getDependId() );
633                         if (!lastActivitysCriteria.equals(criteria))
634             {
635                 collActivitys = ActivityPeer.doSelectJoinAttribute(criteria);
636             }
637         }
638         lastActivitysCriteria = criteria;
639
640         return collActivitys;
641     }
642                   
643                     
644                     
645                                 
646                                                               
647                                         
648                     
649                     
650           
651     /**
652      * If this collection has already been initialized with
653      * an identical criteria, it returns the collection.
654      * Otherwise if this Depend is new, it will return
655      * an empty collection; or if this Depend has previously
656      * been saved, it will retrieve related Activitys from storage.
657      *
658      * This method is protected by default in order to keep the public
659      * api reasonable. You can provide public methods for those you
660      * actually need in Depend.
661      */

662     protected List JavaDoc getActivitysJoinActivitySet(Criteria criteria)
663         throws TorqueException
664     {
665         if (collActivitys == null)
666         {
667             if (isNew())
668             {
669                collActivitys = new ArrayList JavaDoc();
670             }
671             else
672             {
673                             criteria.add(ActivityPeer.DEPEND_ID, getDependId() );
674                             collActivitys = ActivityPeer.doSelectJoinActivitySet(criteria);
675             }
676         }
677         else
678         {
679             // the following code is to determine if a new query is
680
// called for. If the criteria is the same as the last
681
// one, just return the collection.
682

683                             criteria.add(ActivityPeer.DEPEND_ID, getDependId() );
684                         if (!lastActivitysCriteria.equals(criteria))
685             {
686                 collActivitys = ActivityPeer.doSelectJoinActivitySet(criteria);
687             }
688         }
689         lastActivitysCriteria = criteria;
690
691         return collActivitys;
692     }
693                   
694                     
695                     
696                                             
697                                                                           
698                                         
699                     
700                     
701           
702     /**
703      * If this collection has already been initialized with
704      * an identical criteria, it returns the collection.
705      * Otherwise if this Depend is new, it will return
706      * an empty collection; or if this Depend has previously
707      * been saved, it will retrieve related Activitys from storage.
708      *
709      * This method is protected by default in order to keep the public
710      * api reasonable. You can provide public methods for those you
711      * actually need in Depend.
712      */

713     protected List JavaDoc getActivitysJoinScarabUserImplRelatedByOldUserId(Criteria criteria)
714         throws TorqueException
715     {
716         if (collActivitys == null)
717         {
718             if (isNew())
719             {
720                collActivitys = new ArrayList JavaDoc();
721             }
722             else
723             {
724                             criteria.add(ActivityPeer.DEPEND_ID, getDependId() );
725                             collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByOldUserId(criteria);
726             }
727         }
728         else
729         {
730             // the following code is to determine if a new query is
731
// called for. If the criteria is the same as the last
732
// one, just return the collection.
733

734                             criteria.add(ActivityPeer.DEPEND_ID, getDependId() );
735                         if (!lastActivitysCriteria.equals(criteria))
736             {
737                 collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByOldUserId(criteria);
738             }
739         }
740         lastActivitysCriteria = criteria;
741
742         return collActivitys;
743     }
744                   
745                     
746                     
747                                             
748                                                                           
749                                         
750                     
751                     
752           
753     /**
754      * If this collection has already been initialized with
755      * an identical criteria, it returns the collection.
756      * Otherwise if this Depend is new, it will return
757      * an empty collection; or if this Depend has previously
758      * been saved, it will retrieve related Activitys from storage.
759      *
760      * This method is protected by default in order to keep the public
761      * api reasonable. You can provide public methods for those you
762      * actually need in Depend.
763      */

764     protected List JavaDoc getActivitysJoinScarabUserImplRelatedByNewUserId(Criteria criteria)
765         throws TorqueException
766     {
767         if (collActivitys == null)
768         {
769             if (isNew())
770             {
771                collActivitys = new ArrayList JavaDoc();
772             }
773             else
774             {
775                             criteria.add(ActivityPeer.DEPEND_ID, getDependId() );
776                             collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByNewUserId(criteria);
777             }
778         }
779         else
780         {
781             // the following code is to determine if a new query is
782
// called for. If the criteria is the same as the last
783
// one, just return the collection.
784

785                             criteria.add(ActivityPeer.DEPEND_ID, getDependId() );
786                         if (!lastActivitysCriteria.equals(criteria))
787             {
788                 collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByNewUserId(criteria);
789             }
790         }
791         lastActivitysCriteria = criteria;
792
793         return collActivitys;
794     }
795                   
796                     
797                     
798                                             
799                                                                           
800                                         
801                     
802                     
803           
804     /**
805      * If this collection has already been initialized with
806      * an identical criteria, it returns the collection.
807      * Otherwise if this Depend is new, it will return
808      * an empty collection; or if this Depend has previously
809      * been saved, it will retrieve related Activitys from storage.
810      *
811      * This method is protected by default in order to keep the public
812      * api reasonable. You can provide public methods for those you
813      * actually need in Depend.
814      */

815     protected List JavaDoc getActivitysJoinAttributeOptionRelatedByOldOptionId(Criteria criteria)
816         throws TorqueException
817     {
818         if (collActivitys == null)
819         {
820             if (isNew())
821             {
822                collActivitys = new ArrayList JavaDoc();
823             }
824             else
825             {
826                             criteria.add(ActivityPeer.DEPEND_ID, getDependId() );
827                             collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByOldOptionId(criteria);
828             }
829         }
830         else
831         {
832             // the following code is to determine if a new query is
833
// called for. If the criteria is the same as the last
834
// one, just return the collection.
835

836                             criteria.add(ActivityPeer.DEPEND_ID, getDependId() );
837                         if (!lastActivitysCriteria.equals(criteria))
838             {
839                 collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByOldOptionId(criteria);
840             }
841         }
842         lastActivitysCriteria = criteria;
843
844         return collActivitys;
845     }
846                   
847                     
848                     
849                                             
850                                                                           
851                                         
852                     
853                     
854           
855     /**
856      * If this collection has already been initialized with
857      * an identical criteria, it returns the collection.
858      * Otherwise if this Depend is new, it will return
859      * an empty collection; or if this Depend has previously
860      * been saved, it will retrieve related Activitys from storage.
861      *
862      * This method is protected by default in order to keep the public
863      * api reasonable. You can provide public methods for those you
864      * actually need in Depend.
865      */

866     protected List JavaDoc getActivitysJoinAttributeOptionRelatedByNewOptionId(Criteria criteria)
867         throws TorqueException
868     {
869         if (collActivitys == null)
870         {
871             if (isNew())
872             {
873                collActivitys = new ArrayList JavaDoc();
874             }
875             else
876             {
877                             criteria.add(ActivityPeer.DEPEND_ID, getDependId() );
878                             collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByNewOptionId(criteria);
879             }
880         }
881         else
882         {
883             // the following code is to determine if a new query is
884
// called for. If the criteria is the same as the last
885
// one, just return the collection.
886

887                             criteria.add(ActivityPeer.DEPEND_ID, getDependId() );
888                         if (!lastActivitysCriteria.equals(criteria))
889             {
890                 collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByNewOptionId(criteria);
891             }
892         }
893         lastActivitysCriteria = criteria;
894
895         return collActivitys;
896     }
897                   
898                     
899                     
900                                 
901                                                               
902                                         
903                     
904                     
905           
906     /**
907      * If this collection has already been initialized with
908      * an identical criteria, it returns the collection.
909      * Otherwise if this Depend is new, it will return
910      * an empty collection; or if this Depend has previously
911      * been saved, it will retrieve related Activitys from storage.
912      *
913      * This method is protected by default in order to keep the public
914      * api reasonable. You can provide public methods for those you
915      * actually need in Depend.
916      */

917     protected List JavaDoc getActivitysJoinAttachment(Criteria criteria)
918         throws TorqueException
919     {
920         if (collActivitys == null)
921         {
922             if (isNew())
923             {
924                collActivitys = new ArrayList JavaDoc();
925             }
926             else
927             {
928                             criteria.add(ActivityPeer.DEPEND_ID, getDependId() );
929                             collActivitys = ActivityPeer.doSelectJoinAttachment(criteria);
930             }
931         }
932         else
933         {
934             // the following code is to determine if a new query is
935
// called for. If the criteria is the same as the last
936
// one, just return the collection.
937

938                             criteria.add(ActivityPeer.DEPEND_ID, getDependId() );
939                         if (!lastActivitysCriteria.equals(criteria))
940             {
941                 collActivitys = ActivityPeer.doSelectJoinAttachment(criteria);
942             }
943         }
944         lastActivitysCriteria = criteria;
945
946         return collActivitys;
947     }
948                   
949                     
950                               
951                                 
952                                                               
953                                         
954                     
955                     
956           
957     /**
958      * If this collection has already been initialized with
959      * an identical criteria, it returns the collection.
960      * Otherwise if this Depend is new, it will return
961      * an empty collection; or if this Depend has previously
962      * been saved, it will retrieve related Activitys from storage.
963      *
964      * This method is protected by default in order to keep the public
965      * api reasonable. You can provide public methods for those you
966      * actually need in Depend.
967      */

968     protected List JavaDoc getActivitysJoinDepend(Criteria criteria)
969         throws TorqueException
970     {
971         if (collActivitys == null)
972         {
973             if (isNew())
974             {
975                collActivitys = new ArrayList JavaDoc();
976             }
977             else
978             {
979                             criteria.add(ActivityPeer.DEPEND_ID, getDependId() );
980                             collActivitys = ActivityPeer.doSelectJoinDepend(criteria);
981             }
982         }
983         else
984         {
985             // the following code is to determine if a new query is
986
// called for. If the criteria is the same as the last
987
// one, just return the collection.
988

989                             criteria.add(ActivityPeer.DEPEND_ID, getDependId() );
990                         if (!lastActivitysCriteria.equals(criteria))
991             {
992                 collActivitys = ActivityPeer.doSelectJoinDepend(criteria);
993             }
994         }
995         lastActivitysCriteria = criteria;
996
997         return collActivitys;
998     }
999                             
1000
1001
1002          
1003    private static List JavaDoc fieldNames = null;
1004
1005    /**
1006     * Generate a list of field names.
1007     *
1008     * @return a list of field names
1009     */

1010    public static synchronized List JavaDoc getFieldNames()
1011    {
1012        if (fieldNames == null)
1013        {
1014            fieldNames = new ArrayList JavaDoc();
1015              fieldNames.add("DependId");
1016              fieldNames.add("ObservedId");
1017              fieldNames.add("ObserverId");
1018              fieldNames.add("TypeId");
1019              fieldNames.add("Deleted");
1020              fieldNames = Collections.unmodifiableList(fieldNames);
1021        }
1022        return fieldNames;
1023    }
1024
1025    /**
1026     * Retrieves a field from the object by name passed in as a String.
1027     *
1028     * @param name field name
1029     * @return value
1030     */

1031    public Object JavaDoc getByName(String JavaDoc name)
1032    {
1033          if (name.equals("DependId"))
1034        {
1035                return getDependId();
1036            }
1037          if (name.equals("ObservedId"))
1038        {
1039                return getObservedId();
1040            }
1041          if (name.equals("ObserverId"))
1042        {
1043                return getObserverId();
1044            }
1045          if (name.equals("TypeId"))
1046        {
1047                return getTypeId();
1048            }
1049          if (name.equals("Deleted"))
1050        {
1051                return Boolean.valueOf(getDeleted());
1052            }
1053          return null;
1054    }
1055    
1056    /**
1057     * Retrieves a field from the object by name passed in
1058     * as a String. The String must be one of the static
1059     * Strings defined in this Class' Peer.
1060     *
1061     * @param name peer name
1062     * @return value
1063     */

1064    public Object JavaDoc getByPeerName(String JavaDoc name)
1065    {
1066          if (name.equals(DependPeer.DEPEND_ID))
1067        {
1068                return getDependId();
1069            }
1070          if (name.equals(DependPeer.OBSERVED_ID))
1071        {
1072                return getObservedId();
1073            }
1074          if (name.equals(DependPeer.OBSERVER_ID))
1075        {
1076                return getObserverId();
1077            }
1078          if (name.equals(DependPeer.DEPEND_TYPE_ID))
1079        {
1080                return getTypeId();
1081            }
1082          if (name.equals(DependPeer.DELETED))
1083        {
1084                return Boolean.valueOf(getDeleted());
1085            }
1086          return null;
1087    }
1088
1089    /**
1090     * Retrieves a field from the object by Position as specified
1091     * in the xml schema. Zero-based.
1092     *
1093     * @param pos position in xml schema
1094     * @return value
1095     */

1096    public Object JavaDoc getByPosition(int pos)
1097    {
1098            if (pos == 0)
1099        {
1100                return getDependId();
1101            }
1102              if (pos == 1)
1103        {
1104                return getObservedId();
1105            }
1106              if (pos == 2)
1107        {
1108                return getObserverId();
1109            }
1110              if (pos == 3)
1111        {
1112                return getTypeId();
1113            }
1114              if (pos == 4)
1115        {
1116                return Boolean.valueOf(getDeleted());
1117            }
1118              return null;
1119    }
1120     
1121    /**
1122     * Stores the object in the database. If the object is new,
1123     * it inserts it; otherwise an update is performed.
1124     *
1125     * @throws Exception
1126     */

1127    public void save() throws Exception JavaDoc
1128    {
1129          save(DependPeer.getMapBuilder()
1130                .getDatabaseMap().getName());
1131      }
1132
1133    /**
1134     * Stores the object in the database. If the object is new,
1135     * it inserts it; otherwise an update is performed.
1136       * Note: this code is here because the method body is
1137     * auto-generated conditionally and therefore needs to be
1138     * in this file instead of in the super class, BaseObject.
1139       *
1140     * @param dbName
1141     * @throws TorqueException
1142     */

1143    public void save(String JavaDoc dbName) throws TorqueException
1144    {
1145        Connection JavaDoc con = null;
1146          try
1147        {
1148            con = Transaction.begin(dbName);
1149            save(con);
1150            Transaction.commit(con);
1151        }
1152        catch(TorqueException e)
1153        {
1154            Transaction.safeRollback(con);
1155            throw e;
1156        }
1157      }
1158
1159      /** flag to prevent endless save loop, if this object is referenced
1160        by another object which falls in this transaction. */

1161    private boolean alreadyInSave = false;
1162      /**
1163     * Stores the object in the database. If the object is new,
1164     * it inserts it; otherwise an update is performed. This method
1165     * is meant to be used as part of a transaction, otherwise use
1166     * the save() method and the connection details will be handled
1167     * internally
1168     *
1169     * @param con
1170     * @throws TorqueException
1171     */

1172    public void save(Connection JavaDoc con) throws TorqueException
1173    {
1174          if (!alreadyInSave)
1175        {
1176            alreadyInSave = true;
1177
1178
1179  
1180            // If this object has been modified, then save it to the database.
1181
if (isModified())
1182            {
1183                if (isNew())
1184                {
1185                    DependPeer.doInsert((Depend)this, con);
1186                    setNew(false);
1187                }
1188                else
1189                {
1190                    DependPeer.doUpdate((Depend)this, con);
1191                }
1192
1193                      if (isCacheOnSave())
1194                {
1195                    DependManager.putInstance(this);
1196                }
1197              }
1198
1199                                      
1200                            if (collActivitys != null)
1201            {
1202                for (int i = 0; i < collActivitys.size(); i++)
1203                {
1204                    ((Activity)collActivitys.get(i)).save(con);
1205                }
1206            }
1207                          alreadyInSave = false;
1208        }
1209      }
1210
1211    /**
1212     * Specify whether to cache the object after saving to the db.
1213     * This method returns false
1214     */

1215    protected boolean isCacheOnSave()
1216    {
1217        return true;
1218    }
1219
1220                        
1221      /**
1222     * Set the PrimaryKey using ObjectKey.
1223     *
1224     * @param dependId ObjectKey
1225     */

1226    public void setPrimaryKey(ObjectKey dependId)
1227        throws TorqueException {
1228            setDependId(new Integer JavaDoc(((NumberKey)dependId).intValue()));
1229        }
1230
1231    /**
1232     * Set the PrimaryKey using a String.
1233     *
1234     * @param key
1235     */

1236    public void setPrimaryKey(String JavaDoc key) throws TorqueException
1237    {
1238            setDependId(new Integer JavaDoc(key));
1239        }
1240
1241  
1242    /**
1243     * returns an id that differentiates this object from others
1244     * of its class.
1245     */

1246    public ObjectKey getPrimaryKey()
1247    {
1248          return SimpleKey.keyFor(getDependId());
1249      }
1250 
1251    /**
1252     * get an id that differentiates this object from others
1253     * of its class.
1254     */

1255    public String JavaDoc getQueryKey()
1256    {
1257        if (getPrimaryKey() == null)
1258        {
1259            return "";
1260        }
1261        else
1262        {
1263            return getPrimaryKey().toString();
1264        }
1265    }
1266
1267    /**
1268     * set an id that differentiates this object from others
1269     * of its class.
1270     */

1271    public void setQueryKey(String JavaDoc key)
1272        throws TorqueException
1273    {
1274        setPrimaryKey(key);
1275    }
1276
1277    /**
1278     * Makes a copy of this object.
1279     * It creates a new object filling in the simple attributes.
1280       * It then fills all the association collections and sets the
1281     * related objects to isNew=true.
1282       */

1283      public Depend copy() throws TorqueException
1284    {
1285        Depend copyObj = new Depend();
1286            copyObj.setDependId(dependId);
1287          copyObj.setObservedId(observedId);
1288          copyObj.setObserverId(observerId);
1289          copyObj.setTypeId(typeId);
1290          copyObj.setDeleted(deleted);
1291  
1292                      copyObj.setDependId((Integer JavaDoc)null);
1293                                    
1294                                      
1295                
1296        List JavaDoc v = getActivitys();
1297        for (int i = 0; i < v.size(); i++)
1298        {
1299            Activity obj = (Activity) v.get(i);
1300            copyObj.addActivity(obj.copy());
1301        }
1302                            return copyObj;
1303    }
1304
1305    /**
1306     * returns a peer instance associated with this om. Since Peer classes
1307     * are not to have any instance attributes, this method returns the
1308     * same instance for all member of this class. The method could therefore
1309     * be static, but this would prevent one from overriding the behavior.
1310     */

1311    public DependPeer getPeer()
1312    {
1313        return peer;
1314    }
1315
1316    public String JavaDoc toString()
1317    {
1318        StringBuffer JavaDoc str = new StringBuffer JavaDoc();
1319        str.append("Depend:\n");
1320        str.append("DependId = ")
1321               .append(getDependId())
1322             .append("\n");
1323        str.append("ObservedId = ")
1324               .append(getObservedId())
1325             .append("\n");
1326        str.append("ObserverId = ")
1327               .append(getObserverId())
1328             .append("\n");
1329        str.append("TypeId = ")
1330               .append(getTypeId())
1331             .append("\n");
1332        str.append("Deleted = ")
1333               .append(getDeleted())
1334             .append("\n");
1335        return(str.toString());
1336    }
1337}
1338
Popular Tags