KickJava   Java API By Example, From Geeks To Geeks.

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


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  * You should not use this class directly. It should not even be
32  * extended all references should be to Attachment
33  */

34 public abstract class BaseAttachment extends BaseObject
35     implements org.apache.fulcrum.intake.Retrievable
36 {
37     /** The Peer class */
38     private static final AttachmentPeer peer =
39         new AttachmentPeer();
40
41         
42     /** The value for the attachmentId field */
43     private Long JavaDoc attachmentId;
44       
45     /** The value for the issueId field */
46     private Long JavaDoc issueId;
47       
48     /** The value for the typeId field */
49     private Integer JavaDoc typeId;
50       
51     /** The value for the name field */
52     private String JavaDoc name;
53       
54     /** The value for the data field */
55     private String JavaDoc data;
56       
57     /** The value for the fileName field */
58     private String JavaDoc fileName;
59       
60     /** The value for the mimeType field */
61     private String JavaDoc mimeType;
62       
63     /** The value for the modifiedBy field */
64     private Integer JavaDoc modifiedBy;
65       
66     /** The value for the createdBy field */
67     private Integer JavaDoc createdBy;
68       
69     /** The value for the modifiedDate field */
70     private Date JavaDoc modifiedDate;
71       
72     /** The value for the createdDate field */
73     private Date JavaDoc createdDate;
74                                                                 
75     /** The value for the deleted field */
76     private boolean deleted = false;
77   
78     
79     /**
80      * Get the AttachmentId
81      *
82      * @return Long
83      */

84     public Long JavaDoc getAttachmentId()
85     {
86         return attachmentId;
87     }
88
89                                               
90     /**
91      * Set the value of AttachmentId
92      *
93      * @param v new value
94      */

95     public void setAttachmentId(Long JavaDoc v) throws TorqueException
96     {
97     
98                   if (!ObjectUtils.equals(this.attachmentId, v))
99               {
100             this.attachmentId = v;
101             setModified(true);
102         }
103     
104           
105                                   
106         // update associated Activity
107
if (collActivitys != null)
108         {
109             for (int i = 0; i < collActivitys.size(); i++)
110             {
111                 ((Activity) collActivitys.get(i))
112                         .setAttachmentId(v);
113             }
114         }
115                                           
116         // update associated ActivitySet
117
if (collActivitySets != null)
118         {
119             for (int i = 0; i < collActivitySets.size(); i++)
120             {
121                 ((ActivitySet) collActivitySets.get(i))
122                         .setAttachmentId(v);
123             }
124         }
125                       }
126   
127     /**
128      * Get the IssueId
129      *
130      * @return Long
131      */

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

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

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

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

198     public String JavaDoc getName()
199     {
200         return name;
201     }
202
203                         
204     /**
205      * Set the value of Name
206      *
207      * @param v new value
208      */

209     public void setName(String JavaDoc v)
210     {
211     
212                   if (!ObjectUtils.equals(this.name, v))
213               {
214             this.name = v;
215             setModified(true);
216         }
217     
218           
219               }
220   
221     /**
222      * Get the Data
223      *
224      * @return String
225      */

226     public String JavaDoc getData()
227     {
228         return data;
229     }
230
231                         
232     /**
233      * Set the value of Data
234      *
235      * @param v new value
236      */

237     public void setData(String JavaDoc v)
238     {
239     
240                   if (!ObjectUtils.equals(this.data, v))
241               {
242             this.data = v;
243             setModified(true);
244         }
245     
246           
247               }
248   
249     /**
250      * Get the FileName
251      *
252      * @return String
253      */

254     public String JavaDoc getFileName()
255     {
256         return fileName;
257     }
258
259                         
260     /**
261      * Set the value of FileName
262      *
263      * @param v new value
264      */

265     public void setFileName(String JavaDoc v)
266     {
267     
268                   if (!ObjectUtils.equals(this.fileName, v))
269               {
270             this.fileName = v;
271             setModified(true);
272         }
273     
274           
275               }
276   
277     /**
278      * Get the MimeType
279      *
280      * @return String
281      */

282     public String JavaDoc getMimeType()
283     {
284         return mimeType;
285     }
286
287                         
288     /**
289      * Set the value of MimeType
290      *
291      * @param v new value
292      */

293     public void setMimeType(String JavaDoc v)
294     {
295     
296                   if (!ObjectUtils.equals(this.mimeType, v))
297               {
298             this.mimeType = v;
299             setModified(true);
300         }
301     
302           
303               }
304   
305     /**
306      * Get the ModifiedBy
307      *
308      * @return Integer
309      */

310     public Integer JavaDoc getModifiedBy()
311     {
312         return modifiedBy;
313     }
314
315                               
316     /**
317      * Set the value of ModifiedBy
318      *
319      * @param v new value
320      */

321     public void setModifiedBy(Integer JavaDoc v) throws TorqueException
322     {
323     
324                   if (!ObjectUtils.equals(this.modifiedBy, v))
325               {
326             this.modifiedBy = v;
327             setModified(true);
328         }
329     
330                                                                                   
331                 if (aScarabUserRelatedByModifiedBy != null && !ObjectUtils.equals(aScarabUserRelatedByModifiedBy.getUserId(), v))
332                 {
333             aScarabUserRelatedByModifiedBy = null;
334         }
335       
336               }
337   
338     /**
339      * Get the CreatedBy
340      *
341      * @return Integer
342      */

343     public Integer JavaDoc getCreatedBy()
344     {
345         return createdBy;
346     }
347
348                               
349     /**
350      * Set the value of CreatedBy
351      *
352      * @param v new value
353      */

354     public void setCreatedBy(Integer JavaDoc v) throws TorqueException
355     {
356     
357                   if (!ObjectUtils.equals(this.createdBy, v))
358               {
359             this.createdBy = v;
360             setModified(true);
361         }
362     
363                                                                                   
364                 if (aScarabUserRelatedByCreatedBy != null && !ObjectUtils.equals(aScarabUserRelatedByCreatedBy.getUserId(), v))
365                 {
366             aScarabUserRelatedByCreatedBy = null;
367         }
368       
369               }
370   
371     /**
372      * Get the ModifiedDate
373      *
374      * @return Date
375      */

376     public Date JavaDoc getModifiedDate()
377     {
378         return modifiedDate;
379     }
380
381                         
382     /**
383      * Set the value of ModifiedDate
384      *
385      * @param v new value
386      */

387     public void setModifiedDate(Date JavaDoc v)
388     {
389     
390                   if (!ObjectUtils.equals(this.modifiedDate, v))
391               {
392             this.modifiedDate = v;
393             setModified(true);
394         }
395     
396           
397               }
398   
399     /**
400      * Get the CreatedDate
401      *
402      * @return Date
403      */

404     public Date JavaDoc getCreatedDate()
405     {
406         return createdDate;
407     }
408
409                         
410     /**
411      * Set the value of CreatedDate
412      *
413      * @param v new value
414      */

415     public void setCreatedDate(Date JavaDoc v)
416     {
417     
418                   if (!ObjectUtils.equals(this.createdDate, v))
419               {
420             this.createdDate = v;
421             setModified(true);
422         }
423     
424           
425               }
426   
427     /**
428      * Get the Deleted
429      *
430      * @return boolean
431      */

432     public boolean getDeleted()
433     {
434         return deleted;
435     }
436
437                         
438     /**
439      * Set the value of Deleted
440      *
441      * @param v new value
442      */

443     public void setDeleted(boolean v)
444     {
445     
446                   if (this.deleted != v)
447               {
448             this.deleted = v;
449             setModified(true);
450         }
451     
452           
453               }
454   
455       
456         
457                   
458         private Issue aIssue;
459
460     /**
461      * Declares an association between this object and a Issue object
462      *
463      * @param v Issue
464      * @throws TorqueException
465      */

466     public void setIssue(Issue v) throws TorqueException
467     {
468             if (v == null)
469         {
470                   setIssueId((Long JavaDoc) null);
471               }
472         else
473         {
474             setIssueId(v.getIssueId());
475         }
476             aIssue = v;
477     }
478
479                         
480     /**
481      * Get the associated Issue object
482      *
483      * @return the associated Issue object
484      * @throws TorqueException
485      */

486     public Issue getIssue() throws TorqueException
487     {
488         if ( !ObjectUtils.equals(getIssueId(), null) )
489         {
490                 return IssueManager.getInstance(SimpleKey.keyFor(getIssueId()));
491             }
492         return aIssue;
493     }
494
495     /**
496      * Provides convenient way to set a relationship based on a
497      * ObjectKey, for example
498      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
499      *
500          */

501     public void setIssueKey(ObjectKey key) throws TorqueException
502     {
503     
504                     setIssueId(new Long JavaDoc(((NumberKey) key).longValue()));
505               }
506   
507         
508                   
509         private AttachmentType aAttachmentType;
510
511     /**
512      * Declares an association between this object and a AttachmentType object
513      *
514      * @param v AttachmentType
515      * @throws TorqueException
516      */

517     public void setAttachmentType(AttachmentType v) throws TorqueException
518     {
519             if (v == null)
520         {
521                   setTypeId((Integer JavaDoc) null);
522               }
523         else
524         {
525             setTypeId(v.getAttachmentTypeId());
526         }
527             aAttachmentType = v;
528     }
529
530                         
531     /**
532      * Get the associated AttachmentType object
533      *
534      * @return the associated AttachmentType object
535      * @throws TorqueException
536      */

537     public AttachmentType getAttachmentType() throws TorqueException
538     {
539         if ( !ObjectUtils.equals(getTypeId(), null) )
540         {
541                 return AttachmentTypeManager.getInstance(SimpleKey.keyFor(getTypeId()));
542             }
543         return aAttachmentType;
544     }
545
546     /**
547      * Provides convenient way to set a relationship based on a
548      * ObjectKey, for example
549      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
550      *
551          */

552     public void setAttachmentTypeKey(ObjectKey key) throws TorqueException
553     {
554     
555                     setTypeId(new Integer JavaDoc(((NumberKey) key).intValue()));
556               }
557   
558             
559                         
560             private ScarabUser aScarabUserRelatedByCreatedBy;
561
562     /**
563      * Declares an association between this object and a ScarabUser object
564      *
565      * @param v ScarabUser
566      * @throws TorqueException
567      */

568     public void setScarabUserRelatedByCreatedBy(ScarabUser v) throws TorqueException
569     {
570             if (v == null)
571         {
572                   setCreatedBy((Integer JavaDoc) null);
573               }
574         else
575         {
576             setCreatedBy(v.getUserId());
577         }
578             aScarabUserRelatedByCreatedBy = v;
579     }
580
581                         
582     /**
583      * Get the associated ScarabUser object
584      *
585      * @return the associated ScarabUser object
586      * @throws TorqueException
587      */

588     public ScarabUser getScarabUserRelatedByCreatedBy() throws TorqueException
589     {
590         if ( !ObjectUtils.equals(getCreatedBy(), null) )
591         {
592                 return ScarabUserManager.getInstance(SimpleKey.keyFor(getCreatedBy()));
593             }
594         return aScarabUserRelatedByCreatedBy;
595     }
596
597     /**
598      * Provides convenient way to set a relationship based on a
599      * ObjectKey, for example
600      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
601      *
602          */

603     public void setScarabUserRelatedByCreatedByKey(ObjectKey key) throws TorqueException
604     {
605     
606                     setCreatedBy(new Integer JavaDoc(((NumberKey) key).intValue()));
607               }
608   
609             
610                         
611             private ScarabUser aScarabUserRelatedByModifiedBy;
612
613     /**
614      * Declares an association between this object and a ScarabUser object
615      *
616      * @param v ScarabUser
617      * @throws TorqueException
618      */

619     public void setScarabUserRelatedByModifiedBy(ScarabUser v) throws TorqueException
620     {
621             if (v == null)
622         {
623                   setModifiedBy((Integer JavaDoc) null);
624               }
625         else
626         {
627             setModifiedBy(v.getUserId());
628         }
629             aScarabUserRelatedByModifiedBy = v;
630     }
631
632                         
633     /**
634      * Get the associated ScarabUser object
635      *
636      * @return the associated ScarabUser object
637      * @throws TorqueException
638      */

639     public ScarabUser getScarabUserRelatedByModifiedBy() throws TorqueException
640     {
641         if ( !ObjectUtils.equals(getModifiedBy(), null) )
642         {
643                 return ScarabUserManager.getInstance(SimpleKey.keyFor(getModifiedBy()));
644             }
645         return aScarabUserRelatedByModifiedBy;
646     }
647
648     /**
649      * Provides convenient way to set a relationship based on a
650      * ObjectKey, for example
651      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
652      *
653          */

654     public void setScarabUserRelatedByModifiedByKey(ObjectKey key) throws TorqueException
655     {
656     
657                     setModifiedBy(new Integer JavaDoc(((NumberKey) key).intValue()));
658               }
659      
660                                 
661             
662     /**
663      * Collection to store aggregation of collActivitys
664      */

665     protected List JavaDoc collActivitys;
666
667     /**
668      * Temporary storage of collActivitys to save a possible db hit in
669      * the event objects are add to the collection, but the
670      * complete collection is never requested.
671      */

672     protected void initActivitys()
673     {
674         if (collActivitys == null)
675         {
676             collActivitys = new ArrayList JavaDoc();
677         }
678     }
679
680             
681     /**
682      * Method called to associate a Activity object to this object
683      * through the Activity foreign key attribute
684      *
685      * @param l Activity
686      * @throws TorqueException
687      */

688     public void addActivity(Activity l) throws TorqueException
689     {
690         getActivitys().add(l);
691         l.setAttachment((Attachment)this);
692     }
693
694     /**
695      * The criteria used to select the current contents of collActivitys
696      */

697     private Criteria lastActivitysCriteria = null;
698
699     /**
700      * If this collection has already been initialized, returns
701      * the collection. Otherwise returns the results of
702      * getActivitys(new Criteria())
703      *
704      * @throws TorqueException
705      */

706     public List JavaDoc getActivitys() throws TorqueException
707     {
708         if (collActivitys == null)
709         {
710             collActivitys = getActivitys(new Criteria(10));
711         }
712         return collActivitys;
713     }
714
715     /**
716      * If this collection has already been initialized with
717      * an identical criteria, it returns the collection.
718      * Otherwise if this Attachment has previously
719      * been saved, it will retrieve related Activitys from storage.
720      * If this Attachment is new, it will return
721      * an empty collection or the current collection, the criteria
722      * is ignored on a new object.
723      *
724      * @throws TorqueException
725      */

726     public List JavaDoc getActivitys(Criteria criteria) throws TorqueException
727     {
728         if (collActivitys == null)
729         {
730             if (isNew())
731             {
732                collActivitys = new ArrayList JavaDoc();
733             }
734             else
735             {
736                       criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
737                       collActivitys = ActivityPeer.doSelect(criteria);
738             }
739         }
740         else
741         {
742             // criteria has no effect for a new object
743
if (!isNew())
744             {
745                 // the following code is to determine if a new query is
746
// called for. If the criteria is the same as the last
747
// one, just return the collection.
748
criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
749                       if (!lastActivitysCriteria.equals(criteria))
750                 {
751                     collActivitys = ActivityPeer.doSelect(criteria);
752                 }
753             }
754         }
755         lastActivitysCriteria = criteria;
756
757         return collActivitys;
758     }
759
760     /**
761      * If this collection has already been initialized, returns
762      * the collection. Otherwise returns the results of
763      * getActivitys(new Criteria(),Connection)
764      * This method takes in the Connection also as input so that
765      * referenced objects can also be obtained using a Connection
766      * that is taken as input
767      */

768     public List JavaDoc getActivitys(Connection JavaDoc con) throws TorqueException
769     {
770         if (collActivitys == null)
771         {
772             collActivitys = getActivitys(new Criteria(10),con);
773         }
774         return collActivitys;
775     }
776
777     /**
778      * If this collection has already been initialized with
779      * an identical criteria, it returns the collection.
780      * Otherwise if this Attachment has previously
781      * been saved, it will retrieve related Activitys from storage.
782      * If this Attachment is new, it will return
783      * an empty collection or the current collection, the criteria
784      * is ignored on a new object.
785      * This method takes in the Connection also as input so that
786      * referenced objects can also be obtained using a Connection
787      * that is taken as input
788      */

789     public List JavaDoc getActivitys(Criteria criteria,Connection JavaDoc con) throws TorqueException
790     {
791         if (collActivitys == null)
792         {
793             if (isNew())
794             {
795                collActivitys = new ArrayList JavaDoc();
796             }
797             else
798             {
799                        criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
800                        collActivitys = ActivityPeer.doSelect(criteria,con);
801              }
802          }
803          else
804          {
805              // criteria has no effect for a new object
806
if (!isNew())
807              {
808                  // the following code is to determine if a new query is
809
// called for. If the criteria is the same as the last
810
// one, just return the collection.
811
criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
812                      if (!lastActivitysCriteria.equals(criteria))
813                  {
814                      collActivitys = ActivityPeer.doSelect(criteria,con);
815                  }
816              }
817          }
818          lastActivitysCriteria = criteria;
819
820          return collActivitys;
821      }
822
823                                                                   
824               
825                     
826                     
827                                 
828                                                               
829                                         
830                     
831                     
832           
833     /**
834      * If this collection has already been initialized with
835      * an identical criteria, it returns the collection.
836      * Otherwise if this Attachment is new, it will return
837      * an empty collection; or if this Attachment has previously
838      * been saved, it will retrieve related Activitys from storage.
839      *
840      * This method is protected by default in order to keep the public
841      * api reasonable. You can provide public methods for those you
842      * actually need in Attachment.
843      */

844     protected List JavaDoc getActivitysJoinIssue(Criteria criteria)
845         throws TorqueException
846     {
847         if (collActivitys == null)
848         {
849             if (isNew())
850             {
851                collActivitys = new ArrayList JavaDoc();
852             }
853             else
854             {
855                             criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
856                             collActivitys = ActivityPeer.doSelectJoinIssue(criteria);
857             }
858         }
859         else
860         {
861             // the following code is to determine if a new query is
862
// called for. If the criteria is the same as the last
863
// one, just return the collection.
864

865                             criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
866                         if (!lastActivitysCriteria.equals(criteria))
867             {
868                 collActivitys = ActivityPeer.doSelectJoinIssue(criteria);
869             }
870         }
871         lastActivitysCriteria = criteria;
872
873         return collActivitys;
874     }
875                   
876                     
877                     
878                                 
879                                                               
880                                         
881                     
882                     
883           
884     /**
885      * If this collection has already been initialized with
886      * an identical criteria, it returns the collection.
887      * Otherwise if this Attachment is new, it will return
888      * an empty collection; or if this Attachment has previously
889      * been saved, it will retrieve related Activitys from storage.
890      *
891      * This method is protected by default in order to keep the public
892      * api reasonable. You can provide public methods for those you
893      * actually need in Attachment.
894      */

895     protected List JavaDoc getActivitysJoinAttribute(Criteria criteria)
896         throws TorqueException
897     {
898         if (collActivitys == null)
899         {
900             if (isNew())
901             {
902                collActivitys = new ArrayList JavaDoc();
903             }
904             else
905             {
906                             criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
907                             collActivitys = ActivityPeer.doSelectJoinAttribute(criteria);
908             }
909         }
910         else
911         {
912             // the following code is to determine if a new query is
913
// called for. If the criteria is the same as the last
914
// one, just return the collection.
915

916                             criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
917                         if (!lastActivitysCriteria.equals(criteria))
918             {
919                 collActivitys = ActivityPeer.doSelectJoinAttribute(criteria);
920             }
921         }
922         lastActivitysCriteria = criteria;
923
924         return collActivitys;
925     }
926                   
927                     
928                     
929                                 
930                                                               
931                                         
932                     
933                     
934           
935     /**
936      * If this collection has already been initialized with
937      * an identical criteria, it returns the collection.
938      * Otherwise if this Attachment is new, it will return
939      * an empty collection; or if this Attachment has previously
940      * been saved, it will retrieve related Activitys from storage.
941      *
942      * This method is protected by default in order to keep the public
943      * api reasonable. You can provide public methods for those you
944      * actually need in Attachment.
945      */

946     protected List JavaDoc getActivitysJoinActivitySet(Criteria criteria)
947         throws TorqueException
948     {
949         if (collActivitys == null)
950         {
951             if (isNew())
952             {
953                collActivitys = new ArrayList JavaDoc();
954             }
955             else
956             {
957                             criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
958                             collActivitys = ActivityPeer.doSelectJoinActivitySet(criteria);
959             }
960         }
961         else
962         {
963             // the following code is to determine if a new query is
964
// called for. If the criteria is the same as the last
965
// one, just return the collection.
966

967                             criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
968                         if (!lastActivitysCriteria.equals(criteria))
969             {
970                 collActivitys = ActivityPeer.doSelectJoinActivitySet(criteria);
971             }
972         }
973         lastActivitysCriteria = criteria;
974
975         return collActivitys;
976     }
977                   
978                     
979                     
980                                             
981                                                                           
982                                         
983                     
984                     
985           
986     /**
987      * If this collection has already been initialized with
988      * an identical criteria, it returns the collection.
989      * Otherwise if this Attachment is new, it will return
990      * an empty collection; or if this Attachment has previously
991      * been saved, it will retrieve related Activitys from storage.
992      *
993      * This method is protected by default in order to keep the public
994      * api reasonable. You can provide public methods for those you
995      * actually need in Attachment.
996      */

997     protected List JavaDoc getActivitysJoinScarabUserImplRelatedByOldUserId(Criteria criteria)
998         throws TorqueException
999     {
1000        if (collActivitys == null)
1001        {
1002            if (isNew())
1003            {
1004               collActivitys = new ArrayList JavaDoc();
1005            }
1006            else
1007            {
1008                            criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
1009                            collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByOldUserId(criteria);
1010            }
1011        }
1012        else
1013        {
1014            // the following code is to determine if a new query is
1015
// called for. If the criteria is the same as the last
1016
// one, just return the collection.
1017

1018                            criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
1019                        if (!lastActivitysCriteria.equals(criteria))
1020            {
1021                collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByOldUserId(criteria);
1022            }
1023        }
1024        lastActivitysCriteria = criteria;
1025
1026        return collActivitys;
1027    }
1028                  
1029                    
1030                    
1031                                            
1032                                                                          
1033                                        
1034                    
1035                    
1036          
1037    /**
1038     * If this collection has already been initialized with
1039     * an identical criteria, it returns the collection.
1040     * Otherwise if this Attachment is new, it will return
1041     * an empty collection; or if this Attachment has previously
1042     * been saved, it will retrieve related Activitys from storage.
1043     *
1044     * This method is protected by default in order to keep the public
1045     * api reasonable. You can provide public methods for those you
1046     * actually need in Attachment.
1047     */

1048    protected List JavaDoc getActivitysJoinScarabUserImplRelatedByNewUserId(Criteria criteria)
1049        throws TorqueException
1050    {
1051        if (collActivitys == null)
1052        {
1053            if (isNew())
1054            {
1055               collActivitys = new ArrayList JavaDoc();
1056            }
1057            else
1058            {
1059                            criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
1060                            collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByNewUserId(criteria);
1061            }
1062        }
1063        else
1064        {
1065            // the following code is to determine if a new query is
1066
// called for. If the criteria is the same as the last
1067
// one, just return the collection.
1068

1069                            criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
1070                        if (!lastActivitysCriteria.equals(criteria))
1071            {
1072                collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByNewUserId(criteria);
1073            }
1074        }
1075        lastActivitysCriteria = criteria;
1076
1077        return collActivitys;
1078    }
1079                  
1080                    
1081                    
1082                                            
1083                                                                          
1084                                        
1085                    
1086                    
1087          
1088    /**
1089     * If this collection has already been initialized with
1090     * an identical criteria, it returns the collection.
1091     * Otherwise if this Attachment is new, it will return
1092     * an empty collection; or if this Attachment has previously
1093     * been saved, it will retrieve related Activitys from storage.
1094     *
1095     * This method is protected by default in order to keep the public
1096     * api reasonable. You can provide public methods for those you
1097     * actually need in Attachment.
1098     */

1099    protected List JavaDoc getActivitysJoinAttributeOptionRelatedByOldOptionId(Criteria criteria)
1100        throws TorqueException
1101    {
1102        if (collActivitys == null)
1103        {
1104            if (isNew())
1105            {
1106               collActivitys = new ArrayList JavaDoc();
1107            }
1108            else
1109            {
1110                            criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
1111                            collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByOldOptionId(criteria);
1112            }
1113        }
1114        else
1115        {
1116            // the following code is to determine if a new query is
1117
// called for. If the criteria is the same as the last
1118
// one, just return the collection.
1119

1120                            criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
1121                        if (!lastActivitysCriteria.equals(criteria))
1122            {
1123                collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByOldOptionId(criteria);
1124            }
1125        }
1126        lastActivitysCriteria = criteria;
1127
1128        return collActivitys;
1129    }
1130                  
1131                    
1132                    
1133                                            
1134                                                                          
1135                                        
1136                    
1137                    
1138          
1139    /**
1140     * If this collection has already been initialized with
1141     * an identical criteria, it returns the collection.
1142     * Otherwise if this Attachment is new, it will return
1143     * an empty collection; or if this Attachment has previously
1144     * been saved, it will retrieve related Activitys from storage.
1145     *
1146     * This method is protected by default in order to keep the public
1147     * api reasonable. You can provide public methods for those you
1148     * actually need in Attachment.
1149     */

1150    protected List JavaDoc getActivitysJoinAttributeOptionRelatedByNewOptionId(Criteria criteria)
1151        throws TorqueException
1152    {
1153        if (collActivitys == null)
1154        {
1155            if (isNew())
1156            {
1157               collActivitys = new ArrayList JavaDoc();
1158            }
1159            else
1160            {
1161                            criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
1162                            collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByNewOptionId(criteria);
1163            }
1164        }
1165        else
1166        {
1167            // the following code is to determine if a new query is
1168
// called for. If the criteria is the same as the last
1169
// one, just return the collection.
1170

1171                            criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
1172                        if (!lastActivitysCriteria.equals(criteria))
1173            {
1174                collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByNewOptionId(criteria);
1175            }
1176        }
1177        lastActivitysCriteria = criteria;
1178
1179        return collActivitys;
1180    }
1181                  
1182                    
1183                              
1184                                
1185                                                              
1186                                        
1187                    
1188                    
1189          
1190    /**
1191     * If this collection has already been initialized with
1192     * an identical criteria, it returns the collection.
1193     * Otherwise if this Attachment is new, it will return
1194     * an empty collection; or if this Attachment has previously
1195     * been saved, it will retrieve related Activitys from storage.
1196     *
1197     * This method is protected by default in order to keep the public
1198     * api reasonable. You can provide public methods for those you
1199     * actually need in Attachment.
1200     */

1201    protected List JavaDoc getActivitysJoinAttachment(Criteria criteria)
1202        throws TorqueException
1203    {
1204        if (collActivitys == null)
1205        {
1206            if (isNew())
1207            {
1208               collActivitys = new ArrayList JavaDoc();
1209            }
1210            else
1211            {
1212                            criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
1213                            collActivitys = ActivityPeer.doSelectJoinAttachment(criteria);
1214            }
1215        }
1216        else
1217        {
1218            // the following code is to determine if a new query is
1219
// called for. If the criteria is the same as the last
1220
// one, just return the collection.
1221

1222                            criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
1223                        if (!lastActivitysCriteria.equals(criteria))
1224            {
1225                collActivitys = ActivityPeer.doSelectJoinAttachment(criteria);
1226            }
1227        }
1228        lastActivitysCriteria = criteria;
1229
1230        return collActivitys;
1231    }
1232                  
1233                    
1234                    
1235                                
1236                                                              
1237                                        
1238                    
1239                    
1240          
1241    /**
1242     * If this collection has already been initialized with
1243     * an identical criteria, it returns the collection.
1244     * Otherwise if this Attachment is new, it will return
1245     * an empty collection; or if this Attachment has previously
1246     * been saved, it will retrieve related Activitys from storage.
1247     *
1248     * This method is protected by default in order to keep the public
1249     * api reasonable. You can provide public methods for those you
1250     * actually need in Attachment.
1251     */

1252    protected List JavaDoc getActivitysJoinDepend(Criteria criteria)
1253        throws TorqueException
1254    {
1255        if (collActivitys == null)
1256        {
1257            if (isNew())
1258            {
1259               collActivitys = new ArrayList JavaDoc();
1260            }
1261            else
1262            {
1263                            criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
1264                            collActivitys = ActivityPeer.doSelectJoinDepend(criteria);
1265            }
1266        }
1267        else
1268        {
1269            // the following code is to determine if a new query is
1270
// called for. If the criteria is the same as the last
1271
// one, just return the collection.
1272

1273                            criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() );
1274                        if (!lastActivitysCriteria.equals(criteria))
1275            {
1276                collActivitys = ActivityPeer.doSelectJoinDepend(criteria);
1277            }
1278        }
1279        lastActivitysCriteria = criteria;
1280
1281        return collActivitys;
1282    }
1283                            
1284
1285
1286                          
1287            
1288    /**
1289     * Collection to store aggregation of collActivitySets
1290     */

