KickJava   Java API By Example, From Geeks To Geeks.

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


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

32 public abstract class BaseRModuleIssueType extends BaseObject
33     implements org.apache.fulcrum.intake.Retrievable
34 {
35     /** The Peer class */
36     private static final RModuleIssueTypePeer peer =
37         new RModuleIssueTypePeer();
38
39         
40     /** The value for the moduleId field */
41     private Integer JavaDoc moduleId;
42       
43     /** The value for the issueTypeId field */
44     private Integer JavaDoc issueTypeId;
45                                                                 
46     /** The value for the active field */
47     private boolean active = true;
48                                                                 
49     /** The value for the display field */
50     private boolean display = true;
51                                           
52     /** The value for the order field */
53     private int order = 0;
54                                                                 
55     /** The value for the dedupe field */
56     private boolean dedupe = true;
57                                           
58     /** The value for the history field */
59     private int history = 5;
60                                           
61     /** The value for the comments field */
62     private int comments = 5;
63       
64     /** The value for the displayName field */
65     private String JavaDoc displayName;
66       
67     /** The value for the displayDescription field */
68     private String JavaDoc displayDescription;
69   
70     
71     /**
72      * Get the ModuleId
73      *
74      * @return Integer
75      */

76     public Integer JavaDoc getModuleId()
77     {
78         return moduleId;
79     }
80
81                                             
82     /**
83      * Set the value of ModuleId
84      *
85      * @param v new value
86      */

87     public void setModuleId(Integer JavaDoc v) throws TorqueException
88     {
89     
90                   if (!ObjectUtils.equals(this.moduleId, v))
91               {
92             this.moduleId = v;
93             setModified(true);
94         }
95     
96                                           
97                 if (aModule != null && !ObjectUtils.equals(aModule.getModuleId(), v))
98                 {
99             aModule = null;
100         }
101       
102                                   
103         // update associated Condition
104
if (collConditions != null)
105         {
106             for (int i = 0; i < collConditions.size(); i++)
107             {
108                 ((Condition) collConditions.get(i))
109                         .setModuleId(v);
110             }
111         }
112                       }
113   
114     /**
115      * Get the IssueTypeId
116      *
117      * @return Integer
118      */

119     public Integer JavaDoc getIssueTypeId()
120     {
121         return issueTypeId;
122     }
123
124                                             
125     /**
126      * Set the value of IssueTypeId
127      *
128      * @param v new value
129      */

130     public void setIssueTypeId(Integer JavaDoc v) throws TorqueException
131     {
132     
133                   if (!ObjectUtils.equals(this.issueTypeId, v))
134               {
135             this.issueTypeId = v;
136             setModified(true);
137         }
138     
139                                   
140                 if (aIssueType != null && !ObjectUtils.equals(aIssueType.getIssueTypeId(), v))
141                 {
142             aIssueType = null;
143         }
144       
145                                   
146         // update associated Condition
147
if (collConditions != null)
148         {
149             for (int i = 0; i < collConditions.size(); i++)
150             {
151                 ((Condition) collConditions.get(i))
152                         .setIssueTypeId(v);
153             }
154         }
155                       }
156   
157     /**
158      * Get the Active
159      *
160      * @return boolean
161      */

162     public boolean getActive()
163     {
164         return active;
165     }
166
167                         
168     /**
169      * Set the value of Active
170      *
171      * @param v new value
172      */

173     public void setActive(boolean v)
174     {
175     
176                   if (this.active != v)
177               {
178             this.active = v;
179             setModified(true);
180         }
181     
182           
183               }
184   
185     /**
186      * Get the Display
187      *
188      * @return boolean
189      */

190     public boolean getDisplay()
191     {
192         return display;
193     }
194
195                         
196     /**
197      * Set the value of Display
198      *
199      * @param v new value
200      */

201     public void setDisplay(boolean v)
202     {
203     
204                   if (this.display != v)
205               {
206             this.display = v;
207             setModified(true);
208         }
209     
210           
211               }
212   
213     /**
214      * Get the Order
215      *
216      * @return int
217      */

218     public int getOrder()
219     {
220         return order;
221     }
222
223                         
224     /**
225      * Set the value of Order
226      *
227      * @param v new value
228      */

229     public void setOrder(int v)
230     {
231     
232                   if (this.order != v)
233               {
234             this.order = v;
235             setModified(true);
236         }
237     
238           
239               }
240   
241     /**
242      * Get the Dedupe
243      *
244      * @return boolean
245      */

246     public boolean getDedupe()
247     {
248         return dedupe;
249     }
250
251                         
252     /**
253      * Set the value of Dedupe
254      *
255      * @param v new value
256      */

257     public void setDedupe(boolean v)
258     {
259     
260                   if (this.dedupe != v)
261               {
262             this.dedupe = v;
263             setModified(true);
264         }
265     
266           
267               }
268   
269     /**
270      * Get the History
271      *
272      * @return int
273      */

274     public int getHistory()
275     {
276         return history;
277     }
278
279                         
280     /**
281      * Set the value of History
282      *
283      * @param v new value
284      */

285     public void setHistory(int v)
286     {
287     
288                   if (this.history != v)
289               {
290             this.history = v;
291             setModified(true);
292         }
293     
294           
295               }
296   
297     /**
298      * Get the Comments
299      *
300      * @return int
301      */

302     public int getComments()
303     {
304         return comments;
305     }
306
307                         
308     /**
309      * Set the value of Comments
310      *
311      * @param v new value
312      */

313     public void setComments(int v)
314     {
315     
316                   if (this.comments != v)
317               {
318             this.comments = v;
319             setModified(true);
320         }
321     
322           
323               }
324   
325     /**
326      * Get the DisplayName
327      *
328      * @return String
329      */

330     public String JavaDoc getDisplayName()
331     {
332         return displayName;
333     }
334
335                         
336     /**
337      * Set the value of DisplayName
338      *
339      * @param v new value
340      */

341     public void setDisplayName(String JavaDoc v)
342     {
343     
344                   if (!ObjectUtils.equals(this.displayName, v))
345               {
346             this.displayName = v;
347             setModified(true);
348         }
349     
350           
351               }
352   
353     /**
354      * Get the DisplayDescription
355      *
356      * @return String
357      */

358     public String JavaDoc getDisplayDescription()
359     {
360         return displayDescription;
361     }
362
363                         
364     /**
365      * Set the value of DisplayDescription
366      *
367      * @param v new value
368      */

369     public void setDisplayDescription(String JavaDoc v)
370     {
371     
372                   if (!ObjectUtils.equals(this.displayDescription, v))
373               {
374             this.displayDescription = v;
375             setModified(true);
376         }
377     
378           
379               }
380   
381       
382             
383                   
384         private Module aModule;
385
386     /**
387      * Declares an association between this object and a Module object
388      *
389      * @param v Module
390      * @throws TorqueException
391      */

392     public void setModule(Module v) throws TorqueException
393     {
394             if (v == null)
395         {
396                   setModuleId((Integer JavaDoc) null);
397               }
398         else
399         {
400             setModuleId(v.getModuleId());
401         }
402             aModule = v;
403     }
404
405                         
406     /**
407      * Get the associated Module object
408      *
409      * @return the associated Module object
410      * @throws TorqueException
411      */

412     public Module getModule() throws TorqueException
413     {
414         if ( !ObjectUtils.equals(getModuleId(), null) )
415         {
416                 return ModuleManager.getInstance(SimpleKey.keyFor(getModuleId()));
417             }
418         return aModule;
419     }
420
421     /**
422      * Provides convenient way to set a relationship based on a
423      * ObjectKey, for example
424      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
425      *
426          */

427     public void setModuleKey(ObjectKey key) throws TorqueException
428     {
429     
430                     setModuleId(new Integer JavaDoc(((NumberKey) key).intValue()));
431               }
432   
433         
434                   
435         private IssueType aIssueType;
436
437     /**
438      * Declares an association between this object and a IssueType object
439      *
440      * @param v IssueType
441      * @throws TorqueException
442      */

443     public void setIssueType(IssueType v) throws TorqueException
444     {
445             if (v == null)
446         {
447                   setIssueTypeId((Integer JavaDoc) null);
448               }
449         else
450         {
451             setIssueTypeId(v.getIssueTypeId());
452         }
453             aIssueType = v;
454     }
455
456                         
457     /**
458      * Get the associated IssueType object
459      *
460      * @return the associated IssueType object
461      * @throws TorqueException
462      */

463     public IssueType getIssueType() throws TorqueException
464     {
465         if ( !ObjectUtils.equals(getIssueTypeId(), null) )
466         {
467                 return IssueTypeManager.getInstance(SimpleKey.keyFor(getIssueTypeId()));
468             }
469         return aIssueType;
470     }
471
472     /**
473      * Provides convenient way to set a relationship based on a
474      * ObjectKey, for example
475      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
476      *
477          */

478     public void setIssueTypeKey(ObjectKey key) throws TorqueException
479     {
480     
481                     setIssueTypeId(new Integer JavaDoc(((NumberKey) key).intValue()));
482               }
483      
484                                               
485             
486     /**
487      * Collection to store aggregation of collConditions
488      */

489     protected List JavaDoc collConditions;
490
491     /**
492      * Temporary storage of collConditions to save a possible db hit in
493      * the event objects are add to the collection, but the
494      * complete collection is never requested.
495      */

496     protected void initConditions()
497     {
498         if (collConditions == null)
499         {
500             collConditions = new ArrayList JavaDoc();
501         }
502     }
503
504             
505     /**
506      * Method called to associate a Condition object to this object
507      * through the Condition foreign key attribute
508      *
509      * @param l Condition
510      * @throws TorqueException
511      */

512     public void addCondition(Condition l) throws TorqueException
513     {
514         getConditions().add(l);
515         l.setRModuleIssueType((RModuleIssueType)this);
516     }
517
518     /**
519      * The criteria used to select the current contents of collConditions
520      */

521     private Criteria lastConditionsCriteria = null;
522
523     /**
524      * If this collection has already been initialized, returns
525      * the collection. Otherwise returns the results of
526      * getConditions(new Criteria())
527      *
528      * @throws TorqueException
529      */

530     public List JavaDoc getConditions() throws TorqueException
531     {
532         if (collConditions == null)
533         {
534             collConditions = getConditions(new Criteria(10));
535         }
536         return collConditions;
537     }
538
539     /**
540      * If this collection has already been initialized with
541      * an identical criteria, it returns the collection.
542      * Otherwise if this RModuleIssueType has previously
543      * been saved, it will retrieve related Conditions from storage.
544      * If this RModuleIssueType is new, it will return
545      * an empty collection or the current collection, the criteria
546      * is ignored on a new object.
547      *
548      * @throws TorqueException
549      */

550     public List JavaDoc getConditions(Criteria criteria) throws TorqueException
551     {
552         if (collConditions == null)
553         {
554             if (isNew())
555             {
556                collConditions = new ArrayList JavaDoc();
557             }
558             else
559             {
560                       criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
561                       criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
562                       collConditions = ConditionPeer.doSelect(criteria);
563             }
564         }
565         else
566         {
567             // criteria has no effect for a new object
568
if (!isNew())
569             {
570                 // the following code is to determine if a new query is
571
// called for. If the criteria is the same as the last
572
// one, just return the collection.
573
criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
574                       criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
575                       if (!lastConditionsCriteria.equals(criteria))
576                 {
577                     collConditions = ConditionPeer.doSelect(criteria);
578                 }
579             }
580         }
581         lastConditionsCriteria = criteria;
582
583         return collConditions;
584     }
585
586     /**
587      * If this collection has already been initialized, returns
588      * the collection. Otherwise returns the results of
589      * getConditions(new Criteria(),Connection)
590      * This method takes in the Connection also as input so that
591      * referenced objects can also be obtained using a Connection
592      * that is taken as input
593      */

594     public List JavaDoc getConditions(Connection JavaDoc con) throws TorqueException
595     {
596         if (collConditions == null)
597         {
598             collConditions = getConditions(new Criteria(10),con);
599         }
600         return collConditions;
601     }
602
603     /**
604      * If this collection has already been initialized with
605      * an identical criteria, it returns the collection.
606      * Otherwise if this RModuleIssueType has previously
607      * been saved, it will retrieve related Conditions from storage.
608      * If this RModuleIssueType is new, it will return
609      * an empty collection or the current collection, the criteria
610      * is ignored on a new object.
611      * This method takes in the Connection also as input so that
612      * referenced objects can also be obtained using a Connection
613      * that is taken as input
614      */

615     public List JavaDoc getConditions(Criteria criteria,Connection JavaDoc con) throws TorqueException
616     {
617         if (collConditions == null)
618         {
619             if (isNew())
620             {
621                collConditions = new ArrayList JavaDoc();
622             }
623             else
624             {
625                        criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
626                        criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
627                        collConditions = ConditionPeer.doSelect(criteria,con);
628              }
629          }
630          else
631          {
632              // criteria has no effect for a new object
633
if (!isNew())
634              {
635                  // the following code is to determine if a new query is
636
// called for. If the criteria is the same as the last
637
// one, just return the collection.
638
criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
639                      criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
640                      if (!lastConditionsCriteria.equals(criteria))
641                  {
642                      collConditions = ConditionPeer.doSelect(criteria,con);
643                  }
644              }
645          }
646          lastConditionsCriteria = criteria;
647
648          return collConditions;
649      }
650
651                                           
652               
653                     
654                     
655                                                                             
656                                                                                                           
657                                         
658                     
659                     
660           
661     /**
662      * If this collection has already been initialized with
663      * an identical criteria, it returns the collection.
664      * Otherwise if this RModuleIssueType is new, it will return
665      * an empty collection; or if this RModuleIssueType has previously
666      * been saved, it will retrieve related Conditions from storage.
667      *
668      * This method is protected by default in order to keep the public
669      * api reasonable. You can provide public methods for those you
670      * actually need in RModuleIssueType.
671      */

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

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

725     protected List JavaDoc getConditionsJoinTransition(Criteria criteria)
726         throws TorqueException
727     {
728         if (collConditions == null)
729         {
730             if (isNew())
731             {
732                collConditions = new ArrayList JavaDoc();
733             }
734             else
735             {
736                             criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
737                             criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
738                             collConditions = ConditionPeer.doSelectJoinTransition(criteria);
739             }
740         }
741         else
742         {
743             // the following code is to determine if a new query is
744
// called for. If the criteria is the same as the last
745
// one, just return the collection.
746

747                             criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
748                             criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
749                         if (!lastConditionsCriteria.equals(criteria))
750             {
751                 collConditions = ConditionPeer.doSelectJoinTransition(criteria);
752             }
753         }
754         lastConditionsCriteria = criteria;
755
756         return collConditions;
757     }
758                   
759                     
760                     
761                                 
762                                                               
763                                         
764                     
765                     
766           
767     /**
768      * If this collection has already been initialized with
769      * an identical criteria, it returns the collection.
770      * Otherwise if this RModuleIssueType is new, it will return
771      * an empty collection; or if this RModuleIssueType has previously
772      * been saved, it will retrieve related Conditions from storage.
773      *
774      * This method is protected by default in order to keep the public
775      * api reasonable. You can provide public methods for those you
776      * actually need in RModuleIssueType.
777      */

778     protected List JavaDoc getConditionsJoinAttribute(Criteria criteria)
779         throws TorqueException
780     {
781         if (collConditions == null)
782         {
783             if (isNew())
784             {
785                collConditions = new ArrayList JavaDoc();
786             }
787             else
788             {
789                             criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
790                             criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
791                             collConditions = ConditionPeer.doSelectJoinAttribute(criteria);
792             }
793         }
794         else
795         {
796             // the following code is to determine if a new query is
797
// called for. If the criteria is the same as the last
798
// one, just return the collection.
799

800                             criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
801                             criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
802                         if (!lastConditionsCriteria.equals(criteria))
803             {
804                 collConditions = ConditionPeer.doSelectJoinAttribute(criteria);
805             }
806         }
807         lastConditionsCriteria = criteria;
808
809         return collConditions;
810     }
811                   
812                     
813                     
814                                 
815                                                               
816                                         
817                     
818                     
819           
820     /**
821      * If this collection has already been initialized with
822      * an identical criteria, it returns the collection.
823      * Otherwise if this RModuleIssueType is new, it will return
824      * an empty collection; or if this RModuleIssueType has previously
825      * been saved, it will retrieve related Conditions from storage.
826      *
827      * This method is protected by default in order to keep the public
828      * api reasonable. You can provide public methods for those you
829      * actually need in RModuleIssueType.
830      */

831     protected List JavaDoc getConditionsJoinAttributeOption(Criteria criteria)
832         throws TorqueException
833     {
834         if (collConditions == null)
835         {
836             if (isNew())
837             {
838                collConditions = new ArrayList JavaDoc();
839             }
840             else
841             {
842                             criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
843                             criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
844                             collConditions = ConditionPeer.doSelectJoinAttributeOption(criteria);
845             }
846         }
847         else
848         {
849             // the following code is to determine if a new query is
850
// called for. If the criteria is the same as the last
851
// one, just return the collection.
852

853                             criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
854                             criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
855                         if (!lastConditionsCriteria.equals(criteria))
856             {
857                 collConditions = ConditionPeer.doSelectJoinAttributeOption(criteria);
858             }
859         }
860         lastConditionsCriteria = criteria;
861
862         return collConditions;
863     }
864                   
865                     
866                               
867                                                       
868                                                                                     
869                                         
870                     
871                     
872           
873     /**
874      * If this collection has already been initialized with
875      * an identical criteria, it returns the collection.
876      * Otherwise if this RModuleIssueType is new, it will return
877      * an empty collection; or if this RModuleIssueType has previously
878      * been saved, it will retrieve related Conditions from storage.
879      *
880      * This method is protected by default in order to keep the public
881      * api reasonable. You can provide public methods for those you
882      * actually need in RModuleIssueType.
883      */

884     protected List JavaDoc getConditionsJoinRModuleIssueType(Criteria criteria)
885         throws TorqueException
886     {
887         if (collConditions == null)
888         {
889             if (isNew())
890             {
891                collConditions = new ArrayList JavaDoc();
892             }
893             else
894             {
895                             criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
896                             criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
897                             collConditions = ConditionPeer.doSelectJoinRModuleIssueType(criteria);
898             }
899         }
900         else
901         {
902             // the following code is to determine if a new query is
903
// called for. If the criteria is the same as the last
904
// one, just return the collection.
905

906                             criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
907                             criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
908                         if (!lastConditionsCriteria.equals(criteria))
909             {
910                 collConditions = ConditionPeer.doSelectJoinRModuleIssueType(criteria);
911             }
912         }
913         lastConditionsCriteria = criteria;
914
915         return collConditions;
916     }
917                             
918
919
920           
921     private static List JavaDoc fieldNames = null;
922
923     /**
924      * Generate a list of field names.
925      *
926      * @return a list of field names
927      */

928     public static synchronized List JavaDoc getFieldNames()
929     {
930         if (fieldNames == null)
931         {
932             fieldNames = new ArrayList JavaDoc();
933               fieldNames.add("ModuleId");
934               fieldNames.add("IssueTypeId");
935               fieldNames.add("Active");
936               fieldNames.add("Display");
937               fieldNames.add("Order");
938               fieldNames.add("Dedupe");
939               fieldNames.add("History");
940               fieldNames.add("Comments");
941               fieldNames.add("DisplayName");
942               fieldNames.add("DisplayDescription");
943               fieldNames = Collections.unmodifiableList(fieldNames);
944         }
945         return fieldNames;
946     }
947
948     /**
949      * Retrieves a field from the object by name passed in as a String.
950      *
951      * @param name field name
952      * @return value
953      */

954     public Object JavaDoc getByName(String JavaDoc name)
955     {
956           if (name.equals("ModuleId"))
957         {
958                 return getModuleId();
959             }
960           if (name.equals("IssueTypeId"))
961         {
962                 return getIssueTypeId();
963             }
964           if (name.equals("Active"))
965         {
966                 return Boolean.valueOf(getActive());
967             }
968           if (name.equals("Display"))
969         {
970                 return Boolean.valueOf(getDisplay());
971             }
972           if (name.equals("Order"))
973         {
974                 return new Integer JavaDoc(getOrder());
975             }
976           if (name.equals("Dedupe"))
977         {
978                 return Boolean.valueOf(getDedupe());
979             }
980           if (name.equals("History"))
981         {
982                 return new Integer JavaDoc(getHistory());
983             }
984           if (name.equals("Comments"))
985         {
986                 return new Integer JavaDoc(getComments());
987             }
988           if (name.equals("DisplayName"))
989         {
990                 return getDisplayName();
991             }
992           if (name.equals("DisplayDescription"))
993         {
994                 return getDisplayDescription();
995             }
996           return null;
997     }
998     
999     /**
1000     * Retrieves a field from the object by name passed in
1001     * as a String. The String must be one of the static
1002     * Strings defined in this Class' Peer.
1003     *
1004     * @param name peer name
1005     * @return value
1006     */

1007    public Object JavaDoc getByPeerName(String JavaDoc name)
1008    {
1009          if (name.equals(RModuleIssueTypePeer.MODULE_ID))
1010        {
1011                return getModuleId();
1012            }
1013          if (name.equals(RModuleIssueTypePeer.ISSUE_TYPE_ID))
1014        {
1015                return getIssueTypeId();
1016            }
1017          if (name.equals(RModuleIssueTypePeer.ACTIVE))
1018        {
1019                return Boolean.valueOf(getActive());
1020            }
1021          if (name.equals(RModuleIssueTypePeer.DISPLAY))
1022        {
1023                return Boolean.valueOf(getDisplay());
1024            }
1025          if (name.equals(RModuleIssueTypePeer.PREFERRED_ORDER))
1026        {
1027                return new Integer JavaDoc(getOrder());
1028            }
1029          if (name.equals(RModuleIssueTypePeer.DEDUPE))
1030        {
1031                return Boolean.valueOf(getDedupe());
1032            }
1033          if (name.equals(RModuleIssueTypePeer.HISTORY))
1034        {
1035                return new Integer JavaDoc(getHistory());
1036            }
1037          if (name.equals(RModuleIssueTypePeer.COMMENTS))
1038        {
1039                return new Integer JavaDoc(getComments());
1040            }
1041          if (name.equals(RModuleIssueTypePeer.DISPLAY_NAME))
1042        {
1043                return getDisplayName();
1044            }
1045          if (name.equals(RModuleIssueTypePeer.DISPLAY_DESCRIPTION))
1046        {
1047                return getDisplayDescription();
1048            }
1049          return null;
1050    }
1051
1052    /**
1053     * Retrieves a field from the object by Position as specified
1054     * in the xml schema. Zero-based.
1055     *
1056     * @param pos position in xml schema
1057     * @return value
1058     */

1059    public Object JavaDoc getByPosition(int pos)
1060    {
1061            if (pos == 0)
1062        {
1063                return getModuleId();
1064            }
1065              if (pos == 1)
1066        {
1067                return getIssueTypeId();
1068            }
1069              if (pos == 2)
1070        {
1071                return Boolean.valueOf(getActive());
1072            }
1073              if (pos == 3)
1074        {
1075                return Boolean.valueOf(getDisplay());
1076            }
1077              if (pos == 4)
1078        {
1079                return new Integer JavaDoc(getOrder());
1080            }
1081              if (pos == 5)
1082        {
1083                return Boolean.valueOf(getDedupe());
1084            }
1085              if (pos == 6)
1086        {
1087                return new Integer JavaDoc(getHistory());
1088            }
1089              if (pos == 7)
1090        {
1091                return new Integer JavaDoc(getComments());
1092            }
1093              if (pos == 8)
1094        {
1095                return getDisplayName();
1096            }
1097              if (pos == 9)
1098        {
1099                return getDisplayDescription();
1100            }
1101              return null;
1102    }
1103     
1104    /**
1105     * Stores the object in the database. If the object is new,
1106     * it inserts it; otherwise an update is performed.
1107     *
1108     * @throws Exception
1109     */

1110    public void save() throws Exception JavaDoc
1111    {
1112          save(RModuleIssueTypePeer.getMapBuilder()
1113                .getDatabaseMap().getName());
1114      }
1115
1116    /**
1117     * Stores the object in the database. If the object is new,
1118     * it inserts it; otherwise an update is performed.
1119       * Note: this code is here because the method body is
1120     * auto-generated conditionally and therefore needs to be
1121     * in this file instead of in the super class, BaseObject.
1122       *
1123     * @param dbName
1124     * @throws TorqueException
1125     */

1126    public void save(String JavaDoc dbName) throws TorqueException
1127    {
1128        Connection JavaDoc con = null;
1129          try
1130        {
1131            con = Transaction.begin(dbName);
1132            save(con);
1133            Transaction.commit(con);
1134        }
1135        catch(TorqueException e)
1136        {
1137            Transaction.safeRollback(con);
1138            throw e;
1139        }
1140      }
1141
1142      /** flag to prevent endless save loop, if this object is referenced
1143        by another object which falls in this transaction. */

1144    private boolean alreadyInSave = false;
1145      /**
1146     * Stores the object in the database. If the object is new,
1147     * it inserts it; otherwise an update is performed. This method
1148     * is meant to be used as part of a transaction, otherwise use
1149     * the save() method and the connection details will be handled
1150     * internally
1151     *
1152     * @param con
1153     * @throws TorqueException
1154     */

1155    public void save(Connection JavaDoc con) throws TorqueException
1156    {
1157          if (!alreadyInSave)
1158        {
1159            alreadyInSave = true;
1160
1161
1162  
1163            // If this object has been modified, then save it to the database.
1164
if (isModified())
1165            {
1166                if (isNew())
1167                {
1168                    RModuleIssueTypePeer.doInsert((RModuleIssueType)this, con);
1169                    setNew(false);
1170                }
1171                else
1172                {
1173                    RModuleIssueTypePeer.doUpdate((RModuleIssueType)this, con);
1174                }
1175
1176                      if (isCacheOnSave())
1177                {
1178                    RModuleIssueTypeManager.putInstance(this);
1179                }
1180              }
1181
1182                                                        
1183                            if (collConditions != null)
1184            {
1185                for (int i = 0; i < collConditions.size(); i++)
1186                {
1187                    ((Condition)collConditions.get(i)).save(con);
1188                }
1189            }
1190                          alreadyInSave = false;
1191        }
1192      }
1193
1194    /**
1195     * Specify whether to cache the object after saving to the db.
1196     * This method returns false
1197     */

1198    protected boolean isCacheOnSave()
1199    {
1200        return true;
1201    }
1202
1203                                              
1204  
1205    private final SimpleKey[] pks = new SimpleKey[2];
1206    private final ComboKey comboPK = new ComboKey(pks);
1207
1208    /**
1209     * Set the PrimaryKey with an ObjectKey
1210     *
1211     * @param key
1212     */

1213    public void setPrimaryKey(ObjectKey key) throws TorqueException
1214    {
1215        SimpleKey[] keys = (SimpleKey[]) key.getValue();
1216        SimpleKey tmpKey = null;
1217                      setModuleId(new Integer JavaDoc(((NumberKey)keys[0]).intValue()));
1218                        setIssueTypeId(new Integer JavaDoc(((NumberKey)keys[1]).intValue()));
1219              }
1220
1221    /**
1222     * Set the PrimaryKey using SimpleKeys.
1223     *
1224         * @param moduleId Integer
1225         * @param issueTypeId Integer
1226         */

1227    public void setPrimaryKey( Integer JavaDoc moduleId, Integer JavaDoc issueTypeId)
1228        throws TorqueException
1229    {
1230            setModuleId(moduleId);
1231            setIssueTypeId(issueTypeId);
1232        }
1233
1234    /**
1235     * Set the PrimaryKey using a String.
1236     */

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

1246    public ObjectKey getPrimaryKey()
1247    {
1248              pks[0] = SimpleKey.keyFor(getModuleId());
1249                  pks[1] = SimpleKey.keyFor(getIssueTypeId());
1250                  return comboPK;
1251      }
1252 
1253    /**
1254     * get an id that differentiates this object from others
1255     * of its class.
1256     */

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

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

1285      public RModuleIssueType copy() throws TorqueException
1286    {
1287        RModuleIssueType copyObj = new RModuleIssueType();
1288            copyObj.setModuleId(moduleId);
1289          copyObj.setIssueTypeId(issueTypeId);
1290          copyObj.setActive(active);
1291          copyObj.setDisplay(display);
1292          copyObj.setOrder(order);
1293          copyObj.setDedupe(dedupe);
1294          copyObj.setHistory(history);
1295          copyObj.setComments(comments);
1296          copyObj.setDisplayName(displayName);
1297          copyObj.setDisplayDescription(displayDescription);
1298  
1299                      copyObj.setModuleId((Integer JavaDoc)null);
1300                                copyObj.setIssueTypeId((Integer JavaDoc)null);
1301                                                            
1302                                                        
1303                
1304        List JavaDoc v = getConditions();
1305        for (int i = 0; i < v.size(); i++)
1306        {
1307            Condition obj = (Condition) v.get(i);
1308            copyObj.addCondition(obj.copy());
1309        }
1310                            return copyObj;
1311    }
1312
1313    /**
1314     * returns a peer instance associated with this om. Since Peer classes
1315     * are not to have any instance attributes, this method returns the
1316     * same instance for all member of this class. The method could therefore
1317     * be static, but this would prevent one from overriding the behavior.
1318     */

1319    public RModuleIssueTypePeer getPeer()
1320    {
1321        return peer;
1322    }
1323
1324    public String JavaDoc toString()
1325    {
1326        StringBuffer JavaDoc str = new StringBuffer JavaDoc();
1327        str.append("RModuleIssueType:\n");
1328        str.append("ModuleId = ")
1329               .append(getModuleId())
1330             .append("\n");
1331        str.append("IssueTypeId = ")
1332               .append(getIssueTypeId())
1333             .append("\n");
1334        str.append("Active = ")
1335               .append(getActive())
1336             .append("\n");
1337        str.append("Display = ")
1338               .append(getDisplay())
1339             .append("\n");
1340        str.append("Order = ")
1341               .append(getOrder())
1342             .append("\n");
1343        str.append("Dedupe = ")
1344               .append(getDedupe())
1345             .append("\n");
1346        str.append("History = ")
1347               .append(getHistory())
1348             .append("\n");
1349        str.append("Comments = ")
1350               .append(getComments())
1351             .append("\n");
1352        str.append("DisplayName = ")
1353               .append(getDisplayName())
1354             .append("\n");
1355        str.append("DisplayDescription = ")
1356               .append(getDisplayDescription())
1357             .append("\n");
1358        return(str.toString());
1359    }
1360}
1361
Popular Tags