001: /**
002: * Copyright (c) 2004 Red Hat, Inc. All rights reserved.
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
017: * USA
018: *
019: * Component of: Red Hat Application Server
020: *
021: * Initial Developers: Aizaz Ahmed
022: * Vivek Lakshmanan
023: * Andrew Overholt
024: * Matthew Wringe
025: *
026: */package olstore.entity;
027:
028: import javax.ejb.EntityBean;
029:
030: import olstore.entity.TypeLocal;
031:
032: import java.util.Collection;
033: import java.math.BigDecimal;
034:
035: /**
036: * @ejb.bean name="Item"
037: * description="This bean is used to store information about sales items."
038: * type="CMP"
039: * schema="olstore_item"
040: * primkey-field="itemId"
041: * reentrant="false"
042: * cmp-version="2.x"
043: * view-type="local"
044: * local-jndi-name="ItemLocal_L"
045: *
046: * @ejb.relation
047: * name="User-Item"
048: * role-name="Items-belong-to-Users"
049: * target-ejb="User"
050: * target-multiple="yes"
051: *
052: * @ejb.relation
053: * name="Order-Item"
054: * role-name="Items-belong-to-Orders"
055: * target-ejb="Order"
056: *
057: * @ejb.transaction
058: * type="Required"
059: *
060: *--
061: * This is needed for JOnAS.
062: * If you are not using JOnAS you can safely remove the tags below.
063: * @jonas.bean ejb-name="Item"
064: * jndi-name="ItemLocal"
065: * @jonas.jdbc-mapping jndi-name="jdbc_1" jdbc-table-name="olstore_item"
066: * automatic-pk="true"
067: * --
068: *
069: * @ejb.persistence
070: *
071: * @ejb.finder
072: * query="SELECT OBJECT(a) FROM olstore_item as a"
073: * signature="java.util.Collection findAll()"
074: *
075: * @ejb.finder
076: * query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.name = ?1"
077: * signature="java.util.Collection findByName(java.lang.String name)"
078: *
079: * @ejb.finder
080: * query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.itemId = ?1"
081: * signature="olstore.entity.Item findByPrimaryKey(java.lang.Integer itemId)"
082: *
083: * @ejb.finder
084: * query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.mainPage = 'true'"
085: * signature="java.util.Collection findByMainPage()"
086: *
087: * @ejb.finder
088: * query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.specialOffer = 'true' AND c.mainPage = 'true'"
089: * signature="java.util.Collection findByMainPageAndSpecialOffer()"
090: *
091: * @ejb.finder
092: * query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.typeId.name = ?1"
093: * signature="java.util.Collection findByType(java.lang.String type)"
094: *
095: * @ejb.finder
096: * query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.typeId.name = ?1 AND c.specialOffer = 'true'"
097: * signature="java.util.Collection findByTypeAndSpecialOffer(java.lang.String typeIdName)"
098: *
099: * @ejb.finder
100: * query="SELECT DISTINCT OBJECT(p) FROM olstore_user u, IN ( u.friends ) AS f, IN ( f.user.purchased ) AS p WHERE u.username = ?2 AND p.typeId.name = ?1"
101: * signature="java.util.Collection findByTypeAndFriendsOf(java.lang.String typeIdName, java.lang.String username)"
102: *
103: * @ejb.finder
104: * query="SELECT DISTINCT OBJECT(p) FROM olstore_user u, IN ( u.friends ) AS f, IN ( f.user.purchased ) AS p WHERE u.username = ?1 AND p.mainPage = 'true'"
105: * signature="java.util.Collection findByMainPageAndFriendsOf(java.lang.String username)"
106: *
107: * @ejb.finder
108: * query="SELECT OBJECT(c) FROM olstore_item AS c WHERE c.specialOffer = 'true'"
109: * signature="java.util.Collection findBySpecialOffer()"
110: *
111: *
112: *--
113: * This is needed for JOnAS.
114: * If you are not using JOnAS you can safely remove the tags below.
115: * @jonas.finder-method-jdbc-mapping method-name="findAll"
116: * jdbc-where-clause=""
117: * @jonas.jdbc-mapping jndi-name="jdbc_1"
118: * jdbc-table-name="olstore_item"
119: *
120: *--
121: *
122: **/
123:
124: public abstract class ItemBean implements EntityBean {
125:
126: /**
127: * The ejbCreate method.
128: *
129: * @ejb.create-method
130: */
131: public java.lang.Integer ejbCreate(String name, BigDecimal price)
132: throws javax.ejb.CreateException {
133: setName(name);
134: setPrice(price);
135: return null;
136: }
137:
138: /**
139: * The container invokes this method immediately after it calls ejbCreate.
140: *
141: */
142: public void ejbPostCreate(String name, BigDecimal price)
143: throws javax.ejb.CreateException {
144: }
145:
146: /**
147: * Returns the name
148: * @return the name
149: *
150: * @ejb.persistent-field
151: * @ejb.persistence
152: * column-name="name"
153: * sql-type="VARCHAR"
154: *
155: * @ejb.interface-method
156: *
157: *
158: */
159: public abstract java.lang.String getName();
160:
161: /**
162: * Sets the name
163: *
164: * @param java.lang.String the new name value
165: *
166: * @ejb.interface-method
167: */
168: public abstract void setName(java.lang.String name);
169:
170: /**
171: * Returns the shortDesc
172: * @return the shortDesc
173: *
174: * @ejb.persistent-field
175: * @ejb.persistence
176: * column-name="shortDesc"
177: * sql-type="VARCHAR"
178: *
179: * @ejb.interface-method
180: *
181: */
182: public abstract java.lang.String getShortDesc();
183:
184: /**
185: * Sets the shortDesc
186: *
187: * @param java.lang.String the new shortDesc value
188: *
189: * @ejb.interface-method
190: */
191: public abstract void setShortDesc(java.lang.String shortDesc);
192:
193: /**
194: * Returns the longDesc
195: * @return the longDesc
196: *
197: * @ejb.persistent-field
198: * @ejb.persistence
199: * column-name="longDesc"
200: * sql-type="VARCHAR"
201: *
202: * @ejb.interface-method
203: *
204: */
205: public abstract java.lang.String getLongDesc();
206:
207: /**
208: * Sets the longDesc
209: *
210: * @param java.lang.String the new longDesc value
211: *
212: * @ejb.interface-method
213: */
214: public abstract void setLongDesc(java.lang.String longDesc);
215:
216: /**
217: * Returns whether or not the item should appear on the main page
218: * @return the mainPage
219: *
220: * @ejb.persistent-field
221: * @ejb.persistence
222: * column-name="mainPage"
223: * sql-type="BOOLEAN"
224: *
225: * @ejb.interface-method
226: *
227: */
228: public abstract java.lang.Boolean getMainPage();
229:
230: /**
231: * Sets whether or not the item should appear on the main page
232: *
233: * @param java.lang.Boolean mainPage
234: *
235: * @ejb.interface-method
236: */
237: public abstract void setMainPage(java.lang.Boolean mainPage);
238:
239: /**
240: * Returns whether or not the item is a special offer.
241: * @return specialOffer
242: *
243: * @ejb.persistent-field
244: * @ejb.persistence
245: * column-name="specialOffer"
246: * sql-type="BOOLEAN"
247: *
248: * @ejb.interface-method
249: *
250: */
251: public abstract java.lang.Boolean getSpecialOffer();
252:
253: /**
254: * Sets whether or not the item should appear on the main page
255: *
256: * @param java.lang.Boolean the new specialOffer value
257: *
258: * @ejb.interface-method
259: */
260: public abstract void setSpecialOffer(java.lang.Boolean specialOffer);
261:
262: /**
263: * Returns the itemId
264: * @return the itemId
265: *
266: * @ejb.persistent-field
267: * @ejb.persistence
268: * column-name="itemId"
269: * sql-type="INTEGER"
270: * @ejb.pk-field
271: * @ejb.interface-method
272: *
273: */
274: public abstract java.lang.Integer getItemId();
275:
276: /**
277: * Sets the itemId
278: *
279: * @param java.lang.Integer the new itemId value
280: *
281: * @ejb.interface-method
282: */
283: public abstract void setItemId(java.lang.Integer itemId);
284:
285: /**
286: * Returns the price
287: * @return the price
288: *
289: * @ejb.persistent-field
290: * @ejb.persistence
291: * column-name="price"
292: * sql-type="NUMERIC"
293: *
294: * @ejb.interface-method
295: *
296: */
297: public abstract BigDecimal getPrice();
298:
299: /**
300: * Sets the price
301: *
302: * @param BigDecimal the new price value
303: *
304: * @ejb.interface-method
305: */
306: public abstract void setPrice(BigDecimal price);
307:
308: /**
309: * Returns the typeId of the item
310: *
311: * @return TypeId
312: *
313: * @ejb.interface-method
314: *
315: * @ejb.relation
316: * name="Item-Type"
317: * target-ejb="Type"
318: * role-name="Item-belongs-to-Type"
319: * target-multiple="yes"
320: *
321: */
322:
323: public abstract TypeLocal getTypeId();
324:
325: /**
326: * Sets the TypeId
327: *
328: * @param type
329: *
330: * @ejb.interface-method
331: */
332:
333: public abstract void setTypeId(TypeLocal type);
334:
335: /**
336: * Returns the properties of the item
337: *
338: * @return Properties
339: *
340: * @ejb.interface-method
341: *
342: * @ejb.relation
343: * name="Item-Property"
344: * target-ejb="Property"
345: * role-name="Item-has-many-Properties"
346: *
347: */
348:
349: public abstract Collection getProperties();
350:
351: /**
352: *
353: * @param properties
354: *
355: * @ejb.interface-method
356: *
357: */
358:
359: public abstract void setProperties(Collection properties);
360:
361: /**
362: * Returns the pictures of the item
363: *
364: * @return Pictures
365: *
366: * @ejb.interface-method
367: *
368: * @ejb.relation
369: * name="Item-Picture"
370: * target-ejb="Picture"
371: * role-name="Item-has-many-Pictures"
372: *
373: */
374:
375: public abstract Collection getPictures();
376:
377: /**
378: *
379: * @param pictures
380: *
381: * @ejb.interface-method
382: *
383: */
384:
385: public abstract void setPictures(Collection pictures);
386:
387: }
|