1291    protected List JavaDoc collActivitySets;
1292
1293    /**
1294     * Temporary storage of collActivitySets to save a possible db hit in
1295     * the event objects are add to the collection, but the
1296     * complete collection is never requested.
1297     */

1298    protected void initActivitySets()
1299    {
1300        if (collActivitySets == null)
1301        {
1302            collActivitySets = new ArrayList JavaDoc();
1303        }
1304    }
1305
1306            
1307    /**
1308     * Method called to associate a ActivitySet object to this object
1309     * through the ActivitySet foreign key attribute
1310     *
1311     * @param l ActivitySet
1312     * @throws TorqueException
1313     */

1314    public void addActivitySet(ActivitySet l) throws TorqueException
1315    {
1316        getActivitySets().add(l);
1317        l.setAttachment((Attachment)this);
1318    }
1319
1320    /**
1321     * The criteria used to select the current contents of collActivitySets
1322     */

1323    private Criteria lastActivitySetsCriteria = null;
1324
1325    /**
1326     * If this collection has already been initialized, returns
1327     * the collection. Otherwise returns the results of
1328     * getActivitySets(new Criteria())
1329     *
1330     * @throws TorqueException
1331     */

1332    public List JavaDoc getActivitySets() throws TorqueException
1333    {
1334        if (collActivitySets == null)
1335        {
1336            collActivitySets = getActivitySets(new Criteria(10));
1337        }
1338        return collActivitySets;
1339    }
1340
1341    /**
1342     * If this collection has already been initialized with
1343     * an identical criteria, it returns the collection.
1344     * Otherwise if this Attachment has previously
1345     * been saved, it will retrieve related ActivitySets from storage.
1346     * If this Attachment is new, it will return
1347     * an empty collection or the current collection, the criteria
1348     * is ignored on a new object.
1349     *
1350     * @throws TorqueException
1351     */

