KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.tigris.scarab.om;
2
3
4 import java.math.BigDecimal JavaDoc;
5 import java.sql.Connection JavaDoc;
6 import java.util.ArrayList JavaDoc;
7 import java.util.Collections JavaDoc;
8 import java.util.Date JavaDoc;
9 import java.util.List JavaDoc;
10
11 import org.apache.commons.lang.ObjectUtils;
12 import org.apache.fulcrum.intake.Retrievable;
13 import org.apache.torque.TorqueException;
14 import org.apache.torque.om.BaseObject;
15 import org.apache.torque.om.ComboKey;
16 import org.apache.torque.om.DateKey;
17 import org.apache.torque.om.NumberKey;
18 import org.apache.torque.om.ObjectKey;
19 import org.apache.torque.om.SimpleKey;
20 import org.apache.torque.om.StringKey;
21 import org.apache.torque.om.Persistent;
22 import org.apache.torque.util.Criteria;
23 import org.apache.torque.util.Transaction;
24
25   
26       
27     
28   
29 /**
30  * You should not use this class directly. It should not even be
31  * extended all references should be to RModuleAttribute
32  */

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

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

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

117     public Integer JavaDoc getAttributeId()
118     {
119         return attributeId;
120     }
121
122                                             
123     /**
124      * Set the value of AttributeId
125      *
126      * @param v new value
127      */

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

160     public Integer JavaDoc getIssueTypeId()
161     {
162         return issueTypeId;
163     }
164
165                                             
166     /**
167      * Set the value of IssueTypeId
168      *
169      * @param v new value
170      */

171     public void setIssueTypeId(Integer JavaDoc v) throws TorqueException
172     {
173     
174                   if (!ObjectUtils.equals(this.issueTypeId, v))
175               {
176             this.issueTypeId = v;
177             setModified(true);
178         }
179     
180                                   
181                 if (aIssueType != null && !ObjectUtils.equals(aIssueType.getIssueTypeId(), v))
182                 {
183             aIssueType = null;
184         }
185       
186                                   
187         // update associated Condition
188
if (collConditions != null)
189         {
190             for (int i = 0; i < collConditions.size(); i++)
191             {
192                 ((Condition) collConditions.get(i))
193                         .setIssueTypeId(v);
194             }
195         }
196                       }
197   
198     /**
199      * Get the DisplayValue
200      *
201      * @return String
202      */

203     public String JavaDoc getDisplayValue()
204     {
205         return displayValue;
206     }
207
208                         
209     /**
210      * Set the value of DisplayValue
211      *
212      * @param v new value
213      */

214     public void setDisplayValue(String JavaDoc v)
215     {
216     
217                   if (!ObjectUtils.equals(this.displayValue, v))
218               {
219             this.displayValue = v;
220             setModified(true);
221         }
222     
223           
224               }
225   
226     /**
227      * Get the Active
228      *
229      * @return boolean
230      */

231     public boolean getActive()
232     {
233         return active;
234     }
235
236                         
237     /**
238      * Set the value of Active
239      *
240      * @param v new value
241      */

242     public void setActive(boolean v)
243     {
244     
245                   if (this.active != v)
246               {
247             this.active = v;
248             setModified(true);
249         }
250     
251           
252               }
253   
254     /**
255      * Get the Required
256      *
257      * @return boolean
258      */

259     public boolean getRequired()
260     {
261         return required;
262     }
263
264                         
265     /**
266      * Set the value of Required
267      *
268      * @param v new value
269      */

270     public void setRequired(boolean v)
271     {
272     
273                   if (this.required != v)
274               {
275             this.required = v;
276             setModified(true);
277         }
278     
279           
280               }
281   
282     /**
283      * Get the Order
284      *
285      * @return int
286      */

287     public int getOrder()
288     {
289         return order;
290     }
291
292                         
293     /**
294      * Set the value of Order
295      *
296      * @param v new value
297      */

298     public void setOrder(int v)
299     {
300     
301                   if (this.order != v)
302               {
303             this.order = v;
304             setModified(true);
305         }
306     
307           
308               }
309   
310     /**
311      * Get the QuickSearch
312      *
313      * @return boolean
314      */

315     public boolean getQuickSearch()
316     {
317         return quickSearch;
318     }
319
320                         
321     /**
322      * Set the value of QuickSearch
323      *
324      * @param v new value
325      */

