KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cmpdb > testCreateCMPBeansFromDB_ProductBean


1 package cmpdb;
2
3 import java.math.BigDecimal JavaDoc;
4 import java.util.Collection JavaDoc;
5 import javax.ejb.*;
6
7 /**
8  * This is the bean class for the ProductBean enterprise bean.
9  * Created Jan 5, 2006 7:14:01 PM
10  * @author honza
11  */

12 public abstract class ProductBean implements EntityBean, ProductLocalBusiness {
13     private EntityContext context;
14     
15     // <editor-fold defaultstate="collapsed" desc="EJB infrastructure methods. Click on the + sign on the left to edit the code.">
16
// TODO Consider creating Transfer Object to encapsulate data
17
// TODO Review finder methods
18
/**
19      * @see javax.ejb.EntityBean#setEntityContext(javax.ejb.EntityContext)
20      */

21     public void setEntityContext(EntityContext aContext) {
22         context = aContext;
23     }
24     
25     /**
26      * @see javax.ejb.EntityBean#ejbActivate()
27      */

28     public void ejbActivate() {
29         
30     }
31     
32     /**
33      * @see javax.ejb.EntityBean#ejbPassivate()
34      */

35     public void ejbPassivate() {
36         
37     }
38     
39     /**
40      * @see javax.ejb.EntityBean#ejbRemove()
41      */

42     public void ejbRemove() {
43         
44     }
45     
46     /**
47      * @see javax.ejb.EntityBean#unsetEntityContext()
48      */

49     public void unsetEntityContext() {
50         context = null;
51     }
52     
53     /**
54      * @see javax.ejb.EntityBean#ejbLoad()
55      */

56     public void ejbLoad() {
57         
58     }
59     
60     /**
61      * @see javax.ejb.EntityBean#ejbStore()
62      */

63     public void ejbStore() {
64         
65     }
66     // </editor-fold>
67

68     
69     public abstract Integer JavaDoc getProductId();
70     public abstract void setProductId(Integer JavaDoc productId);
71     
72     public abstract BigDecimal JavaDoc getPurchaseCost();
73     public abstract void setPurchaseCost(BigDecimal JavaDoc purchaseCost);
74     
75     public abstract Integer JavaDoc getQuantityOnHand();
76     public abstract void setQuantityOnHand(Integer JavaDoc quantityOnHand);
77     
78     public abstract BigDecimal JavaDoc getMarkup();
79     public abstract void setMarkup(BigDecimal JavaDoc markup);
80     
81     public abstract String JavaDoc getAvailable();
82     public abstract void setAvailable(String JavaDoc available);
83     
84     public abstract String JavaDoc getDescription();
85     public abstract void setDescription(String JavaDoc description);
86     
87     public abstract cmpdb.ManufactureLocal getManufactureId();
88     public abstract void setManufactureId(cmpdb.ManufactureLocal manufactureId);
89     
90     public abstract cmpdb.ProductCodeLocal getProductCode();
91     public abstract void setProductCode(cmpdb.ProductCodeLocal productCode);
92     
93     public abstract Collection JavaDoc getOrdersBean();
94     public abstract void setOrdersBean(Collection JavaDoc ordersBean);
95     
96     
97     public Integer JavaDoc ejbCreate(Integer JavaDoc productId, BigDecimal JavaDoc purchaseCost, Integer JavaDoc quantityOnHand, BigDecimal JavaDoc markup, String JavaDoc available, String JavaDoc description, cmpdb.ManufactureLocal manufactureId, cmpdb.ProductCodeLocal productCode) throws CreateException {
98         if (productId == null) {
99             throw new CreateException("The field \"productId\" must not be null");
100         }
101         if (manufactureId == null) {
102             throw new CreateException("The field \"manufactureId\" must not be null");
103         }
104         if (productCode == null) {
105             throw new CreateException("The field \"productCode\" must not be null");
106         }
107         
108         // TODO add additional validation code, throw CreateException if data is not valid
109
setProductId(productId);
110         setPurchaseCost(purchaseCost);
111         setQuantityOnHand(quantityOnHand);
112         setMarkup(markup);
113         setAvailable(available);
114         setDescription(description);
115         
116         return null;
117     }
118     
119     public void ejbPostCreate(Integer JavaDoc productId, BigDecimal JavaDoc purchaseCost, Integer JavaDoc quantityOnHand, BigDecimal JavaDoc markup, String JavaDoc available, String JavaDoc description, cmpdb.ManufactureLocal manufactureId, cmpdb.ProductCodeLocal productCode) {
120         // TODO populate relationships here if appropriate
121
setManufactureId(manufactureId);
122         setProductCode(productCode);
123         
124     }
125 }
126
Popular Tags