1352    public List JavaDoc getActivitySets(Criteria criteria) throws TorqueException
1353    {
1354        if (collActivitySets == null)
1355        {
1356            if (isNew())
1357            {
1358               collActivitySets = new ArrayList JavaDoc();
1359            }
1360            else
1361            {
1362                      criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() );
1363                      collActivitySets = ActivitySetPeer.doSelect(criteria);
1364            }
1365        }
1366        else
1367        {
1368            // criteria has no effect for a new object
1369
if (!isNew())
1370            {
1371                // the following code is to determine if a new query is
1372
// called for. If the criteria is the same as the last
1373
// one, just return the collection.
1374
criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() );
1375                      if (!lastActivitySetsCriteria.equals(criteria))
1376                {
1377                    collActivitySets = ActivitySetPeer.doSelect(criteria);
1378                }
1379            }
1380        }
1381        lastActivitySetsCriteria = criteria;
1382
1383        return collActivitySets;
1384    }
1385
1386    /**
1387     * If this collection has already been initialized, returns
1388     * the collection. Otherwise returns the results of
1389     * getActivitySets(new Criteria(),Connection)
1390     * This method takes in the Connection also as input so that
1391     * referenced objects can also be obtained using a Connection
1392     * that is taken as input
1393     */

1394    public List JavaDoc getActivitySets(Connection JavaDoc con) throws TorqueException
1395    {
1396        if (collActivitySets == null)
1397        {
1398            collActivitySets = getActivitySets(new Criteria(10),con);
1399        }
1400        return collActivitySets;
1401    }
1402
1403    /**
1404     * If this collection has already been initialized with
1405     * an identical criteria, it returns the collection.
1406     * Otherwise if this Attachment has previously
1407     * been saved, it will retrieve related ActivitySets from storage.
1408     * If this Attachment is new, it will return
1409     * an empty collection or the current collection, the criteria
1410     * is ignored on a new object.
1411     * This method takes in the Connection also as input so that
1412     * referenced objects can also be obtained using a Connection
1413     * that is taken as input
1414     */

