001: package hero.entity;
002:
003: import hero.interfaces.BnNodeLocal;
004: import hero.interfaces.BnNodePropertyPK;
005: import hero.interfaces.BnNodePropertyValue;
006: import hero.interfaces.InvalidValueException;
007:
008: import javax.ejb.CreateException;
009: import javax.ejb.EJBException;
010: import javax.ejb.EntityBean;
011: import javax.ejb.EntityContext;
012: import javax.ejb.RemoveException;
013:
014: import java.util.Collection;
015:
016: ;
017:
018: /**
019: * The Entity bean represents a BnNodeProperty
020: *
021: * @author Oriol Montala
022: * @version $Revision: 1.11 $
023: *
024: * @ejb:bean name="BnNodeProperty"
025: * display-name="BnNode Property Entity"
026: * type="CMP"
027: * jndi-name="ejb/hero/BnNodeProperty"
028: * local-jndi-name="ejb/hero/BnNodeProperty_L"
029: * view-type="both"
030: * cmp-version="2.x"
031: * reentrant="true"
032: *
033: * @ejb:transaction type="Supports"
034: *
035: *
036: * @ejb.pk generate="true" 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="BnNodeProperty"
043: *
044: * @jonas.shared false
045: *
046: * @ejb:finder signature="java.util.Collection findAll()"
047: * query="SELECT object(n) FROM BnNodeProperty n"
048: * transaction-type="Supports"
049: * @ejb:finder signature="java.util.Collection findByNode(java.lang.String nodeId)" view-type="local"
050: * query="SELECT OBJECT(p) From BnNodeProperty p Where p.bnNode.id = ?1"
051: * transaction-type="Supports"
052: * @ejb:finder signature="java.util.Collection findByTheKey(java.lang.String nodeId, java.lang.String pkey)" view-type="local"
053: * query="SELECT OBJECT(p) From BnNodeProperty p Where p.bnNode.id = ?1 AND p.theKey=?2"
054: * transaction-type="Supports"
055: *
056: *
057: * @ejb.value-object
058: * match="*"
059: * name="BnNodeProperty"
060: *
061: * @ejb.value-object
062: * match="light"
063: * name="BnNodePropertyLight"
064: *
065: * @jboss.persistence
066: * table-name="BnNodeProperty"
067: * create-table="true"
068: * remove-table="false"
069: *
070: * @jboss.container-configuration name="Standard CMP 2.x EntityBean for Bonita"
071: **/
072: public abstract class BnNodePropertyBean implements EntityBean {
073:
074: // -------------------------------------------------------------------------
075: // Members
076: // -------------------------------------------------------------------------
077:
078: public EntityContext mContext;
079:
080: // -------------------------------------------------------------------------
081: // Methods
082: // -------------------------------------------------------------------------
083:
084: // -------------------------------------------------------------------------
085: // Properties (Getters/Setters)
086: // -------------------------------------------------------------------------
087:
088: /**
089: * Retrieve the Property's id.
090: *
091: * @return Returns an int representing the id of this Property.
092: *
093: * @ejb:pk-field
094: * @ejb.value-object
095: * match="light"
096: * @ejb:persistence column-name="id"
097: * @jonas.cmp-field-jdbc-mapping
098: * field-name="id"
099: * jdbc-field-name="id"
100: * @ejb:transaction type="Supports"
101: **/
102: public abstract String getId();
103:
104: /**
105: * Set the Property's id.
106: *
107: * @param pId The id of this Property. Is set at creation time.
108: * @ejb:transaction type="Required"
109: **/
110: public abstract void setId(String pId);
111:
112: /** Retrieve the BnNode.
113: *
114: * @return Returns a BnNodeLocal.
115: * @ejb:interface-method view-type="both"
116: * @ejb:relation name="nodeprp" role-name="property-by" cascade-delete="yes"
117: * @ejb:transaction type="Supports"
118: * @jboss.relation
119: * related-pk-field = "id"
120: * fk-column = "bnodePropertyIdFK"
121: **/
122: public abstract BnNodeLocal getBnNode();
123:
124: /**
125: * Set the BnNode.
126: *
127: * @ejb:interface-method view-type="local"
128: * @param pNode The BnNode of this Property.
129: * @ejb:transaction type="Required"
130: **/
131: public abstract void setBnNode(BnNodeLocal pNode);
132:
133: /**
134: * Retrieve the Key value.
135: *
136: * @return Returns an String representing the Key value of this Property.
137: * @ejb.value-object
138: * match="light"
139: * @ejb:interface-method view-type="both"
140: *
141: * @ejb:persistence column-name="thekey"
142: * @ejb:transaction type="Supports"
143: **/
144: public abstract String getTheKey();
145:
146: /**
147: * Set the key value.
148: * @ejb:interface-method view-type="both"
149: * @param key The Key of this Property.
150: * @ejb:transaction type="Required"
151: **/
152: public abstract void setTheKey(String key);
153:
154: /**
155: * Retrieve the Value value.
156: *
157: * @return Returns an String representing the Value value of this Property.
158: * @ejb.value-object
159: * match="light"
160: * @ejb:interface-method view-type="both"
161: *
162: * @ejb:persistence column-name="thevalue"
163: * @ejb:transaction type="Supports"
164: **/
165: public abstract String getTheValue();
166:
167: /**
168: * Set the Value value.
169: * @ejb:interface-method view-type="both"
170: * @param value The Value value of this Property.
171: * @ejb:transaction type="Required"
172: **/
173: public abstract void setTheValue(String value);
174:
175: /**
176: * Retrieve the Value value.
177: *
178: * @return Returns a Collection representing possibles values of Property.
179: * @ejb.value-object
180: * match="light"
181: * @ejb:interface-method view-type="both"
182: *
183: * @ejb:persistence column-name="possiblevalues"
184: * @ejb:transaction type="Supports"
185: *
186: * @jboss.relation-table create-table="true" remove-table="false"
187: **/
188: public abstract Collection getPossibleValues();
189:
190: /**
191: * Set the possible values of the property
192: * @ejb:interface-method view-type="both"
193: * @param values possibles values of the property
194: * @ejb:transaction type="Required"
195: **/
196: public abstract void setPossibleValues(Collection value);
197:
198: /**
199: * Retrieve the propagation value
200: * @ejb.value-object
201: * match="light"
202: * @return Returns a boolean
203: *
204: * @ejb:interface-method view-type="both"
205: *
206: * @ejb:persistence column-name="propagate"
207: * @ejb:transaction type="Supports"
208: **/
209: public abstract boolean getPropagate();
210:
211: /**
212: * Set the propagation value.
213: * @ejb:interface-method view-type="both"
214: * @param prop if the property is propagateable
215: * @ejb:transaction type="Required"
216: **/
217: public abstract void setPropagate(boolean prop);
218:
219: /**
220: * @ejb.interface-method
221: * @ejb:transaction type="Supports"
222: */
223: public abstract BnNodePropertyValue getBnNodePropertyValue();
224:
225: /**
226: * @ejb.interface-method
227: * @ejb:transaction type="Required"
228: */
229: public abstract void setBnNodePropertyValue(BnNodePropertyValue v);
230:
231: // -------------------------------------------------------------------------
232: // Framework Callbacks
233: // -------------------------------------------------------------------------
234:
235: /**
236: * Create a Property based on the supplied Property Value Object.
237: *
238: *
239: * @throws InvalidValueException If one of the values are not correct,
240: * this will not roll back the transaction
241: * because the caller has the chance to
242: * fix the problem and try again
243: * @throws EJBException If no new unique ID could be retrieved this will
244: * rollback the transaction because there is no
245: * hope to try again
246: * @throws CreateException Because we have to do so (EJB spec.)
247: *
248: * @ejb:create-method view-type="both"
249: **/
250: public BnNodePropertyPK ejbCreate(BnNodePropertyValue prp)
251: throws InvalidValueException, EJBException, CreateException {
252: this .setId(hero.interfaces.BnNodePropertyUtil
253: .generateGUID(this ));
254: // This is only possible in CMPs. Otherwise return a valid PK.
255: return null;
256: }
257:
258: public void ejbPostCreate(BnNodePropertyValue prp) {
259: // Assign value object in ejbPostCreate to apply XDoclet best
260: // practice. If not done, there will be an error in JBoss if
261: // the Value Object has relations.
262: this .setBnNodePropertyValue(prp);
263: }
264:
265: /**
266: * Create a Property based on the supplied key and value.
267: *
268: *
269: * @throws InvalidValueException If one of the values are not correct,
270: * this will not roll back the transaction
271: * because the caller has the chance to
272: * fix the problem and try again
273: * @throws EJBException If no new unique ID could be retrieved this will
274: * rollback the transaction because there is no
275: * hope to try again
276: * @throws CreateException Because we have to do so (EJB spec.)
277: *
278: * @ejb:create-method view-type="both"
279: **/
280: public BnNodePropertyPK ejbCreate(String key, String value)
281: throws InvalidValueException, EJBException, CreateException {
282: this .setTheKey(key);
283: this .setTheValue(value);
284: this .setPropagate(true);
285: this .setId(hero.interfaces.BnNodePropertyUtil
286: .generateGUID(this ));
287:
288: // This is only possible in CMPs. Otherwise return a valid PK.
289: return null;
290: }
291:
292: /**
293: * Create a Property based on the supplied key and value.
294: *
295: *
296: * @throws InvalidValueException If one of the values are not correct,
297: * this will not roll back the transaction
298: * because the caller has the chance to
299: * fix the problem and try again
300: * @throws EJBException If no new unique ID could be retrieved this will
301: * rollback the transaction because there is no
302: * hope to try again
303: * @throws CreateException Because we have to do so (EJB spec.)
304: *
305: * @ejb:create-method view-type="both"
306: **/
307: public BnNodePropertyPK ejbCreate(String key, Collection values)
308: throws InvalidValueException, EJBException, CreateException {
309: this .setTheKey(key);
310: this .setPossibleValues(values);
311: this .setPropagate(true);
312: this .setId(hero.interfaces.BnNodePropertyUtil
313: .generateGUID(this ));
314:
315: // This is only possible in CMPs. Otherwise return a valid PK.
316: return null;
317: }
318:
319: public void setEntityContext(EntityContext lContext) {
320: mContext = lContext;
321: }
322:
323: public void unsetEntityContext() {
324: mContext = null;
325: }
326:
327: public void ejbActivate() {
328: }
329:
330: public void ejbPassivate() {
331: }
332:
333: public void ejbLoad() {
334: }
335:
336: public void ejbStore() {
337: }
338:
339: public void ejbRemove() throws RemoveException {
340: }
341:
342: }
|