001: package hero.entity;
002:
003: import hero.interfaces.BnUserLightValue;
004: import hero.interfaces.BnUserPK;
005: import hero.interfaces.BnUserValue;
006: import hero.interfaces.InvalidValueException;
007:
008: import java.sql.Date;
009: import java.util.Collection;
010:
011: import javax.ejb.CreateException;
012: import javax.ejb.EJBException;
013: import javax.ejb.EntityBean;
014: import javax.ejb.EntityContext;
015: import javax.ejb.RemoveException;
016:
017: /**
018: * The Entity bean represents a BnUser
019: *
020: * @author Fran?ois Charoy
021: * @version $Revision: 1.15 $
022: *
023: * @ejb:bean name="BnUser"
024: * display-name="BnUser Entity"
025: * type="CMP"
026: * jndi-name="ejb/hero/BnUser"
027: * local-jndi-name="ejb/hero/BnUser_L"
028: * view-type="both"
029: * cmp-version="2.x"
030: * reentrant="true"
031: *
032: * The following tag is required to make JBoss guarantee database consistency
033: * when removing entities involved in relations.
034: * @ejb:transaction type="Required"
035: *
036: * @ejb:data-object extends="hero.interfaces.AbstractData"
037: * setdata="false"
038: *
039: * @ejb.pk generate="true" method-intf="remote"
040: *
041: * @jonas.bean
042: * lock-policy="container-read-committed"
043: * @jonas.jdbc-mapping
044: * jndi-name="bonita"
045: * jdbc-table-name="BnUser"
046: *
047: * @jonas.shared false
048: *
049: * @ejb:finder signature="java.util.Collection findAll()"
050: * query="SELECT object(u) FROM BnUser u"
051: * transaction-type="Supports"
052: *
053: * @ejb:finder signature="hero.interfaces.BnUser findByName(java.lang.String pName )" result-type-mapping="Remote"
054: * query="SELECT Object(u) From BnUser as u Where u.name = ?1"
055: * transaction-type="Supports"
056: * @ejb:finder signature="hero.interfaces.BnUserLocal findByName(java.lang.String pName )" result-type-mapping="Local"
057: * query="SELECT Object(u) From BnUser as u Where u.name = ?1"
058: * transaction-type="Supports"
059: *
060: *
061: * @ejb.value-object
062: * match="*"
063: * name="BnUser"
064: *
065: * @ejb.value-object
066: * match="light"
067: * name="BnUserLight"
068: *
069: * @jboss.persistence
070: * table-name="BnUser"
071: * create-table="true"
072: * remove-table="false"
073: *
074: * @jboss.container-configuration name="Standard CMP 2.x EntityBean for Bonita"
075: **/
076:
077: public abstract class BnUserBean implements EntityBean {
078:
079: // -------------------------------------------------------------------------
080: // Members
081: // -------------------------------------------------------------------------
082:
083: public EntityContext mContext;
084:
085: // -------------------------------------------------------------------------
086: // Properties (Getters/Setters)
087: // -------------------------------------------------------------------------
088:
089: /**
090: * Retrieve the BnUser's id.
091: *
092: * @return Returns an int representing the id of this BnUser.
093: *
094: * @ejb:pk-field
095: * @ejb:interface-method view-type="both"
096: * @ejb.value-object
097: * match="light"
098: * @ejb:persistence column-name="id"
099: * @jonas.cmp-field-jdbc-mapping
100: * field-name="id"
101: * jdbc-field-name="id"
102: * @ejb:transaction type="Supports"
103: **/
104: public abstract String getId();
105:
106: /**
107: * Set the BnUser's id.
108: *
109: * @param pId The id of this BnUser. Is set at creation time.
110: * @ejb:transaction type="Required"
111: **/
112: public abstract void setId(String pId);
113:
114: /**
115: * Retrieve the BnUser's Name.
116: *
117: * @return Returns an int representing the Name of this BnUser.
118: * @ejb:interface-method view-type="both"
119: * @ejb.value-object
120: * match="light"
121: *
122: * @ejb:persistence column-name="name"
123: * @ejb:transaction type="Supports"
124: **/
125: public abstract String getName();
126:
127: /**
128: * Set the BnUser's Name.
129: *
130: * @param uName The Name of this BnUser. Is set at creation time.
131: * @ejb:transaction type="Required"
132: **/
133: public abstract void setName(String uName);
134:
135: /**
136: * Retrieve the BnUser's Password.
137: *
138: * @return Returns an int representing the Password of this BnUser.
139: *
140: * @ejb:interface-method view-type="local"
141: * @ejb.value-object
142: * match="light"
143: * @ejb:persistence column-name="password"
144: * @ejb:transaction type="Supports"
145: **/
146: public abstract String getPassword();
147:
148: /**
149: * Set the BnUser's Password.
150: *
151: * @param pPassword The Password of this BnUser
152: * @ejb:transaction type="Required"
153: **/
154: public abstract void setPassword(String pPassword);
155:
156: /**
157: * Retrieve the BnUser's Email.
158: *
159: * @return Returns an String representing the Email of this BnUser.
160: * @ejb:interface-method view-type="both"
161: *
162: * @ejb.value-object
163: * match="light"
164: * @ejb:persistence column-name="email"
165: * @ejb:transaction type="Supports"
166: **/
167: public abstract String getEmail();
168:
169: /**
170: * Set the BnUser's Email.
171: *
172: * @param pEmail The Email of this BnUser. Is set at creation time.
173: * @ejb:persistence column-name="email"
174: * @ejb:interface-method view-type="local"
175: * @ejb:transaction type="Required"
176: **/
177: public abstract void setEmail(String pEmail);
178:
179: /**
180: * Retrieve the BnUser's Jabber address.
181: *
182: * @return Returns an String representing the Jabber address of this BnUser.
183: * @ejb:interface-method view-type="both"
184: *
185: * @ejb.value-object
186: * match="light"
187: *
188: * @ejb:persistence column-name="jabber"
189: * @ejb:transaction type="Supports"
190: **/
191: public abstract String getJabber();
192:
193: /**
194: * Set the BnUser's Jabber address.
195: *
196: * @param pJabber The Jabber address of this BnUser. Is set at creation time.
197: * @ejb:transaction type="Required"
198: **/
199: public abstract void setJabber(String pJabber);
200:
201: /**
202: * @return Returns the creation date of this BnUser
203: *
204: * @ejb:interface-method view-type="local"
205: * @ejb.value-object
206: * match="light"
207: *
208: * @ejb:persistence column-name="creationdate"
209: * @ejb:transaction type="Supports"
210: **/
211: public abstract Date getCreationDate();
212:
213: /**
214: * Specify the creation date of this BnUser
215: *
216: * @param pCreationDate Date of the creation of this BnUser
217: * @ejb:interface-method view-type="local"
218: * @ejb:transaction type="Required"
219: **/
220: public abstract void setCreationDate(Date pCreationDate);
221:
222: /**
223: * @return Returns the modification date of this BnUser
224: *
225: * @ejb.value-object
226: * match="light"
227: * @ejb:persistence column-name="modificationdate"
228: * @ejb:interface-method view-type="local"
229: * @ejb:transaction type="Supports"
230: **/
231: public abstract Date getModificationDate();
232:
233: /**
234: * Specify the modification date of this BnUser
235: *
236: * @param pModificationDate Date of the modification of this BnUser
237: * @ejb:interface-method view-type="local"
238: * @ejb:transaction type="Required"
239: **/
240: public abstract void setModificationDate(Date pModificationDate);
241:
242: /**
243: * @returns the project on which this user works
244: * @ejb:interface-method view-type="local"
245: * @ejb:relation name="Users" role-name="is-user-of" target-multiple="yes"
246: *
247: * @ejb.value-object
248: * match="normal"
249: * type="Collection"
250: * relation="external"
251: * aggregate="hero.interfaces.BnProjectLightValue"
252: * aggregate-name="BnProject"
253: * members="hero.interfaces.BnProjectLocal"
254: * members-name="BnProject"
255: * @ejb:transaction type="Supports"
256: *
257: * @jboss.relation-table create-table="true" remove-table="false"
258: *
259: * @jboss.relation
260: * related-pk-field = "id"
261: * fk-column = "userProjectIdFK"
262: */
263: public abstract Collection getBnProjects();
264:
265: /**
266: * Set the Users of this project
267: *
268: * @param pProjects projects of the user
269: * @ejb:transaction type="Required"
270: **/
271: public abstract void setBnProjects(Collection pProjects);
272:
273: /**
274: * @returns the roles of the user
275: * @ejb:interface-method view-type="local"
276: * @ejb:relation name="Roles" role-name="has-role" multiple="no"
277: *
278: * @ejb.value-object
279: * match="normal"
280: * type="Collection"
281: * relation="external"
282: * aggregate="hero.interfaces.BnRoleValue"
283: * aggregate-name="BnRole"
284: * members="hero.interfaces.BnRoleLocal"
285: * members-name="BnRole"
286: * @ejb:transaction type="Supports"
287: *
288: * @jboss.relation-table create-table="true" remove-table="false"
289: *
290: * @jboss.relation
291: * related-pk-field = "id"
292: * fk-column = "rolesUserIdFK"
293: */
294: public abstract Collection getBnRoles();
295:
296: /**
297: * Set the roles of the user
298: *
299: * @param pRoles roles of the user
300: * @ejb:transaction type="Required"
301: **/
302: public abstract void setBnRoles(Collection pRoles);
303:
304: /**
305: * @returns the authorisation roles of the user (for ejb security)
306: * @ejb:interface-method view-type="local"
307: * @ejb:relation name="AuthRoles" role-name="has-authrole" multiple="yes"
308: *
309: * @ejb.value-object
310: * match="normal"
311: * type="Collection"
312: * relation="external"
313: * aggregate="hero.interfaces.BnAuthRoleValue"
314: * aggregate-name="BnAuthRole"
315: * members="hero.interfaces.BnAuthRoleLocal"
316: * members-name="BnAuthRole"
317: * @ejb:transaction type="Supports"
318: *
319: * @jboss.relation-table create-table="true" remove-table="false"
320: *
321: * @jboss.relation
322: * related-pk-field = "id"
323: * fk-column = "BnAuthRole_id"
324: */
325: public abstract Collection getBnAuthRoles();
326:
327: /**
328: * Set the authorisation roles of the user (for ejb security)
329: *
330: * @param pRoles roles of the user
331: * @ejb:transaction type="Required"
332: **/
333: public abstract void setBnAuthRoles(Collection pRoles);
334:
335: /**
336: * @returns the nodes created by the user
337: * @ejb:interface-method view-type="local"
338: * @ejb:relation name="AgentCreator" role-name="is-node-creator" multiple="yes"
339: * @ejb:transaction type="Supports"
340: *
341: * @jboss.relation-table create-table="true" remove-table="false"
342: */
343: public abstract Collection getCreatedBnAgents();
344:
345: /**
346: * Set the user created agents
347: *
348: * @param pAgents Agents created by the user
349: * @ejb:transaction type="Required"
350: **/
351: public abstract void setCreatedBnAgents(Collection pAgents);
352:
353: /**
354: * @ejb.interface-method
355: * @ejb:transaction type="Supports"
356: */
357: public abstract BnUserValue getBnUserValue();
358:
359: /**
360: *
361: * @ejb.interface-method
362: * @ejb:transaction type="Required"
363: */
364: public abstract void setBnUserValue(BnUserValue v);
365:
366: /**
367: * @returns the light value of the bean (without relationships)
368: * @ejb.interface-method view-type=both
369: * @ejb:transaction type="Supports"
370: */
371: public abstract BnUserLightValue getBnUserLightValue();
372:
373: /**
374: * @return the properties of the user
375: * @ejb:interface-method view-type="both"
376: * @ejb:relation name="userprp" role-name="is-property-of"
377: * @ejb:transaction type="Supports"
378: *
379: * @jboss.relation-table create-table="true" remove-table="false"
380: **/
381: public abstract Collection getBnProperties();
382:
383: /**
384: * Set the properties of the user
385: * @ejb:interface-method view-type="both"
386: * @param pPrp the properties of the user
387: * @ejb:transaction type="Required"
388: **/
389: public abstract void setBnProperties(Collection pPrp);
390:
391: // -------------------------------------------------------------------------
392: // Framework Callbacks
393: // -------------------------------------------------------------------------
394:
395: /**
396: * Create a BnUser based on the supplied BnUser Value Object.
397: *
398: * @param pUser The data used to create the BnUser.
399: *
400: * @throws InvalidValueException If one of the values are not correct,
401: * this will not roll back the transaction
402: * because the caller has the chance to
403: * fix the problem and try again
404: * @throws EJBException If no new unique ID could be retrieved this will
405: * rollback the transaction because there is no
406: * hope to try again
407: * @throws CreateException Because we have to do so (EJB spec.)
408: *
409: * @ejb:create-method view-type="both"
410: **/
411: public BnUserPK ejbCreate(BnUserValue pUser)
412: throws InvalidValueException, EJBException, CreateException {
413: // This is only possible in CMPs. Otherwise return a valid PK.
414: this .setId(hero.interfaces.BnUserUtil.generateGUID(this ));
415:
416: this .setCreationDate(new java.sql.Date(new java.util.Date()
417: .getTime()));
418: this .setModificationDate(new java.sql.Date(new java.util.Date()
419: .getTime()));
420: return null;
421: }
422:
423: public void ejbPostCreate(BnUserValue pUser) {
424: // Assign value object in ejbPostCreate to apply XDoclet best
425: // practice. If not done, there will be an error in JBoss if
426: // the Value Object has relations.
427: this .setBnUserValue(pUser);
428: }
429:
430: public void setEntityContext(EntityContext lContext) {
431: mContext = lContext;
432: }
433:
434: public void unsetEntityContext() {
435: mContext = null;
436: }
437:
438: public void ejbActivate() {
439: }
440:
441: public void ejbPassivate() {
442: }
443:
444: public void ejbLoad() {
445: }
446:
447: public void ejbStore() {
448: }
449:
450: public void ejbRemove() throws RemoveException {
451: }
452: }
|