1415    public List JavaDoc getActivitySets(Criteria criteria,Connection JavaDoc con) throws TorqueException
1416    {
1417        if (collActivitySets == null)
1418        {
1419            if (isNew())
1420            {
1421               collActivitySets = new ArrayList JavaDoc();
1422            }
1423            else
1424            {
1425                       criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() );
1426                       collActivitySets = ActivitySetPeer.doSelect(criteria,con);
1427             }
1428         }
1429         else
1430         {
1431             // criteria has no effect for a new object
1432
if (!isNew())
1433             {
1434                 // the following code is to determine if a new query is
1435
// called for. If the criteria is the same as the last
1436
// one, just return the collection.
1437
criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() );
1438                     if (!lastActivitySetsCriteria.equals(criteria))
1439                 {
1440                     collActivitySets = ActivitySetPeer.doSelect(criteria,con);
1441                 }
1442             }
1443         }
1444         lastActivitySetsCriteria = criteria;
1445
1446         return collActivitySets;
1447     }
1448
1449                              
1450              
1451                    
1452                    
1453                                
1454                                                              
1455                                        
1456                    
1457                    
1458          
1459    /**
1460     * If this collection has already been initialized with
1461     * an identical criteria, it returns the collection.
1462     * Otherwise if this Attachment is new, it will return
1463     * an empty collection; or if this Attachment has previously
1464     * been saved, it will retrieve related ActivitySets from storage.
1465     *
1466     * This method is protected by default in order to keep the public
1467     * api reasonable. You can provide public methods for those you
1468     * actually need in Attachment.
1469     */

