KickJava   Java API By Example, From Geeks To Geeks.

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


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

33 public abstract class BaseTransition extends BaseObject
34     implements org.apache.fulcrum.intake.Retrievable
35 {
36     /** The Peer class */
37     private static final TransitionPeer peer =
38         new TransitionPeer();
39
40         
41     /** The value for the transitionId field */
42     private Integer JavaDoc transitionId;
43       
44     /** The value for the roleId field */
45     private Integer JavaDoc roleId;
46       
47     /** The value for the attributeId field */
48     private Integer JavaDoc attributeId;
49       
50     /** The value for the fromOptionId field */
51     private Integer JavaDoc fromOptionId;
52       
53     /** The value for the toOptionId field */
54     private Integer JavaDoc toOptionId;
55                                                                 
56     /** The value for the disabledIfBlocked field */
57     private boolean disabledIfBlocked = false;
58   
59     
60     /**
61      * Get the TransitionId
62      *
63      * @return Integer
64      */

65     public Integer JavaDoc getTransitionId()
66     {
67         return transitionId;
68     }
69
70                                               
71     /**
72      * Set the value of TransitionId
73      *
74      * @param v new value
75      */

76     public void setTransitionId(Integer JavaDoc v) throws TorqueException
77     {
78     
79                   if (!ObjectUtils.equals(this.transitionId, v))
80               {
81             this.transitionId = v;
82             setModified(true);
83         }
84     
85           
86                                   
87         // update associated Condition
88
if (collConditions != null)
89         {
90             for (int i = 0; i < collConditions.size(); i++)
91             {
92                 ((Condition) collConditions.get(i))
93                         .setTransitionId(v);
94             }
95         }
96                       }
97   
98     /**
99      * Get the RoleId
100      *
101      * @return Integer
102      */

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

114     public void setRoleId(Integer JavaDoc v)
115     {
116     
117                   if (!ObjectUtils.equals(this.roleId, v))
118               {
119             this.roleId = v;
120             setModified(true);
121         }
122     
123           
124               }
125   
126     /**
127      * Get the AttributeId
128      *
129      * @return Integer
130      */

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

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

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

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

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

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

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

241     public void setDisabledIfBlocked(boolean v)
242     {
243     
244                   if (this.disabledIfBlocked != v)
245               {
246             this.disabledIfBlocked = v;
247             setModified(true);
248         }
249     
250           
251               }
252   
253       
254         
255                   
256         private Attribute aAttribute;
257
258     /**
259      * Declares an association between this object and a Attribute object
260      *
261      * @param v Attribute
262      * @throws TorqueException
263      */

264     public void setAttribute(Attribute v) throws TorqueException
265     {
266             if (v == null)
267         {
268                   setAttributeId((Integer JavaDoc) null);
269               }
270         else
271         {
272             setAttributeId(v.getAttributeId());
273         }
274             aAttribute = v;
275     }
276
277                         
278     /**
279      * Get the associated Attribute object
280      *
281      * @return the associated Attribute object
282      * @throws TorqueException
283      */

284     public Attribute getAttribute() throws TorqueException
285     {
286         if ( !ObjectUtils.equals(getAttributeId(), null) )
287         {
288                 return AttributeManager.getInstance(SimpleKey.keyFor(getAttributeId()));
289             }
290         return aAttribute;
291     }
292
293     /**
294      * Provides convenient way to set a relationship based on a
295      * ObjectKey, for example
296      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
297      *
298          */

299     public void setAttributeKey(ObjectKey key) throws TorqueException
300     {
301     
302                     setAttributeId(new Integer JavaDoc(((NumberKey) key).intValue()));
303               }
304   
305         
306                         
307             private AttributeOption aAttributeOptionRelatedByFromOptionId;
308
309     /**
310      * Declares an association between this object and a AttributeOption object
311      *
312      * @param v AttributeOption
313      * @throws TorqueException
314      */

315     public void setAttributeOptionRelatedByFromOptionId(AttributeOption v) throws TorqueException
316     {
317             if (v == null)
318         {
319                   setFromOptionId((Integer JavaDoc) null);
320               }
321         else
322         {
323             setFromOptionId(v.getOptionId());
324         }
325             aAttributeOptionRelatedByFromOptionId = v;
326     }
327
328                         
329     /**
330      * Get the associated AttributeOption object
331      *
332      * @return the associated AttributeOption object
333      * @throws TorqueException
334      */

335     public AttributeOption getAttributeOptionRelatedByFromOptionId() throws TorqueException
336     {
337         if ( !ObjectUtils.equals(getFromOptionId(), null) )
338         {
339                 return AttributeOptionManager.getInstance(SimpleKey.keyFor(getFromOptionId()));
340             }
341         return aAttributeOptionRelatedByFromOptionId;
342     }
343
344     /**
345      * Provides convenient way to set a relationship based on a
346      * ObjectKey, for example
347      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
348      *
349          */

350     public void setAttributeOptionRelatedByFromOptionIdKey(ObjectKey key) throws TorqueException
351     {
352     
353                     setFromOptionId(new Integer JavaDoc(((NumberKey) key).intValue()));
354               }
355   
356         
357                         
358             private AttributeOption aAttributeOptionRelatedByToOptionId;
359
360     /**
361      * Declares an association between this object and a AttributeOption object
362      *
363      * @param v AttributeOption
364      * @throws TorqueException
365      */

366     public void setAttributeOptionRelatedByToOptionId(AttributeOption v) throws TorqueException
367     {
368             if (v == null)
369         {
370                   setToOptionId((Integer JavaDoc) null);
371               }
372         else
373         {
374             setToOptionId(v.getOptionId());
375         }
376             aAttributeOptionRelatedByToOptionId = v;
377     }
378
379                         
380     /**
381      * Get the associated AttributeOption object
382      *
383      * @return the associated AttributeOption object
384      * @throws TorqueException
385      */

386     public AttributeOption getAttributeOptionRelatedByToOptionId() throws TorqueException
387     {
388         if ( !ObjectUtils.equals(getToOptionId(), null) )
389         {
390                 return AttributeOptionManager.getInstance(SimpleKey.keyFor(getToOptionId()));
391             }
392         return aAttributeOptionRelatedByToOptionId;
393     }
394
395     /**
396      * Provides convenient way to set a relationship based on a
397      * ObjectKey, for example
398      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
399      *
400          */

401     public void setAttributeOptionRelatedByToOptionIdKey(ObjectKey key) throws TorqueException
402     {
403     
404                     setToOptionId(new Integer JavaDoc(((NumberKey) key).intValue()));
405               }
406      
407                                 
408             
409     /**
410      * Collection to store aggregation of collConditions
411      */

412     protected List JavaDoc collConditions;
413
414     /**
415      * Temporary storage of collConditions to save a possible db hit in
416      * the event objects are add to the collection, but the
417      * complete collection is never requested.
418      */

419     protected void initConditions()
420     {
421         if (collConditions == null)
422         {
423             collConditions = new ArrayList JavaDoc();
424         }
425     }
426
427             
428     /**
429      * Method called to associate a Condition object to this object
430      * through the Condition foreign key attribute
431      *
432      * @param l Condition
433      * @throws TorqueException
434      */

435     public void addCondition(Condition l) throws TorqueException
436     {
437         getConditions().add(l);
438         l.setTransition((Transition)this);
439     }
440
441     /**
442      * The criteria used to select the current contents of collConditions
443      */

444     private Criteria lastConditionsCriteria = null;
445
446     /**
447      * If this collection has already been initialized, returns
448      * the collection. Otherwise returns the results of
449      * getConditions(new Criteria())
450      *
451      * @throws TorqueException
452      */

453     public List JavaDoc getConditions() throws TorqueException
454     {
455         if (collConditions == null)
456         {
457             collConditions = getConditions(new Criteria(10));
458         }
459         return collConditions;
460     }
461
462     /**
463      * If this collection has already been initialized with
464      * an identical criteria, it returns the collection.
465      * Otherwise if this Transition has previously
466      * been saved, it will retrieve related Conditions from storage.
467      * If this Transition is new, it will return
468      * an empty collection or the current collection, the criteria
469      * is ignored on a new object.
470      *
471      * @throws TorqueException
472      */

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

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

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

591     protected List JavaDoc getConditionsJoinRModuleAttribute(Criteria criteria)
592         throws TorqueException
593     {
594         if (collConditions == null)
595         {
596             if (isNew())
597             {
598                collConditions = new ArrayList JavaDoc();
599             }
600             else
601             {
602                             criteria.add(ConditionPeer.TRANSITION_ID, getTransitionId() );
603                             collConditions = ConditionPeer.doSelectJoinRModuleAttribute(criteria);
604             }
605         }
606         else
607         {
608             // the following code is to determine if a new query is
609
// called for. If the criteria is the same as the last
610
// one, just return the collection.
611

612                             criteria.add(ConditionPeer.TRANSITION_ID, getTransitionId() );
613                         if (!lastConditionsCriteria.equals(criteria))
614             {
615                 collConditions = ConditionPeer.doSelectJoinRModuleAttribute(criteria);
616             }
617         }
618         lastConditionsCriteria = criteria;
619
620         return collConditions;
621     }
622                   
623                     
624                               
625                                 
626                                                               
627                                         
628                     
629                     
630           
631     /**
632      * If this collection has already been initialized with
633      * an identical criteria, it returns the collection.
634      * Otherwise if this Transition is new, it will return
635      * an empty collection; or if this Transition has previously
636      * been saved, it will retrieve related Conditions from storage.
637      *
638      * This method is protected by default in order to keep the public
639      * api reasonable. You can provide public methods for those you
640      * actually need in Transition.
641      */

642     protected List JavaDoc getConditionsJoinTransition(Criteria criteria)
643         throws TorqueException
644     {
645         if (collConditions == null)
646         {
647             if (isNew())
648             {
649                collConditions = new ArrayList JavaDoc();
650             }
651             else
652             {
653                             criteria.add(ConditionPeer.TRANSITION_ID, getTransitionId() );
654                             collConditions = ConditionPeer.doSelectJoinTransition(criteria);
655             }
656         }
657         else
658         {
659             // the following code is to determine if a new query is
660
// called for. If the criteria is the same as the last
661
// one, just return the collection.
662

663                             criteria.add(ConditionPeer.TRANSITION_ID, getTransitionId() );
664                         if (!lastConditionsCriteria.equals(criteria))
665             {
666                 collConditions = ConditionPeer.doSelectJoinTransition(criteria);
667             }
668         }
669         lastConditionsCriteria = criteria;
670
671         return collConditions;
672     }
673                   
674                     
675                     
676                                 
677                                                               
678                                         
679                     
680                     
681           
682     /**
683      * If this collection has already been initialized with
684      * an identical criteria, it returns the collection.
685      * Otherwise if this Transition is new, it will return
686      * an empty collection; or if this Transition has previously
687      * been saved, it will retrieve related Conditions from storage.
688      *
689      * This method is protected by default in order to keep the public
690      * api reasonable. You can provide public methods for those you
691      * actually need in Transition.
692      */

693     protected List JavaDoc getConditionsJoinAttribute(Criteria criteria)
694         throws TorqueException
695     {
696         if (collConditions == null)
697         {
698             if (isNew())
699             {
700                collConditions = new ArrayList JavaDoc();
701             }
702             else
703             {
704                             criteria.add(ConditionPeer.TRANSITION_ID, getTransitionId() );
705                             collConditions = ConditionPeer.doSelectJoinAttribute(criteria);
706             }
707         }
708         else
709         {
710             // the following code is to determine if a new query is
711
// called for. If the criteria is the same as the last
712
// one, just return the collection.
713

714                             criteria.add(ConditionPeer.TRANSITION_ID, getTransitionId() );
715                         if (!lastConditionsCriteria.equals(criteria))
716             {
717                 collConditions = ConditionPeer.doSelectJoinAttribute(criteria);
718             }
719         }
720         lastConditionsCriteria = criteria;
721
722         return collConditions;
723     }
724                   
725                     
726                     
727                                 
728                                                               
729                                         
730                     
731                     
732           
733     /**
734      * If this collection has already been initialized with
735      * an identical criteria, it returns the collection.
736      * Otherwise if this Transition is new, it will return
737      * an empty collection; or if this Transition has previously
738      * been saved, it will retrieve related Conditions from storage.
739      *
740      * This method is protected by default in order to keep the public
741      * api reasonable. You can provide public methods for those you
742      * actually need in Transition.
743      */

744     protected List JavaDoc getConditionsJoinAttributeOption(Criteria criteria)
745         throws TorqueException
746     {
747         if (collConditions == null)
748         {
749             if (isNew())
750             {
751                collConditions = new ArrayList JavaDoc();
752             }
753             else
754             {
755                             criteria.add(ConditionPeer.TRANSITION_ID, getTransitionId() );
756                             collConditions = ConditionPeer.doSelectJoinAttributeOption(criteria);
757             }
758         }
759         else
760         {
761             // the following code is to determine if a new query is
762
// called for. If the criteria is the same as the last
763
// one, just return the collection.
764

765                             criteria.add(ConditionPeer.TRANSITION_ID, getTransitionId() );
766                         if (!lastConditionsCriteria.equals(criteria))
767             {
768                 collConditions = ConditionPeer.doSelectJoinAttributeOption(criteria);
769             }
770         }
771         lastConditionsCriteria = criteria;
772
773         return collConditions;
774     }
775                   
776                     
777                     
778                                                       
779                                                                                     
780                                         
781                     
782                     
783           
784     /**
785      * If this collection has already been initialized with
786      * an identical criteria, it returns the collection.
787      * Otherwise if this Transition is new, it will return
788      * an empty collection; or if this Transition has previously
789      * been saved, it will retrieve related Conditions from storage.
790      *
791      * This method is protected by default in order to keep the public
792      * api reasonable. You can provide public methods for those you
793      * actually need in Transition.
794      */

795     protected List JavaDoc getConditionsJoinRModuleIssueType(Criteria criteria)
796         throws TorqueException
797     {
798         if (collConditions == null)
799         {
800             if (isNew())
801             {
802                collConditions = new ArrayList JavaDoc();
803             }
804             else
805             {
806                             criteria.add(ConditionPeer.TRANSITION_ID, getTransitionId() );
807                             collConditions = ConditionPeer.doSelectJoinRModuleIssueType(criteria);
808             }
809         }
810         else
811         {
812             // the following code is to determine if a new query is
813
// called for. If the criteria is the same as the last
814
// one, just return the collection.
815

816                             criteria.add(ConditionPeer.TRANSITION_ID, getTransitionId() );
817                         if (!lastConditionsCriteria.equals(criteria))
818             {
819                 collConditions = ConditionPeer.doSelectJoinRModuleIssueType(criteria);
820             }
821         }
822         lastConditionsCriteria = criteria;
823
824         return collConditions;
825     }
826                             
827
828
829           
830     private static List JavaDoc fieldNames = null;
831
832     /**
833      * Generate a list of field names.
834      *
835      * @return a list of field names
836      */

837     public static synchronized List JavaDoc getFieldNames()
838     {
839         if (fieldNames == null)
840         {
841             fieldNames = new ArrayList JavaDoc();
842               fieldNames.add("TransitionId");
843               fieldNames.add("RoleId");
844               fieldNames.add("AttributeId");
845               fieldNames.add("FromOptionId");
846               fieldNames.add("ToOptionId");
847               fieldNames.add("DisabledIfBlocked");
848               fieldNames = Collections.unmodifiableList(fieldNames);
849         }
850         return fieldNames;
851     }
852
853     /**
854      * Retrieves a field from the object by name passed in as a String.
855      *
856      * @param name field name
857      * @return value
858      */

859     public Object JavaDoc getByName(String JavaDoc name)
860     {
861           if (name.equals("TransitionId"))
862         {
863                 return getTransitionId();
864             }
865           if (name.equals("RoleId"))
866         {
867                 return getRoleId();
868             }
869           if (name.equals("AttributeId"))
870         {
871                 return getAttributeId();
872             }
873           if (name.equals("FromOptionId"))
874         {
875                 return getFromOptionId();
876             }
877           if (name.equals("ToOptionId"))
878         {
879                 return getToOptionId();
880             }
881           if (name.equals("DisabledIfBlocked"))
882         {
883                 return Boolean.valueOf(getDisabledIfBlocked());
884             }
885           return null;
886     }
887     
888     /**
889      * Retrieves a field from the object by name passed in
890      * as a String. The String must be one of the static
891      * Strings defined in this Class' Peer.
892      *
893      * @param name peer name
894      * @return value
895      */

896     public Object JavaDoc getByPeerName(String JavaDoc name)
897     {
898           if (name.equals(TransitionPeer.TRANSITION_ID))
899         {
900                 return getTransitionId();
901             }
902           if (name.equals(TransitionPeer.ROLE_ID))
903         {
904                 return getRoleId();
905             }
906           if (name.equals(TransitionPeer.ATTRIBUTE_ID))
907         {
908                 return getAttributeId();
909             }
910           if (name.equals(TransitionPeer.FROM_OPTION_ID))
911         {
912                 return getFromOptionId();
913             }
914           if (name.equals(TransitionPeer.TO_OPTION_ID))
915         {
916                 return getToOptionId();
917             }
918           if (name.equals(TransitionPeer.DISABLED_IF_BLOCKED))
919         {
920                 return Boolean.valueOf(getDisabledIfBlocked());
921             }
922           return null;
923     }
924
925     /**
926      * Retrieves a field from the object by Position as specified
927      * in the xml schema. Zero-based.
928      *
929      * @param pos position in xml schema
930      * @return value
931      */

932     public Object JavaDoc getByPosition(int pos)
933     {
934             if (pos == 0)
935         {
936                 return getTransitionId();
937             }
938               if (pos == 1)
939         {
940                 return getRoleId();
941             }
942               if (pos == 2)
943         {
944                 return getAttributeId();
945             }
946               if (pos == 3)
947         {
948                 return getFromOptionId();
949             }
950               if (pos == 4)
951         {
952                 return getToOptionId();
953             }
954               if (pos == 5)
955         {
956                 return Boolean.valueOf(getDisabledIfBlocked());
957             }
958               return null;
959     }
960      
961     /**
962      * Stores the object in the database. If the object is new,
963      * it inserts it; otherwise an update is performed.
964      *
965      * @throws Exception
966      */

967     public void save() throws Exception JavaDoc
968     {
969           save(TransitionPeer.getMapBuilder()
970                 .getDatabaseMap().getName());
971       }
972
973     /**
974      * Stores the object in the database. If the object is new,
975      * it inserts it; otherwise an update is performed.
976        * Note: this code is here because the method body is
977      * auto-generated conditionally and therefore needs to be
978      * in this file instead of in the super class, BaseObject.
979        *
980      * @param dbName
981      * @throws TorqueException
982      */

983     public void save(String JavaDoc dbName) throws TorqueException
984     {
985         Connection JavaDoc con = null;
986           try
987         {
988             con = Transaction.begin(dbName);
989             save(con);
990             Transaction.commit(con);
991         }
992         catch(TorqueException e)
993         {
994             Transaction.safeRollback(con);
995             throw e;
996         }
997       }
998
999       /** flag to prevent endless save loop, if this object is referenced
1000        by another object which falls in this transaction. */

1001    private boolean alreadyInSave = false;
1002      /**
1003     * Stores the object in the database. If the object is new,
1004     * it inserts it; otherwise an update is performed. This method
1005     * is meant to be used as part of a transaction, otherwise use
1006     * the save() method and the connection details will be handled
1007     * internally
1008     *
1009     * @param con
1010     * @throws TorqueException
1011     */

1012    public void save(Connection JavaDoc con) throws TorqueException
1013    {
1014          if (!alreadyInSave)
1015        {
1016            alreadyInSave = true;
1017
1018
1019  
1020            // If this object has been modified, then save it to the database.
1021
if (isModified())
1022            {
1023                if (isNew())
1024                {
1025                    TransitionPeer.doInsert((Transition)this, con);
1026                    setNew(false);
1027                }
1028                else
1029                {
1030                    TransitionPeer.doUpdate((Transition)this, con);
1031                }
1032
1033                      if (isCacheOnSave())
1034                {
1035                    TransitionManager.putInstance(this);
1036                }
1037              }
1038
1039                                      
1040                            if (collConditions != null)
1041            {
1042                for (int i = 0; i < collConditions.size(); i++)
1043                {
1044                    ((Condition)collConditions.get(i)).save(con);
1045                }
1046            }
1047                          alreadyInSave = false;
1048        }
1049      }
1050
1051    /**
1052     * Specify whether to cache the object after saving to the db.
1053     * This method returns false
1054     */

1055    protected boolean isCacheOnSave()
1056    {
1057        return true;
1058    }
1059
1060                        
1061      /**
1062     * Set the PrimaryKey using ObjectKey.
1063     *
1064     * @param transitionId ObjectKey
1065     */

1066    public void setPrimaryKey(ObjectKey transitionId)
1067        throws TorqueException {
1068            setTransitionId(new Integer JavaDoc(((NumberKey)transitionId).intValue()));
1069        }
1070
1071    /**
1072     * Set the PrimaryKey using a String.
1073     *
1074     * @param key
1075     */

1076    public void setPrimaryKey(String JavaDoc key) throws TorqueException
1077    {
1078            setTransitionId(new Integer JavaDoc(key));
1079        }
1080
1081  
1082    /**
1083     * returns an id that differentiates this object from others
1084     * of its class.
1085     */

1086    public ObjectKey getPrimaryKey()
1087    {
1088          return SimpleKey.keyFor(getTransitionId());
1089      }
1090 
1091    /**
1092     * get an id that differentiates this object from others
1093     * of its class.
1094     */

1095    public String JavaDoc getQueryKey()
1096    {
1097        if (getPrimaryKey() == null)
1098        {
1099            return "";
1100        }
1101        else
1102        {
1103            return getPrimaryKey().toString();
1104        }
1105    }
1106
1107    /**
1108     * set an id that differentiates this object from others
1109     * of its class.
1110     */

1111    public void setQueryKey(String JavaDoc key)
1112        throws TorqueException
1113    {
1114        setPrimaryKey(key);
1115    }
1116
1117    /**
1118     * Makes a copy of this object.
1119     * It creates a new object filling in the simple attributes.
1120       * It then fills all the association collections and sets the
1121     * related objects to isNew=true.
1122       */

1123      public Transition copy() throws TorqueException
1124    {
1125        Transition copyObj = new Transition();
1126            copyObj.setTransitionId(transitionId);
1127          copyObj.setRoleId(roleId);
1128          copyObj.setAttributeId(attributeId);
1129          copyObj.setFromOptionId(fromOptionId);
1130          copyObj.setToOptionId(toOptionId);
1131          copyObj.setDisabledIfBlocked(disabledIfBlocked);
1132  
1133                      copyObj.setTransitionId((Integer JavaDoc)null);
1134                                          
1135                                      
1136                
1137        List JavaDoc v = getConditions();
1138        for (int i = 0; i < v.size(); i++)
1139        {
1140            Condition obj = (Condition) v.get(i);
1141            copyObj.addCondition(obj.copy());
1142        }
1143                            return copyObj;
1144    }
1145
1146    /**
1147     * returns a peer instance associated with this om. Since Peer classes
1148     * are not to have any instance attributes, this method returns the
1149     * same instance for all member of this class. The method could therefore
1150     * be static, but this would prevent one from overriding the behavior.
1151     */

1152    public TransitionPeer getPeer()
1153    {
1154        return peer;
1155    }
1156
1157    public String JavaDoc toString()
1158    {
1159        StringBuffer JavaDoc str = new StringBuffer JavaDoc();
1160        str.append("Transition:\n");
1161        str.append("TransitionId = ")
1162               .append(getTransitionId())
1163             .append("\n");
1164        str.append("RoleId = ")
1165               .append(getRoleId())
1166             .append("\n");
1167        str.append("AttributeId = ")
1168               .append(getAttributeId())
1169             .append("\n");
1170        str.append("FromOptionId = ")
1171               .append(getFromOptionId())
1172             .append("\n");
1173        str.append("ToOptionId = ")
1174               .append(getToOptionId())
1175             .append("\n");
1176        str.append("DisabledIfBlocked = ")
1177               .append(getDisabledIfBlocked())
1178             .append("\n");
1179        return(str.toString());
1180    }
1181}
1182
Popular Tags