326     public void setQuickSearch(boolean v)
327     {
328     
329                   if (this.quickSearch != v)
330               {
331             this.quickSearch = v;
332             setModified(true);
333         }
334     
335           
336               }
337   
338     /**
339      * Get the DefaultTextFlag
340      *
341      * @return boolean
342      */

343     public boolean getDefaultTextFlag()
344     {
345         return defaultTextFlag;
346     }
347
348                         
349     /**
350      * Set the value of DefaultTextFlag
351      *
352      * @param v new value
353      */

354     public void setDefaultTextFlag(boolean v)
355     {
356     
357                   if (this.defaultTextFlag != v)
358               {
359             this.defaultTextFlag = v;
360             setModified(true);
361         }
362     
363           
364               }
365   
366       
367         
368                   
369         private Attribute aAttribute;
370
371     /**
372      * Declares an association between this object and a Attribute object
373      *
374      * @param v Attribute
375      * @throws TorqueException
376      */

377     public void setAttribute(Attribute v) throws TorqueException
378     {
379             if (v == null)
380         {
381                   setAttributeId((Integer JavaDoc) null);
382               }
383         else
384         {
385             setAttributeId(v.getAttributeId());
386         }
387             aAttribute = v;
388     }
389
390                         
391     /**
392      * Get the associated Attribute object
393      *
394      * @return the associated Attribute object
395      * @throws TorqueException
396      */

397     public Attribute getAttribute() throws TorqueException
398     {
399         if ( !ObjectUtils.equals(getAttributeId(), null) )
400         {
401                 return AttributeManager.getInstance(SimpleKey.keyFor(getAttributeId()));
402             }
403         return aAttribute;
404     }
405
406     /**
407      * Provides convenient way to set a relationship based on a
408      * ObjectKey, for example
409      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
410      *
411          */

412     public void setAttributeKey(ObjectKey key) throws TorqueException
413     {
414     
415                     setAttributeId(new Integer JavaDoc(((NumberKey) key).intValue()));
416               }
417   
418             
419                   
420         private Module aModule;
421
422     /**
423      * Declares an association between this object and a Module object
424      *
425      * @param v Module
426      * @throws TorqueException
427      */

428     public void setModule(Module v) throws TorqueException
429     {
430             if (v == null)
431         {
432                   setModuleId((Integer JavaDoc) null);
433               }
434         else
435         {
436             setModuleId(v.getModuleId());
437         }
438             aModule = v;
439     }
440
441                         
442     /**
443      * Get the associated Module object
444      *
445      * @return the associated Module object
446      * @throws TorqueException
447      */

448     public Module getModule() throws TorqueException
449     {
450         if ( !ObjectUtils.equals(getModuleId(), null) )
451         {
452                 return ModuleManager.getInstance(SimpleKey.keyFor(getModuleId()));
453             }
454         return aModule;
455     }
456
457     /**
458      * Provides convenient way to set a relationship based on a
459      * ObjectKey, for example
460      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
461      *
462          */

463     public void setModuleKey(ObjectKey key) throws TorqueException
464     {
465     
466                     setModuleId(new Integer JavaDoc(((NumberKey) key).intValue()));
467               }
468   
469         
470                   
471         private IssueType aIssueType;
472
473     /**
474      * Declares an association between this object and a IssueType object
475      *
476      * @param v IssueType
477      * @throws TorqueException
478      */

479     public void setIssueType(IssueType v) throws TorqueException
480     {
481             if (v == null)
482         {
483                   setIssueTypeId((Integer JavaDoc) null);
484               }
485         else
486         {
487             setIssueTypeId(v.getIssueTypeId());
488         }
489             aIssueType = v;
490     }
491
492                         
493     /**
494      * Get the associated IssueType object
495      *
496      * @return the associated IssueType object
497      * @throws TorqueException
498      */

499     public IssueType getIssueType() throws TorqueException
500     {
501         if ( !ObjectUtils.equals(getIssueTypeId(), null) )
502         {
503                 return IssueTypeManager.getInstance(SimpleKey.keyFor(getIssueTypeId()));
504             }
505         return aIssueType;
506     }
507
508     /**
509      * Provides convenient way to set a relationship based on a
510      * ObjectKey, for example
511      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
512      *
513          */