1470    protected List JavaDoc getActivitySetsJoinScarabUserImpl(Criteria criteria)
1471        throws TorqueException
1472    {
1473        if (collActivitySets == null)
1474        {
1475            if (isNew())
1476            {
1477               collActivitySets = new ArrayList JavaDoc();
1478            }
1479            else
1480            {
1481                            criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() );
1482                            collActivitySets = ActivitySetPeer.doSelectJoinScarabUserImpl(criteria);
1483            }
1484        }
1485        else
1486        {
1487            // the following code is to determine if a new query is
1488
// called for. If the criteria is the same as the last
1489
// one, just return the collection.
1490

1491                            criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() );
1492                        if (!lastActivitySetsCriteria.equals(criteria))
1493            {
1494                collActivitySets = ActivitySetPeer.doSelectJoinScarabUserImpl(criteria);
1495            }
1496        }
1497        lastActivitySetsCriteria = criteria;
1498
1499        return collActivitySets;
1500    }
1501                  
1502                    
1503                    
1504                                
1505                                                              
1506                                        
1507                    
1508                    
1509          
1510    /**
1511     * If this collection has already been initialized with
1512     * an identical criteria, it returns the collection.
1513     * Otherwise if this Attachment is new, it will return
1514     * an empty collection; or if this Attachment has previously
1515     * been saved, it will retrieve related ActivitySets from storage.
1516     *
1517     * This method is protected by default in order to keep the public
1518     * api reasonable. You can provide public methods for those you
1519     * actually need in Attachment.
1520     */

