KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > session > UserSessionBean


1 package hero.session;
2 /*
3  * 01/02/2004 - 16:36:12
4  *
5  * UserSessionEJB.java -
6  * Copyright (C) 2004 Ecoo Team
7  * valdes@loria.fr
8  *
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  */

24 import hero.interfaces.BnNodeLocal;
25 import hero.interfaces.BnNodeLocalHome;
26 import hero.interfaces.BnNodeUtil;
27 import hero.interfaces.BnNodeValue;
28 import hero.interfaces.BnProjectLocal;
29 import hero.interfaces.BnProjectLightValue;
30 import hero.interfaces.BnProjectLocalHome;
31 import hero.interfaces.BnProjectUtil;
32 import hero.interfaces.BnProjectValue;
33 import hero.interfaces.BnUserLightValue;
34 import hero.interfaces.BnUserLocal;
35 import hero.interfaces.BnUserLocalHome;
36 import hero.interfaces.BnUserPropertyLocal;
37 import hero.interfaces.BnUserPropertyLocalHome;
38 import hero.interfaces.BnUserPropertyUtil;
39 import hero.interfaces.BnUserValue;
40 import hero.interfaces.EngineLocal;
41 import hero.interfaces.EngineLocalHome;
42 import hero.interfaces.InvalidValueException;
43 import hero.interfaces.ProjectSessionLocal;
44 import hero.interfaces.ProjectSessionLocalHome;
45 import hero.interfaces.ProjectSessionUtil;
46 import hero.interfaces.JMSServicesSessionUtil;
47 import hero.interfaces.JMSServicesSessionLocalHome;
48 import hero.interfaces.JMSServicesSessionLocal;
49 import hero.interfaces.UserServiceLocal;
50 import hero.interfaces.UserServiceLocalHome;
51 import hero.util.BonitaConfig;
52 import hero.historic.BonitaTransfer;
53 import hero.util.EngineException;
54 import hero.util.HeroException;
55 import hero.util.EventConstants;
56 import hero.interfaces.Constants;
57
58 import java.util.ArrayList JavaDoc;
59 import java.util.Map JavaDoc;
60 import java.util.Arrays JavaDoc;
61 import java.util.Collection JavaDoc;
62 import java.util.Iterator JavaDoc;
63 import java.util.Hashtable JavaDoc;
64 import java.util.Enumeration JavaDoc;
65
66 import javax.ejb.CreateException JavaDoc;
67 import javax.ejb.EJBException JavaDoc;
68 import javax.ejb.FinderException JavaDoc;
69 import javax.ejb.RemoveException JavaDoc;
70 import javax.ejb.SessionBean JavaDoc;
71 import javax.ejb.SessionContext JavaDoc;
72
73 import org.apache.log4j.Logger;
74
75 /**
76  *
77  * The User Session Bean, is an stateful session bean that provides the user API to get information on
78  * Todo list and started activities and to produce events on activities (start, terminate, cancel).<br>
79  * This Session Bean is based on Engine Session Bean: a recursive implementation that manage the previous execution operations
80  * and propagates the activity state changes to the activities that are connected to this one.
81  *<br><br>
82  * The User Session Bean API provides information about user projects and activites (project list,
83  * todo list and activity list) and also useful information about project instances or user
84  * preferences. With this API users can performs his task/activities by using start, terminate and
85  * cancel methods and also terminates workflow processes.
86  * <br><br>
87  * <strong>The following lines shows a sample code to use this API in your application:<br><br></strong>
88  * <br>
89  * First of all you have to import the User Session files:<br>
90  * <br>
91  * import hero.interfaces.UserSessionLocalHome;<br>
92  * import hero.interfaces.UserSessionLocal;<br>
93  * import hero.interfaces.UserSessionHome;<br>
94  * import hero.interfaces.UserSession;<br>
95  * import hero.interfaces.UserSessionUtil;<br>
96  * <br>
97  * Now, it is time to create the User Session instance:<br>
98  * <br>
99  * Like this if you want to use local interfaces:<br><br>
100  * UserSessionLocalHome userh = (UserSessionLocalHome)hero.interfaces.UserSessionUtil.getLocalHome();<br>
101  * UserSessionLocal usersession = userh.create();<br>
102  * <br>
103  * or like this if you use remote interfaces:<br>
104  * <br>
105  * UserSessionHome userh = (UserSessionHome)hero.interfaces.UserSessionUtil.getHome();<br>
106  * UserSession usersession = userh.create();<br>
107  * <br>
108  * <br>
109  * Now you can call all User Sessions methods...
110  *
111  *
112  * @ejb:bean name="UserSession"
113  * display-name="UserSession Bean"
114  * type="Stateless"
115  * transaction-type="Container"
116  * jndi-name="ejb/hero/UserSession"
117  * local-jndi-name="ejb/hero/UserSession_L"
118  *
119  * @ejb:ejb-ref ejb-name="BnUser"
120  * ref-name="myhero/BnUser"
121  * @ejb.permission role-name="BONITAUSER,user,SuperAdmin"
122  *
123  *
124  * @jonas.bean
125  * ejb-name="UserSession"
126  * jndi-name="ejb/hero/UserSession"
127  *
128  *
129  *
130  * @copyright INRIA
131  * @author Miguel Valdes
132  **/

