KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > entity > BnAgentBean


1 package hero.entity;
2
3 import hero.interfaces.BnAgentLightValue;
4 import hero.interfaces.BnAgentPK;
5 import hero.interfaces.BnAgentValue;
6 import hero.interfaces.BnProjectLocal;
7 import hero.interfaces.BnUserLocal;
8 import hero.interfaces.InvalidValueException;
9 import hero.util.BonitaServiceLocator;
10 import hero.util.BonitaServiceException;
11
12 import java.util.Date JavaDoc;
13 import java.util.Collection JavaDoc;
14
15 import javax.ejb.CreateException JavaDoc;
16 import javax.ejb.EJBException JavaDoc;
17 import javax.ejb.EntityBean JavaDoc;
18 import javax.ejb.EntityContext JavaDoc;
19 import javax.ejb.RemoveException JavaDoc;
20
21
22 /**
23  * The Entity bean represents a BnUser
24  *
25  * @author Miguel Valdes
26  * @version $Revision: 1.4 $
27  *
28  * @ejb:bean name="BnAgent"
29  * display-name="BnAgent Entity"
30  * type="CMP"
31  * jndi-name="ejb/hero/BnAgent"
32  * local-jndi-name="ejb/hero/BnAgent_L"
33  * view-type="both"
34  * cmp-version="2.x"
35  * reentrant="true"
36  *
37  *
38  *
39  * @ejb:transaction type="Supports"
40  *
41  * @ejb.pk method-intf="both"
42  *
43  * @jonas.bean
44  * ejb-name="BnAgent"
45  * jndi-name="ejb/hero/BnAgent"
46  * lock-policy="container-read-committed"
47  * @jonas.jdbc-mapping
48  * jndi-name="bonita"
49  * jdbc-table-name="BnAgent"
50  *
51  * @jonas.shared false
52  *
53  * @ejb:finder signature="java.util.Collection findAll()"
54  * query="SELECT object(a) FROM BnAgent a"
55  * transaction-type="Supports"
56  *
57  * @ejb:finder signature="hero.interfaces.BnAgent findByName(java.lang.String pName, java.lang.String projectId )" view-type="both" result-type-mapping="Remote"
58  * query="SELECT OBJECT(a) FROM BnAgent a WHERE a.name = ?1 AND a.bnProject.id = ?2"
59  * transaction-type="Supports"
60  * @ejb:finder signature="hero.interfaces.BnAgentLocal findByName(java.lang.String pName, java.lang.String projectId )" view-type="both" result-type-mapping="Local"
61  * query="SELECT OBJECT(a) FROM BnAgent a WHERE a.name = ?1 AND a.bnProject.id = ?2"
62  * transaction-type="Supports"
63  *
64  *
65  * @ejb.value-object
66  * match="*"
67  * name="BnAgent"
68  *
69  * @ejb.value-object
70  * match="light"
71  * name="BnAgentLight"
72  *
73  * @jboss:table-name table-name="BnAgent"
74  *
75  * @jboss:create-table create="true"
76  *
77  * @jboss:remove-table remove="false"
78  **/