514     public void setIssueTypeKey(ObjectKey key) throws TorqueException
515     {
516     
517                     setIssueTypeId(new Integer JavaDoc(((NumberKey) key).intValue()));
518               }
519      
520                                                             
521             
522     /**
523      * Collection to store aggregation of collConditions
524      */

525     protected List JavaDoc collConditions;
526
527     /**
528      * Temporary storage of collConditions to save a possible db hit in
529      * the event objects are add to the collection, but the
530      * complete collection is never requested.
531      */

532     protected void initConditions()
533     {
534         if (collConditions == null)
535         {
536             collConditions = new ArrayList JavaDoc();
537         }
538     }
539
540             
541     /**
542      * Method called to associate a Condition object to this object
543      * through the Condition foreign key attribute
544      *
545      * @param l Condition
546      * @throws TorqueException
547      */

548     public void addCondition(Condition l) throws TorqueException
549     {
550         getConditions().add(l);
551         l.setRModuleAttribute((RModuleAttribute)this);
552     }
553
554     /**
555      * The criteria used to select the current contents of collConditions
556      */

557     private Criteria lastConditionsCriteria = null;
558
559     /**
560      * If this collection has already been initialized, returns
561      * the collection. Otherwise returns the results of
562      * getConditions(new Criteria())
563      *
564      * @throws TorqueException
565      */

566     public List JavaDoc getConditions() throws TorqueException
567     {
568         if (collConditions == null)
569         {
570             collConditions = getConditions(new Criteria(10));
571         }
572         return collConditions;
573     }
574
575     /**
576      * If this collection has already been initialized with
577      * an identical criteria, it returns the collection.
578      * Otherwise if this RModuleAttribute has previously
579      * been saved, it will retrieve related Conditions from storage.
580      * If this RModuleAttribute is new, it will return
581      * an empty collection or the current collection, the criteria
582      * is ignored on a new object.
583      *
584      * @throws TorqueException
585      */

586     public List JavaDoc getConditions(Criteria criteria) throws TorqueException
587     {
588         if (collConditions == null)
589         {
590             if (isNew())
591             {
592                collConditions = new ArrayList JavaDoc();
593             }
594             else
595             {
596                       criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
597                       criteria.add(ConditionPeer.ATTRIBUTE_ID, getAttributeId() );
598                       criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
599                       collConditions = ConditionPeer.doSelect(criteria);
600             }
601         }
602         else
603         {
604             // criteria has no effect for a new object
605
if (!isNew())
606             {
607                 // the following code is to determine if a new query is
608
// called for. If the criteria is the same as the last
609
// one, just return the collection.
610
criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
611                       criteria.add(ConditionPeer.ATTRIBUTE_ID, getAttributeId() );
612                       criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
613                       if (!lastConditionsCriteria.equals(criteria))
614                 {
615                     collConditions = ConditionPeer.doSelect(criteria);
616                 }
617             }
618         }
619         lastConditionsCriteria = criteria;
620
621         return collConditions;
622     }
623
624     /**
625      * If this collection has already been initialized, returns
626      * the collection. Otherwise returns the results of
627      * getConditions(new Criteria(),Connection)
628      * This method takes in the Connection also as input so that
629      * referenced objects can also be obtained using a Connection
630      * that is taken as input
631      */

632     public List JavaDoc getConditions(Connection JavaDoc con) throws TorqueException
633     {
634         if (collConditions == null)
635         {
636             collConditions = getConditions(new Criteria(10),con);
637         }
638         return collConditions;
639     }
640
641     /**
642      * If this collection has already been initialized with
643      * an identical criteria, it returns the collection.
644      * Otherwise if this RModuleAttribute has previously
645      * been saved, it will retrieve related Conditions from storage.
646      * If this RModuleAttribute is new, it will return
647      * an empty collection or the current collection, the criteria
648      * is ignored on a new object.
649      * This method takes in the Connection also as input so that
650      * referenced objects can also be obtained using a Connection
651      * that is taken as input
652      */

