KickJava   Java API By Example, From Geeks To Geeks.

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


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     
31     
32     
33     
34   
35 /**
36  * You should not use this class directly. It should not even be
37  * extended all references should be to Activity
38  */

39 public abstract class BaseActivity extends BaseObject
40     implements org.apache.fulcrum.intake.Retrievable
41 {
42     /** The Peer class */
43     private static final ActivityPeer peer =
44         new ActivityPeer();
45
46         
47     /** The value for the activityId field */
48     private Long JavaDoc activityId;
49       
50     /** The value for the issueId field */
51     private Long JavaDoc issueId;
52       
53     /** The value for the attributeId field */
54     private Integer JavaDoc attributeId;
55       
56     /** The value for the transactionId field */
57     private Long JavaDoc transactionId;
58       
59     /** The value for the oldNumericValue field */
60     private Integer JavaDoc oldNumericValue;
61       
62     /** The value for the newNumericValue field */
63     private Integer JavaDoc newNumericValue;
64       
65     /** The value for the oldUserId field */
66     private Integer JavaDoc oldUserId;
67       
68     /** The value for the newUserId field */
69     private Integer JavaDoc newUserId;
70       
71     /** The value for the oldOptionId field */
72     private Integer JavaDoc oldOptionId;
73       
74     /** The value for the newOptionId field */
75     private Integer JavaDoc newOptionId;
76       
77     /** The value for the oldValue field */
78     private String JavaDoc oldValue;
79       
80     /** The value for the newValue field */
81     private String JavaDoc newValue;
82       
83     /** The value for the dependId field */
84     private Integer JavaDoc dependId;
85       
86     /** The value for the description field */
87     private String JavaDoc description;
88       
89     /** The value for the endDate field */
90     private Date JavaDoc endDate;
91       
92     /** The value for the attachmentId field */
93     private Long JavaDoc attachmentId;
94   
95     
96     /**
97      * Get the ActivityId
98      *
99      * @return Long
100      */

101     public Long JavaDoc getActivityId()
102     {
103         return activityId;
104     }
105
106                         
107     /**
108      * Set the value of ActivityId
109      *
110      * @param v new value
111      */

112     public void setActivityId(Long JavaDoc v)
113     {
114     
115                   if (!ObjectUtils.equals(this.activityId, v))
116               {
117             this.activityId = v;
118             setModified(true);
119         }
120     
121           
122               }
123   
124     /**
125      * Get the IssueId
126      *
127      * @return Long
128      */

129     public Long JavaDoc getIssueId()
130     {
131         return issueId;
132     }
133
134                               
135     /**
136      * Set the value of IssueId
137      *
138      * @param v new value
139      */

140     public void setIssueId(Long JavaDoc v) throws TorqueException
141     {
142     
143                   if (!ObjectUtils.equals(this.issueId, v))
144               {
145             this.issueId = v;
146             setModified(true);
147         }
148     
149                                   
150                 if (aIssue != null && !ObjectUtils.equals(aIssue.getIssueId(), v))
151                 {
152             aIssue = null;
153         }
154       
155               }
156   
157     /**
158      * Get the AttributeId
159      *
160      * @return Integer
161      */

162     public Integer JavaDoc getAttributeId()
163     {
164         return attributeId;
165     }
166
167                               
168     /**
169      * Set the value of AttributeId
170      *
171      * @param v new value
172      */

173     public void setAttributeId(Integer JavaDoc v) throws TorqueException
174     {
175     
176                   if (!ObjectUtils.equals(this.attributeId, v))
177               {
178             this.attributeId = v;
179             setModified(true);
180         }
181     
182                                   
183                 if (aAttribute != null && !ObjectUtils.equals(aAttribute.getAttributeId(), v))
184                 {
185             aAttribute = null;
186         }
187       
188               }
189   
190     /**
191      * Get the TransactionId
192      *
193      * @return Long
194      */

195     public Long JavaDoc getTransactionId()
196     {
197         return transactionId;
198     }
199
200                               
201     /**
202      * Set the value of TransactionId
203      *
204      * @param v new value
205      */

206     public void setTransactionId(Long JavaDoc v) throws TorqueException
207     {
208     
209                   if (!ObjectUtils.equals(this.transactionId, v))
210               {
211             this.transactionId = v;
212             setModified(true);
213         }
214     
215                                   
216                 if (aActivitySet != null && !ObjectUtils.equals(aActivitySet.getActivitySetId(), v))
217                 {
218             aActivitySet = null;
219         }
220       
221               }
222   
223     /**
224      * Get the OldNumericValue
225      *
226      * @return Integer
227      */

228     public Integer JavaDoc getOldNumericValue()
229     {
230         return oldNumericValue;
231     }
232
233                         
234     /**
235      * Set the value of OldNumericValue
236      *
237      * @param v new value
238      */

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

256     public Integer JavaDoc getNewNumericValue()
257     {
258         return newNumericValue;
259     }
260
261                         
262     /**
263      * Set the value of NewNumericValue
264      *
265      * @param v new value
266      */

267     public void setNewNumericValue(Integer JavaDoc v)
268     {
269     
270                   if (!ObjectUtils.equals(this.newNumericValue, v))
271               {
272             this.newNumericValue = v;
273             setModified(true);
274         }
275     
276           
277               }
278   
279     /**
280      * Get the OldUserId
281      *
282      * @return Integer
283      */

284     public Integer JavaDoc getOldUserId()
285     {
286         return oldUserId;
287     }
288
289                               
290     /**
291      * Set the value of OldUserId
292      *
293      * @param v new value
294      */

295     public void setOldUserId(Integer JavaDoc v) throws TorqueException
296     {
297     
298                   if (!ObjectUtils.equals(this.oldUserId, v))
299               {
300             this.oldUserId = v;
301             setModified(true);
302         }
303     
304                                                                                   
305                 if (aScarabUserRelatedByOldUserId != null && !ObjectUtils.equals(aScarabUserRelatedByOldUserId.getUserId(), v))
306                 {
307             aScarabUserRelatedByOldUserId = null;
308         }
309       
310               }
311   
312     /**
313      * Get the NewUserId
314      *
315      * @return Integer
316      */

317     public Integer JavaDoc getNewUserId()
318     {
319         return newUserId;
320     }
321
322                               
323     /**
324      * Set the value of NewUserId
325      *
326      * @param v new value
327      */

328     public void setNewUserId(Integer JavaDoc v) throws TorqueException
329     {
330     
331                   if (!ObjectUtils.equals(this.newUserId, v))
332               {
333             this.newUserId = v;
334             setModified(true);
335         }
336     
337                                                                                   
338                 if (aScarabUserRelatedByNewUserId != null && !ObjectUtils.equals(aScarabUserRelatedByNewUserId.getUserId(), v))
339                 {
340             aScarabUserRelatedByNewUserId = null;
341         }
342       
343               }
344   
345     /**
346      * Get the OldOptionId
347      *
348      * @return Integer
349      */

350     public Integer JavaDoc getOldOptionId()
351     {
352         return oldOptionId;
353     }
354
355                               
356     /**
357      * Set the value of OldOptionId
358      *
359      * @param v new value
360      */

361     public void setOldOptionId(Integer JavaDoc v) throws TorqueException
362     {
363     
364                   if (!ObjectUtils.equals(this.oldOptionId, v))
365               {
366             this.oldOptionId = v;
367             setModified(true);
368         }
369     
370                                                                           
371                 if (aAttributeOptionRelatedByOldOptionId != null && !ObjectUtils.equals(aAttributeOptionRelatedByOldOptionId.getOptionId(), v))
372                 {
373             aAttributeOptionRelatedByOldOptionId = null;
374         }
375       
376               }
377   
378     /**
379      * Get the NewOptionId
380      *
381      * @return Integer
382      */

383     public Integer JavaDoc getNewOptionId()
384     {
385         return newOptionId;
386     }
387
388                               
389     /**
390      * Set the value of NewOptionId
391      *
392      * @param v new value
393      */

394     public void setNewOptionId(Integer JavaDoc v) throws TorqueException
395     {
396     
397                   if (!ObjectUtils.equals(this.newOptionId, v))
398               {
399             this.newOptionId = v;
400             setModified(true);
401         }
402     
403                                                                           
404                 if (aAttributeOptionRelatedByNewOptionId != null && !ObjectUtils.equals(aAttributeOptionRelatedByNewOptionId.getOptionId(), v))
405                 {
406             aAttributeOptionRelatedByNewOptionId = null;
407         }
408       
409               }
410   
411     /**
412      * Get the OldValue
413      *
414      * @return String
415      */

416     public String JavaDoc getOldValue()
417     {
418         return oldValue;
419     }
420
421                         
422     /**
423      * Set the value of OldValue
424      *
425      * @param v new value
426      */

427     public void setOldValue(String JavaDoc v)
428     {
429     
430                   if (!ObjectUtils.equals(this.oldValue, v))
431               {
432             this.oldValue = v;
433             setModified(true);
434         }
435     
436           
437               }
438   
439     /**
440      * Get the NewValue
441      *
442      * @return String
443      */

444     public String JavaDoc getNewValue()
445     {
446         return newValue;
447     }
448
449                         
450     /**
451      * Set the value of NewValue
452      *
453      * @param v new value
454      */

455     public void setNewValue(String JavaDoc v)
456     {
457     
458                   if (!ObjectUtils.equals(this.newValue, v))
459               {
460             this.newValue = v;
461             setModified(true);
462         }
463     
464           
465               }
466   
467     /**
468      * Get the DependId
469      *
470      * @return Integer
471      */

472     public Integer JavaDoc getDependId()
473     {
474         return dependId;
475     }
476
477                               
478     /**
479      * Set the value of DependId
480      *
481      * @param v new value
482      */

483     public void setDependId(Integer JavaDoc v) throws TorqueException
484     {
485     
486                   if (!ObjectUtils.equals(this.dependId, v))
487               {
488             this.dependId = v;
489             setModified(true);
490         }
491     
492                                   
493                 if (aDepend != null && !ObjectUtils.equals(aDepend.getDependId(), v))
494                 {
495             aDepend = null;
496         }
497       
498               }
499   
500     /**
501      * Get the Description
502      *
503      * @return String
504      */

505     public String JavaDoc getDescription()
506     {
507         return description;
508     }
509
510                         
511     /**
512      * Set the value of Description
513      *
514      * @param v new value
515      */

516     public void setDescription(String JavaDoc v)
517     {
518     
519                   if (!ObjectUtils.equals(this.description, v))
520               {
521             this.description = v;
522             setModified(true);
523         }
524     
525           
526               }
527   
528     /**
529      * Get the EndDate
530      *
531      * @return Date
532      */

533     public Date JavaDoc getEndDate()
534     {
535         return endDate;
536     }
537
538                         
539     /**
540      * Set the value of EndDate
541      *
542      * @param v new value
543      */

544     public void setEndDate(Date JavaDoc v)
545     {
546     
547                   if (!ObjectUtils.equals(this.endDate, v))
548               {
549             this.endDate = v;
550             setModified(true);
551         }
552     
553           
554               }
555   
556     /**
557      * Get the AttachmentId
558      *
559      * @return Long
560      */

561     public Long JavaDoc getAttachmentId()
562     {
563         return attachmentId;
564     }
565
566                               
567     /**
568      * Set the value of AttachmentId
569      *
570      * @param v new value
571      */

572     public void setAttachmentId(Long JavaDoc v) throws TorqueException
573     {
574     
575                   if (!ObjectUtils.equals(this.attachmentId, v))
576               {
577             this.attachmentId = v;
578             setModified(true);
579         }
580     
581                                   
582                 if (aAttachment != null && !ObjectUtils.equals(aAttachment.getAttachmentId(), v))
583                 {
584             aAttachment = null;
585         }
586       
587               }
588   
589       
590         
591                   
592         private Issue aIssue;
593
594     /**
595      * Declares an association between this object and a Issue object
596      *
597      * @param v Issue
598      * @throws TorqueException
599      */

600     public void setIssue(Issue v) throws TorqueException
601     {
602             if (v == null)
603         {
604                   setIssueId((Long JavaDoc) null);
605               }
606         else
607         {
608             setIssueId(v.getIssueId());
609         }
610             aIssue = v;
611     }
612
613                         
614     /**
615      * Get the associated Issue object
616      *
617      * @return the associated Issue object
618      * @throws TorqueException
619      */

620     public Issue getIssue() throws TorqueException
621     {
622         if ( !ObjectUtils.equals(getIssueId(), null) )
623         {
624                 return IssueManager.getInstance(SimpleKey.keyFor(getIssueId()));
625             }
626         return aIssue;
627     }
628
629     /**
630      * Provides convenient way to set a relationship based on a
631      * ObjectKey, for example
632      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
633      *
634          */

635     public void setIssueKey(ObjectKey key) throws TorqueException
636     {
637     
638                     setIssueId(new Long JavaDoc(((NumberKey) key).longValue()));
639               }
640   
641         
642                   
643         private Attribute aAttribute;
644
645     /**
646      * Declares an association between this object and a Attribute object
647      *
648      * @param v Attribute
649      * @throws TorqueException
650      */

651     public void setAttribute(Attribute v) throws TorqueException
652     {
653             if (v == null)
654         {
655                   setAttributeId((Integer JavaDoc) null);
656               }
657         else
658         {
659             setAttributeId(v.getAttributeId());
660         }
661             aAttribute = v;
662     }
663
664                         
665     /**
666      * Get the associated Attribute object
667      *
668      * @return the associated Attribute object
669      * @throws TorqueException
670      */

671     public Attribute getAttribute() throws TorqueException
672     {
673         if ( !ObjectUtils.equals(getAttributeId(), null) )
674         {
675                 return AttributeManager.getInstance(SimpleKey.keyFor(getAttributeId()));
676             }
677         return aAttribute;
678     }
679
680     /**
681      * Provides convenient way to set a relationship based on a
682      * ObjectKey, for example
683      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
684      *
685          */

686     public void setAttributeKey(ObjectKey key) throws TorqueException
687     {
688     
689                     setAttributeId(new Integer JavaDoc(((NumberKey) key).intValue()));
690               }
691   
692         
693                   
694         private ActivitySet aActivitySet;
695
696     /**
697      * Declares an association between this object and a ActivitySet object
698      *
699      * @param v ActivitySet
700      * @throws TorqueException
701      */

702     public void setActivitySet(ActivitySet v) throws TorqueException
703     {
704             if (v == null)
705         {
706                   setTransactionId((Long JavaDoc) null);
707               }
708         else
709         {
710             setTransactionId(v.getActivitySetId());
711         }
712             aActivitySet = v;
713     }
714
715                         
716     /**
717      * Get the associated ActivitySet object
718      *
719      * @return the associated ActivitySet object
720      * @throws TorqueException
721      */

722     public ActivitySet getActivitySet() throws TorqueException
723     {
724         if ( !ObjectUtils.equals(getTransactionId(), null) )
725         {
726                 return ActivitySetManager.getInstance(SimpleKey.keyFor(getTransactionId()));
727             }
728         return aActivitySet;
729     }
730
731     /**
732      * Provides convenient way to set a relationship based on a
733      * ObjectKey, for example
734      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
735      *
736          */

737     public void setActivitySetKey(ObjectKey key) throws TorqueException
738     {
739     
740                     setTransactionId(new Long JavaDoc(((NumberKey) key).longValue()));
741               }
742   
743             
744                         
745             private ScarabUser aScarabUserRelatedByOldUserId;
746
747     /**
748      * Declares an association between this object and a ScarabUser object
749      *
750      * @param v ScarabUser
751      * @throws TorqueException
752      */

753     public void setScarabUserRelatedByOldUserId(ScarabUser v) throws TorqueException
754     {
755             if (v == null)
756         {
757                   setOldUserId((Integer JavaDoc) null);
758               }
759         else
760         {
761             setOldUserId(v.getUserId());
762         }
763             aScarabUserRelatedByOldUserId = v;
764     }
765
766                         
767     /**
768      * Get the associated ScarabUser object
769      *
770      * @return the associated ScarabUser object
771      * @throws TorqueException
772      */

773     public ScarabUser getScarabUserRelatedByOldUserId() throws TorqueException
774     {
775         if ( !ObjectUtils.equals(getOldUserId(), null) )
776         {
777                 return ScarabUserManager.getInstance(SimpleKey.keyFor(getOldUserId()));
778             }
779         return aScarabUserRelatedByOldUserId;
780     }
781
782     /**
783      * Provides convenient way to set a relationship based on a
784      * ObjectKey, for example
785      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
786      *
787          */

788     public void setScarabUserRelatedByOldUserIdKey(ObjectKey key) throws TorqueException
789     {
790     
791                     setOldUserId(new Integer JavaDoc(((NumberKey) key).intValue()));
792               }
793   
794             
795                         
796             private ScarabUser aScarabUserRelatedByNewUserId;
797
798     /**
799      * Declares an association between this object and a ScarabUser object
800      *
801      * @param v ScarabUser
802      * @throws TorqueException
803      */

804     public void setScarabUserRelatedByNewUserId(ScarabUser v) throws TorqueException
805     {
806             if (v == null)
807         {
808                   setNewUserId((Integer JavaDoc) null);
809               }
810         else
811         {
812             setNewUserId(v.getUserId());
813         }
814             aScarabUserRelatedByNewUserId = v;
815     }
816
817                         
818     /**
819      * Get the associated ScarabUser object
820      *
821      * @return the associated ScarabUser object
822      * @throws TorqueException
823      */

824     public ScarabUser getScarabUserRelatedByNewUserId() throws TorqueException
825     {
826         if ( !ObjectUtils.equals(getNewUserId(), null) )
827         {
828                 return ScarabUserManager.getInstance(SimpleKey.keyFor(getNewUserId()));
829             }
830         return aScarabUserRelatedByNewUserId;
831     }
832
833     /**
834      * Provides convenient way to set a relationship based on a
835      * ObjectKey, for example
836      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
837      *
838          */

839     public void setScarabUserRelatedByNewUserIdKey(ObjectKey key) throws TorqueException
840     {
841     
842                     setNewUserId(new Integer JavaDoc(((NumberKey) key).intValue()));
843               }
844   
845         
846                         
847             private AttributeOption aAttributeOptionRelatedByOldOptionId;
848
849     /**
850      * Declares an association between this object and a AttributeOption object
851      *
852      * @param v AttributeOption
853      * @throws TorqueException
854      */

855     public void setAttributeOptionRelatedByOldOptionId(AttributeOption v) throws TorqueException
856     {
857             if (v == null)
858         {
859                   setOldOptionId((Integer JavaDoc) null);
860               }
861         else
862         {
863             setOldOptionId(v.getOptionId());
864         }
865             aAttributeOptionRelatedByOldOptionId = v;
866     }
867
868                         
869     /**
870      * Get the associated AttributeOption object
871      *
872      * @return the associated AttributeOption object
873      * @throws TorqueException
874      */

875     public AttributeOption getAttributeOptionRelatedByOldOptionId() throws TorqueException
876     {
877         if ( !ObjectUtils.equals(getOldOptionId(), null) )
878         {
879                 return AttributeOptionManager.getInstance(SimpleKey.keyFor(getOldOptionId()));
880             }
881         return aAttributeOptionRelatedByOldOptionId;
882     }
883
884     /**
885      * Provides convenient way to set a relationship based on a
886      * ObjectKey, for example
887      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
888      *
889          */

890     public void setAttributeOptionRelatedByOldOptionIdKey(ObjectKey key) throws TorqueException
891     {
892     
893                     setOldOptionId(new Integer JavaDoc(((NumberKey) key).intValue()));
894               }
895   
896         
897                         
898             private AttributeOption aAttributeOptionRelatedByNewOptionId;
899
900     /**
901      * Declares an association between this object and a AttributeOption object
902      *
903      * @param v AttributeOption
904      * @throws TorqueException
905      */

906     public void setAttributeOptionRelatedByNewOptionId(AttributeOption v) throws TorqueException
907     {
908             if (v == null)
909         {
910                   setNewOptionId((Integer JavaDoc) null);
911               }
912         else
913         {
914             setNewOptionId(v.getOptionId());
915         }
916             aAttributeOptionRelatedByNewOptionId = v;
917     }
918
919                         
920     /**
921      * Get the associated AttributeOption object
922      *
923      * @return the associated AttributeOption object
924      * @throws TorqueException
925      */

926     public AttributeOption getAttributeOptionRelatedByNewOptionId() throws TorqueException
927     {
928         if ( !ObjectUtils.equals(getNewOptionId(), null) )
929         {
930                 return AttributeOptionManager.getInstance(SimpleKey.keyFor(getNewOptionId()));
931             }
932         return aAttributeOptionRelatedByNewOptionId;
933     }
934
935     /**
936      * Provides convenient way to set a relationship based on a
937      * ObjectKey, for example
938      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
939      *
940          */

941     public void setAttributeOptionRelatedByNewOptionIdKey(ObjectKey key) throws TorqueException
942     {
943     
944                     setNewOptionId(new Integer JavaDoc(((NumberKey) key).intValue()));
945               }
946   
947         
948                   
949         private Attachment aAttachment;
950
951     /**
952      * Declares an association between this object and a Attachment object
953      *
954      * @param v Attachment
955      * @throws TorqueException
956      */

957     public void setAttachment(Attachment v) throws TorqueException
958     {
959             if (v == null)
960         {
961                   setAttachmentId((Long JavaDoc) null);
962               }
963         else
964         {
965             setAttachmentId(v.getAttachmentId());
966         }
967             aAttachment = v;
968     }
969
970                         
971     /**
972      * Get the associated Attachment object
973      *
974      * @return the associated Attachment object
975      * @throws TorqueException
976      */

977     public Attachment getAttachment() throws TorqueException
978     {
979         if ( !ObjectUtils.equals(getAttachmentId(), null) )
980         {
981                 return AttachmentManager.getInstance(SimpleKey.keyFor(getAttachmentId()));
982             }
983         return aAttachment;
984     }
985
986     /**
987      * Provides convenient way to set a relationship based on a
988      * ObjectKey, for example
989      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
990      *
991          */

992     public void setAttachmentKey(ObjectKey key) throws TorqueException
993     {
994     
995                     setAttachmentId(new Long JavaDoc(((NumberKey) key).longValue()));
996               }
997   
998         
999                   
1000        private Depend aDepend;
1001
1002    /**
1003     * Declares an association between this object and a Depend object
1004     *
1005     * @param v Depend
1006     * @throws TorqueException
1007     */

1008    public void setDepend(Depend v) throws TorqueException
1009    {
1010            if (v == null)
1011        {
1012                  setDependId((Integer JavaDoc) null);
1013              }
1014        else
1015        {
1016            setDependId(v.getDependId());
1017        }
1018            aDepend = v;
1019    }
1020
1021                        
1022    /**
1023     * Get the associated Depend object
1024     *
1025     * @return the associated Depend object
1026     * @throws TorqueException
1027     */

1028    public Depend getDepend() throws TorqueException
1029    {
1030        if ( !ObjectUtils.equals(getDependId(), null) )
1031        {
1032                return DependManager.getInstance(SimpleKey.keyFor(getDependId()));
1033            }
1034        return aDepend;
1035    }
1036
1037    /**
1038     * Provides convenient way to set a relationship based on a
1039     * ObjectKey, for example
1040     * <code>bar.setFooKey(foo.getPrimaryKey())</code>
1041     *
1042         */

1043    public void setDependKey(ObjectKey key) throws TorqueException
1044    {
1045    
1046                    setDependId(new Integer JavaDoc(((NumberKey) key).intValue()));
1047              }
1048     
1049                
1050    private static List JavaDoc fieldNames = null;
1051
1052    /**
1053     * Generate a list of field names.
1054     *
1055     * @return a list of field names
1056     */

1057    public static synchronized List JavaDoc getFieldNames()
1058    {
1059        if (fieldNames == null)
1060        {
1061            fieldNames = new ArrayList JavaDoc();
1062              fieldNames.add("ActivityId");
1063              fieldNames.add("IssueId");
1064              fieldNames.add("AttributeId");
1065              fieldNames.add("TransactionId");
1066              fieldNames.add("OldNumericValue");
1067              fieldNames.add("NewNumericValue");
1068              fieldNames.add("OldUserId");
1069              fieldNames.add("NewUserId");
1070              fieldNames.add("OldOptionId");
1071              fieldNames.add("NewOptionId");
1072              fieldNames.add("OldValue");
1073              fieldNames.add("NewValue");
1074              fieldNames.add("DependId");
1075              fieldNames.add("Description");
1076              fieldNames.add("EndDate");
1077              fieldNames.add("AttachmentId");
1078              fieldNames = Collections.unmodifiableList(fieldNames);
1079        }
1080        return fieldNames;
1081    }
1082
1083    /**
1084     * Retrieves a field from the object by name passed in as a String.
1085     *
1086     * @param name field name
1087     * @return value
1088     */

1089    public Object JavaDoc getByName(String JavaDoc name)
1090    {
1091          if (name.equals("ActivityId"))
1092        {
1093                return getActivityId();
1094            }
1095          if (name.equals("IssueId"))
1096        {
1097                return getIssueId();
1098            }
1099          if (name.equals("AttributeId"))
1100        {
1101                return getAttributeId();
1102            }
1103          if (name.equals("TransactionId"))
1104        {
1105                return getTransactionId();
1106            }
1107          if (name.equals("OldNumericValue"))
1108        {
1109                return getOldNumericValue();
1110            }
1111          if (name.equals("NewNumericValue"))
1112        {
1113                return getNewNumericValue();
1114            }
1115          if (name.equals("OldUserId"))
1116        {
1117                return getOldUserId();
1118            }
1119          if (name.equals("NewUserId"))
1120        {
1121                return getNewUserId();
1122            }
1123          if (name.equals("OldOptionId"))
1124        {
1125                return getOldOptionId();
1126            }
1127          if (name.equals("NewOptionId"))
1128        {
1129                return getNewOptionId();
1130            }
1131          if (name.equals("OldValue"))
1132        {
1133                return getOldValue();
1134            }
1135          if (name.equals("NewValue"))
1136        {
1137                return getNewValue();
1138            }
1139          if (name.equals("DependId"))
1140        {
1141                return getDependId();
1142            }
1143          if (name.equals("Description"))
1144        {
1145                return getDescription();
1146            }
1147          if (name.equals("EndDate"))
1148        {
1149                return getEndDate();
1150            }
1151          if (name.equals("AttachmentId"))
1152        {
1153                return getAttachmentId();
1154            }
1155          return null;
1156    }
1157    
1158    /**
1159     * Retrieves a field from the object by name passed in
1160     * as a String. The String must be one of the static
1161     * Strings defined in this Class' Peer.
1162     *
1163     * @param name peer name
1164     * @return value
1165     */

1166    public Object JavaDoc getByPeerName(String JavaDoc name)
1167    {
1168          if (name.equals(ActivityPeer.ACTIVITY_ID))
1169        {
1170                return getActivityId();
1171            }
1172          if (name.equals(ActivityPeer.ISSUE_ID))
1173        {
1174                return getIssueId();
1175            }
1176          if (name.equals(ActivityPeer.ATTRIBUTE_ID))
1177        {
1178                return getAttributeId();
1179            }
1180          if (name.equals(ActivityPeer.TRANSACTION_ID))
1181        {
1182                return getTransactionId();
1183            }
1184          if (name.equals(ActivityPeer.OLD_NUMERIC_VALUE))
1185        {
1186                return getOldNumericValue();
1187            }
1188          if (name.equals(ActivityPeer.NEW_NUMERIC_VALUE))
1189        {
1190                return getNewNumericValue();
1191            }
1192          if (name.equals(ActivityPeer.OLD_USER_ID))
1193        {
1194                return getOldUserId();
1195            }
1196          if (name.equals(ActivityPeer.NEW_USER_ID))
1197        {
1198                return getNewUserId();
1199            }
1200          if (name.equals(ActivityPeer.OLD_OPTION_ID))
1201        {
1202                return getOldOptionId();
1203            }
1204          if (name.equals(ActivityPeer.NEW_OPTION_ID))
1205        {
1206                return getNewOptionId();
1207            }
1208          if (name.equals(ActivityPeer.OLD_VALUE))
1209        {
1210                return getOldValue();
1211            }
1212          if (name.equals(ActivityPeer.NEW_VALUE))
1213        {
1214                return getNewValue();
1215            }
1216          if (name.equals(ActivityPeer.DEPEND_ID))
1217        {
1218                return getDependId();
1219            }
1220          if (name.equals(ActivityPeer.DESCRIPTION))
1221        {
1222                return getDescription();
1223            }
1224          if (name.equals(ActivityPeer.END_DATE))
1225        {
1226                return getEndDate();
1227            }
1228          if (name.equals(ActivityPeer.ATTACHMENT_ID))
1229        {
1230                return getAttachmentId();
1231            }
1232          return null;
1233    }
1234
1235    /**
1236     * Retrieves a field from the object by Position as specified
1237     * in the xml schema. Zero-based.
1238     *
1239     * @param pos position in xml schema
1240     * @return value
1241     */

1242    public Object JavaDoc getByPosition(int pos)
1243    {
1244            if (pos == 0)
1245        {
1246                return getActivityId();
1247            }
1248              if (pos == 1)
1249        {
1250                return getIssueId();
1251            }
1252              if (pos == 2)
1253        {
1254                return getAttributeId();
1255            }
1256              if (pos == 3)
1257        {
1258                return getTransactionId();
1259            }
1260              if (pos == 4)
1261        {
1262                return getOldNumericValue();
1263            }
1264              if (pos == 5)
1265        {
1266                return getNewNumericValue();
1267            }
1268              if (pos == 6)
1269        {
1270                return getOldUserId();
1271            }
1272              if (pos == 7)
1273        {
1274                return getNewUserId();
1275            }
1276              if (pos == 8)
1277        {
1278                return getOldOptionId();
1279            }
1280              if (pos == 9)
1281        {
1282                return getNewOptionId();
1283            }
1284              if (pos == 10)
1285        {
1286                return getOldValue();
1287            }
1288              if (pos == 11)
1289        {
1290                return getNewValue();
1291            }
1292              if (pos == 12)
1293        {
1294                return getDependId();
1295            }
1296              if (pos == 13)
1297        {
1298                return getDescription();
1299            }
1300              if (pos == 14)
1301        {
1302                return getEndDate();
1303            }
1304              if (pos == 15)
1305        {
1306                return getAttachmentId();
1307            }
1308              return null;
1309    }
1310     
1311    /**
1312     * Stores the object in the database. If the object is new,
1313     * it inserts it; otherwise an update is performed.
1314     *
1315     * @throws Exception
1316     */

1317    public void save() throws Exception JavaDoc
1318    {
1319          save(ActivityPeer.getMapBuilder()
1320                .getDatabaseMap().getName());
1321      }
1322
1323    /**
1324     * Stores the object in the database. If the object is new,
1325     * it inserts it; otherwise an update is performed.
1326       * Note: this code is here because the method body is
1327     * auto-generated conditionally and therefore needs to be
1328     * in this file instead of in the super class, BaseObject.
1329       *
1330     * @param dbName
1331     * @throws TorqueException
1332     */

1333    public void save(String JavaDoc dbName) throws TorqueException
1334    {
1335        Connection JavaDoc con = null;
1336          try
1337        {
1338            con = Transaction.begin(dbName);
1339            save(con);
1340            Transaction.commit(con);
1341        }
1342        catch(TorqueException e)
1343        {
1344            Transaction.safeRollback(con);
1345            throw e;
1346        }
1347      }
1348
1349      /** flag to prevent endless save loop, if this object is referenced
1350        by another object which falls in this transaction. */

1351    private boolean alreadyInSave = false;
1352      /**
1353     * Stores the object in the database. If the object is new,
1354     * it inserts it; otherwise an update is performed. This method
1355     * is meant to be used as part of a transaction, otherwise use
1356     * the save() method and the connection details will be handled
1357     * internally
1358     *
1359     * @param con
1360     * @throws TorqueException
1361     */

1362    public void save(Connection JavaDoc con) throws TorqueException
1363    {
1364          if (!alreadyInSave)
1365        {
1366            alreadyInSave = true;
1367
1368
1369  
1370            // If this object has been modified, then save it to the database.
1371
if (isModified())
1372            {
1373                if (isNew())
1374                {
1375                    ActivityPeer.doInsert((Activity)this, con);
1376                    setNew(false);
1377                }
1378                else
1379                {
1380                    ActivityPeer.doUpdate((Activity)this, con);
1381                }
1382
1383                      if (isCacheOnSave())
1384                {
1385                    ActivityManager.putInstance(this);
1386                }
1387              }
1388
1389                      alreadyInSave = false;
1390        }
1391      }
1392
1393    /**
1394     * Specify whether to cache the object after saving to the db.
1395     * This method returns false
1396     */

1397    protected boolean isCacheOnSave()
1398    {
1399        return true;
1400    }
1401
1402                  
1403      /**
1404     * Set the PrimaryKey using ObjectKey.
1405     *
1406     * @param activityId ObjectKey
1407     */

1408    public void setPrimaryKey(ObjectKey activityId)
1409         {
1410            setActivityId(new Long JavaDoc(((NumberKey)activityId).longValue()));
1411        }
1412
1413    /**
1414     * Set the PrimaryKey using a String.
1415     *
1416     * @param key
1417     */

1418    public void setPrimaryKey(String JavaDoc key)
1419    {
1420            setActivityId(new Long JavaDoc(key));
1421        }
1422
1423  
1424    /**
1425     * returns an id that differentiates this object from others
1426     * of its class.
1427     */

1428    public ObjectKey getPrimaryKey()
1429    {
1430          return SimpleKey.keyFor(getActivityId());
1431      }
1432 
1433    /**
1434     * get an id that differentiates this object from others
1435     * of its class.
1436     */

1437    public String JavaDoc getQueryKey()
1438    {
1439        if (getPrimaryKey() == null)
1440        {
1441            return "";
1442        }
1443        else
1444        {
1445            return getPrimaryKey().toString();
1446        }
1447    }
1448
1449    /**
1450     * set an id that differentiates this object from others
1451     * of its class.
1452     */

1453    public void setQueryKey(String JavaDoc key)
1454        throws TorqueException
1455    {
1456        setPrimaryKey(key);
1457    }
1458
1459    /**
1460     * Makes a copy of this object.
1461     * It creates a new object filling in the simple attributes.
1462       * It then fills all the association collections and sets the
1463     * related objects to isNew=true.
1464       */

1465      public Activity copy() throws TorqueException
1466    {
1467        Activity copyObj = new Activity();
1468            copyObj.setActivityId(activityId);
1469          copyObj.setIssueId(issueId);
1470          copyObj.setAttributeId(attributeId);
1471          copyObj.setTransactionId(transactionId);
1472          copyObj.setOldNumericValue(oldNumericValue);
1473          copyObj.setNewNumericValue(newNumericValue);
1474          copyObj.setOldUserId(oldUserId);
1475          copyObj.setNewUserId(newUserId);
1476          copyObj.setOldOptionId(oldOptionId);
1477          copyObj.setNewOptionId(newOptionId);
1478          copyObj.setOldValue(oldValue);
1479          copyObj.setNewValue(newValue);
1480          copyObj.setDependId(dependId);
1481          copyObj.setDescription(description);
1482          copyObj.setEndDate(endDate);
1483          copyObj.setAttachmentId(attachmentId);
1484  
1485                      copyObj.setActivityId((Long JavaDoc)null);
1486                                                                                                      
1487                return copyObj;
1488    }
1489
1490    /**
1491     * returns a peer instance associated with this om. Since Peer classes
1492     * are not to have any instance attributes, this method returns the
1493     * same instance for all member of this class. The method could therefore
1494     * be static, but this would prevent one from overriding the behavior.
1495     */

1496    public ActivityPeer getPeer()
1497    {
1498        return peer;
1499    }
1500
1501    public String JavaDoc toString()
1502    {
1503        StringBuffer JavaDoc str = new StringBuffer JavaDoc();
1504        str.append("Activity:\n");
1505        str.append("ActivityId = ")
1506               .append(getActivityId())
1507             .append("\n");
1508        str.append("IssueId = ")
1509               .append(getIssueId())
1510             .append("\n");
1511        str.append("AttributeId = ")
1512               .append(getAttributeId())
1513             .append("\n");
1514        str.append("TransactionId = ")
1515               .append(getTransactionId())
1516             .append("\n");
1517        str.append("OldNumericValue = ")
1518               .append(getOldNumericValue())
1519             .append("\n");
1520        str.append("NewNumericValue = ")
1521               .append(getNewNumericValue())
1522             .append("\n");
1523        str.append("OldUserId = ")
1524               .append(getOldUserId())
1525             .append("\n");
1526        str.append("NewUserId = ")
1527               .append(getNewUserId())
1528             .append("\n");
1529        str.append("OldOptionId = ")
1530               .append(getOldOptionId())
1531             .append("\n");
1532        str.append("NewOptionId = ")
1533               .append(getNewOptionId())
1534             .append("\n");
1535        str.append("OldValue = ")
1536               .append(getOldValue())
1537             .append("\n");
1538        str.append("NewValue = ")
1539               .append(getNewValue())
1540             .append("\n");
1541        str.append("DependId = ")
1542               .append(getDependId())
1543             .append("\n");
1544        str.append("Description = ")
1545               .append(getDescription())
1546             .append("\n");
1547        str.append("EndDate = ")
1548               .append(getEndDate())
1549             .append("\n");
1550        str.append("AttachmentId = ")
1551               .append(getAttachmentId())
1552             .append("\n");
1553        return(str.toString());
1554    }
1555}
1556
Popular Tags