KickJava   Java API By Example, From Geeks To Geeks.

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


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

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

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

81     public void setAttributeGroupId(Integer JavaDoc v) throws TorqueException
82     {
83     
84                   if (!ObjectUtils.equals(this.attributeGroupId, v))
85               {
86             this.attributeGroupId = v;
87             setModified(true);
88         }
89     
90           
91                                   
92         // update associated RAttributeAttributeGroup
93
if (collRAttributeAttributeGroups != null)
94         {
95             for (int i = 0; i < collRAttributeAttributeGroups.size(); i++)
96             {
97                 ((RAttributeAttributeGroup) collRAttributeAttributeGroups.get(i))
98                         .setGroupId(v);
99             }
100         }
101                       }
102   
103     /**
104      * Get the Name
105      *
106      * @return String
107      */

108     public String JavaDoc getName()
109     {
110         return name;
111     }
112
113                         
114     /**
115      * Set the value of Name
116      *
117      * @param v new value
118      */

119     public void setName(String JavaDoc v)
120     {
121     
122                   if (!ObjectUtils.equals(this.name, v))
123               {
124             this.name = v;
125             setModified(true);
126         }
127     
128           
129               }
130   
131     /**
132      * Get the Description
133      *
134      * @return String
135      */

136     public String JavaDoc getDescription()
137     {
138         return description;
139     }
140
141                         
142     /**
143      * Set the value of Description
144      *
145      * @param v new value
146      */

147     public void setDescription(String JavaDoc v)
148     {
149     
150                   if (!ObjectUtils.equals(this.description, v))
151               {
152             this.description = v;
153             setModified(true);
154         }
155     
156           
157               }
158   
159     /**
160      * Get the ModuleId
161      *
162      * @return Integer
163      */

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