1521    protected List JavaDoc getActivitySetsJoinActivitySetType(Criteria criteria)
1522        throws TorqueException
1523    {
1524        if (collActivitySets == null)
1525        {
1526            if (isNew())
1527            {
1528               collActivitySets = new ArrayList JavaDoc();
1529            }
1530            else
1531            {
1532                            criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() );
1533                            collActivitySets = ActivitySetPeer.doSelectJoinActivitySetType(criteria);
1534            }
1535        }
1536        else
1537        {
1538            // the following code is to determine if a new query is
1539
// called for. If the criteria is the same as the last
1540
// one, just return the collection.
1541

1542                            criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() );
1543                        if (!lastActivitySetsCriteria.equals(criteria))
1544            {
1545                collActivitySets = ActivitySetPeer.doSelectJoinActivitySetType(criteria);
1546            }
1547        }
1548        lastActivitySetsCriteria = criteria;
1549
1550        return collActivitySets;
1551    }
1552                  
1553                    
1554                              
1555                                
1556                                                              
1557                                        
1558                    
1559                    
1560          
1561    /**
1562     * If this collection has already been initialized with
1563     * an identical criteria, it returns the collection.
1564     * Otherwise if this Attachment is new, it will return
1565     * an empty collection; or if this Attachment has previously
1566     * been saved, it will retrieve related ActivitySets from storage.
1567     *
1568     * This method is protected by default in order to keep the public
1569     * api reasonable. You can provide public methods for those you
1570     * actually need in Attachment.
1571     */

1572    protected List JavaDoc getActivitySetsJoinAttachment(Criteria criteria)
1573        throws TorqueException
1574    {
1575        if (collActivitySets == null)
1576        {
1577            if (isNew())
1578            {
1579               collActivitySets = new ArrayList JavaDoc();
1580            }
1581            else
1582            {
1583                            criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() );
1584                            collActivitySets = ActivitySetPeer.doSelectJoinAttachment(criteria);
1585            }
1586        }
1587        else
1588        {
1589            // the following code is to determine if a new query is
1590
// called for. If the criteria is the same as the last
1591
// one, just return the collection.
1592

1593                            criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() );
1594                        if (!lastActivitySetsCriteria.equals(criteria))
1595            {
1596                collActivitySets = ActivitySetPeer.doSelectJoinAttachment(criteria);
1597            }
1598        }
1599        lastActivitySetsCriteria = criteria;
1600
1601        return collActivitySets;
1602    }
1603                            
1604
1605
1606          
1607    private static List JavaDoc fieldNames = null;
1608
1609    /**
1610     * Generate a list of field names.
1611     *
1612     * @return a list of field names
1613     */

