KickJava   Java API By Example, From Geeks To Geeks.

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


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 RIssueTypeAttribute
31  */

32 public abstract class BaseRIssueTypeAttribute extends BaseObject
33     implements org.apache.fulcrum.intake.Retrievable
34 {
35     /** The Peer class */
36     private static final RIssueTypeAttributePeer peer =
37         new RIssueTypeAttributePeer();
38
39         
40     /** The value for the attributeId field */
41     private Integer JavaDoc attributeId;
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 required field */
50     private boolean required = false;
51                                           
52     /** The value for the order field */
53     private int order = 0;
54                                                                 
55     /** The value for the quickSearch field */
56     private boolean quickSearch = false;
57                                                                 
58     /** The value for the defaultTextFlag field */
59     private boolean defaultTextFlag = false;
60                                                                 
61     /** The value for the locked field */
62     private boolean locked = false;
63   
64     
65     /**
66      * Get the AttributeId
67      *
68      * @return Integer
69      */

70     public Integer JavaDoc getAttributeId()
71     {
72         return attributeId;
73     }
74
75                               
76     /**
77      * Set the value of AttributeId
78      *
79      * @param v new value
80      */

81     public void setAttributeId(Integer JavaDoc v) throws TorqueException
82     {
83     
84                   if (!ObjectUtils.equals(this.attributeId, v))
85               {
86             this.attributeId = v;
87             setModified(true);
88         }
89     
90                                   
91                 if (aAttribute != null && !ObjectUtils.equals(aAttribute.getAttributeId(), v))
92                 {
93             aAttribute = null;
94         }
95       
96               }
97   
98     /**
99      * Get the IssueTypeId
100      *
101      * @return Integer
102      */

103     public Integer JavaDoc getIssueTypeId()
104     {
105         return issueTypeId;
106     }
107
108                               
109     /**
110      * Set the value of IssueTypeId
111      *
112      * @param v new value
113      */

114     public void setIssueTypeId(Integer JavaDoc v) throws TorqueException
115     {
116     
117                   if (!ObjectUtils.equals(this.issueTypeId, v))
118               {
119             this.issueTypeId = v;
120             setModified(true);
121         }
122     
123                                   
124                 if (aIssueType != null && !ObjectUtils.equals(aIssueType.getIssueTypeId(), v))
125                 {
126             aIssueType = null;
127         }
128       
129               }
130   
131     /**
132      * Get the Active
133      *
134      * @return boolean
135      */

136     public boolean getActive()
137     {
138         return active;
139     }
140
141                         
142     /**
143      * Set the value of Active
144      *
145      * @param v new value
146      */

147     public void setActive(boolean v)
148     {
149     
150                   if (this.active != v)
151               {
152             this.active = v;
153             setModified(true);
154         }
155     
156           
157               }
158   
159     /**
160      * Get the Required
161      *
162      * @return boolean
163      */

164     public boolean getRequired()
165     {
166         return required;
167     }
168
169                         
170     /**
171      * Set the value of Required
172      *
173      * @param v new value
174      */

175     public void setRequired(boolean v)
176     {
177     
178                   if (this.required != v)
179               {
180             this.required = v;
181             setModified(true);
182         }
183     
184           
185               }
186   
187     /**
188      * Get the Order
189      *
190      * @return int
191      */

192     public int getOrder()
193     {
194         return order;
195     }
196
197                         
198     /**
199      * Set the value of Order
200      *
201      * @param v new value
202      */

203     public void setOrder(int v)
204     {
205     
206                   if (this.order != v)
207               {
208             this.order = v;
209             setModified(true);
210         }
211     
212           
213               }
214   
215     /**
216      * Get the QuickSearch
217      *
218      * @return boolean
219      */

220     public boolean getQuickSearch()
221     {
222         return quickSearch;
223     }
224
225                         
226     /**
227      * Set the value of QuickSearch
228      *
229      * @param v new value
230      */

231     public void setQuickSearch(boolean v)
232     {
233     
234                   if (this.quickSearch != v)
235               {
236             this.quickSearch = v;
237             setModified(true);
238         }
239     
240           
241               }
242   
243     /**
244      * Get the DefaultTextFlag
245      *
246      * @return boolean
247      */

248     public boolean getDefaultTextFlag()
249     {
250         return defaultTextFlag;
251     }
252
253                         
254     /**
255      * Set the value of DefaultTextFlag
256      *
257      * @param v new value
258      */

259     public void setDefaultTextFlag(boolean v)
260     {
261     
262                   if (this.defaultTextFlag != v)
263               {
264             this.defaultTextFlag = v;
265             setModified(true);
266         }
267     
268           
269               }
270   
271     /**
272      * Get the Locked
273      *
274      * @return boolean
275      */

276     public boolean getLocked()
277     {
278         return locked;
279     }
280
281                         
282     /**
283      * Set the value of Locked
284      *
285      * @param v new value
286      */

287     public void setLocked(boolean v)
288     {
289     
290                   if (this.locked != v)
291               {
292             this.locked = v;
293             setModified(true);
294         }
295     
296           
297               }
298   
299       
300         
301                   
302         private Attribute aAttribute;
303
304     /**
305      * Declares an association between this object and a Attribute object
306      *
307      * @param v Attribute
308      * @throws TorqueException
309      */

310     public void setAttribute(Attribute v) throws TorqueException
311     {
312             if (v == null)
313         {
314                   setAttributeId((Integer JavaDoc) null);
315               }
316         else
317         {
318             setAttributeId(v.getAttributeId());
319         }
320             aAttribute = v;
321     }
322
323                         
324     /**
325      * Get the associated Attribute object
326      *
327      * @return the associated Attribute object
328      * @throws TorqueException
329      */

330     public Attribute getAttribute() throws TorqueException
331     {
332         if ( !ObjectUtils.equals(getAttributeId(), null) )
333         {
334                 return AttributeManager.getInstance(SimpleKey.keyFor(getAttributeId()));
335             }
336         return aAttribute;
337     }
338
339     /**
340      * Provides convenient way to set a relationship based on a
341      * ObjectKey, for example
342      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
343      *
344          */

345     public void setAttributeKey(ObjectKey key) throws TorqueException
346     {
347     
348                     setAttributeId(new Integer JavaDoc(((NumberKey) key).intValue()));
349               }
350   
351         
352                   
353         private IssueType aIssueType;
354
355     /**
356      * Declares an association between this object and a IssueType object
357      *
358      * @param v IssueType
359      * @throws TorqueException
360      */

361     public void setIssueType(IssueType v) throws TorqueException
362     {
363             if (v == null)
364         {
365                   setIssueTypeId((Integer JavaDoc) null);
366               }
367         else
368         {
369             setIssueTypeId(v.getIssueTypeId());
370         }
371             aIssueType = v;
372     }
373
374                         
375     /**
376      * Get the associated IssueType object
377      *
378      * @return the associated IssueType object
379      * @throws TorqueException
380      */

381     public IssueType getIssueType() throws TorqueException
382     {
383         if ( !ObjectUtils.equals(getIssueTypeId(), null) )
384         {
385                 return IssueTypeManager.getInstance(SimpleKey.keyFor(getIssueTypeId()));
386             }
387         return aIssueType;
388     }
389
390     /**
391      * Provides convenient way to set a relationship based on a
392      * ObjectKey, for example
393      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
394      *
395          */

396     public void setIssueTypeKey(ObjectKey key) throws TorqueException
397     {
398     
399                     setIssueTypeId(new Integer JavaDoc(((NumberKey) key).intValue()));
400               }
401      
402                 
403     private static List JavaDoc fieldNames = null;
404
405     /**
406      * Generate a list of field names.
407      *
408      * @return a list of field names
409      */

410     public static synchronized List JavaDoc getFieldNames()
411     {
412         if (fieldNames == null)
413         {
414             fieldNames = new ArrayList JavaDoc();
415               fieldNames.add("AttributeId");
416               fieldNames.add("IssueTypeId");
417               fieldNames.add("Active");
418               fieldNames.add("Required");
419               fieldNames.add("Order");
420               fieldNames.add("QuickSearch");
421               fieldNames.add("DefaultTextFlag");
422               fieldNames.add("Locked");
423               fieldNames = Collections.unmodifiableList(fieldNames);
424         }
425         return fieldNames;
426     }
427
428     /**
429      * Retrieves a field from the object by name passed in as a String.
430      *
431      * @param name field name
432      * @return value
433      */

434     public Object JavaDoc getByName(String JavaDoc name)
435     {
436           if (name.equals("AttributeId"))
437         {
438                 return getAttributeId();
439             }
440           if (name.equals("IssueTypeId"))
441         {
442                 return getIssueTypeId();
443             }
444           if (name.equals("Active"))
445         {
446                 return Boolean.valueOf(getActive());
447             }
448           if (name.equals("Required"))
449         {
450                 return Boolean.valueOf(getRequired());
451             }
452           if (name.equals("Order"))
453         {
454                 return new Integer JavaDoc(getOrder());
455             }
456           if (name.equals("QuickSearch"))
457         {
458                 return Boolean.valueOf(getQuickSearch());
459             }
460           if (name.equals("DefaultTextFlag"))
461         {
462                 return Boolean.valueOf(getDefaultTextFlag());
463             }
464           if (name.equals("Locked"))
465         {
466                 return Boolean.valueOf(getLocked());
467             }
468           return null;
469     }
470     
471     /**
472      * Retrieves a field from the object by name passed in
473      * as a String. The String must be one of the static
474      * Strings defined in this Class' Peer.
475      *
476      * @param name peer name
477      * @return value
478      */

479     public Object JavaDoc getByPeerName(String JavaDoc name)
480     {
481           if (name.equals(RIssueTypeAttributePeer.ATTRIBUTE_ID))
482         {
483                 return getAttributeId();
484             }
485           if (name.equals(RIssueTypeAttributePeer.ISSUE_TYPE_ID))
486         {
487                 return getIssueTypeId();
488             }
489           if (name.equals(RIssueTypeAttributePeer.ACTIVE))
490         {
491                 return Boolean.valueOf(getActive());
492             }
493           if (name.equals(RIssueTypeAttributePeer.REQUIRED))
494         {
495                 return Boolean.valueOf(getRequired());
496             }
497           if (name.equals(RIssueTypeAttributePeer.PREFERRED_ORDER))
498         {
499                 return new Integer JavaDoc(getOrder());
500             }
501           if (name.equals(RIssueTypeAttributePeer.QUICK_SEARCH))
502         {
503                 return Boolean.valueOf(getQuickSearch());
504             }
505           if (name.equals(RIssueTypeAttributePeer.DEFAULT_TEXT_FLAG))
506         {
507                 return Boolean.valueOf(getDefaultTextFlag());
508             }
509           if (name.equals(RIssueTypeAttributePeer.LOCKED))
510         {
511                 return Boolean.valueOf(getLocked());
512             }
513           return null;
514     }
515
516     /**
517      * Retrieves a field from the object by Position as specified
518      * in the xml schema. Zero-based.
519      *
520      * @param pos position in xml schema
521      * @return value
522      */

523     public Object JavaDoc getByPosition(int pos)
524     {
525             if (pos == 0)
526         {
527                 return getAttributeId();
528             }
529               if (pos == 1)
530         {
531                 return getIssueTypeId();
532             }
533               if (pos == 2)
534         {
535                 return Boolean.valueOf(getActive());
536             }
537               if (pos == 3)
538         {
539                 return Boolean.valueOf(getRequired());
540             }
541               if (pos == 4)
542         {
543                 return new Integer JavaDoc(getOrder());
544             }
545               if (pos == 5)
546         {
547                 return Boolean.valueOf(getQuickSearch());
548             }
549               if (pos == 6)
550         {
551                 return Boolean.valueOf(getDefaultTextFlag());
552             }
553               if (pos == 7)
554         {
555                 return Boolean.valueOf(getLocked());
556             }
557               return null;
558     }
559      
560     /**
561      * Stores the object in the database. If the object is new,
562      * it inserts it; otherwise an update is performed.
563      *
564      * @throws Exception
565      */

566     public void save() throws Exception JavaDoc
567     {
568           save(RIssueTypeAttributePeer.getMapBuilder()
569                 .getDatabaseMap().getName());
570       }
571
572     /**
573      * Stores the object in the database. If the object is new,
574      * it inserts it; otherwise an update is performed.
575        * Note: this code is here because the method body is
576      * auto-generated conditionally and therefore needs to be
577      * in this file instead of in the super class, BaseObject.
578        *
579      * @param dbName
580      * @throws TorqueException
581      */

582     public void save(String JavaDoc dbName) throws TorqueException
583     {
584         Connection JavaDoc con = null;
585           try
586         {
587             con = Transaction.begin(dbName);
588             save(con);
589             Transaction.commit(con);
590         }
591         catch(TorqueException e)
592         {
593             Transaction.safeRollback(con);
594             throw e;
595         }
596       }
597
598       /** flag to prevent endless save loop, if this object is referenced
599         by another object which falls in this transaction. */

600     private boolean alreadyInSave = false;
601       /**
602      * Stores the object in the database. If the object is new,
603      * it inserts it; otherwise an update is performed. This method
604      * is meant to be used as part of a transaction, otherwise use
605      * the save() method and the connection details will be handled
606      * internally
607      *
608      * @param con
609      * @throws TorqueException
610      */

611     public void save(Connection JavaDoc con) throws TorqueException
612     {
613           if (!alreadyInSave)
614         {
615             alreadyInSave = true;
616
617
618   
619             // If this object has been modified, then save it to the database.
620
if (isModified())
621             {
622                 if (isNew())
623                 {
624                     RIssueTypeAttributePeer.doInsert((RIssueTypeAttribute)this, con);
625                     setNew(false);
626                 }
627                 else
628                 {
629                     RIssueTypeAttributePeer.doUpdate((RIssueTypeAttribute)this, con);
630                 }
631
632                       if (isCacheOnSave())
633                 {
634                     RIssueTypeAttributeManager.putInstance(this);
635                 }
636               }
637
638                       alreadyInSave = false;
639         }
640       }
641
642     /**
643      * Specify whether to cache the object after saving to the db.
644      * This method returns false
645      */

646     protected boolean isCacheOnSave()
647     {
648         return true;
649     }
650
651                                               
652   
653     private final SimpleKey[] pks = new SimpleKey[2];
654     private final ComboKey comboPK = new ComboKey(pks);
655
656     /**
657      * Set the PrimaryKey with an ObjectKey
658      *
659      * @param key
660      */

661     public void setPrimaryKey(ObjectKey key) throws TorqueException
662     {
663         SimpleKey[] keys = (SimpleKey[]) key.getValue();
664         SimpleKey tmpKey = null;
665                       setAttributeId(new Integer JavaDoc(((NumberKey)keys[0]).intValue()));
666                         setIssueTypeId(new Integer JavaDoc(((NumberKey)keys[1]).intValue()));
667               }
668
669     /**
670      * Set the PrimaryKey using SimpleKeys.
671      *
672          * @param attributeId Integer
673          * @param issueTypeId Integer
674          */

675     public void setPrimaryKey( Integer JavaDoc attributeId, Integer JavaDoc issueTypeId)
676         throws TorqueException
677     {
678             setAttributeId(attributeId);
679             setIssueTypeId(issueTypeId);
680         }
681
682     /**
683      * Set the PrimaryKey using a String.
684      */

685     public void setPrimaryKey(String JavaDoc key) throws TorqueException
686     {
687         setPrimaryKey(new ComboKey(key));
688     }
689   
690     /**
691      * returns an id that differentiates this object from others
692      * of its class.
693      */

694     public ObjectKey getPrimaryKey()
695     {
696               pks[0] = SimpleKey.keyFor(getAttributeId());
697                   pks[1] = SimpleKey.keyFor(getIssueTypeId());
698                   return comboPK;
699       }
700  
701     /**
702      * get an id that differentiates this object from others
703      * of its class.
704      */

705     public String JavaDoc getQueryKey()
706     {
707         if (getPrimaryKey() == null)
708         {
709             return "";
710         }
711         else
712         {
713             return getPrimaryKey().toString();
714         }
715     }
716
717     /**
718      * set an id that differentiates this object from others
719      * of its class.
720      */

721     public void setQueryKey(String JavaDoc key)
722         throws TorqueException
723     {
724         setPrimaryKey(key);
725     }
726
727     /**
728      * Makes a copy of this object.
729      * It creates a new object filling in the simple attributes.
730        * It then fills all the association collections and sets the
731      * related objects to isNew=true.
732        */

733       public RIssueTypeAttribute copy() throws TorqueException
734     {
735         RIssueTypeAttribute copyObj = new RIssueTypeAttribute();
736             copyObj.setAttributeId(attributeId);
737           copyObj.setIssueTypeId(issueTypeId);
738           copyObj.setActive(active);
739           copyObj.setRequired(required);
740           copyObj.setOrder(order);
741           copyObj.setQuickSearch(quickSearch);
742           copyObj.setDefaultTextFlag(defaultTextFlag);
743           copyObj.setLocked(locked);
744   
745                       copyObj.setAttributeId((Integer JavaDoc)null);
746                                 copyObj.setIssueTypeId((Integer JavaDoc)null);
747                                                 
748                 return copyObj;
749     }
750
751     /**
752      * returns a peer instance associated with this om. Since Peer classes
753      * are not to have any instance attributes, this method returns the
754      * same instance for all member of this class. The method could therefore
755      * be static, but this would prevent one from overriding the behavior.
756      */

757     public RIssueTypeAttributePeer getPeer()
758     {
759         return peer;
760     }
761
762     public String JavaDoc toString()
763     {
764         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
765         str.append("RIssueTypeAttribute:\n");
766         str.append("AttributeId = ")
767                .append(getAttributeId())
768              .append("\n");
769         str.append("IssueTypeId = ")
770                .append(getIssueTypeId())
771              .append("\n");
772         str.append("Active = ")
773                .append(getActive())
774              .append("\n");
775         str.append("Required = ")
776                .append(getRequired())
777              .append("\n");
778         str.append("Order = ")
779                .append(getOrder())
780              .append("\n");
781         str.append("QuickSearch = ")
782                .append(getQuickSearch())
783              .append("\n");
784         str.append("DefaultTextFlag = ")
785                .append(getDefaultTextFlag())
786              .append("\n");
787         str.append("Locked = ")
788                .append(getLocked())
789              .append("\n");
790         return(str.toString());
791     }
792 }
793
Popular Tags