KickJava   Java API By Example, From Geeks To Geeks.

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


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

35 public abstract class BaseRModuleUserAttribute extends BaseObject
36     implements org.apache.fulcrum.intake.Retrievable
37 {
38     /** The Peer class */
39     private static final RModuleUserAttributePeer peer =
40         new RModuleUserAttributePeer();
41
42         
43     /** The value for the rmuaId field */
44     private Long JavaDoc rmuaId;
45       
46     /** The value for the listId field */
47     private Long JavaDoc listId;
48       
49     /** The value for the moduleId field */
50     private Integer JavaDoc moduleId;
51       
52     /** The value for the userId field */
53     private Integer JavaDoc userId;
54       
55     /** The value for the issueTypeId field */
56     private Integer JavaDoc issueTypeId;
57       
58     /** The value for the attributeId field */
59     private Integer JavaDoc attributeId;
60                                           
61     /** The value for the order field */
62     private int order = 0;
63   
64     
65     /**
66      * Get the RmuaId
67      *
68      * @return Long
69      */

70     public Long JavaDoc getRmuaId()
71     {
72         return rmuaId;
73     }
74
75                         
76     /**
77      * Set the value of RmuaId
78      *
79      * @param v new value
80      */

81     public void setRmuaId(Long JavaDoc v)
82     {
83     
84                   if (!ObjectUtils.equals(this.rmuaId, v))
85               {
86             this.rmuaId = v;
87             setModified(true);
88         }
89     
90           
91               }
92   
93     /**
94      * Get the ListId
95      *
96      * @return Long
97      */

98     public Long JavaDoc getListId()
99     {
100         return listId;
101     }
102
103                               
104     /**
105      * Set the value of ListId
106      *
107      * @param v new value
108      */

109     public void setListId(Long JavaDoc v) throws TorqueException
110     {
111     
112                   if (!ObjectUtils.equals(this.listId, v))
113               {
114             this.listId = v;
115             setModified(true);
116         }
117     
118                                   
119                 if (aMITList != null && !ObjectUtils.equals(aMITList.getListId(), v))
120                 {
121             aMITList = null;
122         }
123       
124               }
125   
126     /**
127      * Get the ModuleId
128      *
129      * @return Integer
130      */

131     public Integer JavaDoc getModuleId()
132     {
133         return moduleId;
134     }
135
136                               
137     /**
138      * Set the value of ModuleId
139      *
140      * @param v new value
141      */

142     public void setModuleId(Integer JavaDoc v) throws TorqueException
143     {
144     
145                   if (!ObjectUtils.equals(this.moduleId, v))
146               {
147             this.moduleId = v;
148             setModified(true);
149         }
150     
151                                           
152                 if (aModule != null && !ObjectUtils.equals(aModule.getModuleId(), v))
153                 {
154             aModule = null;
155         }
156       
157               }
158   
159     /**
160      * Get the UserId
161      *
162      * @return Integer
163      */

164     public Integer JavaDoc getUserId()
165     {
166         return userId;
167     }
168
169                               
170     /**
171      * Set the value of UserId
172      *
173      * @param v new value
174      */

175     public void setUserId(Integer JavaDoc v) throws TorqueException
176     {
177     
178                   if (!ObjectUtils.equals(this.userId, v))
179               {
180             this.userId = v;
181             setModified(true);
182         }
183     
184                                           
185                 if (aScarabUser != null && !ObjectUtils.equals(aScarabUser.getUserId(), v))
186                 {
187             aScarabUser = null;
188         }
189       
190               }
191   
192     /**
193      * Get the IssueTypeId
194      *
195      * @return Integer
196      */

197     public Integer JavaDoc getIssueTypeId()
198     {
199         return issueTypeId;
200     }
201
202                               
203     /**
204      * Set the value of IssueTypeId
205      *
206      * @param v new value
207      */

208     public void setIssueTypeId(Integer JavaDoc v) throws TorqueException
209     {
210     
211                   if (!ObjectUtils.equals(this.issueTypeId, v))
212               {
213             this.issueTypeId = v;
214             setModified(true);
215         }
216     
217                                   
218                 if (aIssueType != null && !ObjectUtils.equals(aIssueType.getIssueTypeId(), v))
219                 {
220             aIssueType = null;
221         }
222       
223               }
224   
225     /**
226      * Get the AttributeId
227      *
228      * @return Integer
229      */

230     public Integer JavaDoc getAttributeId()
231     {
232         return attributeId;
233     }
234
235                               
236     /**
237      * Set the value of AttributeId
238      *
239      * @param v new value
240      */

241     public void setAttributeId(Integer JavaDoc v) throws TorqueException
242     {
243     
244                   if (!ObjectUtils.equals(this.attributeId, v))
245               {
246             this.attributeId = v;
247             setModified(true);
248         }
249     
250                                   
251                 if (aAttribute != null && !ObjectUtils.equals(aAttribute.getAttributeId(), v))
252                 {
253             aAttribute = null;
254         }
255       
256               }
257   
258     /**
259      * Get the Order
260      *
261      * @return int
262      */

263     public int getOrder()
264     {
265         return order;
266     }
267
268                         
269     /**
270      * Set the value of Order
271      *
272      * @param v new value
273      */

274     public void setOrder(int v)
275     {
276     
277                   if (this.order != v)
278               {
279             this.order = v;
280             setModified(true);
281         }
282     
283           
284               }
285   
286       
287         
288                   
289         private MITList aMITList;
290
291     /**
292      * Declares an association between this object and a MITList object
293      *
294      * @param v MITList
295      * @throws TorqueException
296      */

297     public void setMITList(MITList v) throws TorqueException
298     {
299             if (v == null)
300         {
301                   setListId((Long JavaDoc) null);
302               }
303         else
304         {
305             setListId(v.getListId());
306         }
307             aMITList = v;
308     }
309
310                         
311     /**
312      * Get the associated MITList object
313      *
314      * @return the associated MITList object
315      * @throws TorqueException
316      */

317     public MITList getMITList() throws TorqueException
318     {
319         if ( !ObjectUtils.equals(getListId(), null) )
320         {
321                 return MITListManager.getInstance(SimpleKey.keyFor(getListId()));
322             }
323         return aMITList;
324     }
325
326     /**
327      * Provides convenient way to set a relationship based on a
328      * ObjectKey, for example
329      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
330      *
331          */

332     public void setMITListKey(ObjectKey key) throws TorqueException
333     {
334     
335                     setListId(new Long JavaDoc(((NumberKey) key).longValue()));
336               }
337   
338             
339                   
340         private Module aModule;
341
342     /**
343      * Declares an association between this object and a Module object
344      *
345      * @param v Module
346      * @throws TorqueException
347      */

348     public void setModule(Module v) throws TorqueException
349     {
350             if (v == null)
351         {
352                   setModuleId((Integer JavaDoc) null);
353               }
354         else
355         {
356             setModuleId(v.getModuleId());
357         }
358             aModule = v;
359     }
360
361                         
362     /**
363      * Get the associated Module object
364      *
365      * @return the associated Module object
366      * @throws TorqueException
367      */

368     public Module getModule() throws TorqueException
369     {
370         if ( !ObjectUtils.equals(getModuleId(), null) )
371         {
372                 return ModuleManager.getInstance(SimpleKey.keyFor(getModuleId()));
373             }
374         return aModule;
375     }
376
377     /**
378      * Provides convenient way to set a relationship based on a
379      * ObjectKey, for example
380      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
381      *
382          */

383     public void setModuleKey(ObjectKey key) throws TorqueException
384     {
385     
386                     setModuleId(new Integer JavaDoc(((NumberKey) key).intValue()));
387               }
388   
389             
390                   
391         private ScarabUser aScarabUser;
392
393     /**
394      * Declares an association between this object and a ScarabUser object
395      *
396      * @param v ScarabUser
397      * @throws TorqueException
398      */

399     public void setScarabUser(ScarabUser v) throws TorqueException
400     {
401             if (v == null)
402         {
403                   setUserId((Integer JavaDoc) null);
404               }
405         else
406         {
407             setUserId(v.getUserId());
408         }
409             aScarabUser = v;
410     }
411
412                         
413     /**
414      * Get the associated ScarabUser object
415      *
416      * @return the associated ScarabUser object
417      * @throws TorqueException
418      */

419     public ScarabUser getScarabUser() throws TorqueException
420     {
421         if ( !ObjectUtils.equals(getUserId(), null) )
422         {
423                 return ScarabUserManager.getInstance(SimpleKey.keyFor(getUserId()));
424             }
425         return aScarabUser;
426     }
427
428     /**
429      * Provides convenient way to set a relationship based on a
430      * ObjectKey, for example
431      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
432      *
433          */

434     public void setScarabUserKey(ObjectKey key) throws TorqueException
435     {
436     
437                     setUserId(new Integer JavaDoc(((NumberKey) key).intValue()));
438               }
439   
440         
441                   
442         private IssueType aIssueType;
443
444     /**
445      * Declares an association between this object and a IssueType object
446      *
447      * @param v IssueType
448      * @throws TorqueException
449      */

450     public void setIssueType(IssueType v) throws TorqueException
451     {
452             if (v == null)
453         {
454                   setIssueTypeId((Integer JavaDoc) null);
455               }
456         else
457         {
458             setIssueTypeId(v.getIssueTypeId());
459         }
460             aIssueType = v;
461     }
462
463                         
464     /**
465      * Get the associated IssueType object
466      *
467      * @return the associated IssueType object
468      * @throws TorqueException
469      */

470     public IssueType getIssueType() throws TorqueException
471     {
472         if ( !ObjectUtils.equals(getIssueTypeId(), null) )
473         {
474                 return IssueTypeManager.getInstance(SimpleKey.keyFor(getIssueTypeId()));
475             }
476         return aIssueType;
477     }
478
479     /**
480      * Provides convenient way to set a relationship based on a
481      * ObjectKey, for example
482      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
483      *
484          */

485     public void setIssueTypeKey(ObjectKey key) throws TorqueException
486     {
487     
488                     setIssueTypeId(new Integer JavaDoc(((NumberKey) key).intValue()));
489               }
490   
491         
492                   
493         private Attribute aAttribute;
494
495     /**
496      * Declares an association between this object and a Attribute object
497      *
498      * @param v Attribute
499      * @throws TorqueException
500      */

501     public void setAttribute(Attribute v) throws TorqueException
502     {
503             if (v == null)
504         {
505                   setAttributeId((Integer JavaDoc) null);
506               }
507         else
508         {
509             setAttributeId(v.getAttributeId());
510         }
511             aAttribute = v;
512     }
513
514                         
515     /**
516      * Get the associated Attribute object
517      *
518      * @return the associated Attribute object
519      * @throws TorqueException
520      */

521     public Attribute getAttribute() throws TorqueException
522     {
523         if ( !ObjectUtils.equals(getAttributeId(), null) )
524         {
525                 return AttributeManager.getInstance(SimpleKey.keyFor(getAttributeId()));
526             }
527         return aAttribute;
528     }
529
530     /**
531      * Provides convenient way to set a relationship based on a
532      * ObjectKey, for example
533      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
534      *
535          */

536     public void setAttributeKey(ObjectKey key) throws TorqueException
537     {
538     
539                     setAttributeId(new Integer JavaDoc(((NumberKey) key).intValue()));
540               }
541      
542                 
543     private static List JavaDoc fieldNames = null;
544
545     /**
546      * Generate a list of field names.
547      *
548      * @return a list of field names
549      */

550     public static synchronized List JavaDoc getFieldNames()
551     {
552         if (fieldNames == null)
553         {
554             fieldNames = new ArrayList JavaDoc();
555               fieldNames.add("RmuaId");
556               fieldNames.add("ListId");
557               fieldNames.add("ModuleId");
558               fieldNames.add("UserId");
559               fieldNames.add("IssueTypeId");
560               fieldNames.add("AttributeId");
561               fieldNames.add("Order");
562               fieldNames = Collections.unmodifiableList(fieldNames);
563         }
564         return fieldNames;
565     }
566
567     /**
568      * Retrieves a field from the object by name passed in as a String.
569      *
570      * @param name field name
571      * @return value
572      */

573     public Object JavaDoc getByName(String JavaDoc name)
574     {
575           if (name.equals("RmuaId"))
576         {
577                 return getRmuaId();
578             }
579           if (name.equals("ListId"))
580         {
581                 return getListId();
582             }
583           if (name.equals("ModuleId"))
584         {
585                 return getModuleId();
586             }
587           if (name.equals("UserId"))
588         {
589                 return getUserId();
590             }
591           if (name.equals("IssueTypeId"))
592         {
593                 return getIssueTypeId();
594             }
595           if (name.equals("AttributeId"))
596         {
597                 return getAttributeId();
598             }
599           if (name.equals("Order"))
600         {
601                 return new Integer JavaDoc(getOrder());
602             }
603           return null;
604     }
605     
606     /**
607      * Retrieves a field from the object by name passed in
608      * as a String. The String must be one of the static
609      * Strings defined in this Class' Peer.
610      *
611      * @param name peer name
612      * @return value
613      */

614     public Object JavaDoc getByPeerName(String JavaDoc name)
615     {
616           if (name.equals(RModuleUserAttributePeer.RMUA_ID))
617         {
618                 return getRmuaId();
619             }
620           if (name.equals(RModuleUserAttributePeer.LIST_ID))
621         {
622                 return getListId();
623             }
624           if (name.equals(RModuleUserAttributePeer.MODULE_ID))
625         {
626                 return getModuleId();
627             }
628           if (name.equals(RModuleUserAttributePeer.USER_ID))
629         {
630                 return getUserId();
631             }
632           if (name.equals(RModuleUserAttributePeer.ISSUE_TYPE_ID))
633         {
634                 return getIssueTypeId();
635             }
636           if (name.equals(RModuleUserAttributePeer.ATTRIBUTE_ID))
637         {
638                 return getAttributeId();
639             }
640           if (name.equals(RModuleUserAttributePeer.PREFERRED_ORDER))
641         {
642                 return new Integer JavaDoc(getOrder());
643             }
644           return null;
645     }
646
647     /**
648      * Retrieves a field from the object by Position as specified
649      * in the xml schema. Zero-based.
650      *
651      * @param pos position in xml schema
652      * @return value
653      */

654     public Object JavaDoc getByPosition(int pos)
655     {
656             if (pos == 0)
657         {
658                 return getRmuaId();
659             }
660               if (pos == 1)
661         {
662                 return getListId();
663             }
664               if (pos == 2)
665         {
666                 return getModuleId();
667             }
668               if (pos == 3)
669         {
670                 return getUserId();
671             }
672               if (pos == 4)
673         {
674                 return getIssueTypeId();
675             }
676               if (pos == 5)
677         {
678                 return getAttributeId();
679             }
680               if (pos == 6)
681         {
682                 return new Integer JavaDoc(getOrder());
683             }
684               return null;
685     }
686      
687     /**
688      * Stores the object in the database. If the object is new,
689      * it inserts it; otherwise an update is performed.
690      *
691      * @throws Exception
692      */

693     public void save() throws Exception JavaDoc
694     {
695           save(RModuleUserAttributePeer.getMapBuilder()
696                 .getDatabaseMap().getName());
697       }
698
699     /**
700      * Stores the object in the database. If the object is new,
701      * it inserts it; otherwise an update is performed.
702        * Note: this code is here because the method body is
703      * auto-generated conditionally and therefore needs to be
704      * in this file instead of in the super class, BaseObject.
705        *
706      * @param dbName
707      * @throws TorqueException
708      */

709     public void save(String JavaDoc dbName) throws TorqueException
710     {
711         Connection JavaDoc con = null;
712           try
713         {
714             con = Transaction.begin(dbName);
715             save(con);
716             Transaction.commit(con);
717         }
718         catch(TorqueException e)
719         {
720             Transaction.safeRollback(con);
721             throw e;
722         }
723       }
724
725       /** flag to prevent endless save loop, if this object is referenced
726         by another object which falls in this transaction. */

727     private boolean alreadyInSave = false;
728       /**
729      * Stores the object in the database. If the object is new,
730      * it inserts it; otherwise an update is performed. This method
731      * is meant to be used as part of a transaction, otherwise use
732      * the save() method and the connection details will be handled
733      * internally
734      *
735      * @param con
736      * @throws TorqueException
737      */

738     public void save(Connection JavaDoc con) throws TorqueException
739     {
740           if (!alreadyInSave)
741         {
742             alreadyInSave = true;
743
744
745   
746             // If this object has been modified, then save it to the database.
747
if (isModified())
748             {
749                 if (isNew())
750                 {
751                     RModuleUserAttributePeer.doInsert((RModuleUserAttribute)this, con);
752                     setNew(false);
753                 }
754                 else
755                 {
756                     RModuleUserAttributePeer.doUpdate((RModuleUserAttribute)this, con);
757                 }
758
759                       if (isCacheOnSave())
760                 {
761                     RModuleUserAttributeManager.putInstance(this);
762                 }
763               }
764
765                       alreadyInSave = false;
766         }
767       }
768
769     /**
770      * Specify whether to cache the object after saving to the db.
771      * This method returns false
772      */

773     protected boolean isCacheOnSave()
774     {
775         return true;
776     }
777
778                   
779       /**
780      * Set the PrimaryKey using ObjectKey.
781      *
782      * @param rmuaId ObjectKey
783      */

784     public void setPrimaryKey(ObjectKey rmuaId)
785          {
786             setRmuaId(new Long JavaDoc(((NumberKey)rmuaId).longValue()));
787         }
788
789     /**
790      * Set the PrimaryKey using a String.
791      *
792      * @param key
793      */

794     public void setPrimaryKey(String JavaDoc key)
795     {
796             setRmuaId(new Long JavaDoc(key));
797         }
798
799   
800     /**
801      * returns an id that differentiates this object from others
802      * of its class.
803      */

804     public ObjectKey getPrimaryKey()
805     {
806           return SimpleKey.keyFor(getRmuaId());
807       }
808  
809     /**
810      * get an id that differentiates this object from others
811      * of its class.
812      */

813     public String JavaDoc getQueryKey()
814     {
815         if (getPrimaryKey() == null)
816         {
817             return "";
818         }
819         else
820         {
821             return getPrimaryKey().toString();
822         }
823     }
824
825     /**
826      * set an id that differentiates this object from others
827      * of its class.
828      */

829     public void setQueryKey(String JavaDoc key)
830         throws TorqueException
831     {
832         setPrimaryKey(key);
833     }
834
835     /**
836      * Makes a copy of this object.
837      * It creates a new object filling in the simple attributes.
838        * It then fills all the association collections and sets the
839      * related objects to isNew=true.
840        */

841       public RModuleUserAttribute copy() throws TorqueException
842     {
843         RModuleUserAttribute copyObj = new RModuleUserAttribute();
844             copyObj.setRmuaId(rmuaId);
845           copyObj.setListId(listId);
846           copyObj.setModuleId(moduleId);
847           copyObj.setUserId(userId);
848           copyObj.setIssueTypeId(issueTypeId);
849           copyObj.setAttributeId(attributeId);
850           copyObj.setOrder(order);
851   
852                       copyObj.setRmuaId((Long JavaDoc)null);
853                                                 
854                 return copyObj;
855     }
856
857     /**
858      * returns a peer instance associated with this om. Since Peer classes
859      * are not to have any instance attributes, this method returns the
860      * same instance for all member of this class. The method could therefore
861      * be static, but this would prevent one from overriding the behavior.
862      */

863     public RModuleUserAttributePeer getPeer()
864     {
865         return peer;
866     }
867
868     public String JavaDoc toString()
869     {
870         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
871         str.append("RModuleUserAttribute:\n");
872         str.append("RmuaId = ")
873                .append(getRmuaId())
874              .append("\n");
875         str.append("ListId = ")
876                .append(getListId())
877              .append("\n");
878         str.append("ModuleId = ")
879                .append(getModuleId())
880              .append("\n");
881         str.append("UserId = ")
882                .append(getUserId())
883              .append("\n");
884         str.append("IssueTypeId = ")
885                .append(getIssueTypeId())
886              .append("\n");
887         str.append("AttributeId = ")
888                .append(getAttributeId())
889              .append("\n");
890         str.append("Order = ")
891                .append(getOrder())
892              .append("\n");
893         return(str.toString());
894     }
895 }
896
Popular Tags