1614    public static synchronized List JavaDoc getFieldNames()
1615    {
1616        if (fieldNames == null)
1617        {
1618            fieldNames = new ArrayList JavaDoc();
1619              fieldNames.add("AttachmentId");
1620              fieldNames.add("IssueId");
1621              fieldNames.add("TypeId");
1622              fieldNames.add("Name");
1623              fieldNames.add("Data");
1624              fieldNames.add("FileName");
1625              fieldNames.add("MimeType");
1626              fieldNames.add("ModifiedBy");
1627              fieldNames.add("CreatedBy");
1628              fieldNames.add("ModifiedDate");
1629              fieldNames.add("CreatedDate");
1630              fieldNames.add("Deleted");
1631              fieldNames = Collections.unmodifiableList(fieldNames);
1632        }
1633        return fieldNames;
1634    }
1635
1636    /**
1637     * Retrieves a field from the object by name passed in as a String.
1638     *
1639     * @param name field name
1640     * @return value
1641     */

1642    public Object JavaDoc getByName(String JavaDoc name)
1643    {
1644          if (name.equals("AttachmentId"))
1645        {
1646                return getAttachmentId();
1647            }
1648          if (name.equals("IssueId"))
1649        {
1650                return getIssueId();
1651            }
1652          if (name.equals("TypeId"))
1653        {
1654                return getTypeId();
1655            }
1656          if (name.equals("Name"))
1657        {
1658                return getName();
1659            }
1660          if (name.equals("Data"))
1661        {
1662                return getData();
1663            }
1664          if (name.equals("FileName"))
1665        {
1666                return getFileName();
1667            }
1668          if (name.equals("MimeType"))
1669        {
1670                return getMimeType();
1671            }
1672          if (name.equals("ModifiedBy"))
1673        {
1674                return getModifiedBy();
1675            }
1676          if (name.equals("CreatedBy"))
1677        {
1678                return getCreatedBy();
1679            }
1680          if (name.equals("ModifiedDate"))
1681        {
1682                return getModifiedDate();
1683            }
1684          if (name.equals("CreatedDate"))
1685        {
1686                return getCreatedDate();
1687            }
1688          if (name.equals("Deleted"))
1689        {
1690                return Boolean.valueOf(getDeleted());
1691            }
1692          return null;
1693    }
1694    
1695    /**
1696     * Retrieves a field from the object by name passed in
1697     * as a String. The String must be one of the static
1698     * Strings defined in this Class' Peer.
1699     *
1700     * @param name peer name
1701     * @return value
1702     */

1703    public Object JavaDoc getByPeerName(String JavaDoc name)
1704    {
1705          if (name.equals(AttachmentPeer.ATTACHMENT_ID))
1706        {
1707                return getAttachmentId();
1708            }
1709          if (name.equals(AttachmentPeer.ISSUE_ID))
1710        {
1711                return getIssueId();
1712            }
1713          if (name.equals(AttachmentPeer.ATTACHMENT_TYPE_ID))
1714        {
1715                return getTypeId();
1716            }
1717          if (name.equals(AttachmentPeer.ATTACHMENT_NAME))
1718        {
1719                return getName();
1720            }
1721          if (name.equals(AttachmentPeer.ATTACHMENT_DATA))
1722        {
1723                return getData();
1724            }
1725          if (name.equals(AttachmentPeer.ATTACHMENT_FILE_PATH))
1726        {
1727                return getFileName();
1728            }
1729          if (name.equals(AttachmentPeer.ATTACHMENT_MIME_TYPE))
1730        {
1731                return getMimeType();
1732            }
1733          if (name.equals(AttachmentPeer.MODIFIED_BY))
1734        {
1735                return getModifiedBy();
1736            }
1737          if (name.equals(AttachmentPeer.CREATED_BY))
1738        {
1739                return getCreatedBy();
1740            }
1741          if (name.equals(AttachmentPeer.MODIFIED_DATE))
1742        {
1743                return getModifiedDate();
1744            }
1745          if (name.equals(AttachmentPeer.CREATED_DATE))
1746        {
1747                return getCreatedDate();
1748            }
1749          if (name.equals(AttachmentPeer.DELETED))
1750        {
1751                return Boolean.valueOf(getDeleted());
1752            }
1753          return null;
1754    }
1755
1756    /**
1757     * Retrieves a field from the object by Position as specified
1758     * in the xml schema. Zero-based.
1759     *
1760     * @param pos position in xml schema
1761     * @return value
1762     */

1763    public Object JavaDoc getByPosition(int pos)
1764    {
1765            if (pos == 0)
1766        {
1767                return getAttachmentId();
1768            }
1769              if (pos == 1)
1770        {
1771                return getIssueId();
1772            }
1773              if (pos == 2)
1774        {
1775                return getTypeId();
1776            }
1777              if (pos == 3)
1778        {
1779                return getName();
1780            }
1781              if (pos == 4)
1782        {
1783                return getData();
1784            }
1785              if (pos == 5)
1786        {
1787                return getFileName();
1788            }
1789              if (pos == 6)
1790        {
1791                return getMimeType();
1792            }
1793              if (pos == 7)
1794        {
1795                return getModifiedBy();
1796            }
1797              if (pos == 8)
1798        {
1799                return getCreatedBy();
1800            }
1801              if (pos == 9)
1802        {
1803                return getModifiedDate();
1804            }
1805              if (pos == 10)
1806        {
1807                return getCreatedDate();
1808            }
1809              if (pos == 11)
1810        {
1811                return Boolean.valueOf(getDeleted());
1812            }
1813              return null;
1814    }
1815     
1816    /**
1817     * Stores the object in the database. If the object is new,
1818     * it inserts it; otherwise an update is performed.
1819     *
1820     * @throws Exception
1821     */

1822    public void save() throws Exception JavaDoc
1823    {
1824          save(AttachmentPeer.getMapBuilder()
1825                .getDatabaseMap().getName());
1826      }
1827
1828    /**
1829     * Stores the object in the database. If the object is new,
1830     * it inserts it; otherwise an update is performed.
1831       * Note: this code is here because the method body is
1832     * auto-generated conditionally and therefore needs to be
1833     * in this file instead of in the super class, BaseObject.
1834       *
1835     * @param dbName
1836     * @throws TorqueException
1837     */

1838    public void save(String JavaDoc dbName) throws TorqueException
1839    {
1840        Connection JavaDoc con = null;
1841          try
1842        {
1843            con = Transaction.begin(dbName);
1844            save(con);
1845            Transaction.commit(con);
1846        }
1847        catch(TorqueException e)
1848        {
1849            Transaction.safeRollback(con);
1850            throw e;
1851        }
1852      }
1853
1854      /** flag to prevent endless save loop, if this object is referenced
1855        by another object which falls in this transaction. */

