001: package hero.entity;
002:
003: import hero.interfaces.BnAgentLightValue;
004: import hero.interfaces.BnAgentPK;
005: import hero.interfaces.BnAgentValue;
006: import hero.interfaces.BnProjectLocal;
007: import hero.interfaces.BnUserLocal;
008: import hero.interfaces.InvalidValueException;
009:
010: import java.util.Date;
011: import java.util.Collection;
012:
013: import javax.ejb.CreateException;
014: import javax.ejb.EJBException;
015: import javax.ejb.EntityBean;
016: import javax.ejb.EntityContext;
017: import javax.ejb.RemoveException;
018:
019: /**
020: * The Entity bean represents a BnUser
021: *
022: * @author Miguel Valdes
023: * @version $Revision: 1.10 $
024: *
025: * @ejb:bean name="BnAgent"
026: * display-name="BnAgent Entity"
027: * type="CMP"
028: * jndi-name="ejb/hero/BnAgent"
029: * local-jndi-name="ejb/hero/BnAgent_L"
030: * view-type="both"
031: * cmp-version="2.x"
032: * reentrant="true"
033: *
034: * @ejb:transaction type="Supports"
035: *
036: * @ejb.pk method-intf="both"
037: *
038: * @jonas.bean
039: * lock-policy="container-read-committed"
040: * @jonas.jdbc-mapping
041: * jndi-name="bonita"
042: * jdbc-table-name="BnAgent"
043: *
044: * @jonas.shared false
045: *
046: * @ejb:finder signature="java.util.Collection findAll()"
047: * query="SELECT object(a) FROM BnAgent a"
048: * transaction-type="Supports"
049: *
050: * @ejb:finder signature="hero.interfaces.BnAgent findByName(java.lang.String pName, java.lang.String projectId )" view-type="both" result-type-mapping="Remote"
051: * query="SELECT OBJECT(a) FROM BnAgent a WHERE a.name = ?1 AND a.bnProject.id = ?2"
052: * transaction-type="Supports"
053: * @ejb:finder signature="hero.interfaces.BnAgentLocal findByName(java.lang.String pName, java.lang.String projectId )" view-type="both" result-type-mapping="Local"
054: * query="SELECT OBJECT(a) FROM BnAgent a WHERE a.name = ?1 AND a.bnProject.id = ?2"
055: * transaction-type="Supports"
056: *
057: *
058: * @ejb.value-object
059: * match="*"
060: * name="BnAgent"
061: *
062: * @ejb.value-object
063: * match="light"
064: * name="BnAgentLight"
065: *
066: * @jboss.persistence
067: * table-name="BnAgent"
068: * create-table="true"
069: * remove-table="false"
070: *
071: * @jboss.container-configuration name="Standard CMP 2.x EntityBean for Bonita"
072: **/
073:
074: public abstract class BnAgentBean implements EntityBean {
075:
076: // -------------------------------------------------------------------------
077: // Members
078: // -------------------------------------------------------------------------
079:
080: public EntityContext mContext;
081:
082: // -------------------------------------------------------------------------
083: // Methods
084: // -------------------------------------------------------------------------
085:
086: // -------------------------------------------------------------------------
087: // Properties (Getters/Setters)
088: // -------------------------------------------------------------------------
089:
090: /**
091: * Retrieve the BnAgent's id.
092: *
093: * @return Returns an int representing the id of this BnAgent.
094: *
095: * @ejb:pk-field
096: * @ejb.value-object
097: * match="light"
098: *
099: * @ejb:persistence column-name="id"
100: * @ejb:interface-method view-type="local"
101: * @jonas.cmp-field-jdbc-mapping
102: * field-name="id"
103: * jdbc-field-name="id"
104: * @ejb:transaction type="Supports"
105: **/
106: public abstract String getId();
107:
108: /**
109: * Set the BnAgent's id.
110: *
111: * @param pId The id of this BnAgent. Is set at creation time.
112: * @ejb:transaction type="Required"
113: **/
114: public abstract void setId(String pId);
115:
116: /**
117: * Retrieve the BnAgent's state.
118: *
119: * @return Returns an int representing the state of this BnAgent.
120: *
121: * @ejb:interface-method view-type="both"
122: * @ejb.value-object
123: * match="light"
124: *
125: * @ejb:persistence column-name="state"
126: * @ejb:transaction type="Supports"
127: **/
128: public abstract int getState();
129:
130: /**
131: * Set the BnAgent's state.
132: *
133: * @param pState The state of this BnAgent. Is set at creation time.
134: * @ejb:interface-method view-type="both"
135: * @ejb:transaction type="Required"
136: **/
137: public abstract void setState(int pState);
138:
139: /**
140: * Retrieve the BnAgent's type.
141: *
142: * @return Returns the type of this BnAgent.
143: *
144: * @ejb:interface-method view-type="both"
145: * @ejb.value-object
146: * match="light"
147: *
148: * @ejb:persistence column-name="type"
149: **/
150: // public abstract AgentType getType();
151: /**
152: * Set the BnAgent's type.
153: *
154: * @param type The type of this BnAgent. Is set at creation time.
155: * @ejb:interface-method view-type="both"
156: * @ejb:transaction type="Required"
157: **/
158: // public abstract void setType( AgentType type );
159: /**
160: * Retrieve the BnAgent's Name.
161: *
162: * @return Returns an int representing the Name of this BnAgent.
163: *
164: * @ejb:interface-method view-type="both"
165: * @ejb.value-object
166: * match="light"
167: *
168: * @ejb:persistence column-name="name"
169: * @ejb:transaction type="Supports"
170: **/
171: public abstract String getName();
172:
173: /**
174: * Set the BnAgent's Name.
175: *
176: * @param pName The Name of this BnAgent. Is set at creation time.
177: * @ejb:transaction type="Required"
178: **/
179: public abstract void setName(String pName);
180:
181: /**
182: * Retrieve the BnAgent's Description.
183: *
184: * @return Returns the description of the BnAgent
185: *
186: * @ejb:interface-method view-type="both"
187: * @ejb.value-object
188: * match="light"
189: *
190: * @ejb:persistence column-name="description"
191: * @ejb:transaction type="Supports"
192: **/
193: public abstract String getDescription();
194:
195: /**
196: * Set the BnAgent's Description.
197: *
198: * @param pDescription The Description of this BnAgent.
199: * @ejb:interface-method view-type="both"
200: * @ejb:transaction type="Required"
201: **/
202: public abstract void setDescription(String pDescription);
203:
204: /** Retrieve the BnAgent's Creator.
205: *
206: * @return Returns a String representing the Name of the BnAgent Creator.
207: * @ejb:interface-method view-type="local"
208: * @ejb:relation name="AgentCreator" role-name="created-by"
209: *
210: * @ejb:value-object match="*"
211: * relation="external"
212: * aggregate="hero.interfaces.BnUserLightValue"
213: * aggregate-name="Creator"
214: * @ejb:transaction type="Supports"
215: * @jboss.relation
216: * related-pk-field = "id"
217: * fk-column = "AgentUserIdFK"
218: **/
219: public abstract BnUserLocal getCreator();
220:
221: /**
222: * Set the BnAgent's Creator.
223: *
224: * @param pCreator The creator of this BnAgent.
225: * @ejb:interface-method view-type="local"
226: * @ejb:transaction type="Required"
227: **/
228: public abstract void setCreator(BnUserLocal pCreator);
229:
230: /**
231: * @return the project of the BnAgent
232: * @ejb:interface-method view-type="local"
233: * @ejb:relation name="Agents" role-name="is-agent-of" cascade-delete="yes"
234: * @ejb:transaction type="Supports"
235: * @jboss.relation
236: * related-pk-field = "id"
237: * fk-column = "agentProjectIdFK"
238: **/
239: public abstract BnProjectLocal getBnProject();
240:
241: /**
242: * Set the BnProject BnAgent.
243: *
244: * @param pProject The Name of this BnAgent. Is set at creation time.
245: * @ejb:transaction type="Required"
246: *
247: **/
248: public abstract void setBnProject(BnProjectLocal pProject);
249:
250: /**
251: * @return the outgoing edges of the agent
252: * @ejb:interface-method view-type="local"
253: * @ejb:relation name="InAgent" role-name="has-edges-in" target-multiple="yes"
254: * @ejb:transaction type="Supports"
255: * @jboss.relation-table create-table="true" remove-table="false"
256: *
257: **/
258: public abstract Collection getOutEdges();
259:
260: /**
261: * Set the Outgoing edges of the BnAgent
262: *
263: * @param pEdges the outgoing edges of the BnAgent
264: * @ejb:transaction type="Required"
265: **/
266: public abstract void setOutEdges(Collection pEdges);
267:
268: /**
269: * @return Return the creation date of the BnAgent
270: * @ejb:interface-method view-type="both"
271: * @ejb:persistence column-name="creationdate"
272: * @ejb:transaction type="Supports"
273: *
274: **/
275: public abstract Date getCreationDate();
276:
277: /**
278: * @param pDate the creation date of the BnAgent
279: * @ejb:interface-method view-type="both"
280: * @ejb:transaction type="Required"
281: *
282: **/
283: public abstract void setCreationDate(Date pDate);
284:
285: /**
286: * @ejb.interface-method
287: * @ejb:transaction type="Supports"
288: */
289: public abstract BnAgentValue getBnAgentValue();
290:
291: /**
292: * @ejb.interface-method
293: * @ejb:transaction type="Required"
294: */
295: public abstract void setBnAgentValue(BnAgentValue v);
296:
297: /**
298: * @ejb.interface-method
299: * @ejb:transaction type="Supports"
300: */
301: public abstract BnAgentLightValue getBnAgentLightValue();
302:
303: /**
304: * @return true if the BnAgent is active
305: * @ejb.interface-method view-type="local"
306: */
307: public boolean isActive() {
308: return (this .getState() == hero.interfaces.Constants.Ag.ACTIVE);
309: }
310:
311: // -------------------------------------------------------------------------
312: // Framework Callbacks
313: // -------------------------------------------------------------------------
314:
315: /**
316: * Create a BnAgent based on the supplied BnAgent Value Object.
317: *
318: *
319: * @throws InvalidValueException If one of the values are not correct,
320: * this will not roll back the transaction
321: * because the caller has the chance to
322: * fix the problem and try again
323: * @throws EJBException If no new unique ID could be retrieved this will
324: * rollback the transaction because there is no
325: * hope to try again
326: * @throws CreateException Because we have to do so (EJB spec.)
327: *
328: * @ejb:create-method view-type="both"
329: **/
330: public BnAgentPK ejbCreate(BnAgentValue nd)
331: throws InvalidValueException, EJBException, CreateException {
332: this .setId(hero.interfaces.BnAgentUtil.generateGUID(this ));
333: // This is only possible in CMPs. Otherwise return a valid PK.
334: return null;
335: }
336:
337: public void ejbPostCreate(BnAgentValue nd) {
338: // Assign value object in ejbPostCreate to apply XDoclet best
339: // practice. If not done, there will be an error in JBoss if
340: // the Value Object has relations.
341: this .setBnAgentValue(nd);
342: }
343:
344: /**
345: * Create a BnAgent based on the supplied Name and type.
346: *
347: *
348: * @throws InvalidValueException If one of the values are not correct,
349: * this will not roll back the transaction
350: * because the caller has the chance to
351: * fix the problem and try again
352: * @throws EJBException If no new unique ID could be retrieved this will
353: * rollback the transaction because there is no
354: * hope to try again
355: * @throws CreateException Because we have to do so (EJB spec.)
356: *
357: * @ejb:create-method view-type="both"
358: **/
359: public BnAgentPK ejbCreate(String name)
360: throws InvalidValueException, EJBException, CreateException {
361: this .setName(name);
362: this .setState(hero.interfaces.Constants.Ag.INACTIVE);
363:
364: this .setId(hero.interfaces.BnAgentUtil.generateGUID(this ));
365:
366: // This is only possible in CMPs. Otherwise return a valid PK.
367: return null;
368: }
369:
370: public void setEntityContext(EntityContext lContext) {
371: mContext = lContext;
372: }
373:
374: public void unsetEntityContext() {
375: mContext = null;
376: }
377:
378: public void ejbActivate() {
379: }
380:
381: public void ejbPassivate() {
382: }
383:
384: public void ejbLoad() {
385: }
386:
387: public void ejbStore() {
388: }
389:
390: public void ejbRemove() throws RemoveException {
391: }
392:
393: }
|