KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > dataregistry > VendorPartBean


1 /*
2  * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. U.S.
3  * Government Rights - Commercial software. Government users are subject
4  * to the Sun Microsystems, Inc. standard license agreement and
5  * applicable provisions of the FAR and its supplements. Use is subject
6  * to license terms.
7  *
8  * This distribution may include materials developed by third parties.
9  * Sun, Sun Microsystems, the Sun logo, Java and J2EE are trademarks
10  * or registered trademarks of Sun Microsystems, Inc. in the U.S. and
11  * other countries.
12  *
13  * Copyright (c) 2005 Sun Microsystems, Inc. Tous droits reserves.
14  *
15  * Droits du gouvernement americain, utilisateurs gouvernementaux - logiciel
16  * commercial. Les utilisateurs gouvernementaux sont soumis au contrat de
17  * licence standard de Sun Microsystems, Inc., ainsi qu'aux dispositions
18  * en vigueur de la FAR (Federal Acquisition Regulations) et des
19  * supplements a celles-ci. Distribue par des licences qui en
20  * restreignent l'utilisation.
21  *
22  * Cette distribution peut comprendre des composants developpes par des
23  * tierces parties. Sun, Sun Microsystems, le logo Sun, Java et J2EE
24  * sont des marques de fabrique ou des marques deposees de Sun
25  * Microsystems, Inc. aux Etats-Unis et dans d'autres pays.
26  */

27
28 package dataregistry;
29
30 import java.util.Collection JavaDoc;
31 import javax.ejb.*;
32
33 /**
34  * This is the bean class for the VendorPartBean enterprise bean.
35  */

36 public abstract class VendorPartBean implements EntityBean, VendorPartLocalBusiness {
37     private EntityContext context;
38     
39     // <editor-fold defaultstate="collapsed" desc="EJB infrastructure methods. Click on the + sign on the left to edit the code.">
40
// TODO Consider creating Transfer Object to encapsulate data
41
// TODO Review finder methods
42
/**
43      * @see EntityBean#setEntityContext(EntityContext)
44      */

45     public void setEntityContext(EntityContext aContext) {
46         context = aContext;
47     }
48     
49     /**
50      * @see EntityBean#ejbActivate()
51      */

52     public void ejbActivate() {
53         
54     }
55     
56     /**
57      * @see EntityBean#ejbPassivate()
58      */

59     public void ejbPassivate() {
60         
61     }
62     
63     /**
64      * @see EntityBean#ejbRemove()
65      */

66     public void ejbRemove() {
67         
68     }
69     
70     /**
71      * @see EntityBean#unsetEntityContext()
72      */

73     public void unsetEntityContext() {
74         context = null;
75     }
76     
77     /**
78      * @see EntityBean#ejbLoad()
79      */

80     public void ejbLoad() {
81         
82     }
83     
84     /**
85      * @see EntityBean#ejbStore()
86      */

87     public void ejbStore() {
88         
89     }
90     // </editor-fold>
91

92     public abstract String JavaDoc getDescription();
93     public abstract void setDescription(String JavaDoc description);
94     
95     public abstract Double JavaDoc getPrice();
96     public abstract void setPrice(Double JavaDoc price);
97     
98     public abstract Collection JavaDoc getLineitemBean();
99     public abstract void setLineitemBean(Collection JavaDoc lineitemBean);
100     
101     public abstract PartLocal getPartBean();
102     public abstract void setPartBean(PartLocal partBean);
103     
104     
105     public Object JavaDoc ejbCreate(String JavaDoc description, Double JavaDoc price, PartLocal partBean, VendorLocal vendorId) throws CreateException {
106         if (price == null) {
107             throw new CreateException("The field \"price\" must not be null");
108         }
109         if (partBean == null) {
110             throw new CreateException("The field \"partBean\" must not be null");
111         }
112         if (vendorId == null) {
113             throw new CreateException("The field \"vendorId\" must not be null");
114         }
115         
116         // TODO add additional validation code, throw CreateException if data is not valid
117
setDescription(description);
118         setPrice(price);
119         
120         return null;
121     }
122     
123     public void ejbPostCreate(String JavaDoc description, Double JavaDoc price, PartLocal partBean, VendorLocal vendorId) {
124         // TODO populate relationships here if appropriate
125
setPartBean(partBean);
126         setVendor(vendorId);
127         
128     }
129     
130     public Object JavaDoc ejbCreate(String JavaDoc description, double price, PartLocal part) throws CreateException {
131         //TODO implement ejbCreate
132
setDescription(description);
133             setPrice(new Double JavaDoc(price));
134             
135         return null;
136     }
137     
138     public void ejbPostCreate(String JavaDoc description, double price, PartLocal part) throws CreateException {
139         //TODO implement ejbPostCreate
140
setPartBean(part);
141     }
142     
143     public Double JavaDoc ejbHomeGetAvgPrice() throws FinderException {
144         //TODO implement ejbHomeGetAvgPrice
145
return ejbSelectAvgPrice();
146     }
147     
148     public abstract Double JavaDoc ejbSelectAvgPrice() throws FinderException;
149     
150     public Double JavaDoc ejbHomeGetTotalPricePerVendor(int vendorId) throws FinderException {
151         //TODO implement ejbHomeGetTotalPricePerVendor
152
return ejbSelectTotalPricePerVendor(vendorId);
153     }
154     
155     public abstract Double JavaDoc ejbSelectTotalPricePerVendor(int vendorId) throws FinderException;
156     
157     public abstract VendorLocal getVendor();
158     
159     public abstract void setVendor(VendorLocal vendor);
160
161 }
162
Popular Tags