79
80 public abstract class BnAgentBean
81    implements EntityBean JavaDoc
82 {
83    
84    // -------------------------------------------------------------------------
85
// Members
86
// -------------------------------------------------------------------------
87

88    public EntityContext JavaDoc mContext;
89    
90    // -------------------------------------------------------------------------
91
// Methods
92
// -------------------------------------------------------------------------
93

94
95    // -------------------------------------------------------------------------
96
// Properties (Getters/Setters)
97
// -------------------------------------------------------------------------
98

99    /**
100    * Retrieve the BnAgent's id.
101    *
102    * @return Returns an int representing the id of this BnAgent.
103    *
104    * @ejb:pk-field
105    * @ejb.value-object
106    * match="light"
107    *
108    * @ejb:persistence column-name="id"
109    * @ejb:interface-method view-type="local"
110    * @jonas.cmp-field-jdbc-mapping
111    * field-name="id"
112    * jdbc-field-name="id"
113    * @ejb:transaction type="Supports"
114    **/

115    public abstract String JavaDoc getId();
116    
117    /**
118    * Set the BnAgent's id.
119    *
120    * @param pId The id of this BnAgent. Is set at creation time.
121    * @ejb:transaction type="Required"
122    **/

123    public abstract void setId( String JavaDoc pId );
124    
125    /**
126    * Retrieve the BnAgent's state.
127    *
128    * @return Returns an int representing the state of this BnAgent.
129    *
130    * @ejb:interface-method view-type="both"
131    * @ejb.value-object
132    * match="light"
133    *
134    * @ejb:persistence column-name="state"
135    * @ejb:transaction type="Supports"
136    **/

137    public abstract int getState();
138    
139    /**
140    * Set the BnAgent's state.
141    *
142    * @param pState The state of this BnAgent. Is set at creation time.
143    * @ejb:interface-method view-type="both"
144    * @ejb:transaction type="Required"
145    **/

146    public abstract void setState( int pState );
147
148    /**
149    * Retrieve the BnAgent's type.
150    *
151    * @return Returns the type of this BnAgent.
152    *
153    * @ejb:interface-method view-type="both"
154    * @ejb.value-object
155    * match="light"
156    *
157    * @ejb:persistence column-name="type"
158    **/

159     // public abstract AgentType getType();
160

161    /**
162    * Set the BnAgent's type.
163    *
164    * @param type The type of this BnAgent. Is set at creation time.
165    * @ejb:interface-method view-type="both"
166    * @ejb:transaction type="Required"
167    **/

168     // public abstract void setType( AgentType type );
169

170    /**
171    * Retrieve the BnAgent's Name.
172    *
173    * @return Returns an int representing the Name of this BnAgent.
174    *
175    * @ejb:interface-method view-type="both"
176    * @ejb.value-object
177    * match="light"
178    *
179    * @ejb:persistence column-name="name"
180    * @ejb:transaction type="Supports"
181    **/

182    public abstract String JavaDoc getName();
183    
184    /**
185    * Set the BnAgent's Name.
186    *
187    * @param pName The Name of this BnAgent. Is set at creation time.
188    * @ejb:transaction type="Required"
189    **/

190    public abstract void setName( String JavaDoc pName );
191
192    /**
193    * Retrieve the BnAgent's Description.
194    *
195    * @return Returns the description of the BnAgent
196    *
197    * @ejb:interface-method view-type="both"
198    * @ejb.value-object
199    * match="light"
200    *
201    * @ejb:persistence column-name="description"
202    * @ejb:transaction type="Supports"
203    **/

204    public abstract String JavaDoc getDescription();
205    
206    /**
207    * Set the BnAgent's Description.
208    *
209    * @param pDescription The Description of this BnAgent.
210    * @ejb:interface-method view-type="both"
211    * @ejb:transaction type="Required"
212    **/

213    public abstract void setDescription( String JavaDoc pDescription );
214
215     /** Retrieve the BnAgent's Creator.
216      *
217      * @return Returns a String representing the Name of the BnAgent Creator.
218      * @ejb:interface-method view-type="local"
219      * @ejb:relation name="AgentCreator" role-name="created-by"
220      * @jboss:auto-key-fields
221      * @jonas:automatic-pk="true"
222
223      * @ejb:value-object match="*"
224      * relation="external"
225      * aggregate="hero.interfaces.BnUserLightValue"
226      * aggregate-name="Creator"
227      * @ejb:transaction type="Supports"
228      **/

229     public abstract BnUserLocal getCreator();
230     
231     /**
232      * Set the BnAgent's Creator.
233      *
234      * @param pCreator The creator of this BnAgent.
235      * @ejb:interface-method view-type="local"
236      * @ejb:transaction type="Required"
237      **/

238     public abstract void setCreator( BnUserLocal pCreator );
239
240     /**
241      * @return the project of the BnAgent
242      * @ejb:interface-method view-type="local"
243      * @ejb:relation name="Agents" role-name="is-agent-of" cascade-delete="yes"
244      * @jboss:auto-key-fields
245      * @jonas:automatic-pk= "true"
246      * @ejb:transaction type="Supports"
247      *
248      **/

249     public abstract BnProjectLocal getBnProject();
250     
251    /**
252    * Set the BnProject BnAgent.
253    *
254    * @param pProject The Name of this BnAgent. Is set at creation time.
255    * @ejb:transaction type="Required"
256    *
257    **/

258     public abstract void setBnProject(BnProjectLocal pProject);
259
260     /**
261      * @return the outgoing edges of the agent
262      * @ejb:interface-method view-type="local"
263      * @ejb:relation name="InAgent" role-name="has-edges-in" target-multiple="yes"
264      * @jboss:auto-key-fields
265      * @jonas:automatic-pk="true"
266      * @ejb:transaction type="Supports"
267      *
268      **/

269     public abstract Collection JavaDoc getOutEdges();
270
271    /**
272    * Set the Outgoing edges of the BnAgent
273    *
274    * @param pEdges the outgoing edges of the BnAgent
275    * @ejb:transaction type="Required"
276    **/

277     public abstract void setOutEdges(Collection JavaDoc pEdges);
278
279     /**
280      * @return Return the creation date of the BnAgent
281      * @ejb:interface-method view-type="both"
282      * @ejb:persistence column-name="creationdate"
283      * @ejb:transaction type="Supports"
284      *
285      **/

286     public abstract Date JavaDoc getCreationDate();
287
288     /**
289      * @param pDate the creation date of the BnAgent
290      * @ejb:interface-method view-type="both"
291      * @ejb:transaction type="Required"
292      *
293      **/

294     public abstract void setCreationDate(Date JavaDoc pDate);
295
296     /**
297      * @ejb.interface-method
298      * @ejb:transaction type="Supports"
299      */

300     public abstract BnAgentValue getBnAgentValue();
301     
302     /**
303      * @ejb.interface-method
304      * @ejb:transaction type="Required"
305      */

306     public abstract void setBnAgentValue(BnAgentValue v);
307
308     /**
309      * @ejb.interface-method
310      * @ejb:transaction type="Supports"
311      */

312     public abstract BnAgentLightValue getBnAgentLightValue();
313
314    /**
315      * @return true if the BnAgent is active
316      * @ejb.interface-method view-type="local"
317      */

318     public boolean isActive() {
319     return (this.getState()==hero.interfaces.Constants.Ag.ACTIVE);
320     }
321   
322    // -------------------------------------------------------------------------
323
// Framework Callbacks
324
// -------------------------------------------------------------------------
325

326    /**
327    * Create a BnAgent based on the supplied BnAgent Value Object.
328    *
329    *
330    * @throws InvalidValueException If one of the values are not correct,
331    * this will not roll back the transaction
332    * because the caller has the chance to
333    * fix the problem and try again
334    * @throws EJBException If no new unique ID could be retrieved this will
335    * rollback the transaction because there is no
336    * hope to try again
337    * @throws CreateException Because we have to do so (EJB spec.)
338    *
339    * @ejb:create-method view-type="both"
340    **/

341    public BnAgentPK ejbCreate(BnAgentValue nd )
342       throws
343          InvalidValueException,
344          EJBException JavaDoc,
345          CreateException JavaDoc
346    {
347        setBnAgentValue(nd);
348        this.setId(hero.interfaces.BnAgentUtil.generateGUID(this));
349       // This is only possible in CMPs. Otherwise return a valid PK.
350
return null;
351    }
352
353    /**
354    * Create a BnAgent based on the supplied Name and type.
355    *
356    *
357    * @throws InvalidValueException If one of the values are not correct,
358    * this will not roll back the transaction
359    * because the caller has the chance to
360    * fix the problem and try again
361    * @throws EJBException If no new unique ID could be retrieved this will
362    * rollback the transaction because there is no
363    * hope to try again
364    * @throws CreateException Because we have to do so (EJB spec.)
365    *
366    * @ejb:create-method view-type="both"
367    **/

368    public BnAgentPK ejbCreate(String JavaDoc name)
369       throws
370          InvalidValueException,
371          EJBException JavaDoc,
372          CreateException JavaDoc
373    {
374        this.setName(name);
375        this.setState(hero.interfaces.Constants.Ag.INACTIVE);
376        
377         this.setId(hero.interfaces.BnAgentUtil.generateGUID(this));
378             
379        // This is only possible in CMPs. Otherwise return a valid PK.
380
return null;
381    }
382
383    
384    public void setEntityContext( EntityContext JavaDoc lContext )
385    {
386       mContext = lContext;
387    }
388    
389    public void unsetEntityContext()
390    {
391       mContext = null;
392    }
393    
394    public void ejbActivate()
395    {
396    }
397    
398    public void ejbPassivate()
399    {
400    }
401    
402    public void ejbLoad()
403    {
404    }
405    
406    public void ejbStore()
407    {
408    }
409    
410    public void ejbRemove()
411       throws
412          RemoveException JavaDoc
413    {
414    }
415
416 }
417
Popular Tags