1856    private boolean alreadyInSave = false;
1857      /**
1858     * Stores the object in the database. If the object is new,
1859     * it inserts it; otherwise an update is performed. This method
1860     * is meant to be used as part of a transaction, otherwise use
1861     * the save() method and the connection details will be handled
1862     * internally
1863     *
1864     * @param con
1865     * @throws TorqueException
1866     */

1867    public void save(Connection JavaDoc con) throws TorqueException
1868    {
1869          if (!alreadyInSave)
1870        {
1871            alreadyInSave = true;
1872
1873
1874  
1875            // If this object has been modified, then save it to the database.
1876
if (isModified())
1877            {
1878                if (isNew())
1879                {
1880                    AttachmentPeer.doInsert((Attachment)this, con);
1881                    setNew(false);
1882                }
1883                else
1884                {
1885                    AttachmentPeer.doUpdate((Attachment)this, con);
1886                }
1887
1888                      if (isCacheOnSave())
1889                {
1890                    AttachmentManager.putInstance(this);
1891                }
1892              }
1893
1894                                      
1895                            if (collActivitys != null)
1896            {
1897                for (int i = 0; i < collActivitys.size(); i++)
1898                {
1899                    ((Activity)collActivitys.get(i)).save(con);
1900                }
1901            }
1902                                          
1903                            if (collActivitySets != null)
1904            {
1905                for (int i = 0; i < collActivitySets.size(); i++)
1906                {
1907                    ((ActivitySet)collActivitySets.get(i)).save(con);
1908                }
1909            }
1910                          alreadyInSave = false;
1911        }
1912      }
1913
1914    /**
1915     * Specify whether to cache the object after saving to the db.
1916     * This method returns false
1917     */

1918    protected boolean isCacheOnSave()
1919    {
1920        return true;
1921    }
1922
1923                        
1924      /**
1925     * Set the PrimaryKey using ObjectKey.
1926     *
1927     * @param attachmentId ObjectKey
1928     */

1929    public void setPrimaryKey(ObjectKey attachmentId)
1930        throws TorqueException {
1931            setAttachmentId(new Long JavaDoc(((NumberKey)attachmentId).longValue()));
1932        }
1933
1934    /**
1935     * Set the PrimaryKey using a String.
1936     *
1937     * @param key
1938     */

1939    public void setPrimaryKey(String JavaDoc key) throws TorqueException
1940    {
1941            setAttachmentId(new Long JavaDoc(key));
1942        }
1943
1944  
1945    /**
1946     * returns an id that differentiates this object from others
1947     * of its class.
1948     */

1949    public ObjectKey getPrimaryKey()
1950    {
1951          return SimpleKey.keyFor(getAttachmentId());
1952      }
1953 
1954    /**
1955     * get an id that differentiates this object from others
1956     * of its class.
1957     */

1958    public String JavaDoc getQueryKey()
1959    {
1960        if (getPrimaryKey() == null)
1961        {
1962            return "";
1963        }
1964        else
1965        {
1966            return getPrimaryKey().toString();
1967        }
1968    }
1969
1970    /**
1971     * set an id that differentiates this object from others
1972     * of its class.
1973     */

1974    public void setQueryKey(String JavaDoc key)
1975        throws TorqueException
1976    {
1977        setPrimaryKey(key);
1978    }
1979
1980    /**
1981     * Makes a copy of this object.
1982     * It creates a new object filling in the simple attributes.
1983       * It then fills all the association collections and sets the
1984     * related objects to isNew=true.
1985       */

1986      public Attachment copy() throws TorqueException
1987    {
1988        Attachment copyObj = new Attachment();
1989            copyObj.setAttachmentId(attachmentId);
1990          copyObj.setIssueId(issueId);
1991          copyObj.setTypeId(typeId);
1992          copyObj.setName(name);
1993          copyObj.setData(data);
1994          copyObj.setFileName(fileName);
1995          copyObj.setMimeType(mimeType);
1996          copyObj.setModifiedBy(modifiedBy);
1997          copyObj.setCreatedBy(createdBy);
1998          copyObj.setModifiedDate(modifiedDate);
1999          copyObj.setCreatedDate(createdDate);
2000          copyObj.setDeleted(deleted);
2001  
2002                      copyObj.setAttachmentId((Long JavaDoc)null);
2003                                                                              
2004                                      
2005                
2006        List JavaDoc v = getActivitys();
2007        for (int i = 0; i < v.size(); i++)
2008        {
2009            Activity obj = (Activity) v.get(i);
2010            copyObj.addActivity(obj.copy());
2011        }
2012                                                  
2013                
2014        v = getActivitySets();
2015        for (int i = 0; i < v.size(); i++)
2016        {
2017            ActivitySet obj = (ActivitySet) v.get(i);
2018            copyObj.addActivitySet(obj.copy());
2019        }
2020                            return copyObj;
2021    }
2022
2023    /**
2024     * returns a peer instance associated with this om. Since Peer classes
2025     * are not to have any instance attributes, this method returns the
2026     * same instance for all member of this class. The method could therefore
2027     * be static, but this would prevent one from overriding the behavior.
2028     */

2029    public AttachmentPeer getPeer()
2030    {
2031        return peer;
2032    }
2033
2034    public String JavaDoc toString()
2035    {
2036        StringBuffer JavaDoc str = new StringBuffer JavaDoc();
2037        str.append("Attachment:\n");
2038        str.append("AttachmentId = ")
2039               .append(getAttachmentId())
2040             .append("\n");
2041        str.append("IssueId = ")
2042               .append(getIssueId())
2043             .append("\n");
2044        str.append("TypeId = ")
2045               .append(getTypeId())
2046             .append("\n");
2047        str.append("Name = ")
2048               .append(getName())
2049             .append("\n");
2050        str.append("Data = ")
2051               .append(getData())
2052             .append("\n");
2053        str.append("FileName = ")
2054               .append(getFileName())
2055             .append("\n");
2056        str.append("MimeType = ")
2057               .append(getMimeType())
2058             .append("\n");
2059        str.append("ModifiedBy = ")
2060               .append(getModifiedBy())
2061             .append("\n");
2062        str.append("CreatedBy = ")
2063               .append(getCreatedBy())
2064             .append("\n");
2065        str.append("ModifiedDate = ")
2066               .append(getModifiedDate())
2067             .append("\n");
2068        str.append("CreatedDate = ")
2069               .append(getCreatedDate())
2070             .append("\n");
2071        str.append("Deleted = ")
2072               .append(getDeleted())
2073             .append("\n");
2074        return(str.toString());
2075    }
2076}
2077
Popular Tags