KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > campware > cream > om > BaseService


1 package org.campware.cream.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.turbine.om.Retrievable;
13 import org.apache.torque.TorqueException;
14 import org.apache.torque.om.BaseObject;
15 import org.apache.torque.om.ComboKey;
16 import org.apache.torque.om.DateKey;
17 import org.apache.torque.om.NumberKey;
18 import org.apache.torque.om.ObjectKey;
19 import org.apache.torque.om.SimpleKey;
20 import org.apache.torque.om.StringKey;
21 import org.apache.torque.om.Persistent;
22 import org.apache.torque.util.Criteria;
23 import org.apache.torque.util.Transaction;
24
25   
26     
27     
28     
29   
30 /**
31  * This class was autogenerated by Torque on:
32  *
33  * [Wed May 04 09:10:56 CEST 2005]
34  *
35  * You should not use this class directly. It should not even be
36  * extended all references should be to Service
37  */

38 public abstract class BaseService extends BaseObject
39     implements org.apache.turbine.om.Retrievable
40 {
41     /** The Peer class */
42     private static final ServicePeer peer =
43         new ServicePeer();
44
45         
46     /** The value for the serviceId field */
47     private int serviceId;
48                                                 
49     /** The value for the serviceCode field */
50     private String JavaDoc serviceCode = "AUTO";
51                                           
52     /** The value for the status field */
53     private int status = 30;
54                                           
55     /** The value for the priority field */
56     private int priority = 30;
57       
58     /** The value for the issuedDate field */
59     private Date JavaDoc issuedDate;
60       
61     /** The value for the closedDate field */
62     private Date JavaDoc closedDate;
63                                           
64     /** The value for the customerId field */
65     private int customerId = 1000;
66                                           
67     /** The value for the recipientId field */
68     private int recipientId = 1000;
69                                           
70     /** The value for the projectId field */
71     private int projectId = 1000;
72                                           
73     /** The value for the sorderId field */
74     private int sorderId = 1000;
75       
76     /** The value for the invoiceCode field */
77     private String JavaDoc invoiceCode;
78                                                 
79     /** The value for the subject field */
80     private String JavaDoc subject = "---";
81       
82     /** The value for the notes field */
83     private String JavaDoc notes;
84       
85     /** The value for the created field */
86     private Date JavaDoc created;
87       
88     /** The value for the modified field */
89     private Date JavaDoc modified;
90       
91     /** The value for the createdBy field */
92     private String JavaDoc createdBy;
93       
94     /** The value for the modifiedBy field */
95     private String JavaDoc modifiedBy;
96   
97     
98     /**
99      * Get the ServiceId
100      *
101      * @return int
102      */

103     public int getServiceId()
104     {
105         return serviceId;
106     }
107
108                                               
109     /**
110      * Set the value of ServiceId
111      *
112      * @param v new value
113      */

114     public void setServiceId(int v) throws TorqueException
115     {
116     
117                   if (this.serviceId != v)
118               {
119             this.serviceId = v;
120             setModified(true);
121         }
122     
123           
124                                   
125                   // update associated ServiceItem
126
if (collServiceItems != null)
127         {
128             for (int i = 0; i < collServiceItems.size(); i++)
129             {
130                 ((ServiceItem) collServiceItems.get(i))
131                     .setServiceId(v);
132             }
133         }
134                                 }
135   
136     /**
137      * Get the ServiceCode
138      *
139      * @return String
140      */

141     public String JavaDoc getServiceCode()
142     {
143         return serviceCode;
144     }
145
146                         
147     /**
148      * Set the value of ServiceCode
149      *
150      * @param v new value
151      */

152     public void setServiceCode(String JavaDoc v)
153     {
154     
155                   if (!ObjectUtils.equals(this.serviceCode, v))
156               {
157             this.serviceCode = v;
158             setModified(true);
159         }
160     
161           
162               }
163   
164     /**
165      * Get the Status
166      *
167      * @return int
168      */

169     public int getStatus()
170     {
171         return status;
172     }
173
174                         
175     /**
176      * Set the value of Status
177      *
178      * @param v new value
179      */

180     public void setStatus(int v)
181     {
182     
183                   if (this.status != v)
184               {
185             this.status = v;
186             setModified(true);
187         }
188     
189           
190               }
191   
192     /**
193      * Get the Priority
194      *
195      * @return int
196      */

197     public int getPriority()
198     {
199         return priority;
200     }
201
202                         
203     /**
204      * Set the value of Priority
205      *
206      * @param v new value
207      */

208     public void setPriority(int v)
209     {
210     
211                   if (this.priority != v)
212               {
213             this.priority = v;
214             setModified(true);
215         }
216     
217           
218               }
219   
220     /**
221      * Get the IssuedDate
222      *
223      * @return Date
224      */

225     public Date JavaDoc getIssuedDate()
226     {
227         return issuedDate;
228     }
229
230                         
231     /**
232      * Set the value of IssuedDate
233      *
234      * @param v new value
235      */

236     public void setIssuedDate(Date JavaDoc v)
237     {
238     
239                   if (!ObjectUtils.equals(this.issuedDate, v))
240               {
241             this.issuedDate = v;
242             setModified(true);
243         }
244     
245           
246               }
247   
248     /**
249      * Get the ClosedDate
250      *
251      * @return Date
252      */

253     public Date JavaDoc getClosedDate()
254     {
255         return closedDate;
256     }
257
258                         
259     /**
260      * Set the value of ClosedDate
261      *
262      * @param v new value
263      */

264     public void setClosedDate(Date JavaDoc v)
265     {
266     
267                   if (!ObjectUtils.equals(this.closedDate, v))
268               {
269             this.closedDate = v;
270             setModified(true);
271         }
272     
273           
274               }
275   
276     /**
277      * Get the CustomerId
278      *
279      * @return int
280      */

281     public int getCustomerId()
282     {
283         return customerId;
284     }
285
286                               
287     /**
288      * Set the value of CustomerId
289      *
290      * @param v new value
291      */

292     public void setCustomerId(int v) throws TorqueException
293     {
294     
295                   if (this.customerId != v)
296               {
297             this.customerId = v;
298             setModified(true);
299         }
300     
301                                                                   
302                 if (aCustomerRelatedByCustomerId != null && !(aCustomerRelatedByCustomerId.getCustomerId() == v))
303                 {
304             aCustomerRelatedByCustomerId = null;
305         }
306       
307               }
308   
309     /**
310      * Get the RecipientId
311      *
312      * @return int
313      */

314     public int getRecipientId()
315     {
316         return recipientId;
317     }
318
319                               
320     /**
321      * Set the value of RecipientId
322      *
323      * @param v new value
324      */

325     public void setRecipientId(int v) throws TorqueException
326     {
327     
328                   if (this.recipientId != v)
329               {
330             this.recipientId = v;
331             setModified(true);
332         }
333     
334                                                                   
335                 if (aCustomerRelatedByRecipientId != null && !(aCustomerRelatedByRecipientId.getCustomerId() == v))
336                 {
337             aCustomerRelatedByRecipientId = null;
338         }
339       
340               }
341   
342     /**
343      * Get the ProjectId
344      *
345      * @return int
346      */

347     public int getProjectId()
348     {
349         return projectId;
350     }
351
352                               
353     /**
354      * Set the value of ProjectId
355      *
356      * @param v new value
357      */

358     public void setProjectId(int v) throws TorqueException
359     {
360     
361                   if (this.projectId != v)
362               {
363             this.projectId = v;
364             setModified(true);
365         }
366     
367                           
368                 if (aProject != null && !(aProject.getProjectId() == v))
369                 {
370             aProject = null;
371         }
372       
373               }
374   
375     /**
376      * Get the SorderId
377      *
378      * @return int
379      */

380     public int getSorderId()
381     {
382         return sorderId;
383     }
384
385                               
386     /**
387      * Set the value of SorderId
388      *
389      * @param v new value
390      */

391     public void setSorderId(int v) throws TorqueException
392     {
393     
394                   if (this.sorderId != v)
395               {
396             this.sorderId = v;
397             setModified(true);
398         }
399     
400                           
401                 if (aSorder != null && !(aSorder.getSorderId() == v))
402                 {
403             aSorder = null;
404         }
405       
406               }
407   
408     /**
409      * Get the InvoiceCode
410      *
411      * @return String
412      */

413     public String JavaDoc getInvoiceCode()
414     {
415         return invoiceCode;
416     }
417
418                         
419     /**
420      * Set the value of InvoiceCode
421      *
422      * @param v new value
423      */

424     public void setInvoiceCode(String JavaDoc v)
425     {
426     
427                   if (!ObjectUtils.equals(this.invoiceCode, v))
428               {
429             this.invoiceCode = v;
430             setModified(true);
431         }
432     
433           
434               }
435   
436     /**
437      * Get the Subject
438      *
439      * @return String
440      */

441     public String JavaDoc getSubject()
442     {
443         return subject;
444     }
445
446                         
447     /**
448      * Set the value of Subject
449      *
450      * @param v new value
451      */

452     public void setSubject(String JavaDoc v)
453     {
454     
455                   if (!ObjectUtils.equals(this.subject, v))
456               {
457             this.subject = v;
458             setModified(true);
459         }
460     
461           
462               }
463   
464     /**
465      * Get the Notes
466      *
467      * @return String
468      */

469     public String JavaDoc getNotes()
470     {
471         return notes;
472     }
473
474                         
475     /**
476      * Set the value of Notes
477      *
478      * @param v new value
479      */

480     public void setNotes(String JavaDoc v)
481     {
482     
483                   if (!ObjectUtils.equals(this.notes, v))
484               {
485             this.notes = v;
486             setModified(true);
487         }
488     
489           
490               }
491   
492     /**
493      * Get the Created
494      *
495      * @return Date
496      */

497     public Date JavaDoc getCreated()
498     {
499         return created;
500     }
501
502                         
503     /**
504      * Set the value of Created
505      *
506      * @param v new value
507      */

508     public void setCreated(Date JavaDoc v)
509     {
510     
511                   if (!ObjectUtils.equals(this.created, v))
512               {
513             this.created = v;
514             setModified(true);
515         }
516     
517           
518               }
519   
520     /**
521      * Get the Modified
522      *
523      * @return Date
524      */

525     public Date JavaDoc getModified()
526     {
527         return modified;
528     }
529
530                         
531     /**
532      * Set the value of Modified
533      *
534      * @param v new value
535      */

536     public void setModified(Date JavaDoc v)
537     {
538     
539                   if (!ObjectUtils.equals(this.modified, v))
540               {
541             this.modified = v;
542             setModified(true);
543         }
544     
545           
546               }
547   
548     /**
549      * Get the CreatedBy
550      *
551      * @return String
552      */

553     public String JavaDoc getCreatedBy()
554     {
555         return createdBy;
556     }
557
558                         
559     /**
560      * Set the value of CreatedBy
561      *
562      * @param v new value
563      */

564     public void setCreatedBy(String JavaDoc v)
565     {
566     
567                   if (!ObjectUtils.equals(this.createdBy, v))
568               {
569             this.createdBy = v;
570             setModified(true);
571         }
572     
573           
574               }
575   
576     /**
577      * Get the ModifiedBy
578      *
579      * @return String
580      */

581     public String JavaDoc getModifiedBy()
582     {
583         return modifiedBy;
584     }
585
586                         
587     /**
588      * Set the value of ModifiedBy
589      *
590      * @param v new value
591      */

592     public void setModifiedBy(String JavaDoc v)
593     {
594     
595                   if (!ObjectUtils.equals(this.modifiedBy, v))
596               {
597             this.modifiedBy = v;
598             setModified(true);
599         }
600     
601           
602               }
603   
604       
605     
606                         
607         
608         private Customer aCustomerRelatedByCustomerId;
609
610     /**
611      * Declares an association between this object and a Customer object
612      *
613      * @param v Customer
614      * @throws TorqueException
615      */

616     public void setCustomerRelatedByCustomerId(Customer v) throws TorqueException
617     {
618             if (v == null)
619         {
620                           setCustomerId( 1000);
621               }
622         else
623         {
624             setCustomerId(v.getCustomerId());
625         }
626             aCustomerRelatedByCustomerId = v;
627     }
628
629                                             
630     /**
631      * Get the associated Customer object
632      *
633      * @return the associated Customer object
634      * @throws TorqueException
635      */

636     public Customer getCustomerRelatedByCustomerId() throws TorqueException
637     {
638         if (aCustomerRelatedByCustomerId == null && (this.customerId != 0))
639         {
640                           aCustomerRelatedByCustomerId = CustomerPeer.retrieveByPK(SimpleKey.keyFor(this.customerId));
641               
642             /* The following can be used instead of the line above to
643                guarantee the related object contains a reference
644                to this object, but this level of coupling
645                may be undesirable in many circumstances.
646                As it can lead to a db query with many results that may
647                never be used.
648                Customer obj = CustomerPeer.retrieveByPK(this.customerId);
649                obj.addServicesRelatedByCustomerId(this);
650             */

651         }
652         return aCustomerRelatedByCustomerId;
653     }
654
655     /**
656      * Provides convenient way to set a relationship based on a
657      * ObjectKey, for example
658      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
659      *
660          */

661     public void setCustomerRelatedByCustomerIdKey(ObjectKey key) throws TorqueException
662     {
663       
664                         setCustomerId(((NumberKey) key).intValue());
665                   }
666     
667     
668                         
669         
670         private Customer aCustomerRelatedByRecipientId;
671
672     /**
673      * Declares an association between this object and a Customer object
674      *
675      * @param v Customer
676      * @throws TorqueException
677      */

678     public void setCustomerRelatedByRecipientId(Customer v) throws TorqueException
679     {
680             if (v == null)
681         {
682                           setRecipientId( 1000);
683               }
684         else
685         {
686             setRecipientId(v.getCustomerId());
687         }
688             aCustomerRelatedByRecipientId = v;
689     }
690
691                                             
692     /**
693      * Get the associated Customer object
694      *
695      * @return the associated Customer object
696      * @throws TorqueException
697      */

698     public Customer getCustomerRelatedByRecipientId() throws TorqueException
699     {
700         if (aCustomerRelatedByRecipientId == null && (this.recipientId != 0))
701         {
702                           aCustomerRelatedByRecipientId = CustomerPeer.retrieveByPK(SimpleKey.keyFor(this.recipientId));
703               
704             /* The following can be used instead of the line above to
705                guarantee the related object contains a reference
706                to this object, but this level of coupling
707                may be undesirable in many circumstances.
708                As it can lead to a db query with many results that may
709                never be used.
710                Customer obj = CustomerPeer.retrieveByPK(this.recipientId);
711                obj.addServicesRelatedByRecipientId(this);
712             */

713         }
714         return aCustomerRelatedByRecipientId;
715     }
716
717     /**
718      * Provides convenient way to set a relationship based on a
719      * ObjectKey, for example
720      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
721      *
722          */

723     public void setCustomerRelatedByRecipientIdKey(ObjectKey key) throws TorqueException
724     {
725       
726                         setRecipientId(((NumberKey) key).intValue());
727                   }
728     
729     
730                   
731     
732         private Project aProject;
733
734     /**
735      * Declares an association between this object and a Project object
736      *
737      * @param v Project
738      * @throws TorqueException
739      */

740     public void setProject(Project v) throws TorqueException
741     {
742             if (v == null)
743         {
744                           setProjectId( 1000);
745               }
746         else
747         {
748             setProjectId(v.getProjectId());
749         }
750             aProject = v;
751     }
752
753                                             
754     /**
755      * Get the associated Project object
756      *
757      * @return the associated Project object
758      * @throws TorqueException
759      */

760     public Project getProject() throws TorqueException
761     {
762         if (aProject == null && (this.projectId != 0))
763         {
764                           aProject = ProjectPeer.retrieveByPK(SimpleKey.keyFor(this.projectId));
765               
766             /* The following can be used instead of the line above to
767                guarantee the related object contains a reference
768                to this object, but this level of coupling
769                may be undesirable in many circumstances.
770                As it can lead to a db query with many results that may
771                never be used.
772                Project obj = ProjectPeer.retrieveByPK(this.projectId);
773                obj.addServices(this);
774             */

775         }
776         return aProject;
777     }
778
779     /**
780      * Provides convenient way to set a relationship based on a
781      * ObjectKey, for example
782      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
783      *
784          */

785     public void setProjectKey(ObjectKey key) throws TorqueException
786     {
787       
788                         setProjectId(((NumberKey) key).intValue());
789                   }
790     
791     
792                   
793     
794         private Sorder aSorder;
795
796     /**
797      * Declares an association between this object and a Sorder object
798      *
799      * @param v Sorder
800      * @throws TorqueException
801      */

802     public void setSorder(Sorder v) throws TorqueException
803     {
804             if (v == null)
805         {
806                           setSorderId( 1000);
807               }
808         else
809         {
810             setSorderId(v.getSorderId());
811         }
812             aSorder = v;
813     }
814
815                                             
816     /**
817      * Get the associated Sorder object
818      *
819      * @return the associated Sorder object
820      * @throws TorqueException
821      */

822     public Sorder getSorder() throws TorqueException
823     {
824         if (aSorder == null && (this.sorderId != 0))
825         {
826                           aSorder = SorderPeer.retrieveByPK(SimpleKey.keyFor(this.sorderId));
827               
828             /* The following can be used instead of the line above to
829                guarantee the related object contains a reference
830                to this object, but this level of coupling
831                may be undesirable in many circumstances.
832                As it can lead to a db query with many results that may
833                never be used.
834                Sorder obj = SorderPeer.retrieveByPK(this.sorderId);
835                obj.addServices(this);
836             */

837         }
838         return aSorder;
839     }
840
841     /**
842      * Provides convenient way to set a relationship based on a
843      * ObjectKey, for example
844      * <code>bar.setFooKey(foo.getPrimaryKey())</code>
845      *
846          */

847     public void setSorderKey(ObjectKey key) throws TorqueException
848     {
849       
850                         setSorderId(((NumberKey) key).intValue());
851                   }
852        
853                                 
854             
855           /**
856      * Collection to store aggregation of collServiceItems
857      */

858     protected List JavaDoc collServiceItems;
859
860     /**
861      * Temporary storage of collServiceItems to save a possible db hit in
862      * the event objects are add to the collection, but the
863      * complete collection is never requested.
864      */

865     protected void initServiceItems()
866     {
867         if (collServiceItems == null)
868         {
869             collServiceItems = new ArrayList JavaDoc();
870         }
871     }
872
873     /**
874      * Method called to associate a ServiceItem object to this object
875      * through the ServiceItem foreign key attribute
876      *
877      * @param l ServiceItem
878      * @throws TorqueException
879      */

880     public void addServiceItem(ServiceItem l) throws TorqueException
881     {
882         getServiceItems().add(l);
883         l.setService((Service) this);
884     }
885
886     /**
887      * The criteria used to select the current contents of collServiceItems
888      */

889     private Criteria lastServiceItemsCriteria = null;
890       
891     /**
892      * If this collection has already been initialized, returns
893      * the collection. Otherwise returns the results of
894      * getServiceItems(new Criteria())
895      *
896      * @throws TorqueException
897      */

898     public List JavaDoc getServiceItems() throws TorqueException
899     {
900               if (collServiceItems == null)
901         {
902             collServiceItems = getServiceItems(new Criteria(10));
903         }
904         return collServiceItems;
905           }
906
907     /**
908      * If this collection has already been initialized with
909      * an identical criteria, it returns the collection.
910      * Otherwise if this Service has previously
911      * been saved, it will retrieve related ServiceItems from storage.
912      * If this Service is new, it will return
913      * an empty collection or the current collection, the criteria
914      * is ignored on a new object.
915      *
916      * @throws TorqueException
917      */

918     public List JavaDoc getServiceItems(Criteria criteria) throws TorqueException
919     {
920               if (collServiceItems == null)
921         {
922             if (isNew())
923             {
924                collServiceItems = new ArrayList JavaDoc();
925             }
926             else
927             {
928                         criteria.add(ServiceItemPeer.SERVICE_ID, getServiceId() );
929                         collServiceItems = ServiceItemPeer.doSelect(criteria);
930             }
931         }
932         else
933         {
934             // criteria has no effect for a new object
935
if (!isNew())
936             {
937                 // the following code is to determine if a new query is
938
// called for. If the criteria is the same as the last
939
// one, just return the collection.
940
criteria.add(ServiceItemPeer.SERVICE_ID, getServiceId());
941                             if (!lastServiceItemsCriteria.equals(criteria))
942                 {
943                     collServiceItems = ServiceItemPeer.doSelect(criteria);
944                 }
945             }
946         }
947         lastServiceItemsCriteria = criteria;
948
949         return collServiceItems;
950           }
951
952     /**
953      * If this collection has already been initialized, returns
954      * the collection. Otherwise returns the results of
955      * getServiceItems(new Criteria(),Connection)
956      * This method takes in the Connection also as input so that
957      * referenced objects can also be obtained using a Connection
958      * that is taken as input
959      */

960     public List JavaDoc getServiceItems(Connection JavaDoc con) throws TorqueException
961     {
962               if (collServiceItems == null)
963         {
964             collServiceItems = getServiceItems(new Criteria(10), con);
965         }
966         return collServiceItems;
967           }
968
969     /**
970      * If this collection has already been initialized with
971      * an identical criteria, it returns the collection.
972      * Otherwise if this Service has previously
973      * been saved, it will retrieve related ServiceItems from storage.
974      * If this Service is new, it will return
975      * an empty collection or the current collection, the criteria
976      * is ignored on a new object.
977      * This method takes in the Connection also as input so that
978      * referenced objects can also be obtained using a Connection
979      * that is taken as input
980      */

981     public List JavaDoc getServiceItems(Criteria criteria, Connection JavaDoc con)
982             throws TorqueException
983     {
984               if (collServiceItems == null)
985         {
986             if (isNew())
987             {
988                collServiceItems = new ArrayList JavaDoc();
989             }
990             else
991             {
992                          criteria.add(ServiceItemPeer.SERVICE_ID, getServiceId());
993                          collServiceItems = ServiceItemPeer.doSelect(criteria, con);
994              }
995          }
996          else
997          {
998              // criteria has no effect for a new object
999
if (!isNew())
1000             {
1001                 // the following code is to determine if a new query is
1002
// called for. If the criteria is the same as the last
1003
// one, just return the collection.
1004
criteria.add(ServiceItemPeer.SERVICE_ID, getServiceId());
1005                             if (!lastServiceItemsCriteria.equals(criteria))
1006                 {
1007                     collServiceItems = ServiceItemPeer.doSelect(criteria, con);
1008                 }
1009             }
1010         }
1011         lastServiceItemsCriteria = criteria;
1012
1013         return collServiceItems;
1014           }
1015
1016                                                
1017              
1018                    
1019                              
1020                                
1021                                                              
1022                                        
1023                    
1024                    
1025          
1026    /**
1027     * If this collection has already been initialized with
1028     * an identical criteria, it returns the collection.
1029     * Otherwise if this Service is new, it will return
1030     * an empty collection; or if this Service has previously
1031     * been saved, it will retrieve related ServiceItems from storage.
1032     *
1033     * This method is protected by default in order to keep the public
1034     * api reasonable. You can provide public methods for those you
1035     * actually need in Service.
1036     */

1037    protected List JavaDoc getServiceItemsJoinService(Criteria criteria)
1038        throws TorqueException
1039    {
1040                    if (collServiceItems == null)
1041        {
1042            if (isNew())
1043            {
1044               collServiceItems = new ArrayList JavaDoc();
1045            }
1046            else
1047            {
1048                              criteria.add(ServiceItemPeer.SERVICE_ID, getServiceId());
1049                              collServiceItems = ServiceItemPeer.doSelectJoinService(criteria);
1050            }
1051        }
1052        else
1053        {
1054            // the following code is to determine if a new query is
1055
// called for. If the criteria is the same as the last
1056
// one, just return the collection.
1057

1058                        criteria.add(ServiceItemPeer.SERVICE_ID, getServiceId());
1059                                    if (!lastServiceItemsCriteria.equals(criteria))
1060            {
1061                collServiceItems = ServiceItemPeer.doSelectJoinService(criteria);
1062            }
1063        }
1064        lastServiceItemsCriteria = criteria;
1065
1066        return collServiceItems;
1067                }
1068                  
1069                    
1070                    
1071                                
1072                                                              
1073                                        
1074                    
1075                    
1076          
1077    /**
1078     * If this collection has already been initialized with
1079     * an identical criteria, it returns the collection.
1080     * Otherwise if this Service is new, it will return
1081     * an empty collection; or if this Service has previously
1082     * been saved, it will retrieve related ServiceItems from storage.
1083     *
1084     * This method is protected by default in order to keep the public
1085     * api reasonable. You can provide public methods for those you
1086     * actually need in Service.
1087     */

1088    protected List JavaDoc getServiceItemsJoinSorder(Criteria criteria)
1089        throws TorqueException
1090    {
1091                    if (collServiceItems == null)
1092        {
1093            if (isNew())
1094            {
1095               collServiceItems = new ArrayList JavaDoc();
1096            }
1097            else
1098            {
1099                              criteria.add(ServiceItemPeer.SERVICE_ID, getServiceId());
1100                              collServiceItems = ServiceItemPeer.doSelectJoinSorder(criteria);
1101            }
1102        }
1103        else
1104        {
1105            // the following code is to determine if a new query is
1106
// called for. If the criteria is the same as the last
1107
// one, just return the collection.
1108

1109                        criteria.add(ServiceItemPeer.SERVICE_ID, getServiceId());
1110                                    if (!lastServiceItemsCriteria.equals(criteria))
1111            {
1112                collServiceItems = ServiceItemPeer.doSelectJoinSorder(criteria);
1113            }
1114        }
1115        lastServiceItemsCriteria = criteria;
1116
1117        return collServiceItems;
1118                }
1119                  
1120                    
1121                    
1122                                
1123                                                              
1124                                        
1125                    
1126                    
1127          
1128    /**
1129     * If this collection has already been initialized with
1130     * an identical criteria, it returns the collection.
1131     * Otherwise if this Service is new, it will return
1132     * an empty collection; or if this Service has previously
1133     * been saved, it will retrieve related ServiceItems from storage.
1134     *
1135     * This method is protected by default in order to keep the public
1136     * api reasonable. You can provide public methods for those you
1137     * actually need in Service.
1138     */

1139    protected List JavaDoc getServiceItemsJoinProduct(Criteria criteria)
1140        throws TorqueException
1141    {
1142                    if (collServiceItems == null)
1143        {
1144            if (isNew())
1145            {
1146               collServiceItems = new ArrayList JavaDoc();
1147            }
1148            else
1149            {
1150                              criteria.add(ServiceItemPeer.SERVICE_ID, getServiceId());
1151                              collServiceItems = ServiceItemPeer.doSelectJoinProduct(criteria);
1152            }
1153        }
1154        else
1155        {
1156            // the following code is to determine if a new query is
1157
// called for. If the criteria is the same as the last
1158
// one, just return the collection.
1159

1160                        criteria.add(ServiceItemPeer.SERVICE_ID, getServiceId());
1161                                    if (!lastServiceItemsCriteria.equals(criteria))
1162            {
1163                collServiceItems = ServiceItemPeer.doSelectJoinProduct(criteria);
1164            }
1165        }
1166        lastServiceItemsCriteria = criteria;
1167
1168        return collServiceItems;
1169                }
1170                  
1171                    
1172                    
1173                                            
1174                                                                          
1175                                        
1176                    
1177                    
1178          
1179    /**
1180     * If this collection has already been initialized with
1181     * an identical criteria, it returns the collection.
1182     * Otherwise if this Service is new, it will return
1183     * an empty collection; or if this Service has previously
1184     * been saved, it will retrieve related ServiceItems from storage.
1185     *
1186     * This method is protected by default in order to keep the public
1187     * api reasonable. You can provide public methods for those you
1188     * actually need in Service.
1189     */

1190    protected List JavaDoc getServiceItemsJoinCustomerRelatedByCustomerId(Criteria criteria)
1191        throws TorqueException
1192    {
1193                    if (collServiceItems == null)
1194        {
1195            if (isNew())
1196            {
1197               collServiceItems = new ArrayList JavaDoc();
1198            }
1199            else
1200            {
1201                              criteria.add(ServiceItemPeer.SERVICE_ID, getServiceId());
1202                              collServiceItems = ServiceItemPeer.doSelectJoinCustomerRelatedByCustomerId(criteria);
1203            }
1204        }
1205        else
1206        {
1207            // the following code is to determine if a new query is
1208
// called for. If the criteria is the same as the last
1209
// one, just return the collection.
1210

1211                        criteria.add(ServiceItemPeer.SERVICE_ID, getServiceId());
1212                                    if (!lastServiceItemsCriteria.equals(criteria))
1213            {
1214                collServiceItems = ServiceItemPeer.doSelectJoinCustomerRelatedByCustomerId(criteria);
1215            }
1216        }
1217        lastServiceItemsCriteria = criteria;
1218
1219        return collServiceItems;
1220                }
1221                  
1222                    
1223                    
1224                                            
1225                                                                          
1226                                        
1227                    
1228                    
1229          
1230    /**
1231     * If this collection has already been initialized with
1232     * an identical criteria, it returns the collection.
1233     * Otherwise if this Service is new, it will return
1234     * an empty collection; or if this Service has previously
1235     * been saved, it will retrieve related ServiceItems from storage.
1236     *
1237     * This method is protected by default in order to keep the public
1238     * api reasonable. You can provide public methods for those you
1239     * actually need in Service.
1240     */

1241    protected List JavaDoc getServiceItemsJoinCustomerRelatedByRecipientId(Criteria criteria)
1242        throws TorqueException
1243    {
1244                    if (collServiceItems == null)
1245        {
1246            if (isNew())
1247            {
1248               collServiceItems = new ArrayList JavaDoc();
1249            }
1250            else
1251            {
1252                              criteria.add(ServiceItemPeer.SERVICE_ID, getServiceId());
1253                              collServiceItems = ServiceItemPeer.doSelectJoinCustomerRelatedByRecipientId(criteria);
1254            }
1255        }
1256        else
1257        {
1258            // the following code is to determine if a new query is
1259
// called for. If the criteria is the same as the last
1260
// one, just return the collection.
1261

1262                        criteria.add(ServiceItemPeer.SERVICE_ID, getServiceId());
1263                                    if (!lastServiceItemsCriteria.equals(criteria))
1264            {
1265                collServiceItems = ServiceItemPeer.doSelectJoinCustomerRelatedByRecipientId(criteria);
1266            }
1267        }
1268        lastServiceItemsCriteria = criteria;
1269
1270        return collServiceItems;
1271                }
1272                  
1273                    
1274                    
1275                                
1276                                                              
1277                                        
1278                    
1279                    
1280          
1281    /**
1282     * If this collection has already been initialized with
1283     * an identical criteria, it returns the collection.
1284     * Otherwise if this Service is new, it will return
1285     * an empty collection; or if this Service has previously
1286     * been saved, it will retrieve related ServiceItems from storage.
1287     *
1288     * This method is protected by default in order to keep the public
1289     * api reasonable. You can provide public methods for those you
1290     * actually need in Service.
1291     */

1292    protected List JavaDoc getServiceItemsJoinProject(Criteria criteria)
1293        throws TorqueException
1294    {
1295                    if (collServiceItems == null)
1296        {
1297            if (isNew())
1298            {
1299               collServiceItems = new ArrayList JavaDoc();
1300            }
1301            else
1302            {
1303                              criteria.add(ServiceItemPeer.SERVICE_ID, getServiceId());
1304                              collServiceItems = ServiceItemPeer.doSelectJoinProject(criteria);
1305            }
1306        }
1307        else
1308        {
1309            // the following code is to determine if a new query is
1310
// called for. If the criteria is the same as the last
1311
// one, just return the collection.
1312

1313                        criteria.add(ServiceItemPeer.SERVICE_ID, getServiceId());
1314                                    if (!lastServiceItemsCriteria.equals(criteria))
1315            {
1316                collServiceItems = ServiceItemPeer.doSelectJoinProject(criteria);
1317            }
1318        }
1319        lastServiceItemsCriteria = criteria;
1320
1321        return collServiceItems;
1322                }
1323                            
1324
1325
1326          
1327    private static List JavaDoc fieldNames = null;
1328
1329    /**
1330     * Generate a list of field names.
1331     *
1332     * @return a list of field names
1333     */

1334    public static synchronized List JavaDoc getFieldNames()
1335    {
1336        if (fieldNames == null)
1337        {
1338            fieldNames = new ArrayList JavaDoc();
1339              fieldNames.add("ServiceId");
1340              fieldNames.add("ServiceCode");
1341              fieldNames.add("Status");
1342              fieldNames.add("Priority");
1343              fieldNames.add("IssuedDate");
1344              fieldNames.add("ClosedDate");
1345              fieldNames.add("CustomerId");
1346              fieldNames.add("RecipientId");
1347              fieldNames.add("ProjectId");
1348              fieldNames.add("SorderId");
1349              fieldNames.add("InvoiceCode");
1350              fieldNames.add("Subject");
1351              fieldNames.add("Notes");
1352              fieldNames.add("Created");
1353              fieldNames.add("Modified");
1354              fieldNames.add("CreatedBy");
1355              fieldNames.add("ModifiedBy");
1356              fieldNames = Collections.unmodifiableList(fieldNames);
1357        }
1358        return fieldNames;
1359    }
1360
1361    /**
1362     * Retrieves a field from the object by name passed in as a String.
1363     *
1364     * @param name field name
1365     * @return value
1366     */

1367    public Object JavaDoc getByName(String JavaDoc name)
1368    {
1369          if (name.equals("ServiceId"))
1370        {
1371                return new Integer JavaDoc(getServiceId());
1372            }
1373          if (name.equals("ServiceCode"))
1374        {
1375                return getServiceCode();
1376            }
1377          if (name.equals("Status"))
1378        {
1379                return new Integer JavaDoc(getStatus());
1380            }
1381          if (name.equals("Priority"))
1382        {
1383                return new Integer JavaDoc(getPriority());
1384            }
1385          if (name.equals("IssuedDate"))
1386        {
1387                return getIssuedDate();
1388            }
1389          if (name.equals("ClosedDate"))
1390        {
1391                return getClosedDate();
1392            }
1393          if (name.equals("CustomerId"))
1394        {
1395                return new Integer JavaDoc(getCustomerId());
1396            }
1397          if (name.equals("RecipientId"))
1398        {
1399                return new Integer JavaDoc(getRecipientId());
1400            }
1401          if (name.equals("ProjectId"))
1402        {
1403                return new Integer JavaDoc(getProjectId());
1404            }
1405          if (name.equals("SorderId"))
1406        {
1407                return new Integer JavaDoc(getSorderId());
1408            }
1409          if (name.equals("InvoiceCode"))
1410        {
1411                return getInvoiceCode();
1412            }
1413          if (name.equals("Subject"))
1414        {
1415                return getSubject();
1416            }
1417          if (name.equals("Notes"))
1418        {
1419                return getNotes();
1420            }
1421          if (name.equals("Created"))
1422        {
1423                return getCreated();
1424            }
1425          if (name.equals("Modified"))
1426        {
1427                return getModified();
1428            }
1429          if (name.equals("CreatedBy"))
1430        {
1431                return getCreatedBy();
1432            }
1433          if (name.equals("ModifiedBy"))
1434        {
1435                return getModifiedBy();
1436            }
1437          return null;
1438    }
1439    
1440    /**
1441     * Retrieves a field from the object by name passed in
1442     * as a String. The String must be one of the static
1443     * Strings defined in this Class' Peer.
1444     *
1445     * @param name peer name
1446     * @return value
1447     */

1448    public Object JavaDoc getByPeerName(String JavaDoc name)
1449    {
1450          if (name.equals(ServicePeer.SERVICE_ID))
1451        {
1452                return new Integer JavaDoc(getServiceId());
1453            }
1454          if (name.equals(ServicePeer.SERVICE_CODE))
1455        {
1456                return getServiceCode();
1457            }
1458          if (name.equals(ServicePeer.STATUS))
1459        {
1460                return new Integer JavaDoc(getStatus());
1461            }
1462          if (name.equals(ServicePeer.PRIORITY))
1463        {
1464                return new Integer JavaDoc(getPriority());
1465            }
1466          if (name.equals(ServicePeer.ISSUED_DATE))
1467        {
1468                return getIssuedDate();
1469            }
1470          if (name.equals(ServicePeer.CLOSED_DATE))
1471        {
1472                return getClosedDate();
1473            }
1474          if (name.equals(ServicePeer.CUSTOMER_ID))
1475        {
1476                return new Integer JavaDoc(getCustomerId());
1477            }
1478          if (name.equals(ServicePeer.RECIPIENT_ID))
1479        {
1480                return new Integer JavaDoc(getRecipientId());
1481            }
1482          if (name.equals(ServicePeer.PROJECT_ID))
1483        {
1484                return new Integer JavaDoc(getProjectId());
1485            }
1486          if (name.equals(ServicePeer.SORDER_ID))
1487        {
1488                return new Integer JavaDoc(getSorderId());
1489            }
1490          if (name.equals(ServicePeer.INVOICE_CODE))
1491        {
1492                return getInvoiceCode();
1493            }
1494          if (name.equals(ServicePeer.SUBJECT))
1495        {
1496                return getSubject();
1497            }
1498          if (name.equals(ServicePeer.NOTES))
1499        {
1500                return getNotes();
1501            }
1502          if (name.equals(ServicePeer.CREATED))
1503        {
1504                return getCreated();
1505            }
1506          if (name.equals(ServicePeer.MODIFIED))
1507        {
1508                return getModified();
1509            }
1510          if (name.equals(ServicePeer.CREATED_BY))
1511        {
1512                return getCreatedBy();
1513            }
1514          if (name.equals(ServicePeer.MODIFIED_BY))
1515        {
1516                return getModifiedBy();
1517            }
1518          return null;
1519    }
1520
1521    /**
1522     * Retrieves a field from the object by Position as specified
1523     * in the xml schema. Zero-based.
1524     *
1525     * @param pos position in xml schema
1526     * @return value
1527     */

1528    public Object JavaDoc getByPosition(int pos)
1529    {
1530            if (pos == 0)
1531        {
1532                return new Integer JavaDoc(getServiceId());
1533            }
1534              if (pos == 1)
1535        {
1536                return getServiceCode();
1537            }
1538              if (pos == 2)
1539        {
1540                return new Integer JavaDoc(getStatus());
1541            }
1542              if (pos == 3)
1543        {
1544                return new Integer JavaDoc(getPriority());
1545            }
1546              if (pos == 4)
1547        {
1548                return getIssuedDate();
1549            }
1550              if (pos == 5)
1551        {
1552                return getClosedDate();
1553            }
1554              if (pos == 6)
1555        {
1556                return new Integer JavaDoc(getCustomerId());
1557            }
1558              if (pos == 7)
1559        {
1560                return new Integer JavaDoc(getRecipientId());
1561            }
1562              if (pos == 8)
1563        {
1564                return new Integer JavaDoc(getProjectId());
1565            }
1566              if (pos == 9)
1567        {
1568                return new Integer JavaDoc(getSorderId());
1569            }
1570              if (pos == 10)
1571        {
1572                return getInvoiceCode();
1573            }
1574              if (pos == 11)
1575        {
1576                return getSubject();
1577            }
1578              if (pos == 12)
1579        {
1580                return getNotes();
1581            }
1582              if (pos == 13)
1583        {
1584                return getCreated();
1585            }
1586              if (pos == 14)
1587        {
1588                return getModified();
1589            }
1590              if (pos == 15)
1591        {
1592                return getCreatedBy();
1593            }
1594              if (pos == 16)
1595        {
1596                return getModifiedBy();
1597            }
1598              return null;
1599    }
1600     
1601    /**
1602     * Stores the object in the database. If the object is new,
1603     * it inserts it; otherwise an update is performed.
1604     *
1605     * @throws Exception
1606     */

1607    public void save() throws Exception JavaDoc
1608    {
1609          save(ServicePeer.getMapBuilder()
1610                .getDatabaseMap().getName());
1611      }
1612
1613    /**
1614     * Stores the object in the database. If the object is new,
1615     * it inserts it; otherwise an update is performed.
1616       * Note: this code is here because the method body is
1617     * auto-generated conditionally and therefore needs to be
1618     * in this file instead of in the super class, BaseObject.
1619       *
1620     * @param dbName
1621     * @throws TorqueException
1622     */

1623    public void save(String JavaDoc dbName) throws TorqueException
1624    {
1625        Connection JavaDoc con = null;
1626          try
1627        {
1628            con = Transaction.begin(dbName);
1629            save(con);
1630            Transaction.commit(con);
1631        }
1632        catch(TorqueException e)
1633        {
1634            Transaction.safeRollback(con);
1635            throw e;
1636        }
1637      }
1638
1639      /** flag to prevent endless save loop, if this object is referenced
1640        by another object which falls in this transaction. */

1641    private boolean alreadyInSave = false;
1642      /**
1643     * Stores the object in the database. If the object is new,
1644     * it inserts it; otherwise an update is performed. This method
1645     * is meant to be used as part of a transaction, otherwise use
1646     * the save() method and the connection details will be handled
1647     * internally
1648     *
1649     * @param con
1650     * @throws TorqueException
1651     */

1652    public void save(Connection JavaDoc con) throws TorqueException
1653    {
1654          if (!alreadyInSave)
1655        {
1656            alreadyInSave = true;
1657
1658
1659  
1660            // If this object has been modified, then save it to the database.
1661
if (isModified())
1662            {
1663                if (isNew())
1664                {
1665                    ServicePeer.doInsert((Service) this, con);
1666                    setNew(false);
1667                }
1668                else
1669                {
1670                    ServicePeer.doUpdate((Service) this, con);
1671                }
1672            }
1673
1674                                      
1675                
1676                    if (collServiceItems != null)
1677            {
1678                for (int i = 0; i < collServiceItems.size(); i++)
1679                {
1680                    ((ServiceItem) collServiceItems.get(i)).save(con);
1681                }
1682            }
1683                                  alreadyInSave = false;
1684        }
1685      }
1686
1687                        
1688      /**
1689     * Set the PrimaryKey using ObjectKey.
1690     *
1691     * @param key serviceId ObjectKey
1692     */

1693    public void setPrimaryKey(ObjectKey key)
1694        throws TorqueException
1695    {
1696            setServiceId(((NumberKey) key).intValue());
1697        }
1698
1699    /**
1700     * Set the PrimaryKey using a String.
1701     *
1702     * @param key
1703     */

1704    public void setPrimaryKey(String JavaDoc key) throws TorqueException
1705    {
1706            setServiceId(Integer.parseInt(key));
1707        }
1708
1709  
1710    /**
1711     * returns an id that differentiates this object from others
1712     * of its class.
1713     */

1714    public ObjectKey getPrimaryKey()
1715    {
1716          return SimpleKey.keyFor(getServiceId());
1717      }
1718 
1719    /**
1720     * get an id that differentiates this object from others
1721     * of its class.
1722     */

1723    public String JavaDoc getQueryKey()
1724    {
1725        if (getPrimaryKey() == null)
1726        {
1727            return "";
1728        }
1729        else
1730        {
1731            return getPrimaryKey().toString();
1732        }
1733    }
1734
1735    /**
1736     * set an id that differentiates this object from others
1737     * of its class.
1738     */

1739    public void setQueryKey(String JavaDoc key)
1740        throws TorqueException
1741    {
1742        setPrimaryKey(key);
1743    }
1744
1745    /**
1746     * Makes a copy of this object.
1747     * It creates a new object filling in the simple attributes.
1748       * It then fills all the association collections and sets the
1749     * related objects to isNew=true.
1750       */

1751      public Service copy() throws TorqueException
1752    {
1753        return copyInto(new Service());
1754    }
1755  
1756    protected Service copyInto(Service copyObj) throws TorqueException
1757    {
1758          copyObj.setServiceId(serviceId);
1759          copyObj.setServiceCode(serviceCode);
1760          copyObj.setStatus(status);
1761          copyObj.setPriority(priority);
1762          copyObj.setIssuedDate(issuedDate);
1763          copyObj.setClosedDate(closedDate);
1764          copyObj.setCustomerId(customerId);
1765          copyObj.setRecipientId(recipientId);
1766          copyObj.setProjectId(projectId);
1767          copyObj.setSorderId(sorderId);
1768          copyObj.setInvoiceCode(invoiceCode);
1769          copyObj.setSubject(subject);
1770          copyObj.setNotes(notes);
1771          copyObj.setCreated(created);
1772          copyObj.setModified(modified);
1773          copyObj.setCreatedBy(createdBy);
1774          copyObj.setModifiedBy(modifiedBy);
1775  
1776                            copyObj.setServiceId( 0);
1777                                                                                                            
1778                                      
1779                            
1780        List JavaDoc v = getServiceItems();
1781        for (int i = 0; i < v.size(); i++)
1782        {
1783            ServiceItem obj = (ServiceItem) v.get(i);
1784            copyObj.addServiceItem(obj.copy());
1785        }
1786                            return copyObj;
1787    }
1788
1789    /**
1790     * returns a peer instance associated with this om. Since Peer classes
1791     * are not to have any instance attributes, this method returns the
1792     * same instance for all member of this class. The method could therefore
1793     * be static, but this would prevent one from overriding the behavior.
1794     */

1795    public ServicePeer getPeer()
1796    {
1797        return peer;
1798    }
1799
1800    public String JavaDoc toString()
1801    {
1802        StringBuffer JavaDoc str = new StringBuffer JavaDoc();
1803        str.append("Service:\n");
1804        str.append("ServiceId = ")
1805               .append(getServiceId())
1806             .append("\n");
1807        str.append("ServiceCode = ")
1808               .append(getServiceCode())
1809             .append("\n");
1810        str.append("Status = ")
1811               .append(getStatus())
1812             .append("\n");
1813        str.append("Priority = ")
1814               .append(getPriority())
1815             .append("\n");
1816        str.append("IssuedDate = ")
1817               .append(getIssuedDate())
1818             .append("\n");
1819        str.append("ClosedDate = ")
1820               .append(getClosedDate())
1821             .append("\n");
1822        str.append("CustomerId = ")
1823               .append(getCustomerId())
1824             .append("\n");
1825        str.append("RecipientId = ")
1826               .append(getRecipientId())
1827             .append("\n");
1828        str.append("ProjectId = ")
1829               .append(getProjectId())
1830             .append("\n");
1831        str.append("SorderId = ")
1832               .append(getSorderId())
1833             .append("\n");
1834        str.append("InvoiceCode = ")
1835               .append(getInvoiceCode())
1836             .append("\n");
1837        str.append("Subject = ")
1838               .append(getSubject())
1839             .append("\n");
1840        str.append("Notes = ")
1841               .append(getNotes())
1842             .append("\n");
1843        str.append("Created = ")
1844               .append(getCreated())
1845             .append("\n");
1846        str.append("Modified = ")
1847               .append(getModified())
1848             .append("\n");
1849        str.append("CreatedBy = ")
1850               .append(getCreatedBy())
1851             .append("\n");
1852        str.append("ModifiedBy = ")
1853               .append(getModifiedBy())
1854             .append("\n");
1855        return(str.toString());
1856    }
1857}
1858
Popular Tags