653     public List JavaDoc getConditions(Criteria criteria,Connection JavaDoc con) throws TorqueException
654     {
655         if (collConditions == null)
656         {
657             if (isNew())
658             {
659                collConditions = new ArrayList JavaDoc();
660             }
661             else
662             {
663                        criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
664                        criteria.add(ConditionPeer.ATTRIBUTE_ID, getAttributeId() );
665                        criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
666                        collConditions = ConditionPeer.doSelect(criteria,con);
667              }
668          }
669          else
670          {
671              // criteria has no effect for a new object
672
if (!isNew())
673              {
674                  // the following code is to determine if a new query is
675
// called for. If the criteria is the same as the last
676
// one, just return the collection.
677
criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
678                      criteria.add(ConditionPeer.ATTRIBUTE_ID, getAttributeId() );
679                      criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
680                      if (!lastConditionsCriteria.equals(criteria))
681                  {
682                      collConditions = ConditionPeer.doSelect(criteria,con);
683                  }
684              }
685          }
686          lastConditionsCriteria = criteria;
687
688          return collConditions;
689      }
690
691                                           
692               
693                     
694                               
695                                                                             
696                                                                                                           
697                                         
698                     
699                     
700           
701     /**
702      * If this collection has already been initialized with
703      * an identical criteria, it returns the collection.
704      * Otherwise if this RModuleAttribute is new, it will return
705      * an empty collection; or if this RModuleAttribute has previously
706      * been saved, it will retrieve related Conditions from storage.
707      *
708      * This method is protected by default in order to keep the public
709      * api reasonable. You can provide public methods for those you
710      * actually need in RModuleAttribute.
711      */

712     protected List JavaDoc getConditionsJoinRModuleAttribute(Criteria criteria)
713         throws TorqueException
714     {
715         if (collConditions == null)
716         {
717             if (isNew())
718             {
719                collConditions = new ArrayList JavaDoc();
720             }
721             else
722             {
723                             criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
724                             criteria.add(ConditionPeer.ATTRIBUTE_ID, getAttributeId() );
725                             criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
726                             collConditions = ConditionPeer.doSelectJoinRModuleAttribute(criteria);
727             }
728         }
729         else
730         {
731             // the following code is to determine if a new query is
732
// called for. If the criteria is the same as the last
733
// one, just return the collection.
734

735                             criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
736                             criteria.add(ConditionPeer.ATTRIBUTE_ID, getAttributeId() );
737                             criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
738                         if (!lastConditionsCriteria.equals(criteria))
739             {
740                 collConditions = ConditionPeer.doSelectJoinRModuleAttribute(criteria);
741             }
742         }
743         lastConditionsCriteria = criteria;
744
745         return collConditions;
746     }
747                   
748                     
749                     
750                                 
751                                                               
752                                         
753                     
754                     
755           
756     /**
757      * If this collection has already been initialized with
758      * an identical criteria, it returns the collection.
759      * Otherwise if this RModuleAttribute is new, it will return
760      * an empty collection; or if this RModuleAttribute has previously
761      * been saved, it will retrieve related Conditions from storage.
762      *
763      * This method is protected by default in order to keep the public
764      * api reasonable. You can provide public methods for those you
765      * actually need in RModuleAttribute.
766      */

767     protected List JavaDoc getConditionsJoinTransition(Criteria criteria)
768         throws TorqueException
769     {
770         if (collConditions == null)
771         {
772             if (isNew())
773             {
774                collConditions = new ArrayList JavaDoc();
775             }
776             else
777             {
778                             criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
779                             criteria.add(ConditionPeer.ATTRIBUTE_ID, getAttributeId() );
780                             criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
781                             collConditions = ConditionPeer.doSelectJoinTransition(criteria);
782             }
783         }
784         else
785         {
786             // the following code is to determine if a new query is
787
// called for. If the criteria is the same as the last
788
// one, just return the collection.
789

790                             criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
791                             criteria.add(ConditionPeer.ATTRIBUTE_ID, getAttributeId() );
792                             criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
793                         if (!lastConditionsCriteria.equals(criteria))
794             {
795                 collConditions = ConditionPeer.doSelectJoinTransition(criteria);
796             }
797         }
798         lastConditionsCriteria = criteria;
799
800         return collConditions;
801     }
802                   
803                     
804                     
805                                 
806                                                               
807                                         
808                     
809                     
810           
811     /**
812      * If this collection has already been initialized with
813      * an identical criteria, it returns the collection.
814      * Otherwise if this RModuleAttribute is new, it will return
815      * an empty collection; or if this RModuleAttribute has previously
816      * been saved, it will retrieve related Conditions from storage.
817      *
818      * This method is protected by default in order to keep the public
819      * api reasonable. You can provide public methods for those you
820      * actually need in RModuleAttribute.
821      */

