001: /*
002: * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. U.S.
003: * Government Rights - Commercial software. Government users are subject
004: * to the Sun Microsystems, Inc. standard license agreement and
005: * applicable provisions of the FAR and its supplements. Use is subject
006: * to license terms.
007: *
008: * This distribution may include materials developed by third parties.
009: * Sun, Sun Microsystems, the Sun logo, Java and J2EE are trademarks
010: * or registered trademarks of Sun Microsystems, Inc. in the U.S. and
011: * other countries.
012: *
013: * Copyright (c) 2005 Sun Microsystems, Inc. Tous droits reserves.
014: *
015: * Droits du gouvernement americain, utilisateurs gouvernementaux - logiciel
016: * commercial. Les utilisateurs gouvernementaux sont soumis au contrat de
017: * licence standard de Sun Microsystems, Inc., ainsi qu'aux dispositions
018: * en vigueur de la FAR (Federal Acquisition Regulations) et des
019: * supplements a celles-ci. Distribue par des licences qui en
020: * restreignent l'utilisation.
021: *
022: * Cette distribution peut comprendre des composants developpes par des
023: * tierces parties. Sun, Sun Microsystems, le logo Sun, Java et J2EE
024: * sont des marques de fabrique ou des marques deposees de Sun
025: * Microsystems, Inc. aux Etats-Unis et dans d'autres pays.
026: */
027:
028: package dataregistry;
029:
030: import java.util.Collection;
031: import javax.ejb.*;
032:
033: /**
034: * This is the bean class for the VendorPartBean enterprise bean.
035: */
036: public abstract class VendorPartBean implements EntityBean,
037: VendorPartLocalBusiness {
038: private EntityContext context;
039:
040: // <editor-fold defaultstate="collapsed" desc="EJB infrastructure methods. Click on the + sign on the left to edit the code.">
041: // TODO Consider creating Transfer Object to encapsulate data
042: // TODO Review finder methods
043: /**
044: * @see EntityBean#setEntityContext(EntityContext)
045: */
046: public void setEntityContext(EntityContext aContext) {
047: context = aContext;
048: }
049:
050: /**
051: * @see EntityBean#ejbActivate()
052: */
053: public void ejbActivate() {
054:
055: }
056:
057: /**
058: * @see EntityBean#ejbPassivate()
059: */
060: public void ejbPassivate() {
061:
062: }
063:
064: /**
065: * @see EntityBean#ejbRemove()
066: */
067: public void ejbRemove() {
068:
069: }
070:
071: /**
072: * @see EntityBean#unsetEntityContext()
073: */
074: public void unsetEntityContext() {
075: context = null;
076: }
077:
078: /**
079: * @see EntityBean#ejbLoad()
080: */
081: public void ejbLoad() {
082:
083: }
084:
085: /**
086: * @see EntityBean#ejbStore()
087: */
088: public void ejbStore() {
089:
090: }
091:
092: // </editor-fold>
093:
094: public abstract String getDescription();
095:
096: public abstract void setDescription(String description);
097:
098: public abstract Double getPrice();
099:
100: public abstract void setPrice(Double price);
101:
102: public abstract Collection getLineitemBean();
103:
104: public abstract void setLineitemBean(Collection lineitemBean);
105:
106: public abstract PartLocal getPartBean();
107:
108: public abstract void setPartBean(PartLocal partBean);
109:
110: public Object ejbCreate(String description, Double price,
111: PartLocal partBean, VendorLocal vendorId)
112: throws CreateException {
113: if (price == null) {
114: throw new CreateException(
115: "The field \"price\" must not be null");
116: }
117: if (partBean == null) {
118: throw new CreateException(
119: "The field \"partBean\" must not be null");
120: }
121: if (vendorId == null) {
122: throw new CreateException(
123: "The field \"vendorId\" must not be null");
124: }
125:
126: // TODO add additional validation code, throw CreateException if data is not valid
127: setDescription(description);
128: setPrice(price);
129:
130: return null;
131: }
132:
133: public void ejbPostCreate(String description, Double price,
134: PartLocal partBean, VendorLocal vendorId) {
135: // TODO populate relationships here if appropriate
136: setPartBean(partBean);
137: setVendor(vendorId);
138:
139: }
140:
141: public Object ejbCreate(String description, double price,
142: PartLocal part) throws CreateException {
143: //TODO implement ejbCreate
144: setDescription(description);
145: setPrice(new Double(price));
146:
147: return null;
148: }
149:
150: public void ejbPostCreate(String description, double price,
151: PartLocal part) throws CreateException {
152: //TODO implement ejbPostCreate
153: setPartBean(part);
154: }
155:
156: public Double ejbHomeGetAvgPrice() throws FinderException {
157: //TODO implement ejbHomeGetAvgPrice
158: return ejbSelectAvgPrice();
159: }
160:
161: public abstract Double ejbSelectAvgPrice() throws FinderException;
162:
163: public Double ejbHomeGetTotalPricePerVendor(int vendorId)
164: throws FinderException {
165: //TODO implement ejbHomeGetTotalPricePerVendor
166: return ejbSelectTotalPricePerVendor(vendorId);
167: }
168:
169: public abstract Double ejbSelectTotalPricePerVendor(int vendorId)
170: throws FinderException;
171:
172: public abstract VendorLocal getVendor();
173:
174: public abstract void setVendor(VendorLocal vendor);
175:
176: }
|