175     public void setModuleId(Integer JavaDoc v) throws TorqueException
176     {
177     
178                   if (!ObjectUtils.equals(this.moduleId, v))
179               {
180             this.moduleId = v;
181             setModified(true);
182         }
183     
184                                           
185                 if (aModule != null && !ObjectUtils.equals(aModule.getModuleId(), v))
186                 {
187             aModule = 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 Active
227      *
228      * @return boolean
229      */

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

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

258     public boolean getDedupe()
259     {
260         return dedupe;
261     }
262
263                         
264     /**
265      * Set the value of Dedupe
266      *
267      * @param v new value
268      */

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

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

297     public void setOrder(int v)
298     {
299     
300                   if (this.order != v)
301               {
302             this.order = v;
303             setModified(true);
304         }
305     
306           
307               }
308   
309       
310             
311                   
312         private Module aModule;
313
314     /**
315      * Declares an association between this object and a Module object
316      *
317      * @param v Module
318      * @throws TorqueException
319      */

320     public void setModule(Module v) throws TorqueException
321     {
322             if (v == null)
323         {
324                   setModuleId((Integer JavaDoc) null);
325               }
326         else
327         {
328             setModuleId(v.getModuleId());
329         }
330             aModule = v;
331     }
332
333                         
334     /**
335      * Get the associated Module object
336      *
337      * @return the associated Module object
338      * @throws TorqueException
339      */

340     public Module getModule() throws TorqueException
341     {
342         if ( !ObjectUtils.equals(getModuleId(), null) )
343         {
344                 return ModuleManager.getInstance(SimpleKey.keyFor(getModuleId()));
345             }
346         return aModule;
347     }
348
349     /**
350      * Provides convenient way to set a relationship based on a
351      * ObjectKey, for example
352      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
353      *
354          */

355     public void setModuleKey(ObjectKey key) throws TorqueException
356     {
357     
358                     setModuleId(new Integer JavaDoc(((NumberKey) key).intValue()));
359               }
360   
361         
362                   
363         private IssueType aIssueType;
364
365     /**
366      * Declares an association between this object and a IssueType object
367      *
368      * @param v IssueType
369      * @throws TorqueException
370      */

371     public void setIssueType(IssueType v) throws TorqueException
372     {
373             if (v == null)
374         {
375                   setIssueTypeId((Integer JavaDoc) null);
376               }
377         else
378         {
379             setIssueTypeId(v.getIssueTypeId());
380         }
381             aIssueType = v;
382     }
383
384                         
385     /**
386      * Get the associated IssueType object
387      *
388      * @return the associated IssueType object
389      * @throws TorqueException
390      */

391     public IssueType getIssueType() throws TorqueException
392     {
393         if ( !ObjectUtils.equals(getIssueTypeId(), null) )
394         {
395                 return IssueTypeManager.getInstance(SimpleKey.keyFor(getIssueTypeId()));
396             }
397         return aIssueType;
398     }
399
400     /**
401      * Provides convenient way to set a relationship based on a
402      * ObjectKey, for example
403      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
404      *
405          */

406     public void setIssueTypeKey(ObjectKey key) throws TorqueException
407     {
408     
409                     setIssueTypeId(new Integer JavaDoc(((NumberKey) key).intValue()));
410               }
411      
412                                 
413             
414     /**
415      * Collection to store aggregation of collRAttributeAttributeGroups
416      */

417     protected List JavaDoc collRAttributeAttributeGroups;
418
419     /**
420      * Temporary storage of collRAttributeAttributeGroups to save a possible db hit in
421      * the event objects are add to the collection, but the
422      * complete collection is never requested.
423      */

424     protected void initRAttributeAttributeGroups()
425     {
426         if (collRAttributeAttributeGroups == null)
427         {
428             collRAttributeAttributeGroups = new ArrayList JavaDoc();
429         }
430     }
431
432             
433     /**
434      * Method called to associate a RAttributeAttributeGroup object to this object
435      * through the RAttributeAttributeGroup foreign key attribute
436      *
437      * @param l RAttributeAttributeGroup
438      * @throws TorqueException
439      */

440     public void addRAttributeAttributeGroup(RAttributeAttributeGroup l) throws TorqueException
441     {
442         getRAttributeAttributeGroups().add(l);
443         l.setAttributeGroup((AttributeGroup)this);
444     }
445
446     /**
447      * The criteria used to select the current contents of collRAttributeAttributeGroups
448      */

449     private Criteria lastRAttributeAttributeGroupsCriteria = null;
450
451     /**
452      * If this collection has already been initialized, returns
453      * the collection. Otherwise returns the results of
454      * getRAttributeAttributeGroups(new Criteria())
455      *
456      * @throws TorqueException
457      */

458     public List JavaDoc getRAttributeAttributeGroups() throws TorqueException
459     {
460         if (collRAttributeAttributeGroups == null)
461         {
462             collRAttributeAttributeGroups = getRAttributeAttributeGroups(new Criteria(10));
463         }
464         return collRAttributeAttributeGroups;
465     }
466
467     /**
468      * If this collection has already been initialized with
469      * an identical criteria, it returns the collection.
470      * Otherwise if this AttributeGroup has previously
471      * been saved, it will retrieve related RAttributeAttributeGroups from storage.
472      * If this AttributeGroup is new, it will return
473      * an empty collection or the current collection, the criteria
474      * is ignored on a new object.
475      *
476      * @throws TorqueException
477      */

478     public List JavaDoc getRAttributeAttributeGroups(Criteria criteria) throws TorqueException
479     {
480         if (collRAttributeAttributeGroups == null)
481         {
482             if (isNew())
483             {
484                collRAttributeAttributeGroups = new ArrayList JavaDoc();
485             }
486             else
487             {
488                       criteria.add(RAttributeAttributeGroupPeer.GROUP_ID, getAttributeGroupId() );
489                       collRAttributeAttributeGroups = RAttributeAttributeGroupPeer.doSelect(criteria);
490             }
491         }
492         else
493         {
494             // criteria has no effect for a new object
495
if (!isNew())
496             {
497                 // the following code is to determine if a new query is
498
// called for. If the criteria is the same as the last
499
// one, just return the collection.
500
criteria.add(RAttributeAttributeGroupPeer.GROUP_ID, getAttributeGroupId() );
501                       if (!lastRAttributeAttributeGroupsCriteria.equals(criteria))
502                 {
503                     collRAttributeAttributeGroups = RAttributeAttributeGroupPeer.doSelect(criteria);
504                 }
505             }
506         }
507         lastRAttributeAttributeGroupsCriteria = criteria;
508
509         return collRAttributeAttributeGroups;
510     }
511
512     /**
513      * If this collection has already been initialized, returns
514      * the collection. Otherwise returns the results of
515      * getRAttributeAttributeGroups(new Criteria(),Connection)
516      * This method takes in the Connection also as input so that
517      * referenced objects can also be obtained using a Connection
518      * that is taken as input
519      */

520     public List JavaDoc getRAttributeAttributeGroups(Connection JavaDoc con) throws TorqueException
521     {
522         if (collRAttributeAttributeGroups == null)
523         {
524             collRAttributeAttributeGroups = getRAttributeAttributeGroups(new Criteria(10),con);
525         }
526         return collRAttributeAttributeGroups;
527     }
528
529     /**
530      * If this collection has already been initialized with
531      * an identical criteria, it returns the collection.
532      * Otherwise if this AttributeGroup has previously
533      * been saved, it will retrieve related RAttributeAttributeGroups from storage.
534      * If this AttributeGroup is new, it will return
535      * an empty collection or the current collection, the criteria
536      * is ignored on a new object.
537      * This method takes in the Connection also as input so that
538      * referenced objects can also be obtained using a Connection
539      * that is taken as input
540      */

541     public List JavaDoc getRAttributeAttributeGroups(Criteria criteria,Connection JavaDoc con) throws TorqueException
542     {
543         if (collRAttributeAttributeGroups == null)
544         {
545             if (isNew())
546             {
547                collRAttributeAttributeGroups = new ArrayList JavaDoc();
548             }
549             else
550             {
551                        criteria.add(RAttributeAttributeGroupPeer.GROUP_ID, getAttributeGroupId() );
552                        collRAttributeAttributeGroups = RAttributeAttributeGroupPeer.doSelect(criteria,con);
553              }
554          }
555          else
556          {
557              // criteria has no effect for a new object
558
if (!isNew())
559              {
560                  // the following code is to determine if a new query is
561
// called for. If the criteria is the same as the last
562
// one, just return the collection.
563
criteria.add(RAttributeAttributeGroupPeer.GROUP_ID, getAttributeGroupId() );
564                      if (!lastRAttributeAttributeGroupsCriteria.equals(criteria))
565                  {
566                      collRAttributeAttributeGroups = RAttributeAttributeGroupPeer.doSelect(criteria,con);
567                  }
568              }
569          }
570          lastRAttributeAttributeGroupsCriteria = criteria;
571
572          return collRAttributeAttributeGroups;
573      }
574
575                         
576               
577                     
578                     
579                                 
580                                                               
581                                         
582                     
583                     
584           
585     /**
586      * If this collection has already been initialized with
587      * an identical criteria, it returns the collection.
588      * Otherwise if this AttributeGroup is new, it will return
589      * an empty collection; or if this AttributeGroup has previously
590      * been saved, it will retrieve related RAttributeAttributeGroups from storage.
591      *
592      * This method is protected by default in order to keep the public
593      * api reasonable. You can provide public methods for those you
594      * actually need in AttributeGroup.
595      */

596     protected List JavaDoc getRAttributeAttributeGroupsJoinAttribute(Criteria criteria)
597         throws TorqueException
598     {
599         if (collRAttributeAttributeGroups == null)
600         {
601             if (isNew())
602             {
603                collRAttributeAttributeGroups = new ArrayList JavaDoc();
604             }
605             else
606             {
607                             criteria.add(RAttributeAttributeGroupPeer.GROUP_ID, getAttributeGroupId() );
608                             collRAttributeAttributeGroups = RAttributeAttributeGroupPeer.doSelectJoinAttribute(criteria);
609             }
610         }
611         else
612         {
613             // the following code is to determine if a new query is
614
// called for. If the criteria is the same as the last
615
// one, just return the collection.
616

617                             criteria.add(RAttributeAttributeGroupPeer.GROUP_ID, getAttributeGroupId() );
618                         if (!lastRAttributeAttributeGroupsCriteria.equals(criteria))
619             {
620                 collRAttributeAttributeGroups = RAttributeAttributeGroupPeer.doSelectJoinAttribute(criteria);
621             }
622         }
623         lastRAttributeAttributeGroupsCriteria = criteria;
624
625         return collRAttributeAttributeGroups;
626     }
627                   
628                     
629                               
630                                 
631                                                               
632                                         
633                     
634                     
635           
636     /**
637      * If this collection has already been initialized with
638      * an identical criteria, it returns the collection.
639      * Otherwise if this AttributeGroup is new, it will return
640      * an empty collection; or if this AttributeGroup has previously
641      * been saved, it will retrieve related RAttributeAttributeGroups from storage.
642      *
643      * This method is protected by default in order to keep the public
644      * api reasonable. You can provide public methods for those you
645      * actually need in AttributeGroup.
646      */

647     protected List JavaDoc getRAttributeAttributeGroupsJoinAttributeGroup(Criteria criteria)
648         throws TorqueException
649     {
650         if (collRAttributeAttributeGroups == null)
651         {
652             if (isNew())
653             {
654                collRAttributeAttributeGroups = new ArrayList JavaDoc();
655             }
656             else
657             {
658                             criteria.add(RAttributeAttributeGroupPeer.GROUP_ID, getAttributeGroupId() );
659                             collRAttributeAttributeGroups = RAttributeAttributeGroupPeer.doSelectJoinAttributeGroup(criteria);
660             }
661         }
662         else
663         {
664             // the following code is to determine if a new query is
665
// called for. If the criteria is the same as the last
666
// one, just return the collection.
667

668                             criteria.add(RAttributeAttributeGroupPeer.GROUP_ID, getAttributeGroupId() );
669                         if (!lastRAttributeAttributeGroupsCriteria.equals(criteria))
670             {
671                 collRAttributeAttributeGroups = RAttributeAttributeGroupPeer.doSelectJoinAttributeGroup(criteria);
672             }
673         }
674         lastRAttributeAttributeGroupsCriteria = criteria;
675
676         return collRAttributeAttributeGroups;
677     }
678                             
679
680
681           
682     private static List JavaDoc fieldNames = null;
683
684     /**
685      * Generate a list of field names.
686      *
687      * @return a list of field names
688      */

689     public static synchronized List JavaDoc getFieldNames()
690     {
691         if (fieldNames == null)
692         {
693             fieldNames = new ArrayList JavaDoc();
694               fieldNames.add("AttributeGroupId");
695               fieldNames.add("Name");
696               fieldNames.add("Description");
697               fieldNames.add("ModuleId");
698               fieldNames.add("IssueTypeId");
699               fieldNames.add("Active");
700               fieldNames.add("Dedupe");
701               fieldNames.add("Order");
702               fieldNames = Collections.unmodifiableList(fieldNames);
703         }
704         return fieldNames;
705     }
706
707     /**
708      * Retrieves a field from the object by name passed in as a String.
709      *
710      * @param name field name
711      * @return value
712      */

713     public Object JavaDoc getByName(String JavaDoc name)
714     {
715           if (name.equals("AttributeGroupId"))
716         {
717                 return getAttributeGroupId();
718             }
719           if (name.equals("Name"))
720         {
721                 return getName();
722             }
723           if (name.equals("Description"))
724         {
725                 return getDescription();
726             }
727           if (name.equals("ModuleId"))
728         {
729                 return getModuleId();
730             }
731           if (name.equals("IssueTypeId"))
732         {
733                 return getIssueTypeId();
734             }
735           if (name.equals("Active"))
736         {
737                 return Boolean.valueOf(getActive());
738             }
739           if (name.equals("Dedupe"))
740         {
741                 return Boolean.valueOf(getDedupe());
742             }
743           if (name.equals("Order"))
744         {
745                 return new Integer JavaDoc(getOrder());
746             }
747           return null;
748     }
749     
750     /**
751      * Retrieves a field from the object by name passed in
752      * as a String. The String must be one of the static
753      * Strings defined in this Class' Peer.
754      *
755      * @param name peer name
756      * @return value
757      */

758     public Object JavaDoc getByPeerName(String JavaDoc name)
759     {
760           if (name.equals(AttributeGroupPeer.ATTRIBUTE_GROUP_ID))
761         {
762                 return getAttributeGroupId();
763             }
764           if (name.equals(AttributeGroupPeer.NAME))
765         {
766                 return getName();
767             }
768           if (name.equals(AttributeGroupPeer.DESCRIPTION))
769         {
770                 return getDescription();
771             }
772           if (name.equals(AttributeGroupPeer.MODULE_ID))
773         {
774                 return getModuleId();
775             }
776           if (name.equals(AttributeGroupPeer.ISSUE_TYPE_ID))
777         {
778                 return getIssueTypeId();
779             }
780           if (name.equals(AttributeGroupPeer.ACTIVE))
781         {
782                 return Boolean.valueOf(getActive());
783             }
784           if (name.equals(AttributeGroupPeer.DEDUPE))
785         {
786                 return Boolean.valueOf(getDedupe());
787             }
788           if (name.equals(AttributeGroupPeer.PREFERRED_ORDER))
789         {
790                 return new Integer JavaDoc(getOrder());
791             }
792           return null;
793     }
794
795     /**
796      * Retrieves a field from the object by Position as specified
797      * in the xml schema. Zero-based.
798      *
799      * @param pos position in xml schema
800      * @return value
801      */

802     public Object JavaDoc getByPosition(int pos)
803     {
804             if (pos == 0)
805         {
806                 return getAttributeGroupId();
807             }
808               if (pos == 1)
809         {
810                 return getName();
811             }
812               if (pos == 2)
813         {
814                 return getDescription();
815             }
816               if (pos == 3)
817         {
818                 return getModuleId();
819             }
820               if (pos == 4)
821         {
822                 return getIssueTypeId();
823             }
824               if (pos == 5)
825         {
826                 return Boolean.valueOf(getActive());
827             }
828               if (pos == 6)
829         {
830                 return Boolean.valueOf(getDedupe());
831             }
832               if (pos == 7)
833         {
834                 return new Integer JavaDoc(getOrder());
835             }
836               return null;
837     }
838      
839     /**
840      * Stores the object in the database. If the object is new,
841      * it inserts it; otherwise an update is performed.
842      *
843      * @throws Exception
844      */

845     public void save() throws Exception JavaDoc
846     {
847           save(AttributeGroupPeer.getMapBuilder()
848                 .getDatabaseMap().getName());
849       }
850
851     /**
852      * Stores the object in the database. If the object is new,
853      * it inserts it; otherwise an update is performed.
854        * Note: this code is here because the method body is
855      * auto-generated conditionally and therefore needs to be
856      * in this file instead of in the super class, BaseObject.
857        *
858      * @param dbName
859      * @throws TorqueException
860      */

861     public void save(String JavaDoc dbName) throws TorqueException
862     {
863         Connection JavaDoc con = null;
864           try
865         {
866             con = Transaction.begin(dbName);
867             save(con);
868             Transaction.commit(con);
869         }
870         catch(TorqueException e)
871         {
872             Transaction.safeRollback(con);
873             throw e;
874         }
875       }
876
877       /** flag to prevent endless save loop, if this object is referenced
878         by another object which falls in this transaction. */

879     private boolean alreadyInSave = false;
880       /**
881      * Stores the object in the database. If the object is new,
882      * it inserts it; otherwise an update is performed. This method
883      * is meant to be used as part of a transaction, otherwise use
884      * the save() method and the connection details will be handled
885      * internally
886      *
887      * @param con
888      * @throws TorqueException
889      */

890     public void save(Connection JavaDoc con) throws TorqueException
891     {
892           if (!alreadyInSave)
893         {
894             alreadyInSave = true;
895
896
897   
898             // If this object has been modified, then save it to the database.
899
if (isModified())
900             {
901                 if (isNew())
902                 {
903                     AttributeGroupPeer.doInsert((AttributeGroup)this, con);
904                     setNew(false);
905                 }
906                 else
907                 {
908                     AttributeGroupPeer.doUpdate((AttributeGroup)this, con);
909                 }
910
911                       if (isCacheOnSave())
912                 {
913                     AttributeGroupManager.putInstance(this);
914                 }
915               }
916
917                                       
918                             if (collRAttributeAttributeGroups != null)
919             {
920                 for (int i = 0; i < collRAttributeAttributeGroups.size(); i++)
921                 {
922                     ((RAttributeAttributeGroup)collRAttributeAttributeGroups.get(i)).save(con);
923                 }
924             }
925                           alreadyInSave = false;
926         }
927       }
928
929     /**
930      * Specify whether to cache the object after saving to the db.
931      * This method returns false
932      */

933     protected boolean isCacheOnSave()
934     {
935         return true;
936     }
937
938                         
939       /**
940      * Set the PrimaryKey using ObjectKey.
941      *
942      * @param attributeGroupId ObjectKey
943      */

944     public void setPrimaryKey(ObjectKey attributeGroupId)
945         throws TorqueException {
946             setAttributeGroupId(new Integer JavaDoc(((NumberKey)attributeGroupId).intValue()));
947         }
948
949     /**
950      * Set the PrimaryKey using a String.
951      *
952      * @param key
953      */

954     public void setPrimaryKey(String JavaDoc key) throws TorqueException
955     {
956             setAttributeGroupId(new Integer JavaDoc(key));
957         }
958
959   
960     /**
961      * returns an id that differentiates this object from others
962      * of its class.
963      */

964     public ObjectKey getPrimaryKey()
965     {
966           return SimpleKey.keyFor(getAttributeGroupId());
967       }
968  
969     /**
970      * get an id that differentiates this object from others
971      * of its class.
972      */

973     public String JavaDoc getQueryKey()
974     {
975         if (getPrimaryKey() == null)
976         {
977             return "";
978         }
979         else
980         {
981             return getPrimaryKey().toString();
982         }
983     }
984
985     /**
986      * set an id that differentiates this object from others
987      * of its class.
988      */

989     public void setQueryKey(String JavaDoc key)
990         throws TorqueException
991     {
992         setPrimaryKey(key);
993     }
994
995     /**
996      * Makes a copy of this object.
997      * It creates a new object filling in the simple attributes.
998        * It then fills all the association collections and sets the
999      * related objects to isNew=true.
1000       */

1001      public AttributeGroup copy() throws TorqueException
1002    {
1003        AttributeGroup copyObj = new AttributeGroup();
1004            copyObj.setAttributeGroupId(attributeGroupId);
1005          copyObj.setName(name);
1006          copyObj.setDescription(description);
1007          copyObj.setModuleId(moduleId);
1008          copyObj.setIssueTypeId(issueTypeId);
1009          copyObj.setActive(active);
1010          copyObj.setDedupe(dedupe);
1011          copyObj.setOrder(order);
1012  
1013                      copyObj.setAttributeGroupId((Integer JavaDoc)null);
1014                                                      
1015                                      
1016                
1017        List JavaDoc v = getRAttributeAttributeGroups();
1018        for (int i = 0; i < v.size(); i++)
1019        {
1020            RAttributeAttributeGroup obj = (RAttributeAttributeGroup) v.get(i);
1021            copyObj.addRAttributeAttributeGroup(obj.copy());
1022        }
1023                            return copyObj;
1024    }
1025
1026    /**
1027     * returns a peer instance associated with this om. Since Peer classes
1028     * are not to have any instance attributes, this method returns the
1029     * same instance for all member of this class. The method could therefore
1030     * be static, but this would prevent one from overriding the behavior.
1031     */

1032    public AttributeGroupPeer getPeer()
1033    {
1034        return peer;
1035    }
1036
1037    public String JavaDoc toString()
1038    {
1039        StringBuffer JavaDoc str = new StringBuffer JavaDoc();
1040        str.append("AttributeGroup:\n");
1041        str.append("AttributeGroupId = ")
1042               .append(getAttributeGroupId())
1043             .append("\n");
1044        str.append("Name = ")
1045               .append(getName())
1046             .append("\n");
1047        str.append("Description = ")
1048               .append(getDescription())
1049             .append("\n");
1050        str.append("ModuleId = ")
1051               .append(getModuleId())
1052             .append("\n");
1053        str.append("IssueTypeId = ")
1054               .append(getIssueTypeId())
1055             .append("\n");
1056        str.append("Active = ")
1057               .append(getActive())
1058             .append("\n");
1059        str.append("Dedupe = ")
1060               .append(getDedupe())
1061             .append("\n");
1062        str.append("Order = ")
1063               .append(getOrder())
1064             .append("\n");
1065        return(str.toString());
1066    }
1067}
1068
Popular Tags