133
134 public class UserSessionBean implements SessionBean JavaDoc, EventConstants {
135     
136     // -------------------------------------------------------------------------
137
// Static
138
// -------------------------------------------------------------------------
139
// Utility variable
140
private static final Logger trace = Logger.getLogger(UserSessionBean.class);
141     
142     // -------------------------------------------------------------------------
143
// Members
144
// -------------------------------------------------------------------------
145

146     private SessionContext JavaDoc mContext;
147     private BonitaConfig bonitaConfig;
148     
149     // -------------------------------------------------------------------------
150
// Methods
151
// -------------------------------------------------------------------------
152

153     /**
154      * Get user project list. Workflow processes associated to this user (models/cooperative/instances)
155      * @return a Collection of BnProjectLightValue objects - the projects list of the user
156      * @throws HeroException
157      * @ejb:interface-method view-type="both"
158      * @ejb:transaction type="Supports"
159      *
160      **/

161     public Collection JavaDoc getProjectList() throws HeroException {
162         Collection JavaDoc pjts = new ArrayList JavaDoc();
163         Collection JavaDoc pva;
164         try{
165             this.synchronizeUser();
166             BnUserLocalHome userhome = hero.interfaces.BnUserUtil.getLocalHome();
167             BnUserLocal mUser = userhome.findByName(mContext.getCallerPrincipal().getName());
168             trace.info("start by " + mContext.getCallerPrincipal().getName());
169             BnUserValue uv = mUser.getBnUserValue();
170             pva = new ArrayList JavaDoc(Arrays.asList(uv.getBnProjects()));
171         } catch (javax.naming.NamingException JavaDoc ne) {
172             trace.error(ne.getMessage());
173             throw new HeroException(ne.getMessage());
174         } catch (javax.ejb.FinderException JavaDoc fe) {
175             trace.error(mContext.getCallerPrincipal().getName() + " does not exists " + fe.getMessage());
176             throw new HeroException(mContext.getCallerPrincipal().getName() + " does not exists");
177         }
178         return pva;
179     }
180     /**
181      * Get project list names for this user (models/cooperative/instances)
182      * @return a String Collection - the projects list names of the user
183      * @throws HeroException
184      * @ejb:interface-method view-type="both"
185      * @ejb:transaction type="Supports"
186      *
187      **/

188     public Collection JavaDoc getProjectListNames() throws HeroException {
189         trace.info("start by " + mContext.getCallerPrincipal().getName());
190         //Collection projects = null;
191
Collection JavaDoc projectsNames;
192         try{
193             this.synchronizeUser();
194             BnUserLocalHome userhome = hero.interfaces.BnUserUtil.getLocalHome();
195             BnUserLocal mUser = userhome.findByName(mContext.getCallerPrincipal().getName());
196             //projects = mUser.getBnProjects();
197
BnUserValue uv = mUser.getBnUserValue();
198             Collection JavaDoc pva = new ArrayList JavaDoc(Arrays.asList(uv.getBnProjects()));
199             projectsNames = new ArrayList JavaDoc();
200             Iterator JavaDoc i = pva.iterator();
201             while (i.hasNext())
202                 projectsNames.add(((hero.interfaces.BnProjectLightValue) i.next()).getName());
203         } catch (javax.naming.NamingException JavaDoc ne) {ne.printStackTrace();
204             trace.error(ne.getMessage());
205             throw new HeroException(ne.getMessage());
206         } catch (javax.ejb.FinderException JavaDoc fe) {fe.printStackTrace();
207             trace.error(mContext.getCallerPrincipal().getName() + " does not exists " + fe.getMessage());
208             throw new HeroException(mContext.getCallerPrincipal().getName() + " does not exists");
209         }
210         return projectsNames;
211     }
212     
213     /**
214      * Get user instances list. This method is equivalent to getProjectList but
215      * it only returns the current instances of the user.
216      * @return a Collection of BnProjectLightValue objects - the projects list of the user
217      * @throws HeroException
218      * @ejb:interface-method view-type="both"
219      * @ejb:transaction type="Supports"
220      *
221      **/

222     public Collection JavaDoc getInstancesList() throws HeroException {
223         trace.info("start by " + mContext.getCallerPrincipal().getName());
224         this.synchronizeUser();
225         Collection JavaDoc instances = new ArrayList JavaDoc();
226         Collection JavaDoc pva = this.getProjectList();
227         Iterator JavaDoc ps = pva.iterator();
228         
229         while (ps.hasNext())
230         {
231             BnProjectLightValue pro = (BnProjectLightValue)ps.next();
232             if (pro.getType().equals(Constants.Pj.INSTANCE))
233                 instances.add(pro);
234         }
235         return instances;
236     }
237     
238     /**
239      * Get user model list. This method is equivalent to getProjectList but
240      * it only returns the current models of the user.
241      * @return a Collection of BnProjectLightValue objects - the model list of the user
242      * @throws HeroException
243      * @ejb:interface-method view-type="both"
244      * @ejb:transaction type="Supports"
245      *
246      **/

247     public Collection JavaDoc getModelList() throws HeroException {
248         trace.info("start by " + mContext.getCallerPrincipal().getName());
249         this.synchronizeUser();
250         Collection JavaDoc models = new ArrayList JavaDoc();
251         Collection JavaDoc pva = this.getProjectList();
252         Iterator JavaDoc ps = pva.iterator();
253         
254         while (ps.hasNext())
255         {
256             BnProjectLightValue pro = (BnProjectLightValue)ps.next();
257             if (pro.getType().equals(Constants.Pj.MODEL))
258                 models.add(pro);
259         }
260         return models;
261     }
262     
263     /**
264      * Get available workflow models. This method will be improved with users restrictions
265      * @return a Collection of BnProjectLightValue objects - the model list to be instantiated
266      * @throws HeroException
267      * @ejb:interface-method view-type="both"
268      * @ejb:transaction type="Supports"
269      *
270      **/

271     public Collection JavaDoc getModels() throws HeroException {
272         trace.info("start by " + mContext.getCallerPrincipal().getName());
273         this.synchronizeUser();
274         BnProjectLocalHome projhome;
275         BnProjectLocal project;
276         Collection JavaDoc models = new ArrayList JavaDoc();
277         Collection JavaDoc pva = null;
278         try {
279             projhome = hero.interfaces.BnProjectUtil.getLocalHome();
280         } catch (javax.naming.NamingException JavaDoc be) {
281             throw new HeroException(be.getMessage());
282         }
283         try {
284             pva = projhome.findModels(Constants.Pj.MODEL);
285         } catch (FinderException JavaDoc fe) {
286             throw new HeroException("Error in findByModels: "+fe.getMessage());
287         }
288         Iterator JavaDoc ps = pva.iterator();
289         while (ps.hasNext())
290         {
291             BnProjectLocal pro = (BnProjectLocal)ps.next();
292             models.add(pro.getBnProjectLightValue());
293         }
294         return models;
295     }
296     
297     /**
298      * Get user cooperative projects list. This method is equivalent to getProjectList but
299      * it only returns the current cooperative projects of the user.
300      * @return a Collection of BnProjectLightValue objects - the cooperative projects list of the user
301      * @throws HeroException
302      * @ejb:interface-method view-type="both"
303      * @ejb:transaction type="Supports"
304      *
305      **/

306     public Collection JavaDoc getCooperativeList() throws HeroException {
307         trace.info("start by " + mContext.getCallerPrincipal().getName());
308         this.synchronizeUser();
309         Collection JavaDoc coo = new ArrayList JavaDoc();
310         Collection JavaDoc pva = this.getProjectList();
311         Iterator JavaDoc ps = pva.iterator();
312         
313         while (ps.hasNext())
314         {
315             BnProjectLightValue pro = (BnProjectLightValue)ps.next();
316             if (pro.getType().equals(Constants.Pj.COOPERATIVE))
317                 coo.add(pro);
318         }
319         return coo;
320     }
321     
322     /**
323      * Get instances list names for this user. This method is equivalent to getProjectListNames but
324      * it only returns the current instances of the user.
325      * @return a String Collection - the projects list names of the user
326      * @throws HeroException
327      * @ejb:interface-method view-type="both"
328      * @ejb:transaction type="Supports"
329      *
330      **/

331     public Collection JavaDoc getInstancesListNames() throws HeroException {
332         trace.info("start by " + mContext.getCallerPrincipal().getName());
333         this.synchronizeUser();
334         Collection JavaDoc instances = new ArrayList JavaDoc();
335         Collection JavaDoc pva = this.getProjectList();
336         Iterator JavaDoc ps = pva.iterator();
337         while (ps.hasNext())
338         {
339             BnProjectLightValue pro = (BnProjectLightValue)ps.next();
340             if (pro.getName().matches(".*_instance.*"))
341                 instances.add(pro.getName());
342         }
343         return instances;
344     }
345     
346     /**
347      * Delete a Workflow project
348      * @param projectName the name of the project
349      * @throws HeroException
350      * @ejb:interface-method view-type="both"
351      * @ejb:transaction type="Required"
352      *
353      **/

354     public void removeProject(String JavaDoc projectName) throws HeroException {
355         if (this.getProjectConfigTrace(projectName))
356             trace.info("parameter: projectName=" + projectName + " start by " + mContext.getCallerPrincipal().getName());
357         if (this.isAdmin(projectName))
358             this.deleteProject(projectName);
359         else
360             throw new HeroException("Error in delete project: only admin users are allowed to removed it !!");
361     }
362     
363     /**
364      * Obtain all user activities from specific project (ready and anticipable state)
365      * @param projectName the name of the project
366      * @return a String Collection - the list of todo activities of the user for a project
367      * @throws HeroException
368      * @ejb:interface-method view-type="both"
369      * @ejb:transaction type="Supports"
370      *
371      **/

372     public Collection JavaDoc getToDoList(String JavaDoc projectName) throws HeroException {
373         if (this.getProjectConfigTrace(projectName))
374             trace.info("parameter: projectName=" + projectName + " start by " + mContext.getCallerPrincipal().getName());
375         BnProjectLocalHome projhome;
376         BnProjectLocal project;
377         BnNodeLocalHome nodehome;
378         Collection JavaDoc ready;
379         this.synchronizeUser();
380         try {
381             projhome = BnProjectUtil.getLocalHome();
382             nodehome = BnNodeUtil.getLocalHome();
383         } catch (javax.naming.NamingException JavaDoc ne) {
384             if (this.getProjectConfigTrace(projectName))
385                 trace.error(ne.getMessage());
386             throw new HeroException(ne.getMessage());
387         }
388         try {
389             project = projhome.findByName(projectName);
390         } catch (FinderException JavaDoc fe) {
391             if (this.getProjectConfigTrace(projectName))
392                 trace.error("BnProject " + projectName + " does not exists " + fe.getMessage());
393             throw new HeroException("BnProject " + projectName + " does not exists");
394         }
395         try {
396             ready = nodehome.findUserReady(project.getId(), mContext.getCallerPrincipal().getName());
397         } catch (FinderException JavaDoc fe) {
398             if (this.getProjectConfigTrace(projectName))
399                 trace.error(fe.getMessage());
400             ready = new ArrayList JavaDoc();
401         }
402         ArrayList JavaDoc result = new ArrayList JavaDoc();
403         for (Iterator JavaDoc i = ready.iterator(); i.hasNext();) {
404             BnNodeLocal nd = (BnNodeLocal) i.next();
405             if (this.getProjectConfigTrace(projectName))
406                 trace.info("NODE NAME=" + nd.getName());
407             result.add(nd.getName());
408         }
409         return result;
410     }
411     
412     /**
413      * Obtain all user activities from specific project (executing and anticipating state)
414      *
415      * @param projectName the name of the project
416      * @return a String Collectio - the list of active activities of the user for a project
417      * @throws HeroException
418      * @ejb:interface-method view-type="both"
419      * @ejb:transaction type="Supports"
420      *
421      **/

422     public Collection JavaDoc getActivityList(String JavaDoc projectName)
423     throws HeroException {
424         BnProjectLocalHome projhome;
425         BnProjectLocal project;
426         BnNodeLocalHome nodehome;
427         Collection JavaDoc executing;
428         this.synchronizeUser();
429         if (this.getProjectConfigTrace(projectName))
430             trace.info("parameter: -begin projectName=" + projectName + " start by " + mContext.getCallerPrincipal().getName());
431         try {
432             projhome = BnProjectUtil.getLocalHome();
433             nodehome = BnNodeUtil.getLocalHome();
434         } catch (javax.naming.NamingException JavaDoc ne) {
435             if (this.getProjectConfigTrace(projectName))
436                 trace.error(ne.getMessage());
437             throw new HeroException(ne.getMessage());
438         }
439         try {
440             project = projhome.findByName(projectName);
441         } catch (FinderException JavaDoc fe) {
442             if (this.getProjectConfigTrace(projectName))
443                 trace.error("BnProject " + projectName + " does not exists " + fe.getMessage());
444             throw new HeroException("BnProject " + projectName + " does not exists");
445         }
446         try {
447             executing =
448                 nodehome.findUserExecuting(project.getId(), mContext.getCallerPrincipal().getName());
449         } catch (FinderException JavaDoc fe) {
450             if (this.getProjectConfigTrace(projectName))
451                 trace.error(fe.getMessage());
452             executing = new ArrayList JavaDoc();
453         }
454         ArrayList JavaDoc result = new ArrayList JavaDoc();
455         for (Iterator JavaDoc i = executing.iterator(); i.hasNext();) {
456             BnNodeLocal nd = (BnNodeLocal) i.next();
457             result.add(nd.getName());
458         }
459         return result;
460     }
461     
462     /**
463      * Obtain todo user activities for all instances/cooperative projects (ready and anticipable state)
464      * @return a BnNodeValue Collection - the list of todo activities of the user for all instances
465      * @throws HeroException
466      * @ejb:interface-method view-type="both"
467      * @ejb:transaction type="Supports"
468      *
469      **/

470     public Collection JavaDoc getToDoListAllInstances() throws HeroException {
471         trace.info(" start by " + mContext.getCallerPrincipal().getName());
472         BnNodeLocalHome nodehome;
473         Collection JavaDoc ready;
474         this.synchronizeUser();
475         try {
476             nodehome = BnNodeUtil.getLocalHome();
477         } catch (javax.naming.NamingException JavaDoc ne) {
478             trace.error(ne.getMessage());
479             throw new HeroException(ne.getMessage());
480         }
481         try {
482             ready = nodehome.findUserReadyAllProjects(mContext.getCallerPrincipal().getName());
483         } catch (FinderException JavaDoc fe) {
484             trace.error(fe.getMessage());
485             ready = new ArrayList JavaDoc();
486         }
487         ArrayList JavaDoc result = new ArrayList JavaDoc();
488         for (Iterator JavaDoc i = ready.iterator(); i.hasNext();) {
489             BnNodeLocal nd = (BnNodeLocal) i.next();
490             if (nd.getBnProject().getType().equals(Constants.Pj.INSTANCE) || nd.getBnProject().getType().equals(Constants.Pj.COOPERATIVE))
491                 result.add(nd.getBnNodeValue());
492         }
493         return result;
494     }
495     
496     /**
497      * Obtain executing user activities for all instances/cooperative projects (executing and anticipating state)
498      * @return a BnNodeValue Collection - the list of executing activities ot the user for all instances
499      * @throws HeroException
500      * @ejb:interface-method view-type="both"
501      * @ejb:transaction type="Supports"
502      *
503      **/

504     public Collection JavaDoc getActivityListAllInstances() throws HeroException {
505         trace.info(" start by " + mContext.getCallerPrincipal().getName());
506         BnNodeLocalHome nodehome;
507         Collection JavaDoc executing;
508         this.synchronizeUser();
509         try {
510             nodehome = BnNodeUtil.getLocalHome();
511         } catch (javax.naming.NamingException JavaDoc ne) {
512             trace.error(ne.getMessage());
513             throw new HeroException(ne.getMessage());
514         }
515         try {
516             executing = nodehome.findUserExecutingAllProjects(mContext.getCallerPrincipal().getName());
517         } catch (FinderException JavaDoc fe) {
518             trace.error(fe.getMessage());
519             executing = new ArrayList JavaDoc();
520         }
521         ArrayList JavaDoc result = new ArrayList JavaDoc();
522         for (Iterator JavaDoc i = executing.iterator(); i.hasNext();) {
523             BnNodeLocal nd = (BnNodeLocal) i.next();
524             if (nd.getBnProject().getType().equals(Constants.Pj.INSTANCE) || nd.getBnProject().getType().equals(Constants.Pj.COOPERATIVE))
525                 result.add(nd.getBnNodeValue());
526         }
527         return result;
528     }
529     
530     /**
531      * Obtain terminated user activities for all instances/cooperative projects.
532      * @return a BnNodeValue Collection - the list of terminated activities ot the user for all instances
533      * @throws HeroException
534      * @ejb:interface-method view-type="both"
535      * @ejb:transaction type="Supports"
536      *
537      **/

538     public Collection JavaDoc getTerminatedListAllInstances() throws HeroException {
539         trace.info(" start by " + mContext.getCallerPrincipal().getName());
540         BnNodeLocalHome nodehome;
541         Collection JavaDoc executing;
542         this.synchronizeUser();
543         try {
544             nodehome = BnNodeUtil.getLocalHome();
545         } catch (javax.naming.NamingException JavaDoc ne) {
546             trace.error(ne.getMessage());
547             throw new HeroException(ne.getMessage());
548         }
549         try {
550             executing = nodehome.findUserTerminatedAllProjects(mContext.getCallerPrincipal().getName());
551         } catch (FinderException JavaDoc fe) {
552             trace.error(fe.getMessage());
553             executing = new ArrayList JavaDoc();
554         }
555         ArrayList JavaDoc result = new ArrayList JavaDoc();
556         for (Iterator JavaDoc i = executing.iterator(); i.hasNext();) {
557             BnNodeLocal nd = (BnNodeLocal) i.next();
558             if (nd.getBnProject().getType().equals(Constants.Pj.INSTANCE) || nd.getBnProject().getType().equals(Constants.Pj.COOPERATIVE))
559                 result.add(nd.getBnNodeValue());
560         }
561         return result;
562     }
563     
564     
565     /**
566      * Obtain todo user activities matching with project property value (ready and anticipable state activities)
567      * @return a BnNodeValue Collection - the list of todo activities matching to project property value
568      * @param key the key of the property
569      * @param value the value of the property
570      *
571      * @throws HeroException
572      * @ejb:interface-method view-type="both"
573      * @ejb:transaction type="Supports"
574      *
575      **/

576     public Collection JavaDoc getToDoListByProperty(String JavaDoc key, String JavaDoc value) throws HeroException {
577         trace.info(" start by " + mContext.getCallerPrincipal().getName());
578         BnNodeLocalHome nodehome;
579         Collection JavaDoc ready;
580         this.synchronizeUser();
581         try {
582             nodehome = BnNodeUtil.getLocalHome();
583         } catch (javax.naming.NamingException JavaDoc ne) {
584             trace.error(ne.getMessage());
585             throw new HeroException(ne.getMessage());
586         }
587         try {
588             ready = nodehome.findUserReadyAllProjectsByProperty(mContext.getCallerPrincipal().getName(),key,value);
589         } catch (FinderException JavaDoc fe) {
590             trace.error(fe.getMessage());
591             ready = new ArrayList JavaDoc();
592         }
593         ArrayList JavaDoc result = new ArrayList JavaDoc();
594         for (Iterator JavaDoc i = ready.iterator(); i.hasNext();) {
595             BnNodeLocal nd = (BnNodeLocal) i.next();
596             if (nd.getBnProject().getName().matches(".*_instance.*"))
597                 result.add(nd.getBnNodeValue());
598         }
599         return result;
600     }
601     
602     /**
603      * Obtain todo user activities matching with project properties (ready and anticipable state activities)
604      * @return a BnNodeValue Collection - the list of todo activities matching to property value. This method
605      * is oriented to administrative workflow (workflow instances) and supports one, two or three properties (key/value pairs).
606      * Operation constants values: hero.interfaces.Constants.AND, hero.interfaces.Constants.OR
607      *
608      * @param operation AND/OR operations are allowed.
609      * @param properties Hashtable containing the key/value elements
610      *
611      * @throws HeroException
612      * @ejb:interface-method view-type="both"
613      * @ejb:transaction type="Supports"
614      *
615      **/

616     public Collection JavaDoc getToDoListByProperties(int operation, Hashtable JavaDoc properties) throws HeroException {
617         trace.info(" start by " + mContext.getCallerPrincipal().getName());
618         BnNodeLocalHome nodehome;
619         Collection JavaDoc ready = new ArrayList JavaDoc();
620         this.synchronizeUser();
621         try {
622             nodehome = BnNodeUtil.getLocalHome();
623         } catch (javax.naming.NamingException JavaDoc ne) {
624             trace.error(ne.getMessage());
625             throw new HeroException(ne.getMessage());
626         }
627         try {
628             Enumeration JavaDoc keys = properties.keys();
629             Collection JavaDoc vls = properties.values();
630             Iterator JavaDoc values = vls.iterator();
631             if (properties.size() >3)
632             {
633                 throw new HeroException("This method uses EJBQL language to improve queries. These queries are based " +
634                 "on static parameters numbers, so if you want use this method with more than three properties contact us !!");
635             }
636             if (properties.size() == 1)
637                 ready = nodehome.findUserReadyAllProjectsByProperty(mContext.getCallerPrincipal().getName(),(String JavaDoc)keys.nextElement(),(String JavaDoc)values.next());
638             if (operation == Constants.AND)
639             {
640                 if (properties.size() == 2)
641                     ready = nodehome.findUserReadyAllProjectsByTwoPropertiesAND(mContext.getCallerPrincipal().getName(),(String JavaDoc)keys.nextElement(),(String JavaDoc)values.next(),(String JavaDoc)keys.nextElement(),(String JavaDoc)values.next());
642                 else if (properties.size() == 3)
643                     ready = nodehome.findUserReadyAllProjectsByThreePropertiesAND(mContext.getCallerPrincipal().getName(),(String JavaDoc)keys.nextElement(),(String JavaDoc)values.next(),(String JavaDoc)keys.nextElement(),(String JavaDoc)values.next(),(String JavaDoc)keys.nextElement(),(String JavaDoc)values.next());
644             }
645             else if (operation == Constants.OR)
646             {
647                 if (properties.size() == 2)
648                     ready = nodehome.findUserReadyAllProjectsByTwoPropertiesOR(mContext.getCallerPrincipal().getName(),(String JavaDoc)keys.nextElement(),(String JavaDoc)values.next(),(String JavaDoc)keys.nextElement(),(String JavaDoc)values.next());
649                 else if (properties.size() == 3)
650                     ready = nodehome.findUserReadyAllProjectsByThreePropertiesOR(mContext.getCallerPrincipal().getName(),(String JavaDoc)keys.nextElement(),(String JavaDoc)values.next(),(String JavaDoc)keys.nextElement(),(String JavaDoc)values.next(),(String JavaDoc)keys.nextElement(),(String JavaDoc)values.next());
651             }
652         } catch (FinderException JavaDoc fe) {
653             trace.error(fe.getMessage());
654             ready = new ArrayList JavaDoc();
655         }
656         ArrayList JavaDoc result = new ArrayList JavaDoc();
657         for (Iterator JavaDoc i = ready.iterator(); i.hasNext();) {
658             BnNodeLocal nd = (BnNodeLocal) i.next();
659             if (nd.getBnProject().getName().matches(".*_instance.*"))
660                 result.add(nd.getBnNodeValue());
661         }
662         return result;
663     }
664     
665     /**
666      * Obtain todo user activities matching with activity property value (ready and anticipable state activities)
667      * @return a BnNodeValue Collection - the list of todo activities matching to activity property value
668      * @param key the key of the property
669      * @param value the value of the property
670      *
671      * @throws HeroException
672      * @ejb:interface-method view-type="both"
673      * @ejb:transaction type="Supports"
674      *
675      **/

676     public Collection JavaDoc getToDoListByActivityProperty(String JavaDoc key, String JavaDoc value) throws HeroException {
677         trace.info(" start by " + mContext.getCallerPrincipal().getName());
678         BnNodeLocalHome nodehome;
679         Collection JavaDoc ready;
680         this.synchronizeUser();
681         try {
682             nodehome = BnNodeUtil.getLocalHome();
683         } catch (javax.naming.NamingException JavaDoc ne) {
684             trace.error(ne.getMessage());
685             throw new HeroException(ne.getMessage());
686         }
687         try {
688             ready = nodehome.findUserReadyAllActivitiesByProperty(mContext.getCallerPrincipal().getName(),key,value);
689         } catch (FinderException JavaDoc fe) {
690             trace.error(fe.getMessage());
691             ready = new ArrayList JavaDoc();
692         }
693         ArrayList JavaDoc result = new ArrayList JavaDoc();
694         for (Iterator JavaDoc i = ready.iterator(); i.hasNext();) {
695             BnNodeLocal nd = (BnNodeLocal) i.next();
696             if (nd.getBnProject().getName().matches(".*_instance.*"))
697                 result.add(nd.getBnNodeValue());
698         }
699         return result;
700     }
701     
702     /**
703      * Obtain executing user activities matching with property value (executing and anticipating state activities)
704      * @return a BnNodeValue Collection - the list of executing activities matching to property value
705      * @param key the key of the property
706      * @param value the value of the property
707      *
708      * @throws HeroException
709      * @ejb:interface-method view-type="both"
710      * @ejb:transaction type="Supports"
711      *
712      **/

713     public Collection JavaDoc getActivityListByProperty(String JavaDoc key, String JavaDoc value) throws HeroException {
714         trace.info(" start by " + mContext.getCallerPrincipal().getName());
715         BnNodeLocalHome nodehome;
716         Collection JavaDoc executing;
717         this.synchronizeUser();
718         try {
719             nodehome = BnNodeUtil.getLocalHome();
720         } catch (javax.naming.NamingException JavaDoc ne) {
721             trace.error(ne.getMessage());
722             throw new HeroException(ne.getMessage());
723         }
724         try {
725             executing = nodehome.findUserExecutingAllProjectsByProperty(mContext.getCallerPrincipal().getName(),key,value);
726         } catch (FinderException JavaDoc fe) {
727             trace.error(fe.getMessage());
728             executing = new ArrayList JavaDoc();
729         }
730         ArrayList JavaDoc result = new ArrayList JavaDoc();
731         for (Iterator JavaDoc i = executing.iterator(); i.hasNext();) {
732             BnNodeLocal nd = (BnNodeLocal) i.next();
733             if (nd.getBnProject().getName().matches(".*_instance.*"))
734                 result.add(nd.getBnNodeValue());
735         }
736         return result;
737     }
738     /**
739      * Get workflow instances names of this project
740      *
741      * @param projectName the name of the project
742      * @return a String Collection - the names of project instances
743      * @throws HeroException
744      * @ejb:interface-method view-type="both"
745      * @ejb:transaction type="Supports"
746      *
747      **/

748     public Collection JavaDoc getProjectInstancesNames(String JavaDoc projectName)
749     throws