822     protected List JavaDoc getConditionsJoinAttribute(Criteria criteria)
823         throws TorqueException
824     {
825         if (collConditions == null)
826         {
827             if (isNew())
828             {
829                collConditions = new ArrayList JavaDoc();
830             }
831             else
832             {
833                             criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
834                             criteria.add(ConditionPeer.ATTRIBUTE_ID, getAttributeId() );
835                             criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
836                             collConditions = ConditionPeer.doSelectJoinAttribute(criteria);
837             }
838         }
839         else
840         {
841             // the following code is to determine if a new query is
842
// called for. If the criteria is the same as the last
843
// one, just return the collection.
844

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

877     protected List JavaDoc getConditionsJoinAttributeOption(Criteria criteria)
878         throws TorqueException
879     {
880         if (collConditions == null)
881         {
882             if (isNew())
883             {
884                collConditions = new ArrayList JavaDoc();
885             }
886             else
887             {
888                             criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
889                             criteria.add(ConditionPeer.ATTRIBUTE_ID, getAttributeId() );
890                             criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
891                             collConditions = ConditionPeer.doSelectJoinAttributeOption(criteria);
892             }
893         }
894         else
895         {
896             // the following code is to determine if a new query is
897
// called for. If the criteria is the same as the last
898
// one, just return the collection.
899

900                             criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
901                             criteria.add(ConditionPeer.ATTRIBUTE_ID, getAttributeId() );
902                             criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
903                         if (!lastConditionsCriteria.equals(criteria))
904             {
905                 collConditions = ConditionPeer.doSelectJoinAttributeOption(criteria);
906             }
907         }
908         lastConditionsCriteria = criteria;
909
910         return collConditions;
911     }
912                   
913                     
914                     
915                                                       
916                                                                                     
917                                         
918                     
919                     
920           
921     /**
922      * If this collection has already been initialized with
923      * an identical criteria, it returns the collection.
924      * Otherwise if this RModuleAttribute is new, it will return
925      * an empty collection; or if this RModuleAttribute has previously
926      * been saved, it will retrieve related Conditions from storage.
927      *
928      * This method is protected by default in order to keep the public
929      * api reasonable. You can provide public methods for those you
930      * actually need in RModuleAttribute.
931      */

932     protected List JavaDoc getConditionsJoinRModuleIssueType(Criteria criteria)
933         throws TorqueException
934     {
935         if (collConditions == null)
936         {
937             if (isNew())
938             {
939                collConditions = new ArrayList JavaDoc();
940             }
941             else
942             {
943                             criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
944                             criteria.add(ConditionPeer.ATTRIBUTE_ID, getAttributeId() );
945                             criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
946                             collConditions = ConditionPeer.doSelectJoinRModuleIssueType(criteria);
947             }
948         }
949         else
950         {
951             // the following code is to determine if a new query is
952
// called for. If the criteria is the same as the last
953
// one, just return the collection.
954

955                             criteria.add(ConditionPeer.MODULE_ID, getModuleId() );
956                             criteria.add(ConditionPeer.ATTRIBUTE_ID, getAttributeId() );
957                             criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() );
958                         if (!lastConditionsCriteria.equals(criteria))
959             {
960                 collConditions = ConditionPeer.doSelectJoinRModuleIssueType(criteria);
961             }
962         }
963         lastConditionsCriteria = criteria;
964
965         return collConditions;
966     }
967                             
968
969
970           
971     private static List JavaDoc fieldNames = null;
972
973     /**
974      * Generate a list of field names.
975      *
976      * @return a list of field names
977      */

978     public static synchronized List JavaDoc getFieldNames()
979     {
980         if (fieldNames == null)
981         {
982             fieldNames = new ArrayList JavaDoc();
983               fieldNames.add("ModuleId");
984               fieldNames.add("AttributeId");
985               fieldNames.add("IssueTypeId");
986               fieldNames.add("DisplayValue");
987               fieldNames.add("Active");
988               fieldNames.add("Required");
989               fieldNames.add("Order");
990               fieldNames.add("QuickSearch");
991               fieldNames.add("DefaultTextFlag");
992               fieldNames = Collections.unmodifiableList(fieldNames);
993         }
994         return fieldNames;
995     }
996
997     /**
998      * Retrieves a field from the object by name passed in as a String.
999      *
1000     * @param name field name
1001     * @return value
1002     */

1003    public Object JavaDoc getByName(String JavaDoc name)
1004    {
1005          if (name.equals("ModuleId"))
1006        {
1007                return getModuleId();
1008            }
1009          if (name.equals("AttributeId"))
1010        {
1011                return getAttributeId();
1012            }
1013          if (name.equals("IssueTypeId"))
1014        {
1015                return getIssueTypeId();
1016            }
1017          if (name.equals("DisplayValue"))
1018        {
1019                return getDisplayValue();
1020            }
1021          if (name.equals("Active"))
1022        {
1023                return Boolean.valueOf(getActive());
1024            }
1025          if (name.equals("Required"))
1026        {
1027                return Boolean.valueOf(getRequired());
1028            }
1029          if (name.equals("Order"))
1030        {
1031                return new Integer JavaDoc(getOrder());
1032            }
1033          if (name.equals("QuickSearch"))
1034        {
1035                return Boolean.valueOf(getQuickSearch());
1036            }
1037          if (name.equals("DefaultTextFlag"))
1038        {
1039                return Boolean.valueOf(getDefaultTextFlag());
1040            }
1041          return null;
1042    }
1043    
1044    /**
1045     * Retrieves a field from the object by name passed in
1046     * as a String. The String must be one of the static
1047     * Strings defined in this Class' Peer.
1048     *
1049     * @param name peer name
1050     * @return value
1051     */

1052    public Object JavaDoc getByPeerName(String JavaDoc name)
1053    {
1054          if (name.equals(RModuleAttributePeer.MODULE_ID))
1055        {
1056                return getModuleId();
1057            }
1058          if (name.equals(RModuleAttributePeer.ATTRIBUTE_ID))
1059        {
1060                return getAttributeId();
1061            }
1062          if (name.equals(RModuleAttributePeer.ISSUE_TYPE_ID))
1063        {
1064                return getIssueTypeId();
1065            }
1066          if (name.equals(RModuleAttributePeer.DISPLAY_VALUE))
1067        {
1068                return getDisplayValue();
1069            }
1070          if (name.equals(RModuleAttributePeer.ACTIVE))
1071        {
1072                return Boolean.valueOf(getActive());
1073            }
1074          if (name.equals(RModuleAttributePeer.REQUIRED))
1075        {
1076                return Boolean.valueOf(getRequired());
1077            }
1078          if (name.equals(RModuleAttributePeer.PREFERRED_ORDER))
1079        {
1080                return new Integer JavaDoc(getOrder());
1081            }
1082          if (name.equals(RModuleAttributePeer.QUICK_SEARCH))
1083        {
1084                return Boolean.valueOf(getQuickSearch());
1085            }
1086          if (name.equals(RModuleAttributePeer.DEFAULT_TEXT_FLAG))
1087        {
1088                return Boolean.valueOf(getDefaultTextFlag());
1089            }
1090          return null;
1091    }
1092
1093    /**
1094     * Retrieves a field from the object by Position as specified
1095     * in the xml schema. Zero-based.
1096     *
1097     * @param pos position in xml schema
1098     * @return value
1099     */

1100    public Object JavaDoc getByPosition(int pos)
1101    {
1102            if (pos == 0)
1103        {
1104                return getModuleId();
1105            }
1106              if (pos == 1)
1107        {
1108                return getAttributeId();
1109            }
1110              if (pos == 2)
1111        {
1112                return getIssueTypeId();
1113            }
1114              if (pos == 3)
1115        {
1116                return getDisplayValue();
1117            }
1118              if (pos == 4)
1119        {
1120                return Boolean.valueOf(getActive());
1121            }
1122              if (pos == 5)
1123        {
1124                return Boolean.valueOf(getRequired());
1125            }
1126              if (pos == 6)
1127        {
1128                return new Integer JavaDoc(getOrder());
1129            }
1130              if (pos == 7)
1131        {
1132                return Boolean.valueOf(getQuickSearch());
1133            }
1134              if (pos == 8)
1135        {
1136                return Boolean.valueOf(getDefaultTextFlag());
1137            }
1138              return null;
1139    }
1140     
1141    /**
1142     * Stores the object in the database. If the object is new,
1143     * it inserts it; otherwise an update is performed.
1144     *
1145     * @throws Exception
1146     */

1147    public void save() throws Exception JavaDoc
1148    {
1149          save(RModuleAttributePeer.getMapBuilder()
1150                .getDatabaseMap().getName());
1151      }
1152
1153    /**
1154     * Stores the object in the database. If the object is new,
1155     * it inserts it; otherwise an update is performed.
1156       * Note: this code is here because the method body is
1157     * auto-generated conditionally and therefore needs to be
1158     * in this file instead of in the super class, BaseObject.
1159       *
1160     * @param dbName
1161     * @throws TorqueException
1162     */

1163    public void save(String JavaDoc dbName) throws TorqueException
1164    {
1165        Connection JavaDoc con = null;
1166          try
1167        {
1168            con = Transaction.begin(dbName);
1169            save(con);
1170            Transaction.commit(con);
1171        }
1172        catch(TorqueException e)
1173        {
1174            Transaction.safeRollback(con);
1175            throw e;
1176        }
1177      }
1178
1179      /** flag to prevent endless save loop, if this object is referenced
1180        by another object which falls in this transaction. */

1181    private boolean alreadyInSave = false;
1182      /**
1183     * Stores the object in the database. If the object is new,
1184     * it inserts it; otherwise an update is performed. This method
1185     * is meant to be used as part of a transaction, otherwise use
1186     * the save() method and the connection details will be handled
1187     * internally
1188     *
1189     * @param con
1190     * @throws TorqueException
1191     */

1192    public void save(Connection JavaDoc con) throws TorqueException
1193    {
1194          if (!alreadyInSave)
1195        {
1196            alreadyInSave = true;
1197
1198
1199  
1200            // If this object has been modified, then save it to the database.
1201
if (isModified())
1202            {
1203                if (isNew())
1204                {
1205                    RModuleAttributePeer.doInsert((RModuleAttribute)this, con);
1206                    setNew(false);
1207                }
1208                else
1209                {
1210                    RModuleAttributePeer.doUpdate((RModuleAttribute)this, con);
1211                }
1212
1213                      if (isCacheOnSave())
1214                {
1215                    RModuleAttributeManager.putInstance(this);
1216                }
1217              }
1218
1219                                                                          
1220                            if (collConditions != null)
1221            {
1222                for (int i = 0; i < collConditions.size(); i++)
1223                {
1224                    ((Condition)collConditions.get(i)).save(con);
1225                }
1226            }
1227                          alreadyInSave = false;
1228        }
1229      }
1230
1231    /**
1232     * Specify whether to cache the object after saving to the db.
1233     * This method returns false
1234     */

1235    protected boolean isCacheOnSave()
1236    {
1237        return true;
1238    }
1239
1240                                                                    
1241  
1242    private final SimpleKey[] pks = new SimpleKey[3];
1243    private final ComboKey comboPK = new ComboKey(pks);
1244
1245    /**
1246     * Set the PrimaryKey with an ObjectKey
1247     *
1248     * @param key
1249     */

1250    public void setPrimaryKey(ObjectKey key) throws TorqueException
1251    {
1252        SimpleKey[] keys = (SimpleKey[]) key.getValue();
1253        SimpleKey tmpKey = null;
1254                      setModuleId(new Integer JavaDoc(((NumberKey)keys[0]).intValue()));
1255                        setAttributeId(new Integer JavaDoc(((NumberKey)keys[1]).intValue()));
1256                        setIssueTypeId(new Integer JavaDoc(((NumberKey)keys[2]).intValue()));
1257              }
1258
1259    /**
1260     * Set the PrimaryKey using SimpleKeys.
1261     *
1262         * @param moduleId Integer
1263         * @param attributeId Integer
1264         * @param issueTypeId Integer
1265         */

1266    public void setPrimaryKey( Integer JavaDoc moduleId, Integer JavaDoc attributeId, Integer JavaDoc issueTypeId)
1267        throws TorqueException
1268    {
1269            setModuleId(moduleId);
1270            setAttributeId(attributeId);
1271            setIssueTypeId(issueTypeId);
1272        }
1273
1274    /**
1275     * Set the PrimaryKey using a String.
1276     */

1277    public void setPrimaryKey(String JavaDoc key) throws TorqueException
1278    {
1279        setPrimaryKey(new ComboKey(key));
1280    }
1281  
1282    /**
1283     * returns an id that differentiates this object from others
1284     * of its class.
1285     */

1286    public ObjectKey getPrimaryKey()
1287    {
1288              pks[0] = SimpleKey.keyFor(getModuleId());
1289                  pks[1] = SimpleKey.keyFor(getAttributeId());
1290                  pks[2] = SimpleKey.keyFor(getIssueTypeId());
1291                  return comboPK;
1292      }
1293 
1294    /**
1295     * get an id that differentiates this object from others
1296     * of its class.
1297     */

1298    public String JavaDoc getQueryKey()
1299    {
1300        if (getPrimaryKey() == null)
1301        {
1302            return "";
1303        }
1304        else
1305        {
1306            return getPrimaryKey().toString();
1307        }
1308    }
1309
1310    /**
1311     * set an id that differentiates this object from others
1312     * of its class.
1313     */

1314    public void setQueryKey(String JavaDoc key)
1315        throws TorqueException
1316    {
1317        setPrimaryKey(key);
1318    }
1319
1320    /**
1321     * Makes a copy of this object.
1322     * It creates a new object filling in the simple attributes.
1323       * It then fills all the association collections and sets the
1324     * related objects to isNew=true.
1325       */

1326      public RModuleAttribute copy() throws TorqueException
1327    {
1328        RModuleAttribute copyObj = new RModuleAttribute();
1329            copyObj.setModuleId(moduleId);
1330          copyObj.setAttributeId(attributeId);
1331          copyObj.setIssueTypeId(issueTypeId);
1332          copyObj.setDisplayValue(displayValue);
1333          copyObj.setActive(active);
1334          copyObj.setRequired(required);
1335          copyObj.setOrder(order);
1336          copyObj.setQuickSearch(quickSearch);
1337          copyObj.setDefaultTextFlag(defaultTextFlag);
1338  
1339                      copyObj.setModuleId((Integer JavaDoc)null);
1340                                copyObj.setAttributeId((Integer JavaDoc)null);
1341                                copyObj.setIssueTypeId((Integer JavaDoc)null);
1342                                                
1343                                                                          
1344                
1345        List JavaDoc v = getConditions();
1346        for (int i = 0; i < v.size(); i++)
1347        {
1348            Condition obj = (Condition) v.get(i);
1349            copyObj.addCondition(obj.copy());
1350        }
1351                            return copyObj;
1352    }
1353
1354    /**
1355     * returns a peer instance associated with this om. Since Peer classes
1356     * are not to have any instance attributes, this method returns the
1357     * same instance for all member of this class. The method could therefore
1358     * be static, but this would prevent one from overriding the behavior.
1359     */

1360    public RModuleAttributePeer getPeer()
1361    {
1362        return peer;
1363    }
1364
1365    public String JavaDoc toString()
1366    {
1367        StringBuffer JavaDoc str = new StringBuffer JavaDoc();
1368        str.append("RModuleAttribute:\n");
1369        str.append("ModuleId = ")
1370               .append(getModuleId())
1371             .append("\n");
1372        str.append("AttributeId = ")
1373               .append(getAttributeId())
1374             .append("\n");
1375        str.append("IssueTypeId = ")
1376               .append(getIssueTypeId())
1377             .append("\n");
1378        str.append("DisplayValue = ")
1379               .append(getDisplayValue())
1380             .append("\n");
1381        str.append("Active = ")
1382               .append(getActive())
1383             .append("\n");
1384        str.append("Required = ")
1385               .append(getRequired())
1386             .append("\n");
1387        str.append("Order = ")
1388               .append(getOrder())
1389             .append("\n");
1390        str.append("QuickSearch = ")
1391               .append(getQuickSearch())
1392             .append("\n");
1393        str.append("DefaultTextFlag = ")
1394               .append(getDefaultTextFlag())
1395             .append("\n");
1396        return(str.toString());
1397    }
1398}
1399
Popular Tags