KickJava   Java API By Example, From Geeks To Geeks.

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


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

32 public abstract class BaseIssueTemplateInfo extends BaseObject
33     implements org.apache.fulcrum.intake.Retrievable
34 {
35     /** The Peer class */
36     private static final IssueTemplateInfoPeer peer =
37         new IssueTemplateInfoPeer();
38
39         
40     /** The value for the issueId field */
41     private Long JavaDoc issueId;
42       
43     /** The value for the name field */
44     private String JavaDoc name;
45       
46     /** The value for the description field */
47     private String JavaDoc description;
48                                                                 
49     /** The value for the approved field */
50     private boolean approved = false;
51       
52     /** The value for the scopeId field */
53     private Integer JavaDoc scopeId;
54   
55     
56     /**
57      * Get the IssueId
58      *
59      * @return Long
60      */

61     public Long JavaDoc getIssueId()
62     {
63         return issueId;
64     }
65
66                               
67     /**
68      * Set the value of IssueId
69      *
70      * @param v new value
71      */

72     public void setIssueId(Long JavaDoc v) throws TorqueException
73     {
74     
75                   if (!ObjectUtils.equals(this.issueId, v))
76               {
77             this.issueId = v;
78             setModified(true);
79         }
80     
81                                   
82                 if (aIssue != null && !ObjectUtils.equals(aIssue.getIssueId(), v))
83                 {
84             aIssue = null;
85         }
86       
87               }
88   
89     /**
90      * Get the Name
91      *
92      * @return String
93      */

94     public String JavaDoc getName()
95     {
96         return name;
97     }
98
99                         
100     /**
101      * Set the value of Name
102      *
103      * @param v new value
104      */

105     public void setName(String JavaDoc v)
106     {
107     
108                   if (!ObjectUtils.equals(this.name, v))
109               {
110             this.name = v;
111             setModified(true);
112         }
113     
114           
115               }
116   
117     /**
118      * Get the Description
119      *
120      * @return String
121      */

122     public String JavaDoc getDescription()
123     {
124         return description;
125     }
126
127                         
128     /**
129      * Set the value of Description
130      *
131      * @param v new value
132      */

133     public void setDescription(String JavaDoc v)
134     {
135     
136                   if (!ObjectUtils.equals(this.description, v))
137               {
138             this.description = v;
139             setModified(true);
140         }
141     
142           
143               }
144   
145     /**
146      * Get the Approved
147      *
148      * @return boolean
149      */

150     public boolean getApproved()
151     {
152         return approved;
153     }
154
155                         
156     /**
157      * Set the value of Approved
158      *
159      * @param v new value
160      */

161     public void setApproved(boolean v)
162     {
163     
164                   if (this.approved != v)
165               {
166             this.approved = v;
167             setModified(true);
168         }
169     
170           
171               }
172   
173     /**
174      * Get the ScopeId
175      *
176      * @return Integer
177      */

178     public Integer JavaDoc getScopeId()
179     {
180         return scopeId;
181     }
182
183                               
184     /**
185      * Set the value of ScopeId
186      *
187      * @param v new value
188      */

189     public void setScopeId(Integer JavaDoc v) throws TorqueException
190     {
191     
192                   if (!ObjectUtils.equals(this.scopeId, v))
193               {
194             this.scopeId = v;
195             setModified(true);
196         }
197     
198                                   
199                 if (aScope != null && !ObjectUtils.equals(aScope.getScopeId(), v))
200                 {
201             aScope = null;
202         }
203       
204               }
205   
206       
207         
208                   
209         private Issue aIssue;
210
211     /**
212      * Declares an association between this object and a Issue object
213      *
214      * @param v Issue
215      * @throws TorqueException
216      */

217     public void setIssue(Issue v) throws TorqueException
218     {
219             if (v == null)
220         {
221                   setIssueId((Long JavaDoc) null);
222               }
223         else
224         {
225             setIssueId(v.getIssueId());
226         }
227             aIssue = v;
228     }
229
230                         
231     /**
232      * Get the associated Issue object
233      *
234      * @return the associated Issue object
235      * @throws TorqueException
236      */

237     public Issue getIssue() throws TorqueException
238     {
239         if ( !ObjectUtils.equals(getIssueId(), null) )
240         {
241                 return IssueManager.getInstance(SimpleKey.keyFor(getIssueId()));
242             }
243         return aIssue;
244     }
245
246     /**
247      * Provides convenient way to set a relationship based on a
248      * ObjectKey, for example
249      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
250      *
251          */

252     public void setIssueKey(ObjectKey key) throws TorqueException
253     {
254     
255                     setIssueId(new Long JavaDoc(((NumberKey) key).longValue()));
256               }
257   
258         
259                   
260         private Scope aScope;
261
262     /**
263      * Declares an association between this object and a Scope object
264      *
265      * @param v Scope
266      * @throws TorqueException
267      */

268     public void setScope(Scope v) throws TorqueException
269     {
270             if (v == null)
271         {
272                   setScopeId((Integer JavaDoc) null);
273               }
274         else
275         {
276             setScopeId(v.getScopeId());
277         }
278             aScope = v;
279     }
280
281                         
282     /**
283      * Get the associated Scope object
284      *
285      * @return the associated Scope object
286      * @throws TorqueException
287      */

288     public Scope getScope() throws TorqueException
289     {
290         if ( !ObjectUtils.equals(getScopeId(), null) )
291         {
292                 return ScopeManager.getInstance(SimpleKey.keyFor(getScopeId()));
293             }
294         return aScope;
295     }
296
297     /**
298      * Provides convenient way to set a relationship based on a
299      * ObjectKey, for example
300      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
301      *
302          */

303     public void setScopeKey(ObjectKey key) throws TorqueException
304     {
305     
306                     setScopeId(new Integer JavaDoc(((NumberKey) key).intValue()));
307               }
308      
309                 
310     private static List JavaDoc fieldNames = null;
311
312     /**
313      * Generate a list of field names.
314      *
315      * @return a list of field names
316      */

317     public static synchronized List JavaDoc getFieldNames()
318     {
319         if (fieldNames == null)
320         {
321             fieldNames = new ArrayList JavaDoc();
322               fieldNames.add("IssueId");
323               fieldNames.add("Name");
324               fieldNames.add("Description");
325               fieldNames.add("Approved");
326               fieldNames.add("ScopeId");
327               fieldNames = Collections.unmodifiableList(fieldNames);
328         }
329         return fieldNames;
330     }
331
332     /**
333      * Retrieves a field from the object by name passed in as a String.
334      *
335      * @param name field name
336      * @return value
337      */

338     public Object JavaDoc getByName(String JavaDoc name)
339     {
340           if (name.equals("IssueId"))
341         {
342                 return getIssueId();
343             }
344           if (name.equals("Name"))
345         {
346                 return getName();
347             }
348           if (name.equals("Description"))
349         {
350                 return getDescription();
351             }
352           if (name.equals("Approved"))
353         {
354                 return Boolean.valueOf(getApproved());
355             }
356           if (name.equals("ScopeId"))
357         {
358                 return getScopeId();
359             }
360           return null;
361     }
362     
363     /**
364      * Retrieves a field from the object by name passed in
365      * as a String. The String must be one of the static
366      * Strings defined in this Class' Peer.
367      *
368      * @param name peer name
369      * @return value
370      */

371     public Object JavaDoc getByPeerName(String JavaDoc name)
372     {
373           if (name.equals(IssueTemplateInfoPeer.ISSUE_ID))
374         {
375                 return getIssueId();
376             }
377           if (name.equals(IssueTemplateInfoPeer.NAME))
378         {
379                 return getName();
380             }
381           if (name.equals(IssueTemplateInfoPeer.DESCRIPTION))
382         {
383                 return getDescription();
384             }
385           if (name.equals(IssueTemplateInfoPeer.APPROVED))
386         {
387                 return Boolean.valueOf(getApproved());
388             }
389           if (name.equals(IssueTemplateInfoPeer.SCOPE_ID))
390         {
391                 return getScopeId();
392             }
393           return null;
394     }
395
396     /**
397      * Retrieves a field from the object by Position as specified
398      * in the xml schema. Zero-based.
399      *
400      * @param pos position in xml schema
401      * @return value
402      */

403     public Object JavaDoc getByPosition(int pos)
404     {
405             if (pos == 0)
406         {
407                 return getIssueId();
408             }
409               if (pos == 1)
410         {
411                 return getName();
412             }
413               if (pos == 2)
414         {
415                 return getDescription();
416             }
417               if (pos == 3)
418         {
419                 return Boolean.valueOf(getApproved());
420             }
421               if (pos == 4)
422         {
423                 return getScopeId();
424             }
425               return null;
426     }
427      
428     /**
429      * Stores the object in the database. If the object is new,
430      * it inserts it; otherwise an update is performed.
431      *
432      * @throws Exception
433      */

434     public void save() throws Exception JavaDoc
435     {
436           save(IssueTemplateInfoPeer.getMapBuilder()
437                 .getDatabaseMap().getName());
438       }
439
440     /**
441      * Stores the object in the database. If the object is new,
442      * it inserts it; otherwise an update is performed.
443        * Note: this code is here because the method body is
444      * auto-generated conditionally and therefore needs to be
445      * in this file instead of in the super class, BaseObject.
446        *
447      * @param dbName
448      * @throws TorqueException
449      */

450     public void save(String JavaDoc dbName) throws TorqueException
451     {
452         Connection JavaDoc con = null;
453           try
454         {
455             con = Transaction.begin(dbName);
456             save(con);
457             Transaction.commit(con);
458         }
459         catch(TorqueException e)
460         {
461             Transaction.safeRollback(con);
462             throw e;
463         }
464       }
465
466       /** flag to prevent endless save loop, if this object is referenced
467         by another object which falls in this transaction. */

468     private boolean alreadyInSave = false;
469       /**
470      * Stores the object in the database. If the object is new,
471      * it inserts it; otherwise an update is performed. This method
472      * is meant to be used as part of a transaction, otherwise use
473      * the save() method and the connection details will be handled
474      * internally
475      *
476      * @param con
477      * @throws TorqueException
478      */

479     public void save(Connection JavaDoc con) throws TorqueException
480     {
481           if (!alreadyInSave)
482         {
483             alreadyInSave = true;
484
485
486   
487             // If this object has been modified, then save it to the database.
488
if (isModified())
489             {
490                 if (isNew())
491                 {
492                     IssueTemplateInfoPeer.doInsert((IssueTemplateInfo)this, con);
493                     setNew(false);
494                 }
495                 else
496                 {
497                     IssueTemplateInfoPeer.doUpdate((IssueTemplateInfo)this, con);
498                 }
499
500                       if (isCacheOnSave())
501                 {
502                     IssueTemplateInfoManager.putInstance(this);
503                 }
504               }
505
506                       alreadyInSave = false;
507         }
508       }
509
510     /**
511      * Specify whether to cache the object after saving to the db.
512      * This method returns false
513      */

514     protected boolean isCacheOnSave()
515     {
516         return true;
517     }
518
519                         
520       /**
521      * Set the PrimaryKey using ObjectKey.
522      *
523      * @param issueId ObjectKey
524      */

525     public void setPrimaryKey(ObjectKey issueId)
526         throws TorqueException {
527             setIssueId(new Long JavaDoc(((NumberKey)issueId).longValue()));
528         }
529
530     /**
531      * Set the PrimaryKey using a String.
532      *
533      * @param key
534      */

535     public void setPrimaryKey(String JavaDoc key) throws TorqueException
536     {
537             setIssueId(new Long JavaDoc(key));
538         }
539
540   
541     /**
542      * returns an id that differentiates this object from others
543      * of its class.
544      */

545     public ObjectKey getPrimaryKey()
546     {
547           return SimpleKey.keyFor(getIssueId());
548       }
549  
550     /**
551      * get an id that differentiates this object from others
552      * of its class.
553      */

554     public String JavaDoc getQueryKey()
555     {
556         if (getPrimaryKey() == null)
557         {
558             return "";
559         }
560         else
561         {
562             return getPrimaryKey().toString();
563         }
564     }
565
566     /**
567      * set an id that differentiates this object from others
568      * of its class.
569      */

570     public void setQueryKey(String JavaDoc key)
571         throws TorqueException
572     {
573         setPrimaryKey(key);
574     }
575
576     /**
577      * Makes a copy of this object.
578      * It creates a new object filling in the simple attributes.
579        * It then fills all the association collections and sets the
580      * related objects to isNew=true.
581        */

582       public IssueTemplateInfo copy() throws TorqueException
583     {
584         IssueTemplateInfo copyObj = new IssueTemplateInfo();
585             copyObj.setIssueId(issueId);
586           copyObj.setName(name);
587           copyObj.setDescription(description);
588           copyObj.setApproved(approved);
589           copyObj.setScopeId(scopeId);
590   
591                       copyObj.setIssueId((Long JavaDoc)null);
592                                     
593                 return copyObj;
594     }
595
596     /**
597      * returns a peer instance associated with this om. Since Peer classes
598      * are not to have any instance attributes, this method returns the
599      * same instance for all member of this class. The method could therefore
600      * be static, but this would prevent one from overriding the behavior.
601      */

602     public IssueTemplateInfoPeer getPeer()
603     {
604         return peer;
605     }
606
607     public String JavaDoc toString()
608     {
609         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
610         str.append("IssueTemplateInfo:\n");
611         str.append("IssueId = ")
612                .append(getIssueId())
613              .append("\n");
614         str.append("Name = ")
615                .append(getName())
616              .append("\n");
617         str.append("Description = ")
618                .append(getDescription())
619              .append("\n");
620         str.append("Approved = ")
621                .append(getApproved())
622              .append("\n");
623         str.append("ScopeId = ")
624                .append(getScopeId())
625              .append("\n");
626         return(str.toString());
627     }
628 }
629
Popular Tags