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.math.BigDecimal;
031: import java.util.logging.Level;
032: import java.util.logging.Logger;
033: import javax.ejb.*;
034:
035: /**
036: * This is the bean class for the LineitemBean enterprise bean.
037: */
038: public abstract class LineItemBean implements EntityBean,
039: LineItemLocalBusiness {
040: private EntityContext context;
041:
042: // <editor-fold defaultstate="collapsed" desc="EJB infrastructure methods. Click on the + sign on the left to edit the code.">
043: // TODO Consider creating Transfer Object to encapsulate data
044: // TODO Review finder methods
045: /**
046: * @see EntityBean#setEntityContext(EntityContext)
047: */
048: public void setEntityContext(EntityContext aContext) {
049: context = aContext;
050: }
051:
052: /**
053: * @see EntityBean#ejbActivate()
054: */
055: public void ejbActivate() {
056:
057: }
058:
059: /**
060: * @see EntityBean#ejbPassivate()
061: */
062: public void ejbPassivate() {
063:
064: }
065:
066: /**
067: * @see EntityBean#ejbRemove()
068: */
069: public void ejbRemove() {
070:
071: }
072:
073: /**
074: * @see EntityBean#unsetEntityContext()
075: */
076: public void unsetEntityContext() {
077: context = null;
078: }
079:
080: /**
081: * @see EntityBean#ejbLoad()
082: */
083: public void ejbLoad() {
084:
085: }
086:
087: /**
088: * @see EntityBean#ejbStore()
089: */
090: public void ejbStore() {
091:
092: }
093:
094: // </editor-fold>
095:
096: public abstract Integer getOrderId();
097:
098: public abstract void setOrderId(Integer orderId);
099:
100: public abstract BigDecimal getItemId();
101:
102: public abstract void setItemId(BigDecimal itemId);
103:
104: public abstract BigDecimal getQuantity();
105:
106: public abstract void setQuantity(BigDecimal quantity);
107:
108: public abstract VendorPartLocal getVendorPartNumber();
109:
110: public abstract void setVendorPartNumber(
111: VendorPartLocal vendorPartNumber);
112:
113: public LineItemPK ejbCreate(Integer orderId, BigDecimal itemId,
114: BigDecimal quantity, OrderLocal ordersBean,
115: VendorPartLocal vendorPartNumber) throws CreateException {
116: if (orderId == null) {
117: throw new CreateException(
118: "The field \"orderId\" must not be null");
119: }
120: if (itemId == null) {
121: throw new CreateException(
122: "The field \"itemId\" must not be null");
123: }
124: if (quantity == null) {
125: throw new CreateException(
126: "The field \"quantity\" must not be null");
127: }
128: if (ordersBean == null) {
129: throw new CreateException(
130: "The field \"ordersBean\" must not be null");
131: }
132: if (vendorPartNumber == null) {
133: throw new CreateException(
134: "The field \"vendorPartNumber\" must not be null");
135: }
136:
137: // TODO add additional validation code, throw CreateException if data is not valid
138: setOrderId(orderId);
139: setItemId(itemId);
140: setQuantity(quantity);
141:
142: return null;
143: }
144:
145: public void ejbPostCreate(Integer orderId, BigDecimal itemId,
146: BigDecimal quantity, OrderLocal ordersBean,
147: VendorPartLocal vendorPartNumber) {
148: // TODO populate relationships here if appropriate
149: setOrderBean(ordersBean);
150: setVendorPartNumber(vendorPartNumber);
151:
152: }
153:
154: public LineItemPK ejbCreate(OrderLocal ordersBean,
155: BigDecimal quantity, VendorPartLocal vendorPartNumber)
156: throws CreateException {
157: //TODO implement ejbCreate
158: if (quantity == null) {
159: throw new CreateException(
160: "The field \"quantity\" must not be null");
161: }
162: if (ordersBean == null) {
163: throw new CreateException(
164: "The field \"ordersBean\" must not be null");
165: }
166: if (vendorPartNumber == null) {
167: throw new CreateException(
168: "The field \"vendorPartNumber\" must not be null");
169: }
170: setOrderId(ordersBean.getOrderId());
171: setItemId(new BigDecimal(ordersBean.getNexId()));
172: setQuantity(quantity);
173:
174: return null;
175: }
176:
177: public void ejbPostCreate(OrderLocal ordersBean,
178: BigDecimal quantity, VendorPartLocal vendorPartNumber)
179: throws CreateException {
180: //TODO implement ejbPostCreate
181: setOrderBean(ordersBean);
182: setVendorPartNumber(vendorPartNumber);
183: }
184:
185: public abstract dataregistry.OrderLocal getOrderBean();
186:
187: public abstract void setOrderBean(dataregistry.OrderLocal orderBean);
188:
189: }
|