KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > entity > BnProjectBean


1 package hero.entity;
2
3 import hero.interfaces.BnAgentLocal;
4 import hero.interfaces.BnAgentLocalHome;
5 import hero.interfaces.BnEdgeLocal;
6 import hero.interfaces.BnEdgeLocalHome;
7 import hero.interfaces.BnNodeLocal;
8 import hero.interfaces.BnNodeLocalHome;
9 import hero.interfaces.BnProjectLightValue;
10 import hero.interfaces.BnProjectLocal;
11 import hero.interfaces.BnProjectConfigLocal;
12 import hero.interfaces.BnProjectLocalHome;
13 import hero.interfaces.BnProjectPK;
14 import hero.interfaces.BnProjectValue;
15 import hero.interfaces.InvalidValueException;
16 import hero.interfaces.SequenceGenerator;
17 import hero.interfaces.SequenceGeneratorHome;
18 import hero.interfaces.SequenceGeneratorLocal;
19 import hero.interfaces.SequenceGeneratorLocalHome;
20 import hero.interfaces.SequenceGeneratorUtil;
21 import hero.util.HeroException;
22 import hero.util.values.BonitaProjectValue;
23
24 import java.rmi.RemoteException JavaDoc;
25 import java.util.Date JavaDoc;
26 import java.util.Collection JavaDoc;
27
28 import javax.ejb.CreateException JavaDoc;
29 import javax.ejb.EJBException JavaDoc;
30 import javax.ejb.EntityBean JavaDoc;
31 import javax.ejb.EntityContext JavaDoc;
32 import javax.ejb.FinderException JavaDoc;
33 import javax.ejb.RemoveException JavaDoc;
34 import javax.naming.NamingException JavaDoc;
35
36 import org.apache.log4j.Category;
37
38 /**
39  * The Entity bean represents a BnProject
40  *
41  * @author François Charoy
42  * @version $Revision: 1.12 $
43  *
44  * @ejb.bean name="BnProject"
45  * display-name="BnProject Entity"
46  * type="CMP"
47  * jndi-name="ejb/hero/BnProject"
48  * local-jndi-name="ejb/hero/BnProject_L"
49  * view-type="both"
50  * cmp-version="2.x"
51  * reentrant="true"
52  *
53  * @ejb.permission unchecked="yes"
54  * @ejb.pk generate="true" method-intf="remote"
55  *
56  * @jonas.bean
57  * ejb-name="BnProject"
58  * jndi-name="ejb/hero/BnProject"
59  * lock-policy="container-read-committed"
60  *
61  * @jonas.shared false
62  *
63  * @jonas.jdbc-mapping
64  * jndi-name="bonita"
65  * jdbc-table-name="BnProject"
66  *
67  * @ejb.finder signature="java.util.Collection findAll()"
68  * query="SELECT object(p) FROM BnProject p"
69  * transaction-type="Supports"
70  *
71  * @ejb.finder signature="java.util.Collection findModels(java.lang.String type)"
72  * query="SELECT object(p) FROM BnProject as p WHERE p.type = ?1"
73  * transaction-type="Supports"
74  *
75  * @ejb.finder signature="hero.interfaces.BnProject findByName(java.lang.String pName )" result-type-mapping="Remote"
76  * query="SELECT Object(p) From BnProject as p Where p.name = ?1"
77  * transaction-type="Supports"
78  * @ejb.finder signature="hero.interfaces.BnProjectLocal findByName(java.lang.String pName )" result-type-mapping="Local"
79  * query="SELECT Object(p) From BnProject as p Where p.name = ?1"
80  * transaction-type="Supports"
81  *
82  *
83  * @ejb.finder signature="java.util.Collection findByUser(java.lang.String userName )"
84  * query="SELECT OBJECT(p) From BnProject as p, in (p.bnUsers) as u Where u.name = ?1"
85  * transaction-type="Supports"
86  *
87  *
88  * @ejb.finder signature="java.util.Collection findUserInstancesByProject(java.lang.String projectName, java.lang.String userName )"
89  * query="SELECT DISTINCT OBJECT(p) From BnProject AS p, IN (p.bnUsers) u
90  * WHERE p.name LIKE ?1
91  * AND u.name = ?2"
92  * transaction-type="Supports"
93  *
94  * @ejb.finder signature="java.util.Collection findProjectsByProperty(java.lang.String key, java.lang.String value )"
95  * query="SELECT OBJECT(p) From BnProject as p, BnProjectProperty as prop
96  * Where prop.theKey = ?1
97  * AND prop.theValue = ?2
98  * AND p.id = prop.bnProject.id"
99  * transaction-type="Supports"
100  *
101  * @ejb.finder signature="java.util.Collection findByAdmin(java.lang.String userName, java.lang.String roleName, java.lang.String type)"
102  * query="SELECT OBJECT(p) From BnProject as p, in (p.bnRoles) as pr, in (p.bnUsers) as u, in (u.bnRoles) as r
103  * Where u.name = ?1
104  * AND r.name = ?2
105  * AND p.type = ?3
106  * AND r.id = pr.id"
107  * transaction-type="Supports"
108  *
109  * @ejb.value-object
110  * match="*"
111  * name="BnProject"
112  *
113  * @ejb.value-object
114  * match="light"
115  * name="BnProjectLight"
116  *
117  *
118  * @ejb:transaction type="Supports"
119  * @jboss.table-name table-name="BnProject"
120  *
121  * @jboss.create-table create="true"
122  *
123  * @jboss.remove-table remove="false"
124  *
125  * @version $Revision: 1.12 $
126  * @author $Author: mvaldes $
127  **/

128 public abstract class BnProjectBean implements EntityBean JavaDoc {
129
130     // -------------------------------------------------------------------------
131
// Members
132
// -------------------------------------------------------------------------
133
// Static
134
// -------------------------------------------------------------------------
135
// Utility variable
136
private static final Category log = Category.getInstance(BnProjectBean.class);
137     public EntityContext JavaDoc mContext;
138
139
140     // -------------------------------------------------------------------------
141
// Properties (Getters/Setters)
142
// -------------------------------------------------------------------------
143

144     /**
145     * Retrieve the BnProject's id.
146     *
147     * @return Returns an int representing the id of this BnUser.
148     *
149     * @ejb:pk-field
150     * @ejb:interface-method view-type="both"
151     * @ejb.value-object
152     * match="light"
153     *
154     * @ejb:persistence column-name="id"
155     * @jonas.cmp-field-jdbc-mapping
156     * field-name="id"
157     * jdbc-field-name="id"
158     * @ejb:transaction type="Supports"
159     **/

160     public abstract String JavaDoc getId();
161
162     /**
163     * Set the BnProject's id.
164     *
165     * @param pId The id of this BnUser. Is set at creation time.
166     * @ejb:transaction type="Required"
167     **/

168     public abstract void setId(String JavaDoc pId);
169     
170     /**
171     * Get parent of this project (or the name of the project if is not a child)
172     *
173     * @return Returns a String representing the parent name
174     *
175     * @ejb:interface-method view-type="both"
176     * @ejb.value-object
177     * match="light"
178     *
179     * @ejb:persistence column-name="parent"
180     * @ejb:transaction type="Supports"
181     **/

182
183     public abstract String JavaDoc getParent();
184
185     /**
186     * Set the parent of this project (or the name of the project if is not a child)
187     *
188     * @param parent of this project. Is set at creation time.
189     * @ejb:interface-method view-type="both"
190     * @ejb:transaction type="Required"
191     **/

192     public abstract void setParent(String JavaDoc parent);
193
194     /**
195     * Retrieve the BnProject's Name.
196     *
197     * @return Returns an int representing the Name of this BnProject.
198     *
199     * @ejb:interface-method view-type="both"
200     * @ejb.value-object
201     * match="light"
202     *
203     * @ejb:persistence column-name="name"
204     * @ejb:transaction type="Supports"
205     **/

206     public abstract String JavaDoc getName();
207
208     /**
209      * Set the BnProject's Name.
210      *
211      * @param pName The Name of this BnProject. Is set at creation time.
212      * @ejb:transaction type="Required"
213      */

214     public abstract void setName(String JavaDoc pName);
215
216     /**
217      * Get the status of this project (Active/Hidden)
218      *
219      * @return Returns a String representing the status name
220      *
221      * @ejb:interface-method view-type="both"
222      * @ejb.value-object match="light"
223      *
224      * @ejb:persistence column-name="status"
225      * @ejb:transaction type="Supports"
226      */

227
228     public abstract String JavaDoc getStatus();
229
230     /**
231      * Set the status of this project (Active/Hidden)
232      *
233      * @param status of this project. Is set at creation time.
234      * @ejb:interface-method view-type="both"
235      * @ejb:transaction type="Required"
236      */

237     public abstract void setStatus(String JavaDoc status);
238     
239     /**
240      * Get the type of this project (model/cooperative/instance)
241      *
242      * @return Returns a String representing the type name
243      *
244      * @ejb:interface-method view-type="both"
245      * @ejb.value-object match="light"
246      *
247      * @ejb:persistence column-name="type"
248      * @ejb:transaction type="Supports"
249      */

250
251     public abstract String JavaDoc getType();
252
253     /**
254      * Set the type of this project (model/cooperative/instance)
255      *
256      * @param type of this project. Is set at creation time.
257      * @ejb:interface-method view-type="both"
258      * @ejb:transaction type="Required"
259      */

260     public abstract void setType(String JavaDoc type);
261
262     /**
263      * Retrieve the BnProject Creator.
264      *
265      * @return Returns a string representing the name of the creator.
266      *
267      * @ejb.interface-method view-type="both"
268      * @ejb.value-object match="light"
269      *
270      * @ejb:persistence column-name="creator"
271      * @ejb:transaction type="Supports"
272      */

273     public abstract String JavaDoc getCreator();
274
275     /**
276     * Set the Creator Name.
277     *
278     * @param pCreator The Creator of this project
279     * @ejb:transaction type="Required"
280     **/

281     public abstract void setCreator(String JavaDoc pCreator);
282
283     /**
284     * @return Returns the State of this BnProject
285     *
286     * @ejb:interface-method view-type="both"
287     * @ejb.value-object
288     * match="light"
289     *
290     * @ejb:persistence column-name="state"
291     * @ejb:transaction type="Supports"
292     **/

293     public abstract int getState();
294
295     /**
296     * Specify the State of this BnProject
297     *
298     * @param pState State of this BnProject
299     * @ejb:interface-method view-type="both"
300     * @ejb:transaction type="Required"
301     **/

302     public abstract void setState(int pState);
303     
304     /**
305      * @ejb.interface-method
306      * @ejb:interface-method view-type="local"
307      * @ejb:persistence column-name="model"
308      * @ejb:transaction type="Supports"
309      */

310     public abstract BonitaProjectValue getModel();
311
312     /**
313      * @ejb.interface-method
314      * @ejb:interface-method view-type="local"
315      * @ejb:transaction type="Required"
316      */

317     public abstract void setModel(BonitaProjectValue v);
318     
319    /** Retrieve the Config associated with the project.
320     *
321     * @return Returns a BnProjectConfigLocal representing the Name of the role.
322     * @ejb:interface-method view-type="both"
323     * @ejb:relation name="project-config" role-name=config2project" cascade-delete="yes"
324     * @jboss:auto-key-fields
325     * @jonas:automatic-pk="true"
326     * @ejb:transaction type="Supports"
327     **/

328   public abstract BnProjectConfigLocal getBnProjectConfig();
329   
330    /**
331     * Set the Config of this project
332     *
333     * @param pMapper mapper of the role
334     * @ejb:interface-method view-type="local"
335     * @ejb:transaction type="Required"
336     **/

337    public abstract void setBnProjectConfig( BnProjectConfigLocal config);
338
339     /**
340      * @return Return the nodes of the project
341      *
342      * @ejb.interface-method view-type="both"
343      * @ejb.relation name="Nodes" role-name="has-nodes"
344      *
345      * @ejb.value-object
346      * match="normal"
347      * type="Collection"
348      * relation="external"
349      * compose="hero.interfaces.BnNodeValue"
350      * compose-name="BnNode"
351      * members="hero.interfaces.BnNodeLocal"
352      * members-name="BnNode"
353      * @ejb:transaction type="Supports"
354      **/

355     public abstract Collection JavaDoc getBnNodes();
356
357     /**
358     * Specify the Nodes of this BnProject
359     *
360     * @param pNodes Nodes of this BnProject
361     * @ejb:interface-method view-type="local"
362     * @ejb:transaction type="Required"
363     **/

364     public abstract void setBnNodes(Collection JavaDoc pNodes);
365
366     /**
367      * @return Return the edges of the project
368      *
369      * @ejb:interface-method view-type="local"
370      * @ejb:relation name="Edges" role-name="has-edges"
371      *
372      * @ejb.value-object
373      * match="normal"
374      * type="Collection"
375      * relation="external"
376      * compose="hero.interfaces.BnEdgeValue"
377      * compose-name="BnEdge"
378      * members="hero.interfaces.BnEdgeLocal"
379      * members-name="BnEdge"
380      * @ejb:transaction type="Supports"
381      **/

382     public abstract Collection JavaDoc getBnEdges();
383
384     /**
385     * Specify the Edges of this BnProject
386     *
387     * @param pEdges Edges of this BnProject
388     * @ejb:interface-method view-type="local"
389     * @ejb:transaction type="Required"
390     **/

391     public abstract void setBnEdges(Collection JavaDoc pEdges);
392
393     /**
394      * @return Return the Agents of the project
395      *
396      * @ejb.interface-method view-type="local"
397      * @ejb.relation name="Agents" role-name="has-agents"
398      *
399      * @ejb.value-object
400      * match="normal"
401      * type="Collection"
402      * relation="external"
403      * compose="hero.interfaces.BnAgentValue"
404      * compose-name="BnAgent"
405      * members="hero.interfaces.BnAgentLocal"
406      * members-name="BnAgent"
407      * @ejb:transaction type="Supports"
408      **/

409     public abstract Collection JavaDoc getBnAgents();
410
411     /**
412     * Specify the Agents of this BnProject
413     *
414     * @param pAgents Agents of this BnProject
415     * @ejb:interface-method view-type="local"
416     * @ejb:transaction type="Required"
417     **/

418     public abstract void setBnAgents(Collection JavaDoc pAgents);
419
420     /**
421      * @return Return the agentedges of the project
422      *
423      * @ejb:interface-method view-type="local"
424      * @ejb:relation name="AgentEdges" role-name="has-agentedges"
425      *
426      * @ejb.value-object
427      * match="normal"
428      * type="Collection"
429      * relation="external"
430      * compose="hero.interfaces.BnAgentEdgeValue"
431      * compose-name="BnAgentEdge"
432      * members="hero.interfaces.BnAgentEdgeLocal"
433      * members-name="BnAgentEdge"
434      * @ejb:transaction type="Supports"
435      **/

436     public abstract Collection JavaDoc getBnAgentEdges();
437
438     /**
439     * Specify the AgentEdges of this BnProject
440     *
441     * @param pAgentEdges AgentEdges of this BnProject
442     * @ejb:interface-method view-type="local"
443     * @ejb:transaction type="Required"
444     **/

445     public abstract void setBnAgentEdges(Collection JavaDoc pAgentEdges);
446
447     /**
448      * @return Return the users of the project
449      *
450      * @ejb:interface-method view-type="local"
451      * @ejb:relation name="Users" role-name="has-users" target-multiple="yes"
452      * @jboss:auto-key-fields
453      * @jonas :automatic-pk="true"
454      * @jboss.relation-table create-table="true" remove-table="false"
455      *
456      * @ejb.value-object
457      * match="normal"
458      * type="Collection"
459      * relation="external"
460      * aggregate="hero.interfaces.BnUserLightValue"
461      * aggregate-name="BnUser"
462      * members="hero.interfaces.BnUserLocal"
463      * members-name="BnUser"
464      * @ejb:transaction type="Supports"
465      **/

466     public abstract Collection JavaDoc getBnUsers();
467
468     /**
469     * Specify the Users of this BnProject
470     *
471     * @param pUsers Users of this BnProject
472     *
473     * @ejb:interface-method view-type="both"
474     * @ejb:transaction type="Required"
475     **/

476     public abstract void setBnUsers(Collection JavaDoc pUsers);
477
478     /**
479      * @return Return the roles of the project
480      *
481      * @ejb:interface-method view-type="local"
482      * @ejb:relation name="ProjectRoles" role-name="has-roles" target-multiple="yes"
483      * @jboss:auto-key-fields
484      * @jonas :automatic-pk="true"
485      * @jboss.relation-table create-table="true" remove-table="false"
486      *
487      * @ejb.value-object
488      * match="normal"
489      * type="Collection"
490      * relation="external"
491      * aggregate="hero.interfaces.BnRoleValue"
492      * aggregate-name="BnRole"
493      * members="hero.interfaces.BnRoleLocal"
494      * members-name="BnRole"
495      * @ejb:transaction type="Supports"
496      **/

497     public abstract Collection JavaDoc getBnRoles();
498
499     /**
500     * Specify the Roles of this BnProject
501     *
502     * @param pRoles Roles of this BnProject
503     *
504     * @ejb:interface-method view-type="local"
505     * @ejb:transaction type="Required"
506     **/

507     public abstract void setBnRoles(Collection JavaDoc pRoles);
508
509     /**
510      * @return Return the creation date of the BnProject
511      * @ejb:interface-method view-type="both"
512      * @ejb:persistence column-name="creationdate"
513      * @ejb:transaction type="Supports"
514      *
515      **/

516     public abstract Date JavaDoc getCreationDate();
517
518     /**
519      * @param pDate the creation date of the BnProject
520      * @ejb:interface-method view-type="both"
521      * @ejb.value-object
522      * match="light"
523      * @ejb:transaction type="Required"
524      *
525      **/

526     public abstract void setCreationDate(Date JavaDoc pDate);
527     
528     /**
529      * @return Return the date in which the BnProject was finished
530      * @ejb:interface-method view-type="both"
531      * @ejb:persistence column-name="enddate"
532      * @ejb:transaction type="Supports"
533      * @ejb.value-object
534      * match="light"
535      *
536      **/

537     public abstract Date JavaDoc getEndDate();
538
539     /**
540      * @param the date in which the BnProject was finished
541      * @ejb:interface-method view-type="both"
542      * @ejb:transaction type="Required"
543      *
544      **/

545     public abstract void setEndDate(Date JavaDoc pDate);
546
547     /**
548      * @param nodeName name of the node to return
549      * @ejb:interface-method view-type="local"
550      * @ejb:transaction type="Supports"
551      *
552      **/

553     public BnNodeLocal getBnNode(String JavaDoc nodeName) throws HeroException {
554         BnNodeLocalHome nodehome;
555         BnNodeLocal node;
556         try {
557             nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
558         } catch (javax.naming.NamingException JavaDoc be) {
559             throw new HeroException(be.getMessage());
560         }
561         try {
562             node = nodehome.findByName(nodeName, this.getId());
563         } catch (FinderException JavaDoc fe) {
564             throw new HeroException("No BnNode with this name");
565         }
566
567         return node;
568     }
569
570     /**
571      * @param AgentName name of the node to return
572      * @ejb:interface-method view-type="local"
573      * @ejb:transaction type="Supports"
574      *
575      **/

576     public BnAgentLocal getBnAgent(String JavaDoc agentName) throws HeroException {
577         BnAgentLocalHome agenthome;
578         BnAgentLocal agent;
579         try {
580             agenthome = hero.interfaces.BnAgentUtil.getLocalHome();
581         } catch (javax.naming.NamingException JavaDoc be) {
582             throw new HeroException(be.getMessage());
583         }
584         try {
585             agent = agenthome.findByName(agentName, this.getId());
586         } catch (FinderException JavaDoc fe) {
587             throw new HeroException("No BnAgent with this name");
588         }
589         return agent;
590     }
591
592     /**
593      * @param edgeName name of the node to return
594      * @ejb:interface-method view-type="local"
595      * @ejb:transaction type="Supports"
596      *
597      **/

598     public BnEdgeLocal getBnEdge(String JavaDoc edgeName) throws HeroException {
599         BnEdgeLocalHome edgehome;
600         BnEdgeLocal edge;
601         try {
602             edgehome = hero.interfaces.BnEdgeUtil.getLocalHome();
603         } catch (javax.naming.NamingException JavaDoc be) {
604             throw new HeroException(be.getMessage());
605         }
606         try {
607             edge = edgehome.findByName(edgeName, this.getId());
608         } catch (FinderException JavaDoc fe) {
609             throw new HeroException("No BnEdge with this name");
610         }
611
612         return edge;
613     }
614
615     /**
616      * @return the properties of the project
617      * @ejb:interface-method view-type="both"
618      * @ejb:relation name="projectprp" role-name="is-property-of"
619      * @jboss:auto-key-fields
620      *
621      * @ejb.value-object
622      * match="normal"
623      * type="Collection"
624      * relation="external"
625      * compose="hero.interfaces.BnProjectPropertyValue"
626      * compose-name="BnPropertie"
627      * members="hero.interfaces.BnProjectPropertyLocal"
628      * members-name="BnPropertie"
629      * @ejb:transaction type="Supports"
630      *
631      **/

632     public abstract Collection JavaDoc getBnProperties();
633
634     /**
635     * Set the properties of the project
636     * @ejb:interface-method view-type="both"
637     * @param pPrp the properties of the project
638     * @ejb:transaction type="Required"
639     **/

640     public abstract void setBnProperties(Collection JavaDoc pPrp);
641     
642
643     /**
644      * @return the iterations of the project
645      * @ejb:interface-method view-type="both"
646      * @ejb:relation name="projectIte" role-name="is-iteration-of"
647      * @jboss:auto-key-fields
648      *
649      * @ejb.value-object
650      * match="normal"
651      * type="Collection"
652      * relation="external"
653      * compose="hero.interfaces.BnIterationLightValue"
654      * compose-name="BnIteration"
655      * members="hero.interfaces.BnIterationLocal"
656      * members-name="BnIteration"
657      * @ejb:transaction type="Supports"
658      *
659      **/

660     public abstract Collection JavaDoc getBnIterations();
661
662     /**
663     * Set the iterations of the project
664     * @ejb:interface-method view-type="both"
665     * @param ite the iterations of the project
666     * @ejb:transaction type="Required"
667     **/

668     public abstract void setBnIterations(Collection JavaDoc ite);
669
670     /**
671      * @return the Hooks of the project
672      * @ejb:interface-method view-type="both"
673      * @ejb:relation name="projecthook" role-name="is-hook-of"
674      * @jboss:auto-key-fields
675      * @jonas :automatic-pk="true"
676      * @ejb.value-object
677      * match="normal"
678      * type="Collection"
679      * relation="external"
680      * compose="hero.interfaces.BnProjectHookValue"
681      * compose-name="BnHook"
682      * members="hero.interfaces.BnProjectHookLocal"
683      * members-name="BnHook"
684      * @ejb:transaction type="Supports"
685      *
686      **/

687     public abstract Collection JavaDoc getBnHooks();
688
689     /**
690     * Set the Hooks of the project
691     * @ejb:interface-method view-type="both"
692     * @param pHooks the Hooks of the project
693     * @ejb:transaction type="Required"
694     **/

695     public abstract void setBnHooks(Collection JavaDoc pHooks);
696
697     /**
698      * @return the Interactives Hooks of the project
699      * @ejb:interface-method view-type="both"
700      * @ejb:relation name="projectinterhook" role-name="is-hook-of"
701      * @jboss:auto-key-fields
702      *
703      * @ejb.value-object
704      * match="normal"
705      * type="Collection"
706      * relation="external"
707      * compose="hero.interfaces.BnProjectInterHookValue"
708      * compose-name="BnInterHook"
709      * members="hero.interfaces.BnProjectInterHookLocal"
710      * members-name="BnInterHook"
711      * @jonas :automatic-pk="true"
712      * @ejb:transaction type="Supports"
713      *
714      **/

715     public abstract Collection JavaDoc getBnInterHooks();
716
717     /**
718     * Set the Interactives Hooks of the project
719     * @ejb:interface-method view-type="both"
720     * @param pHooks the Hooks of the project
721     * @ejb:transaction type="Required"
722     **/

723     public abstract void setBnInterHooks(Collection JavaDoc pHooks);
724
725     /**
726      * @ejb.interface-method
727      * @ejb:transaction type="Supports"
728      */

729     public abstract BnProjectValue getBnProjectValue();
730
731     /**
732      * @returns the light value of the bean (without relationships)
733      * @ejb.interface-method view-type=both
734      */

735     public abstract BnProjectLightValue getBnProjectLightValue();
736
737     /**
738      * @ejb.interface-method
739      * @ejb:transaction type="Required"
740      */

741     public abstract void setBnProjectValue(BnProjectValue v);
742
743
744
745     // -------------------------------------------------------------------------
746
// Framework Callbacks
747
// -------------------------------------------------------------------------
748

749     /**
750     * Create a BnProject
751     *
752     * @throws InvalidValueException If one of the values are not correct,
753     * this will not roll back the transaction
754     * because the caller has the chance to
755     * fix the problem and try again
756     * @throws EJBException If no new unique ID could be retrieved this will
757     * rollback the transaction because there is no
758     * hope to try again
759     * @throws CreateException Because we have to do so (EJB spec.)
760     *
761     * @ejb:create-method view-type="both"
762     * @ejb:transaction type="Required"
763     **/

764     public BnProjectPK ejbCreate()
765         throws InvalidValueException, EJBException JavaDoc, CreateException JavaDoc {
766             // Each title must have a unique id to identify itself within the DB
767
this.setId(hero.interfaces.BnProjectUtil.generateGUID(this));
768
769         // This is only possible in CMPs. Otherwise return a valid PK.
770
return null;
771     }
772
773     /**
774     * Create a BnProject based on project name and creator.
775     *
776     * @param pName the name of the project
777     * @param pCreator the creator of the project
778     *
779     * @throws EJBException If no new unique ID could be retrieved this will
780     * rollback the transaction because there is no
781     * hope to try again
782     * @throws CreateException Because we have to do so (EJB spec.)
783     *
784     * @ejb:create-method view-type="both"
785     * @ejb:transaction type="Required"
786     **/

787     public BnProjectPK ejbCreate(String JavaDoc pName, String JavaDoc creator)
788         throws InvalidValueException, EJBException JavaDoc, CreateException JavaDoc {
789         log.debug("ejbCreate: pName=" + pName + " creator=" + creator);
790         BnProjectLocalHome projecthome;
791         BnProjectLocal project;
792
793         try {
794             projecthome = hero.interfaces.BnProjectUtil.getLocalHome();
795         } catch (javax.naming.NamingException JavaDoc be) {
796             throw new CreateException JavaDoc(be.getMessage());
797         }
798         try {
799             project = projecthome.findByName(pName);
800             throw new CreateException JavaDoc("BnProject " + pName + " already exist");
801         } catch (FinderException JavaDoc fe) {
802             this.setId(hero.interfaces.BnAgentUtil.generateGUID(this));
803                         
804             try{
805                 SequenceGeneratorHome sgHome = SequenceGeneratorUtil.getHome();
806                 SequenceGenerator sg = sgHome.create();
807                 
808                 this.setId(new Integer JavaDoc(sg.getNextNumber("BnProject")).toString());
809                 
810                 if (pName.matches(".*_instance.*"))
811                     this.setName(pName+this.getId());
812                 else
813                     this.setName(pName);
814                 this.setCreator(creator);
815                 
816             }catch ( NamingException JavaDoc ne ) {
817                 throw new CreateException JavaDoc( "Naming lookup failure: " + ne.getMessage() );
818             }catch ( RemoteException JavaDoc re ) {
819                 throw new CreateException JavaDoc(re.getMessage() );
820             }
821         }
822
823         // This is only possible in CMPs. Otherwise return a valid PK.
824
return null;
825     }
826     
827     public void setEntityContext(EntityContext JavaDoc lContext) {
828         mContext = lContext;
829     }
830
831     public void unsetEntityContext() {
832         mContext = null;
833     }
834
835     public void ejbActivate() {
836     }
837
838     public void ejbPassivate() {
839     }
840
841     public void ejbLoad() {
842     }
843
844     public void ejbStore() {
845     }
846
847     public void ejbRemove() throws RemoveException JavaDoc {
848     }
849 }
850
Popular Tags