Source Code Cross Referenced for UserSessionBean.java in  » Workflow-Engines » bonita-v3.1 » hero » session » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » bonita v3.1 » hero.session 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        package hero.session;
0002:
0003:        /*
0004:         * 01/02/2004 - 16:36:12
0005:         *
0006:         * UserSessionEJB.java - 
0007:         * Copyright (C) 2004 Ecoo Team
0008:         * valdes@loria.fr
0009:         * 
0010:         *
0011:         * This program is free software; you can redistribute it and/or
0012:         * modify it under the terms of the GNU Lesser General Public License
0013:         * as published by the Free Software Foundation; either version 2
0014:         * of the License, or (at your option) any later version.
0015:         *
0016:         * This program is distributed in the hope that it will be useful,
0017:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
0018:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0019:         * GNU Lesser General Public License for more details.
0020:         *
0021:         * You should have received a copy of the GNU Lesser General Public License
0022:         * along with this program; if not, write to the Free Software
0023:         * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
0024:         */
0025:        import hero.interfaces.BnInitiatorMapperLocal;
0026:        import hero.interfaces.BnNodeLocal;
0027:        import hero.interfaces.BnNodeLocalHome;
0028:        import hero.interfaces.BnNodeUtil;
0029:        import hero.interfaces.BnNodeValue;
0030:        import hero.interfaces.BnNodePK;
0031:        import hero.interfaces.BnProjectLocal;
0032:        import hero.interfaces.BnProjectLightValue;
0033:        import hero.interfaces.BnProjectLocalHome;
0034:        import hero.interfaces.BnProjectUtil;
0035:        import hero.interfaces.BnProjectValue;
0036:        import hero.interfaces.BnProjectPK;
0037:        import hero.interfaces.BnRoleLocal;
0038:        import hero.interfaces.BnUserLightValue;
0039:        import hero.interfaces.BnUserLocal;
0040:        import hero.interfaces.BnUserLocalHome;
0041:        import hero.interfaces.BnUserPropertyLocal;
0042:        import hero.interfaces.BnUserPropertyLocalHome;
0043:        import hero.interfaces.BnUserPropertyUtil;
0044:        import hero.interfaces.BnUserValue;
0045:        import hero.interfaces.DeadlineEjbTimerSessionLocal;
0046:        import hero.interfaces.DeadlineEjbTimerSessionLocalHome;
0047:        import hero.interfaces.DeadlineEjbTimerSessionUtil;
0048:        import hero.interfaces.EngineLocal;
0049:        import hero.interfaces.EngineLocalHome;
0050:        import hero.interfaces.InvalidValueException;
0051:        import hero.interfaces.ProjectSessionLocal;
0052:        import hero.interfaces.ProjectSessionLocalHome;
0053:        import hero.interfaces.ProjectSessionUtil;
0054:        import hero.interfaces.JMSServicesSessionUtil;
0055:        import hero.interfaces.JMSServicesSessionLocalHome;
0056:        import hero.interfaces.JMSServicesSessionLocal;
0057:        import hero.interfaces.UserServiceLocal;
0058:        import hero.interfaces.UserServiceLocalHome;
0059:        import hero.util.BonitaConfig;
0060:        import hero.historic.BonitaTransfer;
0061:        import hero.util.AdminException;
0062:        import hero.util.BonitaProjectLocator;
0063:        import hero.util.BonitaServiceException;
0064:        import hero.util.EngineException;
0065:        import hero.util.HeroException;
0066:        import hero.util.EventConstants;
0067:        import hero.interfaces.Constants;
0068:        import hero.util.values.BonitaHookValue;
0069:        import hero.util.values.BonitaProjectValue;
0070:
0071:        import java.util.ArrayList;
0072:        import java.util.Date;
0073:        import java.util.Map;
0074:        import java.util.Arrays;
0075:        import java.util.Collection;
0076:        import java.util.Iterator;
0077:        import java.util.Hashtable;
0078:        import java.util.Enumeration;
0079:
0080:        import javax.ejb.CreateException;
0081:        import javax.ejb.EJBException;
0082:        import javax.ejb.FinderException;
0083:        import javax.ejb.RemoveException;
0084:        import javax.ejb.SessionBean;
0085:        import javax.ejb.SessionContext;
0086:
0087:        import org.apache.log4j.Logger;
0088:
0089:        /**
0090:         *
0091:         * The User Session Bean, is an stateless session bean that provides the user API to get information on
0092:         * Todo list and started activities and to produce events on activities (start, terminate, cancel).<br>
0093:         * This Session Bean is based on Engine Session Bean: a recursive implementation that manage the previous execution operations
0094:         * and propagates the activity state changes to the activities that are connected to this one.
0095:         *<br><br>
0096:         * The User Session Bean API provides information about user projects and activites (project list,
0097:         * todo list and activity list) and also useful information about project instances or user
0098:         * preferences. With this API users can performs his task/activities by using start, terminate and
0099:         * cancel methods and also terminates workflow processes.
0100:         * <br><br>
0101:         * <strong>The following lines shows a sample code to use this API in your application:<br><br></strong>
0102:         * <br>
0103:         * First of all you have to import the User Session files:<br>
0104:         * <br>
0105:         * import hero.interfaces.UserSessionLocalHome;<br>
0106:         * import hero.interfaces.UserSessionLocal;<br>
0107:         * import hero.interfaces.UserSessionHome;<br>
0108:         * import hero.interfaces.UserSession;<br>
0109:         * import hero.interfaces.UserSessionUtil;<br>
0110:         * <br>
0111:         * Now, it is time to create the User Session instance:<br>
0112:         * <br>
0113:         * Like this if you want to use local interfaces:<br><br>
0114:         * UserSessionLocalHome userh = (UserSessionLocalHome)hero.interfaces.UserSessionUtil.getLocalHome();<br>
0115:         * UserSessionLocal usersession = userh.create();<br>
0116:         * <br>
0117:         * or like this if you use remote interfaces:<br>  
0118:         * <br>
0119:         * UserSessionHome userh = (UserSessionHome)hero.interfaces.UserSessionUtil.getHome();<br>
0120:         * UserSession usersession = userh.create();<br>
0121:         * <br>
0122:         * <br>
0123:         * Now you can call all User Sessions methods...  
0124:         * 
0125:         *
0126:         * @ejb:bean name="UserSession"
0127:         *           display-name="UserSession Bean"
0128:         *           type="Stateless"
0129:         *           transaction-type="Container"
0130:         *           jndi-name="ejb/hero/UserSession"
0131:         *           local-jndi-name="ejb/hero/UserSession_L"
0132:         *
0133:         * @ejb:ejb-ref ejb-name="BnUser"
0134:         *              ref-name="myhero/BnUser"
0135:         * @ejb.permission role-name="BONITAUSER,user,SuperAdmin" 
0136:         *
0137:         *
0138:         * @jonas.bean
0139:         *      ejb-name="UserSession"
0140:         *      jndi-name="ejb/hero/UserSession"
0141:         *
0142:         * @jboss.container-configuration name="Standard Stateless SessionBean for Bonita"
0143:         * 
0144:         * @copyright INRIA
0145:         * @author Miguel Valdes
0146:         **/
0147:
0148:        public class UserSessionBean implements  SessionBean, EventConstants {
0149:
0150:            // -------------------------------------------------------------------------
0151:            // Static
0152:            // -------------------------------------------------------------------------
0153:            // Utility variable
0154:            private static final Logger trace = Logger
0155:                    .getLogger(UserSessionBean.class);
0156:
0157:            // -------------------------------------------------------------------------
0158:            // Members 
0159:            // -------------------------------------------------------------------------
0160:
0161:            private SessionContext mContext;
0162:            private BonitaConfig bonitaConfig;
0163:            private JMSServicesSessionLocal jms = null;
0164:
0165:            // -------------------------------------------------------------------------
0166:            // Methods
0167:            // -------------------------------------------------------------------------
0168:
0169:            /**
0170:             * Get user project list. Workflow processes associated to this user (models/cooperative/instances)
0171:             * @return a Collection of BnProjectLightValue objects - the projects list of the user
0172:             * @throws HeroException
0173:             * @ejb:interface-method view-type="both"
0174:             * @ejb:transaction type="Supports"
0175:             *
0176:             **/
0177:            public Collection getProjectList() throws HeroException {
0178:                Collection pjts = new ArrayList();
0179:                Collection pva;
0180:                try {
0181:                    this .synchronizeUser();
0182:                    BnUserLocalHome userhome = hero.interfaces.BnUserUtil
0183:                            .getLocalHome();
0184:                    BnUserLocal mUser = userhome.findByName(mContext
0185:                            .getCallerPrincipal().getName());
0186:                    trace.debug("start by "
0187:                            + mContext.getCallerPrincipal().getName());
0188:                    BnUserValue uv = mUser.getBnUserValue();
0189:                    pva = new ArrayList(Arrays.asList(uv.getBnProjects()));
0190:                } catch (javax.naming.NamingException ne) {
0191:                    trace.error(ne.getMessage());
0192:                    throw new HeroException(ne.getMessage());
0193:                } catch (javax.ejb.FinderException fe) {
0194:                    trace.error(mContext.getCallerPrincipal().getName()
0195:                            + " does not exists " + fe.getMessage());
0196:                    throw new HeroException(mContext.getCallerPrincipal()
0197:                            .getName()
0198:                            + " does not exists");
0199:                }
0200:                return pva;
0201:            }
0202:
0203:            /**
0204:             * Get project list names for this user (models/cooperative/instances)
0205:             * @return a String Collection - the projects list names of the user
0206:             * @throws HeroException
0207:             * @ejb:interface-method view-type="both"
0208:             * @ejb:transaction type="Supports"
0209:             *
0210:             **/
0211:            public Collection getProjectListNames() throws HeroException {
0212:                trace.debug("start by "
0213:                        + mContext.getCallerPrincipal().getName());
0214:                //Collection projects = null;
0215:                Collection projectsNames;
0216:                try {
0217:                    this .synchronizeUser();
0218:                    BnUserLocalHome userhome = hero.interfaces.BnUserUtil
0219:                            .getLocalHome();
0220:                    BnUserLocal mUser = userhome.findByName(mContext
0221:                            .getCallerPrincipal().getName());
0222:                    //projects = mUser.getBnProjects();
0223:                    BnUserValue uv = mUser.getBnUserValue();
0224:                    Collection pva = new ArrayList(Arrays.asList(uv
0225:                            .getBnProjects()));
0226:                    projectsNames = new ArrayList();
0227:                    Iterator i = pva.iterator();
0228:                    while (i.hasNext())
0229:                        projectsNames
0230:                                .add(((hero.interfaces.BnProjectLightValue) i
0231:                                        .next()).getName());
0232:                } catch (javax.naming.NamingException ne) {
0233:                    ne.printStackTrace();
0234:                    trace.error(ne.getMessage());
0235:                    throw new HeroException(ne.getMessage());
0236:                } catch (javax.ejb.FinderException fe) {
0237:                    fe.printStackTrace();
0238:                    trace.error(mContext.getCallerPrincipal().getName()
0239:                            + " does not exists " + fe.getMessage());
0240:                    throw new HeroException(mContext.getCallerPrincipal()
0241:                            .getName()
0242:                            + " does not exists");
0243:                }
0244:                return projectsNames;
0245:            }
0246:
0247:            /**
0248:             * Get user instances list. This method is equivalent to getProjectList but
0249:             * it only returns the current instances of the user.
0250:             * @return a Collection of BnProjectLightValue objects - the projects list of the user
0251:             * @throws HeroException
0252:             * @ejb:interface-method view-type="both"
0253:             * @ejb:transaction type="Supports"
0254:             *
0255:             **/
0256:            public Collection getInstancesList() throws HeroException {
0257:                trace.debug("start by "
0258:                        + mContext.getCallerPrincipal().getName());
0259:                this .synchronizeUser();
0260:                Collection instances = new ArrayList();
0261:                Collection pva = this .getProjectList();
0262:                Iterator ps = pva.iterator();
0263:
0264:                while (ps.hasNext()) {
0265:                    BnProjectLightValue pro = (BnProjectLightValue) ps.next();
0266:                    if (pro.getType().equals(Constants.Pj.INSTANCE))
0267:                        instances.add(pro);
0268:                }
0269:                return instances;
0270:            }
0271:
0272:            /**
0273:             * Get user instances list. This method is equivalent to getProjectList but
0274:             * it only returns the current instances of the user.
0275:             * @return a Collection of BnProjectLightValue objects - the projects list of the user
0276:             * @throws HeroException
0277:             * @ejb:interface-method view-type="both"
0278:             * @ejb:transaction type="Supports"
0279:             *
0280:             **/
0281:            public Collection getInstancesList(int offset, int numrows)
0282:                    throws HeroException {
0283:                trace.debug("start by "
0284:                        + mContext.getCallerPrincipal().getName());
0285:                this .synchronizeUser();
0286:                int cnt = 0;
0287:                int add = 0;
0288:                Collection instances = new ArrayList();
0289:                Collection pva = this .getProjectList();
0290:                Iterator ps = pva.iterator();
0291:
0292:                while (ps.hasNext()) {
0293:                    BnProjectLightValue pro = (BnProjectLightValue) ps.next();
0294:                    if (cnt >= offset) {
0295:                        if (pro.getType().equals(Constants.Pj.INSTANCE)) {
0296:                            instances.add(pro);
0297:                            add++;
0298:                            if (add == numrows)
0299:                                break;
0300:                        }
0301:                    }
0302:                    cnt++;
0303:                }
0304:                return instances;
0305:            }
0306:
0307:            /**
0308:             * Get user model list. This method is equivalent to getProjectList but
0309:             * it only returns the current models of the user.
0310:             * @return a Collection of BnProjectLightValue objects - the model list of the user
0311:             * @throws HeroException
0312:             * @ejb:interface-method view-type="both"
0313:             * @ejb:transaction type="Supports"
0314:             *
0315:             **/
0316:            public Collection getModelList() throws HeroException {
0317:                trace.debug("start by "
0318:                        + mContext.getCallerPrincipal().getName());
0319:                this .synchronizeUser();
0320:                Collection models = new ArrayList();
0321:                Collection pva = this .getProjectList();
0322:                Iterator ps = pva.iterator();
0323:
0324:                while (ps.hasNext()) {
0325:                    BnProjectLightValue pro = (BnProjectLightValue) ps.next();
0326:                    if (pro.getType().equals(Constants.Pj.MODEL))
0327:                        models.add(pro);
0328:                }
0329:                return models;
0330:            }
0331:
0332:            public Collection getModelList(int offset, int numrows)
0333:                    throws HeroException {
0334:                trace.debug("start by "
0335:                        + mContext.getCallerPrincipal().getName());
0336:                this .synchronizeUser();
0337:                int cnt = 0;
0338:                int add = 0;
0339:                Collection models = new ArrayList();
0340:                Collection pva = this .getProjectList();
0341:                Iterator ps = pva.iterator();
0342:
0343:                while (ps.hasNext()) {
0344:                    BnProjectLightValue pro = (BnProjectLightValue) ps.next();
0345:                    if (cnt >= offset) {
0346:                        if (pro.getType().equals(Constants.Pj.MODEL)) {
0347:                            models.add(pro);
0348:                            add++;
0349:                            if (add == numrows)
0350:                                break;
0351:                        }
0352:                    }
0353:                    cnt++;
0354:                }
0355:                return models;
0356:            }
0357:
0358:            /**
0359:             * Get available workflow models. This method will be improved with users restrictions 
0360:             * @return a Collection of BnProjectLightValue objects - the model list to be instantiated
0361:             * @throws HeroException
0362:             * @ejb:interface-method view-type="both"
0363:             * @ejb:transaction type="Supports"
0364:             *
0365:             **/
0366:            public Collection getModels() throws HeroException {
0367:                trace.debug("start by "
0368:                        + mContext.getCallerPrincipal().getName());
0369:                this .synchronizeUser();
0370:                BnProjectLocalHome projhome;
0371:                BnProjectLocal project;
0372:                BnInitiatorMapperLocal initiatorMapper = null;
0373:                Collection models = new ArrayList();
0374:                Collection pva = null;
0375:                String connectedUser = "";
0376:
0377:                try {
0378:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
0379:                } catch (javax.naming.NamingException be) {
0380:                    throw new HeroException(be.getMessage());
0381:                }
0382:                try {
0383:                    pva = projhome.findModels(Constants.Pj.MODEL,
0384:                            Constants.Pj.ACTIVE);
0385:                } catch (FinderException fe) {
0386:                    throw new HeroException("Error in findByModels: "
0387:                            + fe.getMessage());
0388:                }
0389:                connectedUser = mContext.getCallerPrincipal().getName();
0390:                Iterator ps = pva.iterator();
0391:                while (ps.hasNext()) {
0392:                    BnProjectLocal pro = (BnProjectLocal) ps.next();
0393:                    // modification to introduce the Initiator mapper
0394:                    initiatorMapper = pro.getBnInitiatorMapper();
0395:                    if (initiatorMapper != null) {
0396:                        // execute the initiatorMapper to find out if the connected user beleive to the initiator role						
0397:                        hero.initiatorMapper.InitiatorMapper h = hero.initiatorMapper.InitiatorMapper
0398:                                .make(initiatorMapper.getName(),
0399:                                        initiatorMapper.getType());
0400:                        try {
0401:                            Collection users = h.execute(this , initiatorMapper
0402:                                    .getType(), pro, connectedUser);
0403:                            Iterator it_u = users.iterator();
0404:                            while (it_u.hasNext()) {
0405:                                if (connectedUser.equals((String) it_u.next())) {
0406:                                    models.add(pro.getBnProjectLightValue());
0407:                                }
0408:                            }
0409:                        } catch (Exception e) {
0410:                            System.out
0411:                                    .println("Error processing initiator mapper: "
0412:                                            + e.getMessage());
0413:                            //disable the throw so other processes can still be processed
0414:                            //throw new HeroException ("Error processing initiator mapper: " + e.getMessage());
0415:                        }
0416:                    } else {
0417:                        models.add(pro.getBnProjectLightValue());
0418:                    }
0419:                }
0420:                return models;
0421:            }
0422:
0423:            /**
0424:             * Get available workflow models. This method is like getModels()
0425:             * except that no initiatorMapper check is performed.
0426:             * @return a Collection of BnProjectLightValue objects - the model list
0427:             * @throws HeroException
0428:             * @ejb:interface-method view-type="both"
0429:             * @ejb:transaction type="Supports"
0430:             *
0431:             **/
0432:            public Collection getModelsLight() throws HeroException {
0433:                trace.debug("start by "
0434:                        + mContext.getCallerPrincipal().getName());
0435:                this .synchronizeUser();
0436:                BnProjectLocalHome projhome;
0437:                BnProjectLocal project;
0438:                BnInitiatorMapperLocal initiatorMapper = null;
0439:                Collection models = new ArrayList();
0440:                Collection pva = null;
0441:
0442:                try {
0443:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
0444:                } catch (javax.naming.NamingException be) {
0445:                    throw new HeroException(be.getMessage());
0446:                }
0447:                try {
0448:                    pva = projhome.findModels(Constants.Pj.MODEL,
0449:                            Constants.Pj.ACTIVE);
0450:                } catch (FinderException fe) {
0451:                    throw new HeroException("Error in findByModels: "
0452:                            + fe.getMessage());
0453:                }
0454:                Iterator ps = pva.iterator();
0455:                while (ps.hasNext()) {
0456:                    BnProjectLocal pro = (BnProjectLocal) ps.next();
0457:                    models.add(pro.getBnProjectLightValue());
0458:                }
0459:                return models;
0460:            }
0461:
0462:            /**
0463:             * Get available workflow models. This method is like getModels()
0464:             * except that no initiatorMapper check is performed.
0465:             * @return a Collection of BnProjectLightValue objects - the model list
0466:             * @throws HeroException
0467:             * @ejb:interface-method view-type="both"
0468:             * @ejb:transaction type="Supports"
0469:             *
0470:             **/
0471:            public Collection getModelsLightAll() throws HeroException {
0472:                trace.debug("start by "
0473:                        + mContext.getCallerPrincipal().getName());
0474:                this .synchronizeUser();
0475:                BnProjectLocalHome projhome;
0476:                BnProjectLocal project;
0477:                BnInitiatorMapperLocal initiatorMapper = null;
0478:                Collection models = new ArrayList();
0479:                Collection pva = null;
0480:                Collection pvh = null;
0481:
0482:                try {
0483:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
0484:                } catch (javax.naming.NamingException be) {
0485:                    throw new HeroException(be.getMessage());
0486:                }
0487:                try {
0488:                    pva = projhome.findModels(Constants.Pj.MODEL,
0489:                            Constants.Pj.ACTIVE);
0490:                    pvh = projhome.findModels(Constants.Pj.MODEL,
0491:                            Constants.Pj.HIDDEN);
0492:                } catch (FinderException fe) {
0493:                    throw new HeroException("Error in getModelsLightAll: "
0494:                            + fe.getMessage());
0495:                }
0496:                Iterator ps = pva.iterator();
0497:                while (ps.hasNext()) {
0498:                    BnProjectLocal pro = (BnProjectLocal) ps.next();
0499:                    models.add(pro.getBnProjectLightValue());
0500:                }
0501:                ps = pvh.iterator();
0502:                while (ps.hasNext()) {
0503:                    BnProjectLocal pro = (BnProjectLocal) ps.next();
0504:                    models.add(pro.getBnProjectLightValue());
0505:                }
0506:                return models;
0507:            }
0508:
0509:            /**
0510:             * Get available workflow models. This method will be improved with users restrictions 
0511:             * @return a Collection of BnProjectLightValue objects - the model list to be instantiated
0512:             * @throws HeroException
0513:             * @ejb:interface-method view-type="both"
0514:             * @ejb:transaction type="Supports"
0515:             *
0516:             **/
0517:            public Collection getModelsAsPK() throws HeroException {
0518:                trace.debug("start by "
0519:                        + mContext.getCallerPrincipal().getName());
0520:                this .synchronizeUser();
0521:                BnProjectLocalHome projhome;
0522:                BnProjectLocal project;
0523:                BnInitiatorMapperLocal initiatorMapper = null;
0524:                Collection models = new ArrayList();
0525:                Collection pva = null;
0526:                String connectedUser = "";
0527:
0528:                try {
0529:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
0530:                } catch (javax.naming.NamingException be) {
0531:                    throw new HeroException(be.getMessage());
0532:                }
0533:                try {
0534:                    pva = projhome.findModels(Constants.Pj.MODEL,
0535:                            Constants.Pj.ACTIVE);
0536:                    connectedUser = mContext.getCallerPrincipal().getName();
0537:                    Iterator ps = pva.iterator();
0538:                    while (ps.hasNext()) {
0539:                        BnProjectLocal pro = (BnProjectLocal) ps.next();
0540:                        // modification to introduce the Initiator mapper
0541:                        initiatorMapper = pro.getBnInitiatorMapper();
0542:                        if (initiatorMapper != null) {
0543:                            // execute the initiatorMapper to find out if the connected user beleive to the initiator role						
0544:                            hero.initiatorMapper.InitiatorMapper h = hero.initiatorMapper.InitiatorMapper
0545:                                    .make(initiatorMapper.getName(),
0546:                                            initiatorMapper.getType());
0547:                            try {
0548:                                Collection users = h.execute(this ,
0549:                                        initiatorMapper.getType(), pro,
0550:                                        connectedUser);
0551:                                Iterator it_u = users.iterator();
0552:                                while (it_u.hasNext()) {
0553:                                    if (connectedUser.equals((String) it_u
0554:                                            .next())) {
0555:                                        models.add(pro.getPrimaryKey());
0556:                                    }
0557:                                }
0558:                            } catch (Exception e) {
0559:                                System.out
0560:                                        .println("Error processing initiator mapper: "
0561:                                                + e.getMessage());
0562:                                //disable the throw so other processes can still be processed
0563:                                //throw new HeroException ("Error processing initiator mapper: " + e.getMessage());
0564:                            }
0565:                        }
0566:                    }
0567:                } catch (FinderException fe) {
0568:                    throw new HeroException("Error in findByModels: "
0569:                            + fe.getMessage());
0570:                }
0571:                return models;
0572:            }
0573:
0574:            /**
0575:             * Get available workflow models. This method will be improved with users restrictions 
0576:             * @return a Collection of BnProjectLightValue objects - the model list to be instantiated
0577:             * @throws HeroException
0578:             * @ejb:interface-method view-type="both"
0579:             * @ejb:transaction type="Supports"
0580:             *
0581:             **/
0582:            public Collection getModelsByPK(Collection list, int offset,
0583:                    int numrows) throws HeroException {
0584:                trace.debug("start by "
0585:                        + mContext.getCallerPrincipal().getName());
0586:                this .synchronizeUser();
0587:                BnProjectLocalHome projhome;
0588:                BnProjectLocal project;
0589:                BnInitiatorMapperLocal initiatorMapper = null;
0590:                Collection models = new ArrayList();
0591:                Collection pva = null;
0592:                String connectedUser = "";
0593:
0594:                try {
0595:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
0596:                } catch (javax.naming.NamingException be) {
0597:                    throw new HeroException(be.getMessage());
0598:                }
0599:                try {
0600:                    int add = 0;
0601:                    int cnt = 0;
0602:                    Iterator it = list.iterator();
0603:                    while (it.hasNext()) {
0604:                        if (cnt < offset)
0605:                            it.next();
0606:                        else {
0607:                            BnProjectLocal pro = projhome
0608:                                    .findByPrimaryKey((BnProjectPK) it.next());
0609:                            models.add(pro.getBnProjectLightValue());
0610:                            add++;
0611:                            if (add == numrows)
0612:                                break;
0613:                        }
0614:                        cnt++;
0615:                    }
0616:                    return models;
0617:                } catch (FinderException fe) {
0618:                    throw new HeroException("Error in findByModels: "
0619:                            + fe.getMessage());
0620:                }
0621:            }
0622:
0623:            /**
0624:             * Get available workflow models. This method is like getModels()
0625:             * except that no initiatorMapper check is performed.
0626:             * @return a Collection of BnProjectLightValue objects - the model list
0627:             * @throws HeroException
0628:             * @ejb:interface-method view-type="both"
0629:             * @ejb:transaction type="Supports"
0630:             *
0631:             **/
0632:            public Collection getModelsLightAsPK() throws HeroException {
0633:                trace.debug("start by "
0634:                        + mContext.getCallerPrincipal().getName());
0635:                this .synchronizeUser();
0636:                BnProjectLocalHome projhome;
0637:                BnProjectLocal project;
0638:                BnInitiatorMapperLocal initiatorMapper = null;
0639:                Collection models = new ArrayList();
0640:                Collection pva = null;
0641:
0642:                try {
0643:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
0644:                } catch (javax.naming.NamingException be) {
0645:                    throw new HeroException(be.getMessage());
0646:                }
0647:                try {
0648:                    pva = projhome.findModels(Constants.Pj.MODEL,
0649:                            Constants.Pj.ACTIVE);
0650:                    Iterator ps = pva.iterator();
0651:                    while (ps.hasNext()) {
0652:                        BnProjectLocal pro = (BnProjectLocal) ps.next();
0653:                        models.add(pro.getPrimaryKey());
0654:                    }
0655:                    return models;
0656:                } catch (FinderException fe) {
0657:                    throw new HeroException("Error in findByModels: "
0658:                            + fe.getMessage());
0659:                }
0660:            }
0661:
0662:            /**
0663:             * Get available workflow models. This method is like getModels()
0664:             * except that no initiatorMapper check is performed.
0665:             * @return a Collection of BnProjectLightValue objects - the model list
0666:             * @throws HeroException
0667:             * @ejb:interface-method view-type="both"
0668:             * @ejb:transaction type="Supports"
0669:             *
0670:             **/
0671:            public Collection getModelsLightByPK(Collection list, int offset,
0672:                    int numrows) throws HeroException {
0673:                trace.debug("start by "
0674:                        + mContext.getCallerPrincipal().getName());
0675:                this .synchronizeUser();
0676:                BnProjectLocalHome projhome;
0677:                BnProjectLocal project;
0678:                BnInitiatorMapperLocal initiatorMapper = null;
0679:                Collection models = new ArrayList();
0680:                Collection pva = null;
0681:
0682:                try {
0683:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
0684:                } catch (javax.naming.NamingException be) {
0685:                    throw new HeroException(be.getMessage());
0686:                }
0687:                try {
0688:                    int add = 0;
0689:                    int cnt = 0;
0690:                    Iterator it = list.iterator();
0691:                    while (it.hasNext()) {
0692:                        if (cnt < offset)
0693:                            it.next();
0694:                        else {
0695:                            BnProjectLocal pro = projhome
0696:                                    .findByPrimaryKey((BnProjectPK) it.next());
0697:                            models.add(pro.getBnProjectLightValue());
0698:                            add++;
0699:                            if (add == numrows)
0700:                                break;
0701:                        }
0702:                        cnt++;
0703:                    }
0704:                    return models;
0705:                } catch (FinderException fe) {
0706:                    throw new HeroException("Error in findByModels: "
0707:                            + fe.getMessage());
0708:                }
0709:            }
0710:
0711:            /**
0712:             * Get user cooperative projects list. This method is equivalent to getProjectList but
0713:             * it only returns the current cooperative projects of the user.
0714:             * @return a Collection of BnProjectLightValue objects - the cooperative projects list of the user
0715:             * @throws HeroException
0716:             * @ejb:interface-method view-type="both"
0717:             * @ejb:transaction type="Supports"
0718:             *
0719:             **/
0720:            public Collection getCooperativeList() throws HeroException {
0721:                trace.debug("start by "
0722:                        + mContext.getCallerPrincipal().getName());
0723:                this .synchronizeUser();
0724:                Collection coo = new ArrayList();
0725:                Collection pva = this .getProjectList();
0726:                Iterator ps = pva.iterator();
0727:
0728:                while (ps.hasNext()) {
0729:                    BnProjectLightValue pro = (BnProjectLightValue) ps.next();
0730:                    if (pro.getType().equals(Constants.Pj.COOPERATIVE))
0731:                        coo.add(pro);
0732:                }
0733:                return coo;
0734:            }
0735:
0736:            /**
0737:             * Get user cooperative projects list. This method is equivalent to getProjectList but
0738:             * it only returns the current cooperative projects of the user.
0739:             * @return a Collection of BnProjectLightValue objects - the cooperative projects list of the user
0740:             * @throws HeroException
0741:             * @ejb:interface-method view-type="both"
0742:             * @ejb:transaction type="Supports"
0743:             *
0744:             **/
0745:            public Collection getCooperativeList(int offset, int numrows)
0746:                    throws HeroException {
0747:                trace.debug("start by "
0748:                        + mContext.getCallerPrincipal().getName());
0749:                this .synchronizeUser();
0750:                int cnt = 0;
0751:                int add = 0;
0752:                Collection coo = new ArrayList();
0753:                Collection pva = this .getProjectList();
0754:                Iterator ps = pva.iterator();
0755:
0756:                while (ps.hasNext()) {
0757:                    BnProjectLightValue pro = (BnProjectLightValue) ps.next();
0758:                    if (cnt >= offset) {
0759:                        if (pro.getType().equals(Constants.Pj.COOPERATIVE)) {
0760:                            coo.add(pro);
0761:                            add++;
0762:                            if (add == numrows)
0763:                                break;
0764:                        }
0765:                    }
0766:                    cnt++;
0767:                }
0768:                return coo;
0769:            }
0770:
0771:            /**
0772:             * Get instances list names for this user. This method is equivalent to getProjectListNames but
0773:             * it only returns the current instances of the user.
0774:             * @return a String Collection - the projects list names of the user
0775:             * @throws HeroException
0776:             * @ejb:interface-method view-type="both"
0777:             * @ejb:transaction type="Supports"
0778:             *
0779:             **/
0780:            public Collection getInstancesListNames() throws HeroException {
0781:                trace.debug("start by "
0782:                        + mContext.getCallerPrincipal().getName());
0783:                this .synchronizeUser();
0784:                Collection instances = new ArrayList();
0785:                Collection pva = this .getProjectList();
0786:                Iterator ps = pva.iterator();
0787:                while (ps.hasNext()) {
0788:                    BnProjectLightValue pro = (BnProjectLightValue) ps.next();
0789:                    if (pro.getName().matches(".*_instance.*"))
0790:                        instances.add(pro.getName());
0791:                }
0792:                return instances;
0793:            }
0794:
0795:            /**
0796:             * Get instances list names for this user. This method is equivalent to getProjectListNames but
0797:             * it only returns the current instances of the user.
0798:             * @return a String Collection - the projects list names of the user
0799:             * @throws HeroException
0800:             * @ejb:interface-method view-type="both"
0801:             * @ejb:transaction type="Supports"
0802:             *
0803:             **/
0804:            public Collection getInstancesListNames(int offset, int numrows)
0805:                    throws HeroException {
0806:                trace.debug("start by "
0807:                        + mContext.getCallerPrincipal().getName());
0808:                this .synchronizeUser();
0809:                int cnt = 0;
0810:                int add = 0;
0811:                Collection instances = new ArrayList();
0812:                Collection pva = this .getProjectList();
0813:                Iterator ps = pva.iterator();
0814:                while (ps.hasNext()) {
0815:                    BnProjectLightValue pro = (BnProjectLightValue) ps.next();
0816:                    if (cnt >= offset) {
0817:                        if (pro.getName().matches(".*_instance.*")) {
0818:                            instances.add(pro.getName());
0819:                            add++;
0820:                            if (add == numrows)
0821:                                break;
0822:                        }
0823:                    }
0824:                    cnt++;
0825:                }
0826:                return instances;
0827:            }
0828:
0829:            /**
0830:             * Delete a Workflow project
0831:             * @param projectName the name of the project
0832:             * @throws HeroException
0833:             * @ejb:interface-method view-type="both"
0834:             * @ejb:transaction type="Required"
0835:             *
0836:             **/
0837:            public void removeProject(String projectName) throws HeroException {
0838:
0839:                trace.debug("parameter: projectName=" + projectName
0840:                        + " start by "
0841:                        + mContext.getCallerPrincipal().getName());
0842:                if (this .isAdmin(projectName,
0843:                        EventConstants.DEFAULTPROJECTVERSION)) {
0844:                    this .deleteProject(projectName,
0845:                            EventConstants.DEFAULTPROJECTVERSION);
0846:                    this .removeProjectDeadlines(projectName);
0847:                } else
0848:                    throw new HeroException(
0849:                            "Error in delete project: only admin users are allowed to removed it !!");
0850:            }
0851:
0852:            /**
0853:             * Delete a Workflow project
0854:             * @param instName the name of the instance
0855:             * @throws HeroException
0856:             * @ejb:interface-method view-type="both"
0857:             * @ejb:transaction type="Required"
0858:             *
0859:             **/
0860:            public void removeInstance(String instName) throws HeroException {
0861:                trace.debug("parameter: projectName=" + instName + " start by "
0862:                        + mContext.getCallerPrincipal().getName());
0863:                if (this .isAdmin(instName)) {
0864:                    if (instName.matches(".*_instance.*")) {
0865:                        this .deleteInstance(instName);
0866:                        this .removeProjectDeadlines(instName);
0867:                    } else
0868:                        throw new HeroException(
0869:                                "Error while deleting the instance: this process is not an instance.");
0870:                } else
0871:                    throw new HeroException(
0872:                            "Error while deleting the instance: only admin users are allowed to removed it !!");
0873:            }
0874:
0875:            /**
0876:             * Delete a Workflow project
0877:             * @param projectName the name of the project
0878:             * @throws HeroException
0879:             * @ejb:interface-method view-type="both"
0880:             * @ejb:transaction type="Required"
0881:             *
0882:             **/
0883:            public void removeProject(String projectName, String version)
0884:                    throws HeroException {
0885:
0886:                trace.debug("parameter: projectName=" + projectName
0887:                        + " start by "
0888:                        + mContext.getCallerPrincipal().getName());
0889:                if (this .isAdmin(projectName, version)) {
0890:                    this .deleteProject(projectName, version);
0891:                    this .removeProjectDeadlines(projectName);
0892:                } else
0893:                    throw new HeroException(
0894:                            "Error in delete project: only admin users are allowed to removed it !!");
0895:            }
0896:
0897:            private void removeProjectDeadlines(String name)
0898:                    throws HeroException {
0899:
0900:                DeadlineEjbTimerSessionLocalHome dlHome;
0901:                DeadlineEjbTimerSessionLocal dlSession;
0902:                try {
0903:                    dlHome = DeadlineEjbTimerSessionUtil.getLocalHome();
0904:                } catch (javax.naming.NamingException ne) {
0905:                    throw new HeroException(ne.getMessage());
0906:                }
0907:                try {
0908:                    dlSession = dlHome.create();
0909:                    dlSession.removeProjectTimers(name);
0910:                } catch (CreateException he) {
0911:                    throw new HeroException(
0912:                            "setNodeDeadlines Error creating DeadlineEjbTimerSessionLocal");
0913:                }
0914:            }
0915:
0916:            /**
0917:             * Obtain all user activities from specific project (ready and anticipable state)
0918:             * @param projectName the name of the project
0919:             * @return a String Collection - the list of todo activities of the user for a project
0920:             * @throws HeroException
0921:             * @ejb:interface-method view-type="both"
0922:             * @ejb:transaction type="Supports"
0923:             *
0924:             **/
0925:            public Collection getToDoList(String projectName)
0926:                    throws HeroException {
0927:
0928:                trace.debug("parameter: projectName=" + projectName
0929:                        + " start by "
0930:                        + mContext.getCallerPrincipal().getName());
0931:                BnProjectLocalHome projhome;
0932:                BnProjectLocal project;
0933:                BnNodeLocalHome nodehome;
0934:                Collection ready;
0935:                this .synchronizeUser();
0936:                try {
0937:                    projhome = BnProjectUtil.getLocalHome();
0938:                    nodehome = BnNodeUtil.getLocalHome();
0939:                } catch (javax.naming.NamingException ne) {
0940:
0941:                    trace.error(ne.getMessage());
0942:                    throw new HeroException(ne.getMessage());
0943:                }
0944:                try {
0945:                    project = projhome.findByName(projectName);
0946:                } catch (FinderException fe) {
0947:
0948:                    trace.error("BnProject " + projectName
0949:                            + " does not exists " + fe.getMessage());
0950:                    throw new HeroException("BnProject " + projectName
0951:                            + " does not exists");
0952:                }
0953:                try {
0954:                    ready = nodehome.findUserReady(project.getId(), mContext
0955:                            .getCallerPrincipal().getName());
0956:                } catch (FinderException fe) {
0957:
0958:                    trace.error(fe.getMessage());
0959:                    ready = new ArrayList();
0960:                }
0961:                ArrayList result = new ArrayList();
0962:                for (Iterator i = ready.iterator(); i.hasNext();) {
0963:                    BnNodeLocal nd = (BnNodeLocal) i.next();
0964:
0965:                    trace.debug("NODE NAME=" + nd.getName());
0966:                    result.add(nd.getName());
0967:                }
0968:                return result;
0969:            }
0970:
0971:            /**
0972:             * Obtain all user activities from specific project (ready and anticipable state)
0973:             * @param projectName the name of the project
0974:             * @return a String Collection - the list of todo activities of the user for a project
0975:             * @throws HeroException
0976:             * @ejb:interface-method view-type="both"
0977:             * @ejb:transaction type="Supports"
0978:             *
0979:             **/
0980:            public Collection getToDoListAsPK(String projectName)
0981:                    throws HeroException {
0982:
0983:                trace.debug("parameter: projectName=" + projectName
0984:                        + " start by "
0985:                        + mContext.getCallerPrincipal().getName());
0986:                BnProjectLocalHome projhome;
0987:                BnProjectLocal project;
0988:                BnNodeLocalHome nodehome;
0989:                Collection ready;
0990:                ArrayList result = new ArrayList();
0991:                this .synchronizeUser();
0992:                try {
0993:                    projhome = BnProjectUtil.getLocalHome();
0994:                    nodehome = BnNodeUtil.getLocalHome();
0995:                } catch (javax.naming.NamingException ne) {
0996:
0997:                    trace.error(ne.getMessage());
0998:                    throw new HeroException(ne.getMessage());
0999:                }
1000:                try {
1001:                    project = projhome.findByName(projectName);
1002:                } catch (FinderException fe) {
1003:
1004:                    trace.error("BnProject " + projectName
1005:                            + " does not exists " + fe.getMessage());
1006:                    throw new HeroException("BnProject " + projectName
1007:                            + " does not exists");
1008:                }
1009:                try {
1010:                    ready = nodehome.findUserReady(project.getId(), mContext
1011:                            .getCallerPrincipal().getName());
1012:                    for (Iterator i = ready.iterator(); i.hasNext();) {
1013:                        BnNodeLocal nd = (BnNodeLocal) i.next();
1014:                        trace.debug("NODE NAME=" + nd.getName());
1015:                        result.add(nd.getPrimaryKey());
1016:                    }
1017:                } catch (FinderException fe) {
1018:                    trace.error(fe.getMessage());
1019:                    ready = new ArrayList();
1020:                }
1021:                return result;
1022:            }
1023:
1024:            /**
1025:             * Obtain all user activities from specific project (ready and anticipable state)
1026:             * @param projectName the name of the project
1027:             * @return a String Collection - the list of todo activities of the user for a project
1028:             * @throws HeroException
1029:             * @ejb:interface-method view-type="both"
1030:             * @ejb:transaction type="Supports"
1031:             *
1032:             **/
1033:            public Collection getToDoListByPK(String projectName,
1034:                    Collection list, int offset, int numrows)
1035:                    throws HeroException {
1036:
1037:                trace.debug("parameter: projectName=" + projectName
1038:                        + " start by "
1039:                        + mContext.getCallerPrincipal().getName());
1040:                BnProjectLocalHome projhome;
1041:                BnProjectLocal project;
1042:                BnNodeLocalHome nodehome;
1043:                Collection ready;
1044:                ArrayList result = new ArrayList();
1045:                this .synchronizeUser();
1046:                try {
1047:                    projhome = BnProjectUtil.getLocalHome();
1048:                    nodehome = BnNodeUtil.getLocalHome();
1049:                } catch (javax.naming.NamingException ne) {
1050:
1051:                    trace.error(ne.getMessage());
1052:                    throw new HeroException(ne.getMessage());
1053:                }
1054:                try {
1055:                    int add = 0;
1056:                    int cnt = 0;
1057:                    Iterator it = list.iterator();
1058:                    while (it.hasNext()) {
1059:                        if (cnt < offset)
1060:                            it.next();
1061:                        else {
1062:                            BnNodeLocal nd = nodehome
1063:                                    .findByPrimaryKey((BnNodePK) it.next());
1064:                            result.add(nd.getName());
1065:                            add++;
1066:                            if (add == numrows)
1067:                                break;
1068:                        }
1069:                        cnt++;
1070:                    }
1071:                } catch (FinderException fe) {
1072:                    trace.error(fe.getMessage());
1073:                    ready = new ArrayList();
1074:                }
1075:                return result;
1076:            }
1077:
1078:            /**
1079:             * Obtain all user activities from specific project (executing and anticipating state)
1080:             *
1081:             * @param projectName the name of the project
1082:             * @return a String Collectio - the list of active activities of the user for a project
1083:             * @throws HeroException
1084:             * @ejb:interface-method view-type="both"
1085:             * @ejb:transaction type="Supports"
1086:             *
1087:             **/
1088:            public Collection getActivityList(String projectName)
1089:                    throws HeroException {
1090:                BnProjectLocalHome projhome;
1091:                BnProjectLocal project;
1092:                BnNodeLocalHome nodehome;
1093:                Collection executing;
1094:                this .synchronizeUser();
1095:
1096:                trace.debug("parameter: -begin projectName=" + projectName
1097:                        + " start by "
1098:                        + mContext.getCallerPrincipal().getName());
1099:                try {
1100:                    projhome = BnProjectUtil.getLocalHome();
1101:                    nodehome = BnNodeUtil.getLocalHome();
1102:                } catch (javax.naming.NamingException ne) {
1103:
1104:                    trace.error(ne.getMessage());
1105:                    throw new HeroException(ne.getMessage());
1106:                }
1107:                try {
1108:                    project = projhome.findByName(projectName);
1109:                } catch (FinderException fe) {
1110:
1111:                    trace.error("BnProject " + projectName
1112:                            + " does not exists " + fe.getMessage());
1113:                    throw new HeroException("BnProject " + projectName
1114:                            + " does not exists");
1115:                }
1116:                try {
1117:                    executing = nodehome.findUserExecuting(project.getId(),
1118:                            mContext.getCallerPrincipal().getName());
1119:                } catch (FinderException fe) {
1120:
1121:                    trace.error(fe.getMessage());
1122:                    executing = new ArrayList();
1123:                }
1124:                ArrayList result = new ArrayList();
1125:                for (Iterator i = executing.iterator(); i.hasNext();) {
1126:                    BnNodeLocal nd = (BnNodeLocal) i.next();
1127:                    result.add(nd.getName());
1128:                }
1129:                return result;
1130:            }
1131:
1132:            /**
1133:             * Obtain all user activities from specific project (executing and anticipating state)
1134:             *
1135:             * @param projectName the name of the project
1136:             * @return a String Collectio - the list of active activities of the user for a project
1137:             * @throws HeroException
1138:             * @ejb:interface-method view-type="both"
1139:             * @ejb:transaction type="Supports"
1140:             *
1141:             **/
1142:            public Collection getActivityListAsPK(String projectName)
1143:                    throws HeroException {
1144:                BnProjectLocalHome projhome;
1145:                BnProjectLocal project;
1146:                BnNodeLocalHome nodehome;
1147:                Collection executing;
1148:                ArrayList result = new ArrayList();
1149:                this .synchronizeUser();
1150:
1151:                trace.debug("parameter: -begin projectName=" + projectName
1152:                        + " start by "
1153:                        + mContext.getCallerPrincipal().getName());
1154:                try {
1155:                    projhome = BnProjectUtil.getLocalHome();
1156:                    nodehome = BnNodeUtil.getLocalHome();
1157:                } catch (javax.naming.NamingException ne) {
1158:
1159:                    trace.error(ne.getMessage());
1160:                    throw new HeroException(ne.getMessage());
1161:                }
1162:                try {
1163:                    project = projhome.findByName(projectName);
1164:                } catch (FinderException fe) {
1165:
1166:                    trace.error("BnProject " + projectName
1167:                            + " does not exists " + fe.getMessage());
1168:                    throw new HeroException("BnProject " + projectName
1169:                            + " does not exists");
1170:                }
1171:                try {
1172:                    executing = nodehome.findUserExecuting(project.getId(),
1173:                            mContext.getCallerPrincipal().getName());
1174:                    for (Iterator i = executing.iterator(); i.hasNext();) {
1175:                        BnNodeLocal nd = (BnNodeLocal) i.next();
1176:                        result.add(nd.getPrimaryKey());
1177:                    }
1178:                } catch (FinderException fe) {
1179:                    trace.error(fe.getMessage());
1180:                    executing = new ArrayList();
1181:                }
1182:                return result;
1183:            }
1184:
1185:            /**
1186:             * Obtain all user activities from specific project (executing and anticipating state)
1187:             *
1188:             * @param projectName the name of the project
1189:             * @return a String Collectio - the list of active activities of the user for a project
1190:             * @throws HeroException
1191:             * @ejb:interface-method view-type="both"
1192:             * @ejb:transaction type="Supports"
1193:             *
1194:             **/
1195:            public Collection getActivityListByPK(String projectName,
1196:                    Collection list, int offset, int numrows)
1197:                    throws HeroException {
1198:                BnProjectLocalHome projhome;
1199:                BnProjectLocal project;
1200:                BnNodeLocalHome nodehome;
1201:                Collection executing;
1202:                ArrayList result = new ArrayList();
1203:                this .synchronizeUser();
1204:
1205:                trace.debug("parameter: -begin projectName=" + projectName
1206:                        + " start by "
1207:                        + mContext.getCallerPrincipal().getName());
1208:                try {
1209:                    projhome = BnProjectUtil.getLocalHome();
1210:                    nodehome = BnNodeUtil.getLocalHome();
1211:                } catch (javax.naming.NamingException ne) {
1212:
1213:                    trace.error(ne.getMessage());
1214:                    throw new HeroException(ne.getMessage());
1215:                }
1216:                try {
1217:                    int add = 0;
1218:                    int cnt = 0;
1219:                    Iterator it = list.iterator();
1220:                    while (it.hasNext()) {
1221:                        if (cnt < offset)
1222:                            it.next();
1223:                        else {
1224:                            BnNodeLocal nd = nodehome
1225:                                    .findByPrimaryKey((BnNodePK) it.next());
1226:                            result.add(nd.getName());
1227:                            add++;
1228:                            if (add == numrows)
1229:                                break;
1230:                        }
1231:                        cnt++;
1232:                    }
1233:                } catch (FinderException fe) {
1234:                    trace.error(fe.getMessage());
1235:                    executing = new ArrayList();
1236:                }
1237:                return result;
1238:            }
1239:
1240:            /**
1241:             * Obtain todo user activities for all instances/cooperative projects (ready and anticipable state)
1242:             * @return a BnNodeValue Collection - the list of todo activities of the user for all instances
1243:             * @throws HeroException
1244:             * @ejb:interface-method view-type="both"
1245:             * @ejb:transaction type="Supports"
1246:             *
1247:             **/
1248:            public Collection getToDoListAllInstances() throws HeroException {
1249:                trace.debug(" start by "
1250:                        + mContext.getCallerPrincipal().getName());
1251:                BnNodeLocalHome nodehome;
1252:                Collection ready;
1253:                this .synchronizeUser();
1254:                try {
1255:                    nodehome = BnNodeUtil.getLocalHome();
1256:                } catch (javax.naming.NamingException ne) {
1257:                    trace.error(ne.getMessage());
1258:                    throw new HeroException(ne.getMessage());
1259:                }
1260:                try {
1261:                    ready = nodehome.findUserReadyAllProjects(mContext
1262:                            .getCallerPrincipal().getName());
1263:                } catch (FinderException fe) {
1264:                    trace.error(fe.getMessage());
1265:                    ready = new ArrayList();
1266:                }
1267:                ArrayList result = new ArrayList();
1268:                for (Iterator i = ready.iterator(); i.hasNext();) {
1269:                    BnNodeLocal nd = (BnNodeLocal) i.next();
1270:                    if (nd.getBnProject().getType().equals(
1271:                            Constants.Pj.INSTANCE)
1272:                            || nd.getBnProject().getType().equals(
1273:                                    Constants.Pj.COOPERATIVE))
1274:                        result.add(nd.getBnNodeValue());
1275:                }
1276:                return result;
1277:            }
1278:
1279:            /**
1280:             * Obtain todo user activities for all instances/cooperative projects (ready and anticipable state)
1281:             * @return a BnNodeValue Collection - the list of todo activities of the user for all instances
1282:             * @throws HeroException
1283:             * @ejb:interface-method view-type="both"
1284:             * @ejb:transaction type="Supports"
1285:             *
1286:             **/
1287:            public Collection getToDoListAllInstancesAsPK()
1288:                    throws HeroException {
1289:                trace.debug(" start by "
1290:                        + mContext.getCallerPrincipal().getName());
1291:                BnNodeLocalHome nodehome;
1292:                Collection ready;
1293:                ArrayList result = new ArrayList();
1294:                this .synchronizeUser();
1295:                try {
1296:                    nodehome = BnNodeUtil.getLocalHome();
1297:                } catch (javax.naming.NamingException ne) {
1298:                    trace.error(ne.getMessage());
1299:                    throw new HeroException(ne.getMessage());
1300:                }
1301:                try {
1302:                    ready = nodehome.findUserReadyAllProjects(mContext
1303:                            .getCallerPrincipal().getName());
1304:                    for (Iterator i = ready.iterator(); i.hasNext();) {
1305:                        BnNodeLocal nd = (BnNodeLocal) i.next();
1306:                        if (nd.getBnProject().getType().equals(
1307:                                Constants.Pj.INSTANCE)
1308:                                || nd.getBnProject().getType().equals(
1309:                                        Constants.Pj.COOPERATIVE)) {
1310:                            result.add(nd.getPrimaryKey());
1311:                        }
1312:                    }
1313:                } catch (FinderException fe) {
1314:                    trace.error(fe.getMessage());
1315:                    ready = new ArrayList();
1316:                }
1317:                return result;
1318:            }
1319:
1320:            /**
1321:             * Obtain todo user activities for all instances/cooperative projects (ready and anticipable state)
1322:             * @return a BnNodeValue Collection - the list of todo activities of the user for all instances
1323:             * @throws HeroException
1324:             * @ejb:interface-method view-type="both"
1325:             * @ejb:transaction type="Supports"
1326:             *
1327:             **/
1328:            public Collection getToDoListAllInstancesByPK(Collection list,
1329:                    int offset, int numrows) throws HeroException {
1330:                trace.debug(" start by "
1331:                        + mContext.getCallerPrincipal().getName());
1332:                BnNodeLocalHome nodehome;
1333:                Collection ready;
1334:                ArrayList result = new ArrayList();
1335:                this .synchronizeUser();
1336:                try {
1337:                    nodehome = BnNodeUtil.getLocalHome();
1338:                } catch (javax.naming.NamingException ne) {
1339:                    trace.error(ne.getMessage());
1340:                    throw new HeroException(ne.getMessage());
1341:                }
1342:                try {
1343:                    int add = 0;
1344:                    int cnt = 0;
1345:                    Iterator it = list.iterator();
1346:                    while (it.hasNext()) {
1347:                        if (cnt < offset)
1348:                            it.next();
1349:                        else {
1350:                            BnNodeLocal nd = nodehome
1351:                                    .findByPrimaryKey((BnNodePK) it.next());
1352:                            result.add(nd.getBnNodeValue());
1353:                            add++;
1354:                            if (add == numrows)
1355:                                break;
1356:                        }
1357:                        cnt++;
1358:                    }
1359:                } catch (FinderException fe) {
1360:                    trace.error(fe.getMessage());
1361:                    ready = new ArrayList();
1362:                }
1363:                return result;
1364:            }
1365:
1366:            /**
1367:             * Obtain executing user activities for all instances/cooperative projects (executing and anticipating state)
1368:             * @return a BnNodeValue Collection - the list of executing activities ot the user for all instances
1369:             * @throws HeroException
1370:             * @ejb:interface-method view-type="both"
1371:             * @ejb:transaction type="Supports"
1372:             *
1373:             **/
1374:            public Collection getActivityListAllInstances()
1375:                    throws HeroException {
1376:                trace.debug(" start by "
1377:                        + mContext.getCallerPrincipal().getName());
1378:                BnNodeLocalHome nodehome;
1379:                Collection executing;
1380:                this .synchronizeUser();
1381:                try {
1382:                    nodehome = BnNodeUtil.getLocalHome();
1383:                } catch (javax.naming.NamingException ne) {
1384:                    trace.error(ne.getMessage());
1385:                    throw new HeroException(ne.getMessage());
1386:                }
1387:                try {
1388:                    executing = nodehome.findUserExecutingAllProjects(mContext
1389:                            .getCallerPrincipal().getName());
1390:                } catch (FinderException fe) {
1391:                    trace.error(fe.getMessage());
1392:                    executing = new ArrayList();
1393:                }
1394:                ArrayList result = new ArrayList();
1395:                for (Iterator i = executing.iterator(); i.hasNext();) {
1396:                    BnNodeLocal nd = (BnNodeLocal) i.next();
1397:                    if (nd.getBnProject().getType().equals(
1398:                            Constants.Pj.INSTANCE)
1399:                            || nd.getBnProject().getType().equals(
1400:                                    Constants.Pj.COOPERATIVE))
1401:                        result.add(nd.getBnNodeValue());
1402:                }
1403:                return result;
1404:            }
1405:
1406:            /**
1407:             * Obtain executing user activities for all instances/cooperative projects (executing and anticipating state)
1408:             * @return a BnNodeValue Collection - the list of executing activities ot the user for all instances
1409:             * @throws HeroException
1410:             * @ejb:interface-method view-type="both"
1411:             * @ejb:transaction type="Supports"
1412:             *
1413:             **/
1414:            public Collection getActivityListAllInstancesAsPK()
1415:                    throws HeroException {
1416:                trace.debug(" start by "
1417:                        + mContext.getCallerPrincipal().getName());
1418:                BnNodeLocalHome nodehome;
1419:                Collection executing;
1420:                ArrayList result = new ArrayList();
1421:                this .synchronizeUser();
1422:                try {
1423:                    nodehome = BnNodeUtil.getLocalHome();
1424:                } catch (javax.naming.NamingException ne) {
1425:                    trace.error(ne.getMessage());
1426:                    throw new HeroException(ne.getMessage());
1427:                }
1428:                try {
1429:                    executing = nodehome.findUserExecutingAllProjects(mContext
1430:                            .getCallerPrincipal().getName());
1431:                    for (Iterator i = executing.iterator(); i.hasNext();) {
1432:                        BnNodeLocal nd = (BnNodeLocal) i.next();
1433:                        if (nd.getBnProject().getType().equals(
1434:                                Constants.Pj.INSTANCE)
1435:                                || nd.getBnProject().getType().equals(
1436:                                        Constants.Pj.COOPERATIVE)) {
1437:                            result.add(nd.getPrimaryKey());
1438:                        }
1439:                    }
1440:                    return result;
1441:                } catch (FinderException fe) {
1442:                    trace.error(fe.getMessage());
1443:                    executing = new ArrayList();
1444:                }
1445:                return result;
1446:            }
1447:
1448:            /**
1449:             * Obtain executing user activities for all instances/cooperative projects (executing and anticipating state)
1450:             * @return a BnNodeValue Collection - the list of executing activities ot the user for all instances
1451:             * @throws HeroException
1452:             * @ejb:interface-method view-type="both"
1453:             * @ejb:transaction type="Supports"
1454:             *
1455:             **/
1456:            public Collection getActivityListAllInstancesByPK(Collection list,
1457:                    int offset, int numrows) throws HeroException {
1458:                trace.debug(" start by "
1459:                        + mContext.getCallerPrincipal().getName());
1460:                BnNodeLocalHome nodehome;
1461:                Collection executing;
1462:                ArrayList result = new ArrayList();
1463:                this .synchronizeUser();
1464:                try {
1465:                    nodehome = BnNodeUtil.getLocalHome();
1466:                } catch (javax.naming.NamingException ne) {
1467:                    trace.error(ne.getMessage());
1468:                    throw new HeroException(ne.getMessage());
1469:                }
1470:                try {
1471:                    int add = 0;
1472:                    int cnt = 0;
1473:                    Iterator it = list.iterator();
1474:                    while (it.hasNext()) {
1475:                        if (cnt < offset)
1476:                            it.next();
1477:                        else {
1478:                            BnNodeLocal nd = nodehome
1479:                                    .findByPrimaryKey((BnNodePK) it.next());
1480:                            result.add(nd.getBnNodeValue());
1481:                            add++;
1482:                            if (add == numrows)
1483:                                break;
1484:                        }
1485:                        cnt++;
1486:                    }
1487:                } catch (FinderException fe) {
1488:                    trace.error(fe.getMessage());
1489:                    executing = new ArrayList();
1490:                }
1491:                return result;
1492:            }
1493:
1494:            /**
1495:             * Obtain terminated user activities for all instances/cooperative projects.
1496:             * @return a BnNodeValue Collection - the list of terminated activities ot the user for all instances
1497:             * @throws HeroException
1498:             * @ejb:interface-method view-type="both"
1499:             * @ejb:transaction type="Supports"
1500:             *
1501:             **/
1502:            public Collection getTerminatedListAllInstances()
1503:                    throws HeroException {
1504:                trace.debug(" start by "
1505:                        + mContext.getCallerPrincipal().getName());
1506:                BnNodeLocalHome nodehome;
1507:                Collection executing;
1508:                this .synchronizeUser();
1509:                try {
1510:                    nodehome = BnNodeUtil.getLocalHome();
1511:                } catch (javax.naming.NamingException ne) {
1512:                    trace.error(ne.getMessage());
1513:                    throw new HeroException(ne.getMessage());
1514:                }
1515:                try {
1516:                    executing = nodehome.findUserTerminatedAllProjects(mContext
1517:                            .getCallerPrincipal().getName());
1518:                } catch (FinderException fe) {
1519:                    trace.error(fe.getMessage());
1520:                    executing = new ArrayList();
1521:                }
1522:                ArrayList result = new ArrayList();
1523:                for (Iterator i = executing.iterator(); i.hasNext();) {
1524:                    BnNodeLocal nd = (BnNodeLocal) i.next();
1525:                    if (nd.getBnProject().getType().equals(
1526:                            Constants.Pj.INSTANCE)
1527:                            || nd.getBnProject().getType().equals(
1528:                                    Constants.Pj.COOPERATIVE))
1529:                        result.add(nd.getBnNodeValue());
1530:                }
1531:                return result;
1532:            }
1533:
1534:            /**
1535:             * Obtain a subset of the terminated user activities for all instances/cooperative projects.
1536:             * @return a BnNodeValue Collection - the list of terminated activities ot the user for all instances
1537:             * @throws HeroException
1538:             * @ejb:interface-method view-type="both"
1539:             * @ejb:transaction type="Supports"
1540:             *
1541:             **/
1542:            public Collection getTerminatedListAllInstancesAsPK()
1543:                    throws HeroException {
1544:                trace.debug(" start by "
1545:                        + mContext.getCallerPrincipal().getName());
1546:                BnNodeLocalHome nodehome;
1547:                Collection executing;
1548:                ArrayList result = new ArrayList();
1549:                this .synchronizeUser();
1550:                try {
1551:                    nodehome = BnNodeUtil.getLocalHome();
1552:                } catch (javax.naming.NamingException ne) {
1553:                    trace.error(ne.getMessage());
1554:                    throw new HeroException(ne.getMessage());
1555:                }
1556:                try {
1557:                    executing = nodehome.findUserTerminatedAllProjects(mContext
1558:                            .getCallerPrincipal().getName());
1559:                    for (Iterator i = executing.iterator(); i.hasNext();) {
1560:                        BnNodeLocal nd = (BnNodeLocal) i.next();
1561:                        if (nd.getBnProject().getType().equals(
1562:                                Constants.Pj.INSTANCE)
1563:                                || nd.getBnProject().getType().equals(
1564:                                        Constants.Pj.COOPERATIVE)) {
1565:                            result.add(nd.getPrimaryKey());
1566:                        }
1567:                    }
1568:                } catch (FinderException fe) {
1569:                    trace.error(fe.getMessage());
1570:                    executing = new ArrayList();
1571:                }
1572:                return result;
1573:            }
1574:
1575:            /**
1576:             * Obtain a subset of the terminated user activities for all instances/cooperative projects.
1577:             * @return a BnNodeValue Collection - the list of terminated activities ot the user for all instances
1578:             * @throws HeroException
1579:             * @ejb:interface-method view-type="both"
1580:             * @ejb:transaction type="Supports"
1581:             *
1582:             **/
1583:            public Collection getTerminatedListAllInstancesByPK(
1584:                    Collection list, int offset, int numrows)
1585:                    throws HeroException {
1586:                trace.debug(" start by "
1587:                        + mContext.getCallerPrincipal().getName());
1588:                BnNodeLocalHome nodehome;
1589:                Collection executing;
1590:                ArrayList result = new ArrayList();
1591:                this .synchronizeUser();
1592:                try {
1593:                    nodehome = BnNodeUtil.getLocalHome();
1594:                } catch (javax.naming.NamingException ne) {
1595:                    trace.error(ne.getMessage());
1596:                    throw new HeroException(ne.getMessage());
1597:                }
1598:                try {
1599:                    int add = 0;
1600:                    int cnt = 0;
1601:                    Iterator it = list.iterator();
1602:                    while (it.hasNext()) {
1603:                        if (cnt < offset)
1604:                            it.next();
1605:                        else {
1606:                            BnNodeLocal nd = nodehome
1607:                                    .findByPrimaryKey((BnNodePK) it.next());
1608:                            result.add(nd.getBnNodeValue());
1609:                            add++;
1610:                            if (add == numrows)
1611:                                break;
1612:                        }
1613:                        cnt++;
1614:                    }
1615:                } catch (FinderException fe) {
1616:                    trace.error(fe.getMessage());
1617:                    executing = new ArrayList();
1618:                }
1619:                return result;
1620:            }
1621:
1622:            /**
1623:             * Obtain todo user activities matching with project property value (ready and anticipable state activities)
1624:             * @return a BnNodeValue Collection - the list of todo activities matching to project property value
1625:             * @param key the key of the property
1626:             * @param value the value of the property
1627:             * 
1628:             * @throws HeroException
1629:             * @ejb:interface-method view-type="both"
1630:             * @ejb:transaction type="Supports"
1631:             *
1632:             **/
1633:            public Collection getToDoListByProperty(String key, String value)
1634:                    throws HeroException {
1635:                trace.debug(" start by "
1636:                        + mContext.getCallerPrincipal().getName());
1637:                BnNodeLocalHome nodehome;
1638:                Collection ready;
1639:                this .synchronizeUser();
1640:                try {
1641:                    nodehome = BnNodeUtil.getLocalHome();
1642:                } catch (javax.naming.NamingException ne) {
1643:                    trace.error(ne.getMessage());
1644:                    throw new HeroException(ne.getMessage());
1645:                }
1646:                try {
1647:                    ready = nodehome
1648:                            .findUserReadyAllProjectsByProperty(mContext
1649:                                    .getCallerPrincipal().getName(), key, value);
1650:                } catch (FinderException fe) {
1651:                    trace.error(fe.getMessage());
1652:                    ready = new ArrayList();
1653:                }
1654:                ArrayList result = new ArrayList();
1655:                for (Iterator i = ready.iterator(); i.hasNext();) {
1656:                    BnNodeLocal nd = (BnNodeLocal) i.next();
1657:                    if (nd.getBnProject().getName().matches(".*_instance.*"))
1658:                        result.add(nd.getBnNodeValue());
1659:                }
1660:                return result;
1661:            }
1662:
1663:            /**
1664:             * Obtain todo user activities matching with project property value (ready and anticipable state activities)
1665:             * @return a BnNodeValue Collection - the list of todo activities matching to project property value
1666:             * @param key the key of the property
1667:             * @param value the value of the property
1668:             * 
1669:             * @throws HeroException
1670:             * @ejb:interface-method view-type="both"
1671:             * @ejb:transaction type="Supports"
1672:             *
1673:             **/
1674:            public Collection getToDoListByPropertyAsPK(String key, String value)
1675:                    throws HeroException {
1676:                trace.debug(" start by "
1677:                        + mContext.getCallerPrincipal().getName());
1678:                BnNodeLocalHome nodehome;
1679:                Collection ready;
1680:                ArrayList result = new ArrayList();
1681:                this .synchronizeUser();
1682:                try {
1683:                    nodehome = BnNodeUtil.getLocalHome();
1684:                } catch (javax.naming.NamingException ne) {
1685:                    trace.error(ne.getMessage());
1686:                    throw new HeroException(ne.getMessage());
1687:                }
1688:                try {
1689:                    ready = nodehome
1690:                            .findUserReadyAllProjectsByProperty(mContext
1691:                                    .getCallerPrincipal().getName(), key, value);
1692:                    for (Iterator i = ready.iterator(); i.hasNext();) {
1693:                        BnNodeLocal nd = (BnNodeLocal) i.next();
1694:                        if (nd.getBnProject().getName()
1695:                                .matches(".*_instance.*")) {
1696:                            result.add(nd.getPrimaryKey());
1697:                        }
1698:                    }
1699:                } catch (FinderException fe) {
1700:                    trace.error(fe.getMessage());
1701:                    ready = new ArrayList();
1702:                }
1703:                return result;
1704:            }
1705:
1706:            /**
1707:             * Obtain todo user activities matching with project property value (ready and anticipable state activities)
1708:             * @return a BnNodeValue Collection - the list of todo activities matching to project property value
1709:             * @param key the key of the property
1710:             * @param value the value of the property
1711:             * 
1712:             * @throws HeroException
1713:             * @ejb:interface-method view-type="both"
1714:             * @ejb:transaction type="Supports"
1715:             *
1716:             **/
1717:            public Collection getToDoListByPropertyByPK(String key,
1718:                    String value, Collection list, int offset, int numrows)
1719:                    throws HeroException {
1720:                trace.debug(" start by "
1721:                        + mContext.getCallerPrincipal().getName());
1722:                BnNodeLocalHome nodehome;
1723:                Collection ready;
1724:                ArrayList result = new ArrayList();
1725:                this .synchronizeUser();
1726:                try {
1727:                    nodehome = BnNodeUtil.getLocalHome();
1728:                } catch (javax.naming.NamingException ne) {
1729:                    trace.error(ne.getMessage());
1730:                    throw new HeroException(ne.getMessage());
1731:                }
1732:                try {
1733:                    int add = 0;
1734:                    int cnt = 0;
1735:                    Iterator it = list.iterator();
1736:                    while (it.hasNext()) {
1737:                        if (cnt < offset)
1738:                            it.next();
1739:                        else {
1740:                            BnNodeLocal nd = nodehome
1741:                                    .findByPrimaryKey((BnNodePK) it.next());
1742:                            result.add(nd.getBnNodeValue());
1743:                            add++;
1744:                            if (add == numrows)
1745:                                break;
1746:                        }
1747:                        cnt++;
1748:                    }
1749:                } catch (FinderException fe) {
1750:                    trace.error(fe.getMessage());
1751:                    ready = new ArrayList();
1752:                }
1753:                return result;
1754:            }
1755:
1756:            /**
1757:             * Obtain todo user activities matching with project properties (ready and anticipable state activities)
1758:             * @return a BnNodeValue Collection - the list of todo activities matching to property value. This method
1759:             * is oriented to administrative workflow (workflow instances) and supports one, two or three properties (key/value pairs).
1760:             * Operation constants values: hero.interfaces.Constants.AND, hero.interfaces.Constants.OR 
1761:             * 
1762:             * @param operation AND/OR operations are allowed.
1763:             * @param properties Hashtable containing the key/value elements
1764:             * 
1765:             * @throws HeroException
1766:             * @ejb:interface-method view-type="both"
1767:             * @ejb:transaction type="Supports"
1768:             *
1769:             **/
1770:            public Collection getToDoListByProperties(int operation,
1771:                    Hashtable properties) throws HeroException {
1772:                trace.debug(" start by "
1773:                        + mContext.getCallerPrincipal().getName());
1774:                BnNodeLocalHome nodehome;
1775:                Collection ready = new ArrayList();
1776:                this .synchronizeUser();
1777:                try {
1778:                    nodehome = BnNodeUtil.getLocalHome();
1779:                } catch (javax.naming.NamingException ne) {
1780:                    trace.error(ne.getMessage());
1781:                    throw new HeroException(ne.getMessage());
1782:                }
1783:                try {
1784:                    Enumeration keys = properties.keys();
1785:                    Collection vls = properties.values();
1786:                    Iterator values = vls.iterator();
1787:                    if (properties.size() > 3) {
1788:                        throw new HeroException(
1789:                                "This method uses EJBQL language to improve queries. These queries are based "
1790:                                        + "on static parameters numbers, so if you want use this method with more than three properties contact us !!");
1791:                    }
1792:                    if (properties.size() == 1)
1793:                        ready = nodehome.findUserReadyAllProjectsByProperty(
1794:                                mContext.getCallerPrincipal().getName(),
1795:                                (String) keys.nextElement(), (String) values
1796:                                        .next());
1797:                    if (operation == Constants.AND) {
1798:                        if (properties.size() == 2)
1799:                            ready = nodehome
1800:                                    .findUserReadyAllProjectsByTwoPropertiesAND(
1801:                                            mContext.getCallerPrincipal()
1802:                                                    .getName(), (String) keys
1803:                                                    .nextElement(),
1804:                                            (String) values.next(),
1805:                                            (String) keys.nextElement(),
1806:                                            (String) values.next());
1807:                        else if (properties.size() == 3)
1808:                            ready = nodehome
1809:                                    .findUserReadyAllProjectsByThreePropertiesAND(
1810:                                            mContext.getCallerPrincipal()
1811:                                                    .getName(), (String) keys
1812:                                                    .nextElement(),
1813:                                            (String) values.next(),
1814:                                            (String) keys.nextElement(),
1815:                                            (String) values.next(),
1816:                                            (String) keys.nextElement(),
1817:                                            (String) values.next());
1818:                    } else if (operation == Constants.OR) {
1819:                        if (properties.size() == 2)
1820:                            ready = nodehome
1821:                                    .findUserReadyAllProjectsByTwoPropertiesOR(
1822:                                            mContext.getCallerPrincipal()
1823:                                                    .getName(), (String) keys
1824:                                                    .nextElement(),
1825:                                            (String) values.next(),
1826:                                            (String) keys.nextElement(),
1827:                                            (String) values.next());
1828:                        else if (properties.size() == 3)
1829:                            ready = nodehome
1830:                                    .findUserReadyAllProjectsByThreePropertiesOR(
1831:                                            mContext.getCallerPrincipal()
1832:                                                    .getName(), (String) keys
1833:                                                    .nextElement(),
1834:                                            (String) values.next(),
1835:                                            (String) keys.nextElement(),
1836:                                            (String) values.next(),
1837:                                            (String) keys.nextElement(),
1838:                                            (String) values.next());
1839:                    }
1840:                } catch (FinderException fe) {
1841:                    trace.error(fe.getMessage());
1842:                    ready = new ArrayList();
1843:                }
1844:                ArrayList result = new ArrayList();
1845:                for (Iterator i = ready.iterator(); i.hasNext();) {
1846:                    BnNodeLocal nd = (BnNodeLocal) i.next();
1847:                    if (nd.getBnProject().getName().matches(".*_instance.*"))
1848:                        result.add(nd.getBnNodeValue());
1849:                }
1850:                return result;
1851:            }
1852:
1853:            /**
1854:             * Obtain todo user activities matching with project properties (ready and anticipable state activities)
1855:             * @return a BnNodeValue Collection - the list of todo activities matching to property value. This method
1856:             * is oriented to administrative workflow (workflow instances) and supports one, two or three properties (key/value pairs).
1857:             * Operation constants values: hero.interfaces.Constants.AND, hero.interfaces.Constants.OR 
1858:             * 
1859:             * @param operation AND/OR operations are allowed.
1860:             * @param properties Hashtable containing the key/value elements
1861:             * 
1862:             * @throws HeroException
1863:             * @ejb:interface-method view-type="both"
1864:             * @ejb:transaction type="Supports"
1865:             *
1866:             **/
1867:            public Collection getToDoListByPropertiesAsPK(int operation,
1868:                    Hashtable properties) throws HeroException {
1869:                trace.debug(" start by "
1870:                        + mContext.getCallerPrincipal().getName());
1871:                BnNodeLocalHome nodehome;
1872:                Collection ready = new ArrayList();
1873:                ArrayList result = new ArrayList();
1874:                this .synchronizeUser();
1875:                try {
1876:                    nodehome = BnNodeUtil.getLocalHome();
1877:                } catch (javax.naming.NamingException ne) {
1878:                    trace.error(ne.getMessage());
1879:                    throw new HeroException(ne.getMessage());
1880:                }
1881:                try {
1882:                    Enumeration keys = properties.keys();
1883:                    Collection vls = properties.values();
1884:                    Iterator values = vls.iterator();
1885:                    if (properties.size() > 3) {
1886:                        throw new HeroException(
1887:                                "This method uses EJBQL language to improve queries. These queries are based "
1888:                                        + "on static parameters numbers, so if you want use this method with more than three properties contact us !!");
1889:                    }
1890:                    if (properties.size() == 1)
1891:                        ready = nodehome.findUserReadyAllProjectsByProperty(
1892:                                mContext.getCallerPrincipal().getName(),
1893:                                (String) keys.nextElement(), (String) values
1894:                                        .next());
1895:                    if (operation == Constants.AND) {
1896:                        if (properties.size() == 2)
1897:                            ready = nodehome
1898:                                    .findUserReadyAllProjectsByTwoPropertiesAND(
1899:                                            mContext.getCallerPrincipal()
1900:                                                    .getName(), (String) keys
1901:                                                    .nextElement(),
1902:                                            (String) values.next(),
1903:                                            (String) keys.nextElement(),
1904:                                            (String) values.next());
1905:                        else if (properties.size() == 3)
1906:                            ready = nodehome
1907:                                    .findUserReadyAllProjectsByThreePropertiesAND(
1908:                                            mContext.getCallerPrincipal()
1909:                                                    .getName(), (String) keys
1910:                                                    .nextElement(),
1911:                                            (String) values.next(),
1912:                                            (String) keys.nextElement(),
1913:                                            (String) values.next(),
1914:                                            (String) keys.nextElement(),
1915:                                            (String) values.next());
1916:                    } else if (operation == Constants.OR) {
1917:                        if (properties.size() == 2)
1918:                            ready = nodehome
1919:                                    .findUserReadyAllProjectsByTwoPropertiesOR(
1920:                                            mContext.getCallerPrincipal()
1921:                                                    .getName(), (String) keys
1922:                                                    .nextElement(),
1923:                                            (String) values.next(),
1924:                                            (String) keys.nextElement(),
1925:                                            (String) values.next());
1926:                        else if (properties.size() == 3)
1927:                            ready = nodehome
1928:                                    .findUserReadyAllProjectsByThreePropertiesOR(
1929:                                            mContext.getCallerPrincipal()
1930:                                                    .getName(), (String) keys
1931:                                                    .nextElement(),
1932:                                            (String) values.next(),
1933:                                            (String) keys.nextElement(),
1934:                                            (String) values.next(),
1935:                                            (String) keys.nextElement(),
1936:                                            (String) values.next());
1937:                    }
1938:                    for (Iterator i = ready.iterator(); i.hasNext();) {
1939:                        BnNodeLocal nd = (BnNodeLocal) i.next();
1940:                        if (nd.getBnProject().getName()
1941:                                .matches(".*_instance.*")) {
1942:                            result.add(nd.getPrimaryKey());
1943:                        }
1944:                    }
1945:                } catch (FinderException fe) {
1946:                    trace.error(fe.getMessage());
1947:                    ready = new ArrayList();
1948:                }
1949:                return result;
1950:            }
1951:
1952:            /**
1953:             * Obtain todo user activities matching with project properties (ready and anticipable state activities)
1954:             * @return a BnNodeValue Collection - the list of todo activities matching to property value. This method
1955:             * is oriented to administrative workflow (workflow instances) and supports one, two or three properties (key/value pairs).
1956:             * Operation constants values: hero.interfaces.Constants.AND, hero.interfaces.Constants.OR 
1957:             * 
1958:             * @param operation AND/OR operations are allowed.
1959:             * @param properties Hashtable containing the key/value elements
1960:             * 
1961:             * @throws HeroException
1962:             * @ejb:interface-method view-type="both"
1963:             * @ejb:transaction type="Supports"
1964:             *
1965:             **/
1966:            public Collection getToDoListByPropertiesByPK(int operation,
1967:                    Hashtable properties, Collection list, int offset,
1968:                    int numrows) throws HeroException {
1969:                trace.debug(" start by "
1970:                        + mContext.getCallerPrincipal().getName());
1971:                BnNodeLocalHome nodehome;
1972:                Collection ready = new ArrayList();
1973:                ArrayList result = new ArrayList();
1974:                this .synchronizeUser();
1975:                try {
1976:                    nodehome = BnNodeUtil.getLocalHome();
1977:                } catch (javax.naming.NamingException ne) {
1978:                    trace.error(ne.getMessage());
1979:                    throw new HeroException(ne.getMessage());
1980:                }
1981:                try {
1982:                    int add = 0;
1983:                    int cnt = 0;
1984:                    Iterator it = list.iterator();
1985:                    while (it.hasNext()) {
1986:                        if (cnt < offset)
1987:                            it.next();
1988:                        else {
1989:                            BnNodeLocal nd = nodehome
1990:                                    .findByPrimaryKey((BnNodePK) it.next());
1991:                            result.add(nd.getBnNodeValue());
1992:                            add++;
1993:                            if (add == numrows)
1994:                                break;
1995:                        }
1996:                        cnt++;
1997:                    }
1998:                } catch (FinderException fe) {
1999:                    trace.error(fe.getMessage());
2000:                    ready = new ArrayList();
2001:                }
2002:                return result;
2003:            }
2004:
2005:            /**
2006:             * Obtain todo user activities matching with activity property value (ready and anticipable state activities)
2007:             * @return a BnNodeValue Collection - the list of todo activities matching to activity property value
2008:             * @param key the key of the property
2009:             * @param value the value of the property
2010:             * 
2011:             * @throws HeroException
2012:             * @ejb:interface-method view-type="both"
2013:             * @ejb:transaction type="Supports"
2014:             *
2015:             **/
2016:            public Collection getToDoListByActivityProperty(String key,
2017:                    String value) throws HeroException {
2018:                trace.debug(" start by "
2019:                        + mContext.getCallerPrincipal().getName());
2020:                BnNodeLocalHome nodehome;
2021:                Collection ready;
2022:                this .synchronizeUser();
2023:                try {
2024:                    nodehome = BnNodeUtil.getLocalHome();
2025:                } catch (javax.naming.NamingException ne) {
2026:                    trace.error(ne.getMessage());
2027:                    throw new HeroException(ne.getMessage());
2028:                }
2029:                try {
2030:                    ready = nodehome
2031:                            .findUserReadyAllActivitiesByProperty(mContext
2032:                                    .getCallerPrincipal().getName(), key, value);
2033:                } catch (FinderException fe) {
2034:                    trace.error(fe.getMessage());
2035:                    ready = new ArrayList();
2036:                }
2037:                ArrayList result = new ArrayList();
2038:                for (Iterator i = ready.iterator(); i.hasNext();) {
2039:                    BnNodeLocal nd = (BnNodeLocal) i.next();
2040:                    if (nd.getBnProject().getName().matches(".*_instance.*"))
2041:                        result.add(nd.getBnNodeValue());
2042:                }
2043:                return result;
2044:            }
2045:
2046:            /**
2047:             * Obtain todo user activities matching with activity property value (ready and anticipable state activities)
2048:             * @return a BnNodeValue Collection - the list of todo activities matching to activity property value
2049:             * @param key the key of the property
2050:             * @param value the value of the property
2051:             * 
2052:             * @throws HeroException
2053:             * @ejb:interface-method view-type="both"
2054:             * @ejb:transaction type="Supports"
2055:             *
2056:             **/
2057:            public Collection getToDoListByActivityPropertyAsPK(String key,
2058:                    String value) throws HeroException {
2059:                trace.debug(" start by "
2060:                        + mContext.getCallerPrincipal().getName());
2061:                BnNodeLocalHome nodehome;
2062:                Collection ready;
2063:                ArrayList result = new ArrayList();
2064:                this .synchronizeUser();
2065:                try {
2066:                    nodehome = BnNodeUtil.getLocalHome();
2067:                } catch (javax.naming.NamingException ne) {
2068:                    trace.error(ne.getMessage());
2069:                    throw new HeroException(ne.getMessage());
2070:                }
2071:                try {
2072:                    ready = nodehome
2073:                            .findUserReadyAllActivitiesByProperty(mContext
2074:                                    .getCallerPrincipal().getName(), key, value);
2075:                    for (Iterator i = ready.iterator(); i.hasNext();) {
2076:                        BnNodeLocal nd = (BnNodeLocal) i.next();
2077:                        if (nd.getBnProject().getName()
2078:                                .matches(".*_instance.*")) {
2079:                            result.add(nd.getPrimaryKey());
2080:                        }
2081:                    }
2082:                } catch (FinderException fe) {
2083:                    trace.error(fe.getMessage());
2084:                    ready = new ArrayList();
2085:                }
2086:                return result;
2087:            }
2088:
2089:            /**
2090:             * Obtain todo user activities matching with activity property value (ready and anticipable state activities)
2091:             * @return a BnNodeValue Collection - the list of todo activities matching to activity property value
2092:             * @param key the key of the property
2093:             * @param value the value of the property
2094:             * 
2095:             * @throws HeroException
2096:             * @ejb:interface-method view-type="both"
2097:             * @ejb:transaction type="Supports"
2098:             *
2099:             **/
2100:            public Collection getToDoListByActivityPropertyByPK(String key,
2101:                    String value, Collection list, int offset, int numrows)
2102:                    throws HeroException {
2103:                trace.debug(" start by "
2104:                        + mContext.getCallerPrincipal().getName());
2105:                BnNodeLocalHome nodehome;
2106:                Collection ready;
2107:                ArrayList result = new ArrayList();
2108:                this .synchronizeUser();
2109:                try {
2110:                    nodehome = BnNodeUtil.getLocalHome();
2111:                } catch (javax.naming.NamingException ne) {
2112:                    trace.error(ne.getMessage());
2113:                    throw new HeroException(ne.getMessage());
2114:                }
2115:                try {
2116:                    int add = 0;
2117:                    int cnt = 0;
2118:                    Iterator it = list.iterator();
2119:                    while (it.hasNext()) {
2120:                        if (cnt < offset)
2121:                            it.next();
2122:                        else {
2123:                            BnNodeLocal nd = nodehome
2124:                                    .findByPrimaryKey((BnNodePK) it.next());
2125:                            result.add(nd.getBnNodeValue());
2126:                            add++;
2127:                            if (add == numrows)
2128:                                break;
2129:                        }
2130:                        cnt++;
2131:                    }
2132:                } catch (FinderException fe) {
2133:                    trace.error(fe.getMessage());
2134:                    ready = new ArrayList();
2135:                }
2136:                return result;
2137:            }
2138:
2139:            /**
2140:             * Obtain executing user activities matching with property value (executing and anticipating state activities)
2141:             * @return a BnNodeValue Collection - the list of executing activities matching to property value
2142:             * @param key the key of the property
2143:             * @param value the value of the property
2144:             * 
2145:             * @throws HeroException
2146:             * @ejb:interface-method view-type="both"
2147:             * @ejb:transaction type="Supports"
2148:             *
2149:             **/
2150:            public Collection getActivityListByProperty(String key, String value)
2151:                    throws HeroException {
2152:                trace.debug(" start by "
2153:                        + mContext.getCallerPrincipal().getName());
2154:                BnNodeLocalHome nodehome;
2155:                Collection executing;
2156:                this .synchronizeUser();
2157:                try {
2158:                    nodehome = BnNodeUtil.getLocalHome();
2159:                } catch (javax.naming.NamingException ne) {
2160:                    trace.error(ne.getMessage());
2161:                    throw new HeroException(ne.getMessage());
2162:                }
2163:                try {
2164:                    executing = nodehome
2165:                            .findUserExecutingAllProjectsByProperty(mContext
2166:                                    .getCallerPrincipal().getName(), key, value);
2167:                } catch (FinderException fe) {
2168:                    trace.error(fe.getMessage());
2169:                    executing = new ArrayList();
2170:                }
2171:                ArrayList result = new ArrayList();
2172:                for (Iterator i = executing.iterator(); i.hasNext();) {
2173:                    BnNodeLocal nd = (BnNodeLocal) i.next();
2174:                    if (nd.getBnProject().getName().matches(".*_instance.*"))
2175:                        result.add(nd.getBnNodeValue());
2176:                }
2177:                return result;
2178:            }
2179:
2180:            /**
2181:             * Obtain executing user activities matching with property value (executing and anticipating state activities)
2182:             * @return a BnNodeValue Collection - the list of executing activities matching to property value
2183:             * @param key the key of the property
2184:             * @param value the value of the property
2185:             * 
2186:             * @throws HeroException
2187:             * @ejb:interface-method view-type="both"
2188:             * @ejb:transaction type="Supports"
2189:             *
2190:             **/
2191:            public Collection getActivityListByPropertyAsPK(String key,
2192:                    String value) throws HeroException {
2193:                trace.debug(" start by "
2194:                        + mContext.getCallerPrincipal().getName());
2195:                BnNodeLocalHome nodehome;
2196:                Collection executing;
2197:                ArrayList result = new ArrayList();
2198:                this .synchronizeUser();
2199:                try {
2200:                    nodehome = BnNodeUtil.getLocalHome();
2201:                } catch (javax.naming.NamingException ne) {
2202:                    trace.error(ne.getMessage());
2203:                    throw new HeroException(ne.getMessage());
2204:                }
2205:                try {
2206:                    executing = nodehome
2207:                            .findUserExecutingAllProjectsByProperty(mContext
2208:                                    .getCallerPrincipal().getName(), key, value);
2209:                    for (Iterator i = executing.iterator(); i.hasNext();) {
2210:                        BnNodeLocal nd = (BnNodeLocal) i.next();
2211:                        if (nd.getBnProject().getName()
2212:                                .matches(".*_instance.*")) {
2213:                            result.add(nd.getPrimaryKey());
2214:                        }
2215:                    }
2216:                } catch (FinderException fe) {
2217:                    trace.error(fe.getMessage());
2218:                    executing = new ArrayList();
2219:                }
2220:                return result;
2221:            }
2222:
2223:            /**
2224:             * Obtain executing user activities matching with property value (executing and anticipating state activities)
2225:             * @return a BnNodeValue Collection - the list of executing activities matching to property value
2226:             * @param key the key of the property
2227:             * @param value the value of the property
2228:             * 
2229:             * @throws HeroException
2230:             * @ejb:interface-method view-type="both"
2231:             * @ejb:transaction type="Supports"
2232:             *
2233:             **/
2234:            public Collection getActivityListByPropertyByPK(String key,
2235:                    String value, Collection list, int offset, int numrows)
2236:                    throws HeroException {
2237:                trace.debug(" start by "
2238:                        + mContext.getCallerPrincipal().getName());
2239:                BnNodeLocalHome nodehome;
2240:                Collection executing;
2241:                ArrayList result = new ArrayList();
2242:                this .synchronizeUser();
2243:                try {
2244:                    nodehome = BnNodeUtil.getLocalHome();
2245:                } catch (javax.naming.NamingException ne) {
2246:                    trace.error(ne.getMessage());
2247:                    throw new HeroException(ne.getMessage());
2248:                }
2249:                try {
2250:                    int add = 0;
2251:                    int cnt = 0;
2252:                    Iterator it = list.iterator();
2253:                    while (it.hasNext()) {
2254:                        if (cnt < offset)
2255:                            it.next();
2256:                        else {
2257:                            BnNodeLocal nd = nodehome
2258:                                    .findByPrimaryKey((BnNodePK) it.next());
2259:                            result.add(nd.getBnNodeValue());
2260:                            add++;
2261:                            if (add == numrows)
2262:                                break;
2263:                        }
2264:                        cnt++;
2265:                    }
2266:                } catch (FinderException fe) {
2267:                    trace.error(fe.getMessage());
2268:                    executing = new ArrayList();
2269:                }
2270:                return result;
2271:            }
2272:
2273:            /**
2274:             * Get workflow instances names of this project
2275:             *
2276:             * @param projectName the name of the project
2277:             * @param version the name of the version
2278:             * @return a String Collection - the names of project instances
2279:             * @throws HeroException
2280:             * @ejb:interface-method view-type="both"
2281:             * @ejb:transaction type="Supports"
2282:             *
2283:             **/
2284:            public Collection getProjectInstancesNames(String projectName,
2285:                    String version) throws HeroException {
2286:
2287:                trace.debug("parameter: projectName = " + projectName
2288:                        + " start by "
2289:                        + mContext.getCallerPrincipal().getName());
2290:                ArrayList result = new ArrayList();
2291:                BnProjectLocalHome projhome;
2292:                this .synchronizeUser();
2293:                try {
2294:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
2295:
2296:                    Collection instances = projhome
2297:                            .findUserInstancesByProjectVersion(projectName
2298:                                    + "_instance%", version, this .getUser());
2299:                    for (Iterator i = instances.iterator(); i.hasNext();) {
2300:                        BnProjectLocal pl = (BnProjectLocal) i.next();
2301:                        if (!pl.getName().equals(projectName))
2302:                            result.add(pl.getName());
2303:                    }
2304:                    return (result);
2305:                } catch (javax.naming.NamingException ne) {
2306:
2307:                    trace.error(ne.getMessage());
2308:                    throw new HeroException(ne.getMessage());
2309:                } catch (javax.ejb.FinderException fe) {
2310:
2311:                    trace.error(fe.getMessage());
2312:                    throw new HeroException(fe.getMessage());
2313:                }
2314:            }
2315:
2316:            /**
2317:             * Get workflow instances names of this project
2318:             *
2319:             * @param projectName the name of the project
2320:             * @return a String Collection - the names of project instances
2321:             * @throws HeroException
2322:             * @ejb:interface-method view-type="both"
2323:             * @ejb:transaction type="Supports"
2324:             *
2325:             **/
2326:            public Collection getProjectInstancesNames(String projectName)
2327:                    throws HeroException {
2328:                return (this .getProjectInstancesNames(projectName,
2329:                        EventConstants.DEFAULTPROJECTVERSION));
2330:            }
2331:
2332:            /**
2333:             * Get workflow instances names of this project
2334:             *
2335:             * @param projectName the name of the project
2336:             * @param version the name of the version
2337:             * @return a String Collection - the names of project instances
2338:             * @throws HeroException
2339:             * @ejb:interface-method view-type="both"
2340:             * @ejb:transaction type="Supports"
2341:             *
2342:             **/
2343:            public Collection getProjectInstancesNamesAsPK(String projectName,
2344:                    String version) throws HeroException {
2345:
2346:                trace.debug("parameter: projectName = " + projectName
2347:                        + " start by "
2348:                        + mContext.getCallerPrincipal().getName());
2349:                ArrayList result = new ArrayList();
2350:                BnProjectLocalHome projhome;
2351:                this .synchronizeUser();
2352:                try {
2353:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
2354:                    Collection instances = projhome
2355:                            .findUserInstancesByProjectVersion(projectName
2356:                                    + "_instance%", version, this .getUser());
2357:                    for (Iterator i = instances.iterator(); i.hasNext();) {
2358:                        BnProjectLocal pl = (BnProjectLocal) i.next();
2359:                        if (!pl.getName().equals(projectName)) {
2360:                            result.add(pl.getPrimaryKey());
2361:                        }
2362:                    }
2363:                    return result;
2364:                } catch (javax.naming.NamingException ne) {
2365:                    trace.error(ne.getMessage());
2366:                    throw new HeroException(ne.getMessage());
2367:                } catch (javax.ejb.FinderException fe) {
2368:                    trace.error(fe.getMessage());
2369:                    throw new HeroException(fe.getMessage());
2370:                }
2371:            }
2372:
2373:            /**
2374:             * Get workflow instances names of this project
2375:             *
2376:             * @param projectName the name of the project
2377:             * @return a String Collection - the names of project instances
2378:             * @throws HeroException
2379:             * @ejb:interface-method view-type="both"
2380:             * @ejb:transaction type="Supports"
2381:             *
2382:             **/
2383:            public Collection getProjectInstancesNamesAsPK(String projectName)
2384:                    throws HeroException {
2385:                return (this .getProjectInstancesNamesAsPK(projectName,
2386:                        EventConstants.DEFAULTPROJECTVERSION));
2387:            }
2388:
2389:            /**
2390:             * Get workflow instances names of this project
2391:             *
2392:             * @param projectName the name of the project
2393:             * @return a String Collection - the names of project instances
2394:             * @throws HeroException
2395:             * @ejb:interface-method view-type="both"
2396:             * @ejb:transaction type="Supports"
2397:             *
2398:             **/
2399:            public Collection getProjectInstancesNamesByPK(String projectName,
2400:                    Collection list, int offset, int numrows)
2401:                    throws HeroException {
2402:
2403:                trace.debug("parameter: projectName = " + projectName
2404:                        + " start by "
2405:                        + mContext.getCallerPrincipal().getName());
2406:                ArrayList result = new ArrayList();
2407:                BnProjectLocalHome projhome;
2408:                this .synchronizeUser();
2409:                try {
2410:                    int add = 0;
2411:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
2412:                    int cnt = 0;
2413:                    Iterator it = list.iterator();
2414:                    while (it.hasNext()) {
2415:                        if (cnt < offset)
2416:                            it.next();
2417:                        else {
2418:                            BnProjectLocal pl = projhome
2419:                                    .findByPrimaryKey((BnProjectPK) it.next());
2420:                            result.add(pl.getName());
2421:                            add++;
2422:                            if (add == numrows)
2423:                                break;
2424:                        }
2425:                        cnt++;
2426:                    }
2427:                    return (result);
2428:                } catch (javax.naming.NamingException ne) {
2429:                    trace.error(ne.getMessage());
2430:                    throw new HeroException(ne.getMessage());
2431:                } catch (javax.ejb.FinderException fe) {
2432:                    trace.error(fe.getMessage());
2433:                    throw new HeroException(fe.getMessage());
2434:                }
2435:            }
2436:
2437:            /**
2438:             * Get Workflow instances of this project
2439:             *
2440:             * @return a BnProjectValue Collection - list of project instances
2441:             * @param projectName the name of the project
2442:             * @param version the name of the version
2443:             * @ejb:interface-method view-type="both"
2444:             * @ejb:transaction type="Supports"
2445:             *
2446:             **/
2447:            public Collection getProjectInstances(String projectName,
2448:                    String version) throws HeroException {
2449:
2450:                trace.debug("parameter: projectName = " + projectName
2451:                        + " start by "
2452:                        + mContext.getCallerPrincipal().getName());
2453:                ArrayList result = new ArrayList();
2454:                BnProjectLocalHome projhome;
2455:                this .synchronizeUser();
2456:                try {
2457:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
2458:                    Collection instances = projhome
2459:                            .findUserInstancesByProjectVersion(projectName
2460:                                    + "_instance%", version, this .getUser());
2461:                    for (Iterator i = instances.iterator(); i.hasNext();) {
2462:                        BnProjectLocal pl = (BnProjectLocal) i.next();
2463:                        if (!pl.getName().equals(projectName))
2464:                            result.add(pl.getBnProjectValue());
2465:                    }
2466:                    return (result);
2467:                } catch (javax.naming.NamingException ne) {
2468:
2469:                    trace.error(ne.getMessage());
2470:                    throw new HeroException(ne.getMessage());
2471:                } catch (javax.ejb.FinderException fe) {
2472:
2473:                    trace.error(fe.getMessage());
2474:                    throw new HeroException(fe.getMessage());
2475:                }
2476:            }
2477:
2478:            /**
2479:             * Get Workflow instances of this project
2480:             *
2481:             * @return a BnProjectValue Collection - list of project instances
2482:             * @param projectName the name of the project
2483:             * @ejb:interface-method view-type="both"
2484:             * @ejb:transaction type="Supports"
2485:             *
2486:             **/
2487:            public Collection getProjectInstances(String projectName)
2488:                    throws HeroException {
2489:                return (this .getProjectInstances(projectName,
2490:                        EventConstants.DEFAULTPROJECTVERSION));
2491:            }
2492:
2493:            /**
2494:             * Get Workflow instances of this project
2495:             *
2496:             * @return a BnProjectValue Collection - list of project instances
2497:             * @param projectName the name of the project
2498:             * @param version the name of the version
2499:             * @ejb:interface-method view-type="both"
2500:             * @ejb:transaction type="Supports"
2501:             *
2502:             **/
2503:            public Collection getProjectInstancesAsPK(String projectName,
2504:                    String version) throws HeroException {
2505:
2506:                trace.debug("parameter: projectName = " + projectName
2507:                        + " start by "
2508:                        + mContext.getCallerPrincipal().getName());
2509:                ArrayList result = new ArrayList();
2510:                BnProjectLocalHome projhome;
2511:                this .synchronizeUser();
2512:                try {
2513:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
2514:                    Collection instances = projhome
2515:                            .findUserInstancesByProjectVersion(projectName
2516:                                    + "_instance%", version, this .getUser());
2517:                    for (Iterator i = instances.iterator(); i.hasNext();) {
2518:                        BnProjectLocal pl = (BnProjectLocal) i.next();
2519:                        if (!pl.getName().equals(projectName)) {
2520:                            result.add(pl.getPrimaryKey());
2521:                        }
2522:                    }
2523:                    return (result);
2524:                } catch (javax.naming.NamingException ne) {
2525:                    trace.error(ne.getMessage());
2526:                    throw new HeroException(ne.getMessage());
2527:                } catch (javax.ejb.FinderException fe) {
2528:                    trace.error(fe.getMessage());
2529:                    throw new HeroException(fe.getMessage());
2530:                }
2531:            }
2532:
2533:            /**
2534:             * Get Workflow instances of this project
2535:             *
2536:             * @return a BnProjectValue Collection - list of project instances
2537:             * @param projectName the name of the project
2538:             * @ejb:interface-method view-type="both"
2539:             * @ejb:transaction type="Supports"
2540:             *
2541:             **/
2542:            public Collection getProjectInstancesAsPK(String projectName)
2543:                    throws HeroException {
2544:                return (this .getProjectInstancesAsPK(projectName,
2545:                        EventConstants.DEFAULTPROJECTVERSION));
2546:            }
2547:
2548:            /**
2549:             * Get Workflow instances of this project
2550:             *
2551:             * @return a BnProjectValue Collection - list of project instances
2552:             * @param projectName the name of the project
2553:             * @ejb:interface-method view-type="both"
2554:             * @ejb:transaction type="Supports"
2555:             *
2556:             **/
2557:            public Collection getProjectInstancesByPK(String projectName,
2558:                    Collection list, int offset, int numrows)
2559:                    throws HeroException {
2560:
2561:                trace.debug("parameter: projectName = " + projectName
2562:                        + " start by "
2563:                        + mContext.getCallerPrincipal().getName());
2564:                ArrayList result = new ArrayList();
2565:                BnProjectLocalHome projhome;
2566:                this .synchronizeUser();
2567:                try {
2568:                    int add = 0;
2569:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
2570:                    int cnt = 0;
2571:                    Iterator it = list.iterator();
2572:                    while (it.hasNext()) {
2573:                        if (cnt < offset)
2574:                            it.next();
2575:                        else {
2576:                            BnProjectLocal pl = projhome
2577:                                    .findByPrimaryKey((BnProjectPK) it.next());
2578:                            result.add(pl.getBnProjectValue());
2579:                            add++;
2580:                            if (add == numrows)
2581:                                break;
2582:                        }
2583:                        cnt++;
2584:                    }
2585:                    return (result);
2586:                } catch (javax.naming.NamingException ne) {
2587:                    trace.error(ne.getMessage());
2588:                    throw new HeroException(ne.getMessage());
2589:                } catch (javax.ejb.FinderException fe) {
2590:                    trace.error(fe.getMessage());
2591:                    throw new HeroException(fe.getMessage());
2592:                }
2593:            }
2594:
2595:            /**
2596:             * Get Workflow instances from a property
2597:             *
2598:             * @return a BnProjectValue Collection - list of project instances
2599:             * @param projectName the name of the project
2600:             * @ejb:interface-method view-type="both"
2601:             * @ejb:transaction type="Supports"
2602:             *
2603:             **/
2604:
2605:            public Collection getInstancesByProperty(String key, String value)
2606:                    throws HeroException {
2607:                trace.debug("parameters: key = " + key + " value = " + value
2608:                        + " start by "
2609:                        + mContext.getCallerPrincipal().getName());
2610:                ArrayList result = new ArrayList();
2611:                BnProjectLocalHome projhome;
2612:                this .synchronizeUser();
2613:                try {
2614:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
2615:                    Collection instances = projhome.findProjectsByProperty(key,
2616:                            value);
2617:                    for (Iterator i = instances.iterator(); i.hasNext();) {
2618:                        BnProjectLocal pl = (BnProjectLocal) i.next();
2619:                        if (pl.getName().matches(".*_instance.*"))
2620:                            result.add(pl.getBnProjectValue());
2621:                    }
2622:                    return (result);
2623:                } catch (javax.naming.NamingException ne) {
2624:                    trace.error(ne.getMessage());
2625:                    throw new HeroException(ne.getMessage());
2626:                } catch (javax.ejb.FinderException fe) {
2627:                    trace.error(fe.getMessage());
2628:                    throw new HeroException(fe.getMessage());
2629:                }
2630:            }
2631:
2632:            /**
2633:             * Get Workflow instances from a property
2634:             *
2635:             * @return a BnProjectValue Collection - list of project instances
2636:             * @param projectName the name of the project
2637:             * @ejb:interface-method view-type="both"
2638:             * @ejb:transaction type="Supports"
2639:             *
2640:             **/
2641:            public Collection getInstancesByPropertyAsPK(String key,
2642:                    String value) throws HeroException {
2643:                trace.debug("parameters: key = " + key + " value = " + value
2644:                        + " start by "
2645:                        + mContext.getCallerPrincipal().getName());
2646:                ArrayList result = new ArrayList();
2647:                BnProjectLocalHome projhome;
2648:                this .synchronizeUser();
2649:                try {
2650:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
2651:                    Collection instances = projhome.findProjectsByProperty(key,
2652:                            value);
2653:                    for (Iterator i = instances.iterator(); i.hasNext();) {
2654:                        BnProjectLocal pl = (BnProjectLocal) i.next();
2655:                        if (pl.getName().matches(".*_instance.*")) {
2656:                            result.add(pl.getPrimaryKey());
2657:                        }
2658:                    }
2659:                    return (result);
2660:                } catch (javax.naming.NamingException ne) {
2661:                    trace.error(ne.getMessage());
2662:                    throw new HeroException(ne.getMessage());
2663:                } catch (javax.ejb.FinderException fe) {
2664:                    trace.error(fe.getMessage());
2665:                    throw new HeroException(fe.getMessage());
2666:                }
2667:            }
2668:
2669:            /**
2670:             * Get Workflow instances from a property
2671:             *
2672:             * @return a BnProjectValue Collection - list of project instances
2673:             * @param projectName the name of the project
2674:             * @ejb:interface-method view-type="both"
2675:             * @ejb:transaction type="Supports"
2676:             *
2677:             **/
2678:            public Collection getInstancesByPropertyByPK(String key,
2679:                    String value, Collection list, int offset, int numrows)
2680:                    throws HeroException {
2681:                trace.debug("parameters: key = " + key + " value = " + value
2682:                        + " start by "
2683:                        + mContext.getCallerPrincipal().getName());
2684:                ArrayList result = new ArrayList();
2685:                BnProjectLocalHome projhome;
2686:                this .synchronizeUser();
2687:                try {
2688:                    int add = 0;
2689:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
2690:                    int cnt = 0;
2691:                    Iterator it = list.iterator();
2692:                    while (it.hasNext()) {
2693:                        if (cnt < offset)
2694:                            it.next();
2695:                        else {
2696:                            BnProjectLocal pl = projhome
2697:                                    .findByPrimaryKey((BnProjectPK) it.next());
2698:                            result.add(pl.getBnProjectValue());
2699:                            add++;
2700:                            if (add == numrows)
2701:                                break;
2702:                        }
2703:                        cnt++;
2704:                    }
2705:                    return (result);
2706:                } catch (javax.naming.NamingException ne) {
2707:                    trace.error(ne.getMessage());
2708:                    throw new HeroException(ne.getMessage());
2709:                } catch (javax.ejb.FinderException fe) {
2710:                    trace.error(fe.getMessage());
2711:                    throw new HeroException(fe.getMessage());
2712:                }
2713:            }
2714:
2715:            /**
2716:             * Get Workflow instances from a property
2717:             *
2718:             * @return a String Collection - list of project instances
2719:             * @param projectName the name of the project
2720:             * @ejb:interface-method view-type="both"
2721:             * @ejb:transaction type="Supports"
2722:             *
2723:             **/
2724:
2725:            public Collection getInstancesByPropertyNames(String key,
2726:                    String value) throws HeroException {
2727:                trace.debug("parameters: key = " + key + " value = " + value
2728:                        + " start by "
2729:                        + mContext.getCallerPrincipal().getName());
2730:                ArrayList result = new ArrayList();
2731:                BnProjectLocalHome projhome;
2732:                this .synchronizeUser();
2733:                try {
2734:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
2735:                    Collection instances = projhome.findProjectsByProperty(key,
2736:                            value);
2737:                    for (Iterator i = instances.iterator(); i.hasNext();) {
2738:                        BnProjectLocal pl = (BnProjectLocal) i.next();
2739:                        if (pl.getName().matches(".*_instance.*"))
2740:                            result.add(pl.getName());
2741:
2742:                    }
2743:                    return (result);
2744:                } catch (javax.naming.NamingException ne) {
2745:                    trace.error(ne.getMessage());
2746:                    throw new HeroException(ne.getMessage());
2747:                } catch (javax.ejb.FinderException fe) {
2748:                    trace.error(fe.getMessage());
2749:                    throw new HeroException(fe.getMessage());
2750:                }
2751:            }
2752:
2753:            /**
2754:             * Get Workflow instances from a property
2755:             *
2756:             * @return a String Collection - list of project instances
2757:             * @param projectName the name of the project
2758:             * @ejb:interface-method view-type="both"
2759:             * @ejb:transaction type="Supports"
2760:             *
2761:             **/
2762:            public Collection getInstancesByPropertyNamesAsPK(String key,
2763:                    String value) throws HeroException {
2764:                trace.debug("parameters: key = " + key + " value = " + value
2765:                        + " start by "
2766:                        + mContext.getCallerPrincipal().getName());
2767:                ArrayList result = new ArrayList();
2768:                BnProjectLocalHome projhome;
2769:                this .synchronizeUser();
2770:                try {
2771:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
2772:                    Collection instances = projhome.findProjectsByProperty(key,
2773:                            value);
2774:                    for (Iterator i = instances.iterator(); i.hasNext();) {
2775:                        BnProjectLocal pl = (BnProjectLocal) i.next();
2776:                        if (pl.getName().matches(".*_instance.*")) {
2777:                            result.add(pl.getPrimaryKey());
2778:                        }
2779:                    }
2780:                    return (result);
2781:                } catch (javax.naming.NamingException ne) {
2782:                    trace.error(ne.getMessage());
2783:                    throw new HeroException(ne.getMessage());
2784:                } catch (javax.ejb.FinderException fe) {
2785:                    trace.error(fe.getMessage());
2786:                    throw new HeroException(fe.getMessage());
2787:                }
2788:            }
2789:
2790:            /**
2791:             * Get Workflow instances from a property
2792:             *
2793:             * @return a String Collection - list of project instances
2794:             * @param projectName the name of the project
2795:             * @ejb:interface-method view-type="both"
2796:             * @ejb:transaction type="Supports"
2797:             *
2798:             **/
2799:            public Collection getInstancesByPropertyNamesByPK(String key,
2800:                    String value, Collection list, int offset, int numrows)
2801:                    throws HeroException {
2802:                trace.debug("parameters: key = " + key + " value = " + value
2803:                        + " start by "
2804:                        + mContext.getCallerPrincipal().getName());
2805:                ArrayList result = new ArrayList();
2806:                BnProjectLocalHome projhome;
2807:                this .synchronizeUser();
2808:                try {
2809:                    int add = 0;
2810:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
2811:                    int cnt = 0;
2812:                    Iterator it = list.iterator();
2813:                    while (it.hasNext()) {
2814:                        if (cnt < offset)
2815:                            it.next();
2816:                        else {
2817:                            BnProjectLocal pl = projhome
2818:                                    .findByPrimaryKey((BnProjectPK) it.next());
2819:                            result.add(pl.getName());
2820:                            add++;
2821:                            if (add == numrows)
2822:                                break;
2823:                        }
2824:                        cnt++;
2825:                    }
2826:                    return (result);
2827:                } catch (javax.naming.NamingException ne) {
2828:                    trace.error(ne.getMessage());
2829:                    throw new HeroException(ne.getMessage());
2830:                } catch (javax.ejb.FinderException fe) {
2831:                    trace.error(fe.getMessage());
2832:                    throw new HeroException(fe.getMessage());
2833:                }
2834:            }
2835:
2836:            /**
2837:             * Get Workflow projects from a property
2838:             *
2839:             * @return a BnProjectValue Collection - list of projects
2840:             * @param projectName the name of the project
2841:             * @ejb:interface-method view-type="both"
2842:             * @ejb:transaction type="Supports"
2843:             *
2844:             **/
2845:
2846:            public Collection getProjectsByProperty(String key, String value)
2847:                    throws HeroException {
2848:                trace.debug("parameters: key = " + key + " value = " + value
2849:                        + " start by "
2850:                        + mContext.getCallerPrincipal().getName());
2851:                ArrayList result = new ArrayList();
2852:                BnProjectLocalHome projhome;
2853:                this .synchronizeUser();
2854:                try {
2855:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
2856:                    Collection instances = projhome.findProjectsByProperty(key,
2857:                            value);
2858:                    for (Iterator i = instances.iterator(); i.hasNext();) {
2859:                        BnProjectLocal pl = (BnProjectLocal) i.next();
2860:                        if (!pl.getName().matches(".*_instance.*"))
2861:                            result.add(pl.getBnProjectValue());
2862:                    }
2863:                    return (result);
2864:                } catch (javax.naming.NamingException ne) {
2865:                    trace.error(ne.getMessage());
2866:                    throw new HeroException(ne.getMessage());
2867:                } catch (javax.ejb.FinderException fe) {
2868:                    trace.error(fe.getMessage());
2869:                    throw new HeroException(fe.getMessage());
2870:                }
2871:            }
2872:
2873:            /**
2874:             * Get Workflow projects from a property
2875:             *
2876:             * @return a BnProjectValue Collection - list of projects
2877:             * @param projectName the name of the project
2878:             * @ejb:interface-method view-type="both"
2879:             * @ejb:transaction type="Supports"
2880:             *
2881:             **/
2882:            public Collection getProjectsByPropertyAsPK(String key, String value)
2883:                    throws HeroException {
2884:                trace.debug("parameters: key = " + key + " value = " + value
2885:                        + " start by "
2886:                        + mContext.getCallerPrincipal().getName());
2887:                ArrayList result = new ArrayList();
2888:                BnProjectLocalHome projhome;
2889:                this .synchronizeUser();
2890:                try {
2891:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
2892:                    Collection instances = projhome.findProjectsByProperty(key,
2893:                            value);
2894:                    for (Iterator i = instances.iterator(); i.hasNext();) {
2895:                        BnProjectLocal pl = (BnProjectLocal) i.next();
2896:                        if (!pl.getName().matches(".*_instance.*")) {
2897:                            result.add(pl.getPrimaryKey());
2898:                        }
2899:                    }
2900:                    return (result);
2901:                } catch (javax.naming.NamingException ne) {
2902:                    trace.error(ne.getMessage());
2903:                    throw new HeroException(ne.getMessage());
2904:                } catch (javax.ejb.FinderException fe) {
2905:                    trace.error(fe.getMessage());
2906:                    throw new HeroException(fe.getMessage());
2907:                }
2908:            }
2909:
2910:            /**
2911:             * Get Workflow projects from a property
2912:             *
2913:             * @return a BnProjectValue Collection - list of projects
2914:             * @param projectName the name of the project
2915:             * @ejb:interface-method view-type="both"
2916:             * @ejb:transaction type="Supports"
2917:             *
2918:             **/
2919:            public Collection getProjectsByPropertyByPK(String key,
2920:                    String value, Collection list, int offset, int numrows)
2921:                    throws HeroException {
2922:                trace.debug("parameters: key = " + key + " value = " + value
2923:                        + " start by "
2924:                        + mContext.getCallerPrincipal().getName());
2925:                ArrayList result = new ArrayList();
2926:                BnProjectLocalHome projhome;
2927:                this .synchronizeUser();
2928:                try {
2929:                    int add = 0;
2930:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
2931:                    int cnt = 0;
2932:                    Iterator it = list.iterator();
2933:                    while (it.hasNext()) {
2934:                        if (cnt < offset)
2935:                            it.next();
2936:                        else {
2937:                            BnProjectLocal pl = projhome
2938:                                    .findByPrimaryKey((BnProjectPK) it.next());
2939:                            result.add(pl.getBnProjectValue());
2940:                            add++;
2941:                            if (add == numrows)
2942:                                break;
2943:                        }
2944:                        cnt++;
2945:                    }
2946:                    return (result);
2947:                } catch (javax.naming.NamingException ne) {
2948:                    trace.error(ne.getMessage());
2949:                    throw new HeroException(ne.getMessage());
2950:                } catch (javax.ejb.FinderException fe) {
2951:                    trace.error(fe.getMessage());
2952:                    throw new HeroException(fe.getMessage());
2953:                }
2954:            }
2955:
2956:            /**
2957:             * Get Workflow projects from a property
2958:             *
2959:             * @return a String Collection - list of project names
2960:             * @param projectName the name of the project
2961:             * @ejb:interface-method view-type="both"
2962:             * @ejb:transaction type="Supports"
2963:             *
2964:             **/
2965:
2966:            public Collection getProjectsByPropertyNames(String key,
2967:                    String value) throws HeroException {
2968:                trace.debug("parameters: key = " + key + " value = " + value
2969:                        + " start by "
2970:                        + mContext.getCallerPrincipal().getName());
2971:                ArrayList result = new ArrayList();
2972:                BnProjectLocalHome projhome;
2973:                this .synchronizeUser();
2974:                try {
2975:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
2976:                    Collection instances = projhome.findProjectsByProperty(key,
2977:                            value);
2978:                    for (Iterator i = instances.iterator(); i.hasNext();) {
2979:                        BnProjectLocal pl = (BnProjectLocal) i.next();
2980:                        if (!pl.getName().matches(".*_instance.*"))
2981:                            result.add(pl.getName());
2982:
2983:                    }
2984:                    return (result);
2985:                } catch (javax.naming.NamingException ne) {
2986:                    trace.error(ne.getMessage());
2987:                    throw new HeroException(ne.getMessage());
2988:                } catch (javax.ejb.FinderException fe) {
2989:                    trace.error(fe.getMessage());
2990:                    throw new HeroException(fe.getMessage());
2991:                }
2992:            }
2993:
2994:            /**
2995:             * Get Workflow projects from a property
2996:             *
2997:             * @return a String Collection - list of project names
2998:             * @param projectName the name of the project
2999:             * @ejb:interface-method view-type="both"
3000:             * @ejb:transaction type="Supports"
3001:             *
3002:             **/
3003:            public Collection getProjectsByPropertyNamesAsPK(String key,
3004:                    String value) throws HeroException {
3005:                trace.debug("parameters: key = " + key + " value = " + value
3006:                        + " start by "
3007:                        + mContext.getCallerPrincipal().getName());
3008:                ArrayList result = new ArrayList();
3009:                BnProjectLocalHome projhome;
3010:                this .synchronizeUser();
3011:                try {
3012:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
3013:                    Collection instances = projhome.findProjectsByProperty(key,
3014:                            value);
3015:                    for (Iterator i = instances.iterator(); i.hasNext();) {
3016:                        BnProjectLocal pl = (BnProjectLocal) i.next();
3017:                        if (!pl.getName().matches(".*_instance.*")) {
3018:                            result.add(pl.getPrimaryKey());
3019:                        }
3020:                    }
3021:                    return (result);
3022:                } catch (javax.naming.NamingException ne) {
3023:                    trace.error(ne.getMessage());
3024:                    throw new HeroException(ne.getMessage());
3025:                } catch (javax.ejb.FinderException fe) {
3026:                    trace.error(fe.getMessage());
3027:                    throw new HeroException(fe.getMessage());
3028:                }
3029:            }
3030:
3031:            /**
3032:             * Get Workflow projects from a property
3033:             *
3034:             * @return a String Collection - list of project names
3035:             * @param projectName the name of the project
3036:             * @ejb:interface-method view-type="both"
3037:             * @ejb:transaction type="Supports"
3038:             *
3039:             **/
3040:            public Collection getProjectsByPropertyNamesByPK(String key,
3041:                    String value, Collection list, int offset, int numrows)
3042:                    throws HeroException {
3043:                trace.debug("parameters: key = " + key + " value = " + value
3044:                        + " start by "
3045:                        + mContext.getCallerPrincipal().getName());
3046:                ArrayList result = new ArrayList();
3047:                BnProjectLocalHome projhome;
3048:                this .synchronizeUser();
3049:                try {
3050:                    int add = 0;
3051:                    projhome = hero.interfaces.BnProjectUtil.getLocalHome();
3052:                    int cnt = 0;
3053:                    Iterator it = list.iterator();
3054:                    while (it.hasNext()) {
3055:                        if (cnt < offset)
3056:                            it.next();
3057:                        else {
3058:                            BnProjectLocal pl = projhome
3059:                                    .findByPrimaryKey((BnProjectPK) it.next());
3060:                            result.add(pl.getName());
3061:                            add++;
3062:                            if (add == numrows)
3063:                                break;
3064:                        }
3065:                        cnt++;
3066:                    }
3067:                    return (result);
3068:                } catch (javax.naming.NamingException ne) {
3069:                    trace.error(ne.getMessage());
3070:                    throw new HeroException(ne.getMessage());
3071:                } catch (javax.ejb.FinderException fe) {
3072:                    trace.error(fe.getMessage());
3073:                    throw new HeroException(fe.getMessage());
3074:                }
3075:            }
3076:
3077:            /**
3078:             * Get activities names of the model instances assigned to this user
3079:             *
3080:             * @param projectName the name of the project
3081:             * @return a String Collection - the names of activities
3082:             * @throws HeroException
3083:             * @ejb:interface-method view-type="both"
3084:             * @ejb:transaction type="Supports"
3085:             *
3086:             **/
3087:            public Collection getModelInstancesTodoList(String projectName)
3088:                    throws HeroException {
3089:
3090:                trace.debug("parameter: projectName = " + projectName
3091:                        + " start by "
3092:                        + mContext.getCallerPrincipal().getName());
3093:                ArrayList result = new ArrayList();
3094:                BnProjectLocalHome project;
3095:                this .synchronizeUser();
3096:                try {
3097:                    project = hero.interfaces.BnProjectUtil.getLocalHome();
3098:                    Collection instances = project.getUserModelReady(
3099:                            projectName + "_instance%", this .getUser());
3100:                    for (Iterator i = instances.iterator(); i.hasNext();) {
3101:                        String name = (String) i.next();
3102:                        if (name.matches(".*_instance.*"))
3103:                            name = this .getNodeName(name);
3104:
3105:                        result.add(name);
3106:                    }
3107:                    return (result);
3108:                } catch (javax.naming.NamingException ne) {
3109:
3110:                    trace.error(ne.getMessage());
3111:                    throw new HeroException(ne.getMessage());
3112:                }
3113:            }
3114:
3115:            /**
3116:             * Get activities names of the model instances assigned to this user
3117:             *
3118:             * @param projectName the name of the project
3119:             * @return a String Collection - the names of activities
3120:             * @throws HeroException
3121:             * @ejb:interface-method view-type="both"
3122:             * @ejb:transaction type="Supports"
3123:             *
3124:             **/
3125:            public Collection getModelInstancesTodoList(String projectName,
3126:                    int offset, int numrows) throws HeroException {
3127:
3128:                trace.debug("parameter: projectName = " + projectName
3129:                        + " start by "
3130:                        + mContext.getCallerPrincipal().getName());
3131:                ArrayList result = new ArrayList();
3132:                BnProjectLocalHome project;
3133:                this .synchronizeUser();
3134:                try {
3135:                    int cnt = 0;
3136:                    int add = 0;
3137:                    project = hero.interfaces.BnProjectUtil.getLocalHome();
3138:                    Collection instances = project.getUserModelReady(
3139:                            projectName + "_instance%", this .getUser());
3140:                    for (Iterator i = instances.iterator(); i.hasNext();) {
3141:                        String name = (String) i.next();
3142:                        if (cnt >= offset) {
3143:                            if (name.matches(".*_instance.*"))
3144:                                name = this .getNodeName(name);
3145:                            result.add(name);
3146:                            add++;
3147:                            if (add == numrows)
3148:                                break;
3149:                        }
3150:                        cnt++;
3151:                    }
3152:                    return (result);
3153:                } catch (javax.naming.NamingException ne) {
3154:
3155:                    trace.error(ne.getMessage());
3156:                    throw new HeroException(ne.getMessage());
3157:                }
3158:            }
3159:
3160:            /**
3161:             * Get activities names of the model instances terminated by this user
3162:             *
3163:             * @param projectName the name of the project
3164:             * @return a String Collection - the names of activities
3165:             * @throws HeroException
3166:             * @ejb:interface-method view-type="both"
3167:             * @ejb:transaction type="Supports"
3168:             *
3169:             **/
3170:            public Collection getModelInstancesTerminated(String projectName)
3171:                    throws HeroException {
3172:
3173:                trace.debug("parameter: projectName = " + projectName
3174:                        + " start by "
3175:                        + mContext.getCallerPrincipal().getName());
3176:                ArrayList result = new ArrayList();
3177:                BnProjectLocalHome project;
3178:                this .synchronizeUser();
3179:                try {
3180:                    project = hero.interfaces.BnProjectUtil.getLocalHome();
3181:                    Collection instances = project.getUserModelTerminated(
3182:                            projectName + "_instance%", this .getUser());
3183:
3184:                    for (Iterator i = instances.iterator(); i.hasNext();) {
3185:                        String name = (String) i.next();
3186:                        if (name.matches(".*_instance.*"))
3187:                            name = this .getNodeName(name);
3188:
3189:                        result.add(name);
3190:                    }
3191:                    return (result);
3192:                } catch (javax.naming.NamingException ne) {
3193:
3194:                    trace.error(ne.getMessage());
3195:                    throw new HeroException(ne.getMessage());
3196:                }
3197:            }
3198:
3199:            /**
3200:             * Get activities names of the model instances terminated by this user
3201:             *
3202:             * @param projectName the name of the project
3203:             * @return a String Collection - the names of activities
3204:             * @throws HeroException
3205:             * @ejb:interface-method view-type="both"
3206:             * @ejb:transaction type="Supports"
3207:             *
3208:             **/
3209:            public Collection getModelInstancesTerminated(String projectName,
3210:                    int offset, int numrows) throws HeroException {
3211:
3212:                trace.debug("parameter: projectName = " + projectName
3213:                        + " start by "
3214:                        + mContext.getCallerPrincipal().getName());
3215:                ArrayList result = new ArrayList();
3216:                BnProjectLocalHome project;
3217:                this .synchronizeUser();
3218:                try {
3219:                    int cnt = 0;
3220:                    int add = 0;
3221:                    project = hero.interfaces.BnProjectUtil.getLocalHome();
3222:                    Collection instances = project.getUserModelTerminated(
3223:                            projectName + "_instance%", this .getUser());
3224:
3225:                    for (Iterator i = instances.iterator(); i.hasNext();) {
3226:                        String name = (String) i.next();
3227:                        if (cnt >= offset) {
3228:                            if (name.matches(".*_instance.*"))
3229:                                name = this .getNodeName(name);
3230:                            result.add(name);
3231:                            add++;
3232:                            if (add == numrows)
3233:                                break;
3234:                        }
3235:                        cnt++;
3236:                    }
3237:                    return (result);
3238:                } catch (javax.naming.NamingException ne) {
3239:
3240:                    trace.error(ne.getMessage());
3241:                    throw new HeroException(ne.getMessage());
3242:                }
3243:            }
3244:
3245:            /**
3246:             * Get activities model instances assigned to this user
3247:             *
3248:             * @param projectName the name of the project
3249:             * @param nodeName the name of the node
3250:             * @return a BnNodeLightValue Collection - the values 
3251:             * @throws HeroException
3252:             * @ejb:interface-method view-type="both"
3253:             * @ejb:transaction type="Supports"
3254:             *
3255:             **/
3256:            public Collection getInstancesActivityTodoList(String projectName,
3257:                    String nodeName) throws HeroException {
3258:
3259:                trace.debug("parameter: projectName = " + projectName
3260:                        + " nodeName = " + nodeName + " start by "
3261:                        + mContext.getCallerPrincipal().getName());
3262:                ArrayList result = new ArrayList();
3263:                BnNodeLocalHome nodehome;
3264:                this .synchronizeUser();
3265:                try {
3266:                    nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
3267:
3268:                    Collection instances = nodehome.findUserReadyModelActivity(
3269:                            projectName + "_instance%", nodeName, this 
3270:                                    .getUser());
3271:                    for (Iterator i = instances.iterator(); i.hasNext();) {
3272:                        BnNodeLocal pl = (BnNodeLocal) i.next();
3273:                        result.add(pl.getBnNodeLightValue());
3274:                    }
3275:                    return (result);
3276:                } catch (javax.naming.NamingException ne) {
3277:
3278:                    trace.error(ne.getMessage());
3279:                    throw new HeroException(ne.getMessage());
3280:                } catch (javax.ejb.FinderException fe) {
3281:
3282:                    trace.error(fe.getMessage());
3283:                    throw new HeroException(fe.getMessage());
3284:                }
3285:            }
3286:
3287:            /**
3288:             * Get subset of activities model instances assigned to this user
3289:             *
3290:             * @param projectName the name of the project
3291:             * @param nodeName the name of the node
3292:             * @return a BnNodeLightValue Collection - the values 
3293:             * @throws HeroException
3294:             * @ejb:interface-method view-type="both"
3295:             * @ejb:transaction type="Supports"
3296:             *
3297:             **/
3298:            public Collection getInstancesActivityTodoListAsPK(
3299:                    String projectName, String nodeName) throws HeroException {
3300:
3301:                trace.debug("parameter: projectName = " + projectName
3302:                        + " nodeName = " + nodeName + " start by "
3303:                        + mContext.getCallerPrincipal().getName());
3304:                ArrayList result = new ArrayList();
3305:                BnNodeLocalHome nodehome;
3306:                Collection instances = null;
3307:                this .synchronizeUser();
3308:                try {
3309:                    nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
3310:                    instances = nodehome.findUserReadyModelActivity(projectName
3311:                            + "_instance%", nodeName, this .getUser());
3312:                    for (Iterator i = instances.iterator(); i.hasNext();) {
3313:                        BnNodeLocal pl = (BnNodeLocal) i.next();
3314:                        result.add(pl.getPrimaryKey());
3315:                    }
3316:                    return (result);
3317:                } catch (javax.naming.NamingException ne) {
3318:                    trace.error(ne.getMessage());
3319:                    throw new HeroException(ne.getMessage());
3320:                } catch (javax.ejb.FinderException fe) {
3321:                    trace.error(fe.getMessage());
3322:                    throw new HeroException(fe.getMessage());
3323:                }
3324:            }
3325:
3326:            /**
3327:             * Get subset of activities model instances assigned to this user
3328:             *
3329:             * @param projectName the name of the project
3330:             * @param nodeName the name of the node
3331:             * @return a BnNodeLightValue Collection - the values 
3332:             * @throws HeroException
3333:             * @ejb:interface-method view-type="both"
3334:             * @ejb:transaction type="Supports"
3335:             *
3336:             **/
3337:            public Collection getInstancesActivityTodoListByPK(
3338:                    String projectName, String nodeName, Collection list,
3339:                    int offset, int numrows) throws HeroException {
3340:
3341:                trace.debug("parameter: projectName = " + projectName
3342:                        + " nodeName = " + nodeName + " start by "
3343:                        + mContext.getCallerPrincipal().getName());
3344:                ArrayList result = new ArrayList();
3345:                BnNodeLocalHome nodehome;
3346:                Collection instances = null;
3347:                this .synchronizeUser();
3348:                try {
3349:                    int add = 0;
3350:                    nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
3351:                    int cnt = 0;
3352:                    Iterator it = list.iterator();
3353:                    while (it.hasNext()) {
3354:                        if (cnt < offset)
3355:                            it.next();
3356:                        else {
3357:                            BnNodeLocal pl = nodehome
3358:                                    .findByPrimaryKey((BnNodePK) it.next());
3359:                            result.add(pl.getBnNodeLightValue());
3360:                            add++;
3361:                            if (add == numrows)
3362:                                break;
3363:                        }
3364:                        cnt++;
3365:                    }
3366:                    return (result);
3367:                } catch (javax.naming.NamingException ne) {
3368:                    trace.error(ne.getMessage());
3369:                    throw new HeroException(ne.getMessage());
3370:                } catch (javax.ejb.FinderException fe) {
3371:                    trace.error(fe.getMessage());
3372:                    throw new HeroException(fe.getMessage());
3373:                }
3374:            }
3375:
3376:            /**
3377:             * Get activities model instances terminated by this user
3378:             *
3379:             * @param projectName the name of the project
3380:             * @param nodeName the name of the node
3381:             * @return a BnNodeLightValue Collection - the values 
3382:             * @throws HeroException
3383:             * @ejb:interface-method view-type="both"
3384:             * @ejb:transaction type="Supports"
3385:             *
3386:             **/
3387:            public Collection getInstancesActivityTerminated(
3388:                    String projectName, String nodeName) throws HeroException {
3389:
3390:                trace.debug("parameter: projectName = " + projectName
3391:                        + " nodeName = " + nodeName + " start by "
3392:                        + mContext.getCallerPrincipal().getName());
3393:                ArrayList result = new ArrayList();
3394:                BnNodeLocalHome nodehome;
3395:                this .synchronizeUser();
3396:                try {
3397:                    nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
3398:
3399:                    Collection instances = nodehome
3400:                            .findUserTerminatedModelActivity(projectName
3401:                                    + "_instance%", nodeName, this .getUser());
3402:                    for (Iterator i = instances.iterator(); i.hasNext();) {
3403:                        BnNodeLocal pl = (BnNodeLocal) i.next();
3404:                        result.add(pl.getBnNodeLightValue());
3405:                    }
3406:                    return (result);
3407:                } catch (javax.naming.NamingException ne) {
3408:
3409:                    trace.error(ne.getMessage());
3410:                    throw new HeroException(ne.getMessage());
3411:                } catch (javax.ejb.FinderException fe) {
3412:
3413:                    trace.error(fe.getMessage());
3414:                    throw new HeroException(fe.getMessage());
3415:                }
3416:            }
3417:
3418:            /**
3419:             * Get subset of activities model instances terminated by this user
3420:             *
3421:             * @param projectName the name of the project
3422:             * @param nodeName the name of the node
3423:             * @return a BnNodeLightValue Collection - the values 
3424:             * @throws HeroException
3425:             * @ejb:interface-method view-type="both"
3426:             * @ejb:transaction type="Supports"
3427:             *
3428:             **/
3429:            public Collection getInstancesActivityTerminatedAsPK(
3430:                    String projectName, String nodeName) throws HeroException {
3431:
3432:                trace.debug("parameter: projectName = " + projectName
3433:                        + " nodeName = " + nodeName + " start by "
3434:                        + mContext.getCallerPrincipal().getName());
3435:                ArrayList result = new ArrayList();
3436:                BnNodeLocalHome nodehome;
3437:                Collection instances = null;
3438:                this .synchronizeUser();
3439:                try {
3440:                    nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
3441:                    instances = nodehome.findUserTerminatedModelActivity(
3442:                            projectName + "_instance%", nodeName, this 
3443:                                    .getUser());
3444:                    for (Iterator i = instances.iterator(); i.hasNext();) {
3445:                        BnNodeLocal pl = (BnNodeLocal) i.next();
3446:                        result.add(pl.getPrimaryKey());
3447:                    }
3448:                    return (result);
3449:                } catch (javax.naming.NamingException ne) {
3450:                    trace.error(ne.getMessage());
3451:                    throw new HeroException(ne.getMessage());
3452:                } catch (javax.ejb.FinderException fe) {
3453:                    trace.error(fe.getMessage());
3454:                    throw new HeroException(fe.getMessage());
3455:                }
3456:            }
3457:
3458:            /**
3459:             * Get subset of activities model instances terminated by this user
3460:             *
3461:             * @param projectName the name of the project
3462:             * @param nodeName the name of the node
3463:             * @return a BnNodeLightValue Collection - the values 
3464:             * @throws HeroException
3465:             * @ejb:interface-method view-type="both"
3466:             * @ejb:transaction type="Supports"
3467:             *
3468:             **/
3469:            public Collection getInstancesActivityTerminatedByPK(
3470:                    String projectName, String nodeName, Collection list,
3471:                    int offset, int numrows) throws HeroException {
3472:
3473:                trace.debug("parameter: projectName = " + projectName
3474:                        + " nodeName = " + nodeName + " start by "
3475:                        + mContext.getCallerPrincipal().getName());
3476:                ArrayList result = new ArrayList();
3477:                BnNodeLocalHome nodehome;
3478:                Collection instances = null;
3479:                this .synchronizeUser();
3480:                try {
3481:                    int add = 0;
3482:                    nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
3483:                    int cnt = 0;
3484:                    Iterator it = list.iterator();
3485:                    while (it.hasNext()) {
3486:                        if (cnt < offset)
3487:                            it.next();
3488:                        else {
3489:                            BnNodeLocal pl = nodehome
3490:                                    .findByPrimaryKey((BnNodePK) it.next());
3491:                            result.add(pl.getBnNodeLightValue());
3492:                            add++;
3493:                            if (add == numrows)
3494:                                break;
3495:                        }
3496:                        cnt++;
3497:                    }
3498:                    return (result);
3499:                } catch (javax.naming.NamingException ne) {
3500:                    trace.error(ne.getMessage());
3501:                    throw new HeroException(ne.getMessage());
3502:                } catch (javax.ejb.FinderException fe) {
3503:                    trace.error(fe.getMessage());
3504:                    throw new HeroException(fe.getMessage());
3505:                }
3506:            }
3507:
3508:            /**
3509:             * Get models names which have ongoing instances for this user
3510:             *
3511:             * @return a String Collection - the names of workflow models
3512:             * @throws HeroException
3513:             * @ejb:interface-method view-type="both"
3514:             * @ejb:transaction type="Supports"
3515:             *
3516:             **/
3517:            public Collection getUserInstancesProject() throws HeroException {
3518:                trace.debug("start by "
3519:                        + mContext.getCallerPrincipal().getName());
3520:                BnProjectLocalHome project;
3521:                ArrayList result = new ArrayList();
3522:                this .synchronizeUser();
3523:                try {
3524:                    project = hero.interfaces.BnProjectUtil.getLocalHome();
3525:                    Collection projectNames = project
3526:                            .getUserInstancesProject(this .getUser());
3527:                    Iterator i = projectNames.iterator();
3528:                    while (i.hasNext()) {
3529:                        String name = this .getNodeName((String) i.next());
3530:                        if (!result.contains(name))
3531:                            result.add(name);
3532:                    }
3533:                    return (result);
3534:                } catch (javax.naming.NamingException ne) {
3535:
3536:                    trace.error(ne.getMessage());
3537:                    throw new HeroException(ne.getMessage());
3538:                }
3539:            }
3540:
3541:            /**
3542:             * Get instance names for this user
3543:             *
3544:             * @return a String Collection - the names of workflow instances
3545:             * @throws HeroException
3546:             * @ejb:interface-method view-type="both"
3547:             * @ejb:transaction type="Supports"
3548:             *
3549:             **/
3550:            public Collection getUserRealInstancesProject()
3551:                    throws HeroException {
3552:                trace.debug("start by "
3553:                        + mContext.getCallerPrincipal().getName());
3554:                BnProjectLocalHome project;
3555:                ArrayList result = new ArrayList();
3556:                this .synchronizeUser();
3557:                try {
3558:                    project = hero.interfaces.BnProjectUtil.getLocalHome();
3559:                    Collection projectNames = project
3560:                            .getUserInstancesProject(this .getUser());
3561:                    Iterator i = projectNames.iterator();
3562:                    while (i.hasNext()) {
3563:                        result.add((String) i.next());
3564:                    }
3565:                    return (result);
3566:                } catch (javax.naming.NamingException ne) {
3567:
3568:                    trace.error(ne.getMessage());
3569:                    throw new HeroException(ne.getMessage());
3570:                }
3571:            }
3572:
3573:            /**
3574:             * Get model version for this user and project
3575:             *
3576:             * @return a String - the version of workflow model
3577:             * @throws HeroException
3578:             * @ejb:interface-method view-type="both"
3579:             * @ejb:transaction type="Supports"
3580:             *
3581:             **/
3582:            public String getUserModelVersion(String proj) throws HeroException {
3583:                trace.debug("start by "
3584:                        + mContext.getCallerPrincipal().getName());
3585:                BnProjectLocalHome project;
3586:                this .synchronizeUser();
3587:                try {
3588:                    project = hero.interfaces.BnProjectUtil.getLocalHome();
3589:                    String version = project.getUserModelVersion(
3590:                            this .getUser(), proj);
3591:                    return (version);
3592:                } catch (javax.naming.NamingException ne) {
3593:
3594:                    trace.error(ne.getMessage());
3595:                    throw new HeroException(ne.getMessage());
3596:                }
3597:            }
3598:
3599:            /**
3600:             * Get models names which have ongoing instances for this user
3601:             *
3602:             * @return a String Collection - the names of workflow models
3603:             * @throws HeroException
3604:             * @ejb:interface-method view-type="both"
3605:             * @ejb:transaction type="Supports"
3606:             *
3607:             **/
3608:            public Collection getUserInstancesProject(int offset, int numrows)
3609:                    throws HeroException {
3610:                trace.debug("start by "
3611:                        + mContext.getCallerPrincipal().getName());
3612:                BnProjectLocalHome project;
3613:                ArrayList result = new ArrayList();
3614:                this .synchronizeUser();
3615:                try {
3616:                    int cnt = 0;
3617:                    int add = 0;
3618:                    project = hero.interfaces.BnProjectUtil.getLocalHome();
3619:                    Collection projectNames = project
3620:                            .getUserInstancesProject(this .getUser());
3621:                    Iterator i = projectNames.iterator();
3622:                    while (i.hasNext()) {
3623:                        String name = this .getNodeName((String) i.next());
3624:                        if (cnt >= offset) {
3625:                            if (!result.contains(name)) {
3626:                                result.add(name);
3627:                                add++;
3628:                                if (add == numrows)
3629:                                    break;
3630:                            }
3631:                        }
3632:                        cnt++;
3633:                    }
3634:                    return (result);
3635:                } catch (javax.naming.NamingException ne) {
3636:
3637:                    trace.error(ne.getMessage());
3638:                    throw new HeroException(ne.getMessage());
3639:                }
3640:            }
3641:
3642:            /**
3643:             * Get ready, anticipable and executing activities for current user instances 
3644:             *
3645:             * @param projectName the project name
3646:             * @return a String Collection - the names of activities
3647:             * @throws HeroException
3648:             * @ejb:interface-method view-type="both"
3649:             * @ejb:transaction type="Supports"
3650:             *
3651:             **/
3652:            public Collection getUserInstancesProjectNodes(String projectName)
3653:                    throws HeroException {
3654:                trace.debug("parameter: projectName = " + projectName
3655:                        + " start by "
3656:                        + mContext.getCallerPrincipal().getName());
3657:                ArrayList result = new ArrayList();
3658:                BnNodeLocalHome nodehome;
3659:                this .synchronizeUser();
3660:                try {
3661:                    nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
3662:
3663:                    Collection instances = nodehome
3664:                            .findUserInstancesProjectNodes(projectName
3665:                                    + "_instance%", this .getUser());
3666:                    for (Iterator i = instances.iterator(); i.hasNext();) {
3667:                        BnNodeLocal pl = (BnNodeLocal) i.next();
3668:                        result.add(pl.getBnNodeLightValue());
3669:                    }
3670:                    return (result);
3671:                } catch (javax.naming.NamingException ne) {
3672:
3673:                    trace.error(ne.getMessage());
3674:                    throw new HeroException(ne.getMessage());
3675:                } catch (javax.ejb.FinderException fe) {
3676:
3677:                    trace.error(fe.getMessage());
3678:                    throw new HeroException(fe.getMessage());
3679:                }
3680:            }
3681:
3682:            /**
3683:             * Get ready and executing activities for a user instance
3684:             *
3685:             * @param instanceName the project name
3686:             * @param userName the caller's name
3687:             * @return a String Collection - the names of activities
3688:             * @throws HeroException
3689:             * @ejb:interface-method view-type="both"
3690:             * @ejb:transaction type="Supports"
3691:             *
3692:             **/
3693:            public Collection getInstanceNodes(String instanceName,
3694:                    String userName) throws HeroException {
3695:                trace.debug("parameter: projectName = " + instanceName
3696:                        + " start by "
3697:                        + mContext.getCallerPrincipal().getName());
3698:                ArrayList result = new ArrayList();
3699:                BnNodeLocalHome nodehome;
3700:                this .synchronizeUser();
3701:                try {
3702:                    nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
3703:                    Collection nodes = nodehome.findUserInstanceNodes(
3704:                            instanceName, this .getUser());
3705:                    for (Iterator i = nodes.iterator(); i.hasNext();) {
3706:                        BnNodeLocal pl = (BnNodeLocal) i.next();
3707:                        result.add(pl.getName());
3708:                    }
3709:                    return (result);
3710:                } catch (javax.naming.NamingException ne) {
3711:                    trace.error(ne.getMessage());
3712:                    throw new HeroException(ne.getMessage());
3713:                } catch (javax.ejb.FinderException fe) {
3714:                    trace.error(fe.getMessage());
3715:                    throw new HeroException(fe.getMessage());
3716:                }
3717:            }
3718:
3719:            /**
3720:             * Get a subset of the ready, anticipable and executing activities for current user instances 
3721:             *
3722:             * @param projectName the project name
3723:             * @return a String Collection - the names of activities
3724:             * @throws HeroException
3725:             * @ejb:interface-method view-type="both"
3726:             * @ejb:transaction type="Supports"
3727:             *
3728:             **/
3729:            public Collection getUserInstancesProjectNodesAsPK(
3730:                    String projectName) throws HeroException {
3731:                trace.debug("parameter: projectName = " + projectName
3732:                        + " start by "
3733:                        + mContext.getCallerPrincipal().getName());
3734:                ArrayList result = new ArrayList();
3735:                Collection instances = null;
3736:                BnNodeLocalHome nodehome;
3737:                this .synchronizeUser();
3738:                try {
3739:                    nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
3740:                    instances = nodehome.findUserInstancesProjectNodes(
3741:                            projectName + "_instance%", this .getUser());
3742:                    for (Iterator i = instances.iterator(); i.hasNext();) {
3743:                        BnNodeLocal pl = (BnNodeLocal) i.next();
3744:                        result.add(pl.getPrimaryKey());
3745:                    }
3746:                    return (result);
3747:                } catch (javax.naming.NamingException ne) {
3748:
3749:                    trace.error(ne.getMessage());
3750:                    throw new HeroException(ne.getMessage());
3751:                } catch (javax.ejb.FinderException fe) {
3752:
3753:                    trace.error(fe.getMessage());
3754:                    throw new HeroException(fe.getMessage());
3755:                }
3756:            }
3757:
3758:            /**
3759:             * Get a subset of the ready, anticipable and executing activities for current user instances 
3760:             *
3761:             * @param projectName the project name
3762:             * @return a String Collection - the names of activities
3763:             * @throws HeroException
3764:             * @ejb:interface-method view-type="both"
3765:             * @ejb:transaction type="Supports"
3766:             *
3767:             **/
3768:            public Collection getUserInstancesProjectNodesByPK(
3769:                    String projectName, Collection list, int offset, int numrows)
3770:                    throws HeroException {
3771:                trace.debug("parameter: projectName = " + projectName
3772:                        + " start by "
3773:                        + mContext.getCallerPrincipal().getName());
3774:                ArrayList result = new ArrayList();
3775:                Collection instances = null;
3776:                BnNodeLocalHome nodehome;
3777:                this .synchronizeUser();
3778:                try {
3779:                    int add = 0;
3780:                    nodehome = hero.interfaces.BnNodeUtil.getLocalHome();
3781:                    int cnt = 0;
3782:                    Iterator it = list.iterator();
3783:                    while (it.hasNext()) {
3784:                        if (cnt < offset)
3785:                            it.next();
3786:                        else {
3787:                            BnNodeLocal pl = nodehome
3788:                                    .findByPrimaryKey((BnNodePK) it.next());
3789:                            result.add(pl.getBnNodeLightValue());
3790:                            add++;
3791:                            if (add == numrows)
3792:                                break;
3793:                        }
3794:                        cnt++;
3795:                    }
3796:                    return (result);
3797:                } catch (javax.naming.NamingException ne) {
3798:
3799:                    trace.error(ne.getMessage());
3800:                    throw new HeroException(ne.getMessage());
3801:                } catch (javax.ejb.FinderException fe) {
3802:
3803:                    trace.error(fe.getMessage());
3804:                    throw new HeroException(fe.getMessage());
3805:                }
3806:            }
3807:
3808:            /**
3809:             * Tries to start an activity (when activity state is ready or anticipable)
3810:             * @param projectName the name of the project
3811:             * @param nodeName the name of the node
3812:             * @ejb:interface-method view-type="both"
3813:             * @ejb:transaction type="Required" 
3814:             *
3815:             **/
3816:
3817:            public void startActivity(String projectName, String nodeName)
3818:                    throws HeroException {
3819:
3820:                trace.debug("parameters: projectName=" + projectName
3821:                        + " nodeName=" + nodeName + " start by "
3822:                        + mContext.getCallerPrincipal().getName());
3823:                EngineLocalHome enghome;
3824:                this .synchronizeUser();
3825:                try {
3826:                    enghome = hero.interfaces.EngineUtil.getLocalHome();
3827:                    EngineLocal engine = enghome.create();
3828:                    engine.startActivity(projectName, nodeName);
3829:                    engine.remove();
3830:                } catch (javax.naming.NamingException ne) {
3831:
3832:                    trace.error(ne.getMessage());
3833:                    throw new HeroException(ne.getMessage());
3834:                } catch (CreateException c) {
3835:
3836:                    trace.error("Cannot create Engine bean for " + projectName
3837:                            + " " + c.getMessage());
3838:                    throw new HeroException("Cannot create Engine bean for "
3839:                            + projectName + " " + c.getMessage());
3840:                } catch (RemoveException re) {
3841:
3842:                    trace.error(re.getMessage());
3843:                    throw new HeroException(re.getMessage());
3844:                } catch (Exception e) {
3845:                    throw new HeroException("Error: " + e.getMessage());
3846:                }
3847:            }
3848:
3849:            /**
3850:             * Tries to terminate an activity (when activity state is executing or anticipating)
3851:             * @param projectName the name of the project
3852:             * @param nodeName the name of the node
3853:             * @ejb:interface-method view-type="both"
3854:             * @ejb:transaction type="Required"
3855:             **/
3856:            public void terminateActivity(String projectName, String nodeName)
3857:                    throws HeroException {
3858:
3859:                trace.debug("parameters: projectName=" + projectName
3860:                        + " nodeName=" + nodeName + " start by "
3861:                        + mContext.getCallerPrincipal().getName());
3862:                EngineLocalHome enghome;
3863:                this .synchronizeUser();
3864:                try {
3865:                    enghome = hero.interfaces.EngineUtil.getLocalHome();
3866:                    EngineLocal engine = enghome.create();
3867:                    BnProjectLocalHome pHome = BnProjectUtil.getLocalHome();
3868:                    BnProjectLocal mProject = pHome.findByName(projectName);
3869:                    String version = mProject.getVersion();
3870:                    String type = mProject.getType();
3871:
3872:                    boolean terminated = engine.terminateActivity(projectName,
3873:                            nodeName);
3874:                    engine.remove();
3875:
3876:                    if (terminated) {
3877:                        this .historicAction(projectName, version);
3878:                        if (type.equals(Constants.Pj.INSTANCE))
3879:                            this .deleteInstance(projectName);
3880:                        else
3881:                            this .deleteProject(projectName);
3882:                    }
3883:                } catch (javax.naming.NamingException ne) {
3884:                    trace.error(ne.getMessage());
3885:                    throw new HeroException(ne.getMessage());
3886:                } catch (FinderException fe) {
3887:                    trace.error(fe.getMessage());
3888:                    throw new HeroException(fe.getMessage());
3889:                } catch (CreateException c) {
3890:
3891:                    trace.error("Cannot create Engine bean for " + projectName
3892:                            + " " + c.getMessage());
3893:                    throw new HeroException("Cannot create Engine bean for "
3894:                            + projectName);
3895:                } catch (RemoveException re) {
3896:
3897:                    trace.error(re.getMessage());
3898:                    throw new HeroException(re.getMessage());
3899:                }
3900:            }
3901:
3902:            /**
3903:             * Tries to cancel an activity (when activity is executing or anticipating)
3904:             * @param projectName the name of the project
3905:             * @param nodeName the name of the node
3906:             * @ejb:interface-method view-type="both"
3907:             * @ejb:transaction type="Required"
3908:             **/
3909:            public void cancelActivity(String projectName, String nodeName)
3910:                    throws HeroException {
3911:
3912:                trace.debug("parameters: projectName=" + projectName
3913:                        + " nodeName=" + nodeName + " start by "
3914:                        + mContext.getCallerPrincipal().getName());
3915:                EngineLocalHome enghome;
3916:                this .synchronizeUser();
3917:                try {
3918:                    enghome = hero.interfaces.EngineUtil.getLocalHome();
3919:                    EngineLocal engine = enghome.create();
3920:                    engine.cancelActivity(projectName, nodeName);
3921:                    engine.remove();
3922:                } catch (javax.naming.NamingException ne) {
3923:
3924:                    trace.error(ne.getMessage());
3925:                    throw new HeroException(ne.getMessage());
3926:                } catch (CreateException c) {
3927:
3928:                    trace.error("Cannot create Engine bean for " + projectName
3929:                            + " " + c.getMessage());
3930:                    throw new EJBException("Cannot create Engine bean for "
3931:                            + projectName);
3932:                } catch (RemoveException re) {
3933:
3934:                    trace.error(re.getMessage());
3935:                    throw new HeroException(re.getMessage());
3936:                }
3937:            }
3938:
3939:            /**
3940:             * Tries to terminate a project (only when all project activities are terminated)
3941:             * @param projectName the name of the project
3942:             * @param version the name of the instance
3943:             * @throws HeroException
3944:             * @ejb:interface-method view-type="both"
3945:             * @ejb:transaction type="Required"
3946:             **/
3947:            public void terminate(String projectName) throws HeroException {
3948:
3949:                trace.debug("parameter; projectName=" + projectName
3950:                        + " start by "
3951:                        + mContext.getCallerPrincipal().getName());
3952:                EngineLocalHome enghome;
3953:                this .synchronizeUser();
3954:                try {
3955:                    enghome = hero.interfaces.EngineUtil.getLocalHome();
3956:                    EngineLocal engine = enghome.create();
3957:                    engine.terminate(projectName);
3958:                    engine.remove();
3959:                    if (this .getProjectConfigHistoric().equals(
3960:                            Constants.TRANSFER))
3961:                        BonitaTransfer.TransferFile(projectName);
3962:                    deleteInstance(projectName);
3963:                } catch (javax.naming.NamingException ne) {
3964:
3965:                    trace.error(ne.getMessage());
3966:                    throw new HeroException(ne.getMessage());
3967:                } catch (CreateException c) {
3968:
3969:                    trace.error("Cannot create Engine bean for " + projectName
3970:                            + " " + c.getMessage());
3971:                    throw new EJBException("Cannot create Engine bean for "
3972:                            + projectName);
3973:                } catch (EngineException e) {
3974:
3975:                    trace.error("Cannot terminate project " + e.getMessage());
3976:                    throw new HeroException("Cannot terminate project "
3977:                            + e.getMessage());
3978:                } catch (RemoveException re) {
3979:
3980:                    trace.error(re.getMessage());
3981:                    throw new HeroException(re.getMessage());
3982:                }
3983:            }
3984:
3985:            /**
3986:             * Get Node Value from a specific project
3987:             * @return a NodeValue object - get node information
3988:             * @param projectName the name of the project
3989:             * @param nodeName the name of the node
3990:             * @ejb:interface-method view-type="both"
3991:             * @ejb:transaction type="Supports"
3992:             **/
3993:            public BnNodeValue getNode(String projectName, String nodeName)
3994:                    throws HeroException {
3995:
3996:                trace.debug("parameters: projectName=" + projectName
3997:                        + " nodeName=" + nodeName + "start by "
3998:                        + mContext.getCallerPrincipal().getName());
3999:                this .synchronizeUser();
4000:                try {
4001:                    ProjectSessionLocalHome projectseshome = ProjectSessionUtil
4002:                            .getLocalHome();
4003:                    ProjectSessionLocal project = projectseshome.create();
4004:                    project.initProject(projectName);
4005:                    BnNodeValue nv = project.getNodeValue(nodeName);
4006:                    project.remove();
4007:                    return nv;
4008:                } catch (CreateException f) {
4009:
4010:                    trace.error("Project does not exists " + projectName + " "
4011:                            + f.getMessage());
4012:                    throw new HeroException("Project does not exists "
4013:                            + projectName);
4014:                } catch (javax.naming.NamingException r) {
4015:
4016:                    trace.error("Cannot access to project " + r.getMessage());
4017:                    throw new HeroException("Cannot access to project "
4018:                            + r.getMessage());
4019:                } catch (RemoveException re) {
4020:
4021:                    trace.error(re.getMessage());
4022:                    throw new HeroException(re.getMessage());
4023:                }
4024:            }
4025:
4026:            /**
4027:             * Get the user name
4028:             * 
4029:             * @return a String - get user name
4030:             * @ejb:interface-method view-type="both"
4031:             * @ejb:transaction type="Supports"
4032:             **/
4033:            public String getUser() {
4034:                trace.debug("start by "
4035:                        + mContext.getCallerPrincipal().getName());
4036:                return mContext.getCallerPrincipal().getName();
4037:            }
4038:
4039:            /**
4040:             * Get the user light value
4041:             * 
4042:             * @return a BnUserLightValue object - get user information
4043:             * @ejb:interface-method view-type="both"
4044:             * @ejb:transaction type="Supports"
4045:             **/
4046:            public BnUserLightValue getUserLightValue() throws HeroException {
4047:                try {
4048:                    trace.debug("start by "
4049:                            + mContext.getCallerPrincipal().getName());
4050:                    this .synchronizeUser();
4051:                    BnUserLocalHome userhome = hero.interfaces.BnUserUtil
4052:                            .getLocalHome();
4053:                    BnUserLocal mUser = userhome.findByName(mContext
4054:                            .getCallerPrincipal().getName());
4055:                    BnUserLightValue ulv = mUser.getBnUserLightValue();
4056:                    UserServiceLocalHome ushome = null;
4057:                    try {
4058:                        ushome = hero.interfaces.UserServiceUtil.getLocalHome();
4059:                        UserServiceLocal ul = ushome.create();
4060:                        Map infos = ul.getUserInfos(mContext
4061:                                .getCallerPrincipal().getName());
4062:                        ulv.setEmail((String) infos.get("email"));
4063:                        ulv.setPassword((String) infos.get("password"));
4064:                        ulv.setJabber((String) infos.get("jabber"));
4065:                        return ulv;
4066:                    } catch (Exception ce) {
4067:                        trace.error(ce.getMessage());
4068:                        throw new HeroException(ce.getMessage());
4069:                    }
4070:                } catch (javax.naming.NamingException ne) {
4071:                    trace.error(ne.getMessage());
4072:                    throw new HeroException(ne.getMessage());
4073:                } catch (javax.ejb.FinderException fe) {
4074:                    trace.error(mContext.getCallerPrincipal().getName()
4075:                            + " does not exists " + fe.getMessage());
4076:                    throw new HeroException(mContext.getCallerPrincipal()
4077:                            .getName()
4078:                            + " does not exists");
4079:                }
4080:            }
4081:
4082:            /**
4083:             * Set the mail of this user into Bonita database.
4084:             *
4085:             * @param userName the name of the user
4086:             * @param userName the mail of the user
4087:             * @ejb:interface-method view-type="both"
4088:             * @ejb:transaction type="Required"
4089:             * @throws HeroException
4090:             *
4091:             **/
4092:            public void setUserMail(String userName, String mail)
4093:                    throws HeroException {
4094:                trace.debug("parameters:: userName = " + userName + " mail = "
4095:                        + mail + " start by "
4096:                        + mContext.getCallerPrincipal().getName());
4097:                this .synchronizeUser();
4098:                try {
4099:                    BnUserLocalHome userhome = hero.interfaces.BnUserUtil
4100:                            .getLocalHome();
4101:                    BnUserLocal user = userhome.findByName(userName);
4102:                    user.setEmail(mail);
4103:                } catch (javax.naming.NamingException ne) {
4104:                    trace.error(ne.getMessage());
4105:                    throw new HeroException(ne.getMessage());
4106:                } catch (FinderException fe) {
4107:                    trace.error(fe.getMessage());
4108:                    throw new HeroException(fe.getMessage());
4109:                }
4110:            }
4111:
4112:            /**
4113:             * Get the mail of this user from Bonita database.
4114:             *
4115:             * @ejb:interface-method view-type="both"
4116:             * @ejb:transaction type="Supports"
4117:             * @throws HeroException
4118:             *
4119:             **/
4120:            public String getUserMail() throws HeroException {
4121:                trace.debug(" start by "
4122:                        + mContext.getCallerPrincipal().getName());
4123:                UserServiceLocalHome ushome = null;
4124:                this .synchronizeUser();
4125:                try {
4126:                    ushome = hero.interfaces.UserServiceUtil.getLocalHome();
4127:                    UserServiceLocal ul = ushome.create();
4128:                    Map infos = ul.getUserInfos(mContext.getCallerPrincipal()
4129:                            .getName());
4130:                    return ((String) infos.get("email"));
4131:                } catch (Exception ce) {
4132:                    trace.error(ce.getMessage());
4133:                    throw new HeroException(ce.getMessage());
4134:                }
4135:            }
4136:
4137:            /**
4138:             * Get the user password
4139:             *
4140:             * @return a String - get user password
4141:             * @ejb:interface-method view-type="both"
4142:             * @ejb:transaction type="Supports"
4143:             **/
4144:            public String getUserPassword() throws HeroException {
4145:                UserServiceLocalHome ushome = null;
4146:                this .synchronizeUser();
4147:                try {
4148:                    ushome = hero.interfaces.UserServiceUtil.getLocalHome();
4149:                    UserServiceLocal ul = ushome.create();
4150:                    Map infos = ul.getUserInfos(mContext.getCallerPrincipal()
4151:                            .getName());
4152:                    return ((String) infos.get("password"));
4153:                } catch (Exception ce) {
4154:                    trace.error(ce.getMessage());
4155:                    throw new HeroException(ce.getMessage());
4156:                }
4157:            }
4158:
4159:            /**
4160:             * Get the user jabber address
4161:             *
4162:             * @return a String - get user jabber address
4163:             * @ejb:interface-method view-type="both"
4164:             * @ejb:transaction type="Supports"
4165:             **/
4166:            public String getUserJabber() throws HeroException {
4167:                UserServiceLocalHome ushome = null;
4168:                this .synchronizeUser();
4169:                try {
4170:                    ushome = hero.interfaces.UserServiceUtil.getLocalHome();
4171:                    UserServiceLocal ul = ushome.create();
4172:                    Map infos = ul.getUserInfos(mContext.getCallerPrincipal()
4173:                            .getName());
4174:                    return ((String) infos.get("jabber"));
4175:                } catch (Exception ce) {
4176:                    trace.error(ce.getMessage());
4177:                    throw new HeroException(ce.getMessage());
4178:                }
4179:            }
4180:
4181:            /**
4182:             * Get User properties
4183:             *
4184:             * @return a BnUserPropertyValue Collection - list of user properties
4185:             * @ejb:interface-method view-type="both"
4186:             * @ejb:transaction type="Supports"
4187:             *
4188:             **/
4189:            public Collection getUserProperties() throws HeroException {
4190:                Collection prp = new ArrayList();
4191:                BnUserPropertyLocal pl;
4192:                this .synchronizeUser();
4193:                try {
4194:                    BnUserLocalHome userhome = hero.interfaces.BnUserUtil
4195:                            .getLocalHome();
4196:                    BnUserLocal mUser = userhome.findByName(mContext
4197:                            .getCallerPrincipal().getName());
4198:                    Collection pls = mUser.getBnProperties();
4199:
4200:                    for (Iterator i = pls.iterator(); i.hasNext();) {
4201:                        pl = (BnUserPropertyLocal) i.next();
4202:                        prp.add(pl.getBnUserPropertyValue());
4203:                    }
4204:                    return (prp);
4205:                } catch (javax.naming.NamingException ne) {
4206:                    trace.error(ne.getMessage());
4207:                    throw new HeroException(ne.getMessage());
4208:                } catch (javax.ejb.FinderException fe) {
4209:                    trace.error(mContext.getCallerPrincipal().getName()
4210:                            + " does not exists " + fe.getMessage());
4211:                    throw new HeroException(mContext.getCallerPrincipal()
4212:                            .getName()
4213:                            + " does not exists");
4214:                }
4215:            }
4216:
4217:            /**
4218:             * Set a property of a user
4219:             *
4220:             * @param key the key of the property
4221:             * @param value the name of the property
4222:             * @ejb:interface-method view-type="both"
4223:             * @ejb:transaction type="Required"
4224:             *
4225:             **/
4226:
4227:            public void setUserProperty(String key, String value)
4228:                    throws HeroException {
4229:                BnUserPropertyLocalHome pHome;
4230:                BnUserPropertyLocal propertyLocal = null;
4231:                trace.debug("parameters:  key=" + key + " value=" + value
4232:                        + " start by "
4233:                        + mContext.getCallerPrincipal().getName());
4234:                this .synchronizeUser();
4235:
4236:                try {
4237:                    BnUserLocalHome userhome = hero.interfaces.BnUserUtil
4238:                            .getLocalHome();
4239:                    BnUserLocal mUser = userhome.findByName(mContext
4240:                            .getCallerPrincipal().getName());
4241:                    try {
4242:                        pHome = BnUserPropertyUtil.getLocalHome();
4243:                    } catch (javax.naming.NamingException ne) {
4244:                        trace.error(ne.getMessage());
4245:                        throw new HeroException(ne.getMessage());
4246:                    }
4247:                    Collection c = null;
4248:                    try {
4249:                        c = pHome.findByTheKey(mUser.getId(), key);
4250:                    } catch (FinderException fe) {
4251:                        trace.error(fe.getMessage());
4252:                        throw new HeroException(fe.getMessage());
4253:                    }
4254:
4255:                    if (!c.isEmpty()) {
4256:
4257:                        propertyLocal = (BnUserPropertyLocal) (c.toArray())[0];
4258:                        propertyLocal.setTheValue(value);
4259:
4260:                    } else {
4261:                        try {
4262:                            propertyLocal = pHome.create(key, value);
4263:                            propertyLocal.setBnUser(mUser);
4264:
4265:                        } catch (InvalidValueException ie) {
4266:                            trace.error(ie.getMessage());
4267:                            throw new HeroException(ie.getMessage());
4268:                        } catch (javax.ejb.CreateException ce) {
4269:                            trace.error(ce.getMessage());
4270:                            throw new HeroException(ce.getMessage());
4271:                        }
4272:
4273:                    }
4274:                } catch (javax.naming.NamingException ne) {
4275:                    trace.error(ne.getMessage());
4276:                    throw new HeroException(ne.getMessage());
4277:                } catch (javax.ejb.FinderException fe) {
4278:                    trace.error(mContext.getCallerPrincipal().getName()
4279:                            + " does not exists " + fe.getMessage());
4280:                    throw new HeroException(mContext.getCallerPrincipal()
4281:                            .getName()
4282:                            + " does not exists");
4283:                }
4284:            }
4285:
4286:            /**
4287:             * Delete a property of a user
4288:             *
4289:             * @param key the key of the property
4290:             * @ejb:interface-method view-type="both"
4291:             * @ejb:transaction type="Required"
4292:             *
4293:             **/
4294:            public void deleteUserProperty(String key) throws HeroException {
4295:                trace.debug("parameter key=" + key + " start by "
4296:                        + mContext.getCallerPrincipal().getName());
4297:
4298:                BnUserPropertyLocalHome pHome;
4299:                BnUserPropertyLocal propertyLocal = null;
4300:                this .synchronizeUser();
4301:                try {
4302:                    BnUserLocalHome userhome = hero.interfaces.BnUserUtil
4303:                            .getLocalHome();
4304:                    BnUserLocal mUser = userhome.findByName(mContext
4305:                            .getCallerPrincipal().getName());
4306:                    try {
4307:                        pHome = BnUserPropertyUtil.getLocalHome();
4308:                    } catch (javax.naming.NamingException ne) {
4309:                        trace.error(ne.getMessage());
4310:                        throw new HeroException(ne.getMessage());
4311:                    }
4312:                    Collection c = null;
4313:                    try {
4314:                        c = pHome.findByTheKey(mUser.getId(), key);
4315:                    } catch (FinderException fe) {
4316:                        trace.error(fe.getMessage());
4317:                        throw new HeroException(fe.getMessage());
4318:                    }
4319:
4320:                    if (!c.isEmpty()) {
4321:                        try {
4322:                            propertyLocal = (BnUserPropertyLocal) (c.toArray())[0];
4323:                            propertyLocal.remove();
4324:                        } catch (RemoveException rm) {
4325:                            trace.error(rm.getMessage());
4326:                            throw new HeroException(rm.getMessage());
4327:                        }
4328:                    } else {
4329:                        throw new HeroException("Property not found :" + key);
4330:                    }
4331:
4332:                } catch (javax.naming.NamingException ne) {
4333:                    trace.error(ne.getMessage());
4334:                    throw new HeroException(ne.getMessage());
4335:                } catch (javax.ejb.FinderException fe) {
4336:                    trace.error(mContext.getCallerPrincipal().getName()
4337:                            + " does not exists " + fe.getMessage());
4338:                    throw new HeroException(mContext.getCallerPrincipal()
4339:                            .getName()
4340:                            + " does not exists");
4341:                }
4342:            }
4343:
4344:            private void deleteInstances(Collection instances)
4345:                    throws HeroException {
4346:                Iterator inst = instances.iterator();
4347:                this .synchronizeUser();
4348:                try {
4349:                    while (inst.hasNext()) {
4350:                        BnProjectLocal ins = (BnProjectLocal) inst.next();
4351:                        if (ins.getName().matches(".*_instance.*")) {
4352:                            ins.remove();
4353:                            if (jms != null)
4354:                                jms.sendProjectEvent(DELETEPROJECT, ins
4355:                                        .getName());
4356:                        }
4357:                    }
4358:                } catch (RemoveException re) {
4359:                    trace.error("Error in delete instance " + re.getMessage());
4360:                    throw new HeroException("Error in delete project");
4361:                }
4362:            }
4363:
4364:            /*private void deleteSubProcesses(String projectName) throws HeroException{
4365:            	BnProjectLocalHome pHome;		
4366:            	this.synchronizeUser();		
4367:            	try {
4368:            		pHome = hero.interfaces.BnProjectUtil.getLocalHome();
4369:            	} catch (javax.naming.NamingException be) {
4370:            		
4371:            		trace.error(be.getMessage());
4372:            		throw new HeroException(be.getMessage());
4373:            	}
4374:            	try {
4375:            		BnProjectLocal pl = pHome.findByName(projectName);
4376:            		String userName = mContext.getCallerPrincipal().getName();
4377:            		Collection nodes = pl.getBnNodes();
4378:            		Iterator nds = nodes.iterator();
4379:            		while (nds.hasNext())            // Verifies if the project has any subProcesses
4380:            		{
4381:            			BnNodeLocal nd = (BnNodeLocal)nds.next();
4382:            			if (nd.getType()==Constants.Nd.SUB_PROCESS_NODE)
4383:            				this.deleteSubProcesses(nd.getVersion());
4384:            		}
4385:            		pl.remove();
4386:            		if (jms!=null)
4387:            			jms.sendProjectEvent(DELETEPROJECT, projectName);
4388:            	} catch (Exception re) {
4389:            		trace.error("Error in delete subProcess " + re.getMessage());
4390:            		throw new HeroException("Error in delete subProcess");
4391:            	}
4392:            }*/
4393:
4394:            private String getProjectConfigHistoric() throws HeroException {
4395:                return (bonitaConfig.getHistoric());
4396:            }
4397:
4398:            /**
4399:             * Creates the User Session Bean. This method is the first one to invoke in order to
4400:             * use UserSession API. If the user is not authorized this method throws an exception.
4401:             *
4402:             * @throws CreateException
4403:             *
4404:             * @ejb:create-method view-type="both"
4405:             **/
4406:            public void ejbCreate() throws CreateException {
4407:            }
4408:
4409:            private void synchronizeUser() throws HeroException {
4410:                UserServiceLocalHome ushome = null;
4411:                try {
4412:                    ushome = hero.interfaces.UserServiceUtil.getLocalHome();
4413:                    UserServiceLocal ul = ushome.create();
4414:                    ul.findUserLocal(mContext.getCallerPrincipal().getName());
4415:                } catch (Exception ce) {
4416:                    ce.printStackTrace();
4417:                    trace.error("Error in findUserLocal " + ce.getMessage());
4418:                    throw new HeroException("Error in findUserLocal: "
4419:                            + ce.getMessage());
4420:                }
4421:            }
4422:
4423:            private boolean isAdmin(String projectName, String version)
4424:                    throws HeroException {
4425:
4426:                trace
4427:                        .debug("parameters: projectName=" + projectName
4428:                                + "start by "
4429:                                + mContext.getCallerPrincipal().getName());
4430:                this .synchronizeUser();
4431:                try {
4432:                    ProjectSessionLocalHome projectseshome = ProjectSessionUtil
4433:                            .getLocalHome();
4434:                    ProjectSessionLocal project = projectseshome.create();
4435:                    project.initModelWithVersion(projectName, version);
4436:                    boolean admin = project.isAdminOfProject();
4437:                    project.remove();
4438:                    return (admin);
4439:
4440:                } catch (CreateException f) {
4441:
4442:                    trace.error("Project does not exists " + projectName + " "
4443:                            + f.getMessage());
4444:                    throw new HeroException("Project does not exists "
4445:                            + projectName);
4446:                } catch (javax.naming.NamingException r) {
4447:
4448:                    trace.error("Cannot access to project " + r.getMessage());
4449:                    throw new HeroException("Cannot access to project "
4450:                            + r.getMessage());
4451:                } catch (RemoveException re) {
4452:
4453:                    trace.error(re.getMessage());
4454:                    throw new HeroException(re.getMessage());
4455:                }
4456:            }
4457:
4458:            // isAdmin method only for instances
4459:            private boolean isAdmin(String instName) throws HeroException {
4460:                this .synchronizeUser();
4461:                try {
4462:
4463:                    ProjectSessionLocalHome psHome;
4464:                    BnProjectLocalHome pHome;
4465:                    ProjectSessionLocal mPSession;
4466:                    BnProjectLocal mProject;
4467:
4468:                    psHome = ProjectSessionUtil.getLocalHome();
4469:                    pHome = BnProjectUtil.getLocalHome();
4470:
4471:                    mProject = pHome.findByName(instName);
4472:
4473:                    mPSession = psHome.create();
4474:
4475:                    mPSession.initProject(instName);
4476:
4477:                    boolean admin = mPSession.isAdminOfProject();
4478:                    mPSession.remove();
4479:                    return (admin);
4480:
4481:                } catch (CreateException f) {
4482:                    trace.error("Project does not exists " + instName + " "
4483:                            + f.getMessage());
4484:                    throw new HeroException("Project does not exists "
4485:                            + instName);
4486:                } catch (javax.naming.NamingException r) {
4487:                    trace.error("Cannot access to project " + r.getMessage());
4488:                    throw new HeroException("Cannot access to project "
4489:                            + r.getMessage());
4490:                } catch (RemoveException re) {
4491:                    trace.error(re.getMessage());
4492:                    throw new HeroException(re.getMessage());
4493:                } catch (FinderException fe) {
4494:                    trace.error(fe.getMessage());
4495:                    throw new HeroException(fe.getMessage());
4496:                }
4497:            }
4498:
4499:            private void deleteProject(String projectName) throws HeroException {
4500:                this .deleteProject(projectName,
4501:                        EventConstants.DEFAULTPROJECTVERSION);
4502:            }
4503:
4504:            private void deleteProject(String projectName, String version)
4505:                    throws HeroException {
4506:
4507:                trace.debug("parameter: projectName=" + projectName
4508:                        + " start by "
4509:                        + mContext.getCallerPrincipal().getName());
4510:                BnProjectLocalHome pHome;
4511:                this .synchronizeUser();
4512:                BonitaConfig bonitaConfig = BonitaConfig.getInstance();
4513:                try {
4514:                    pHome = hero.interfaces.BnProjectUtil.getLocalHome();
4515:                } catch (javax.naming.NamingException be) {
4516:
4517:                    trace.error(be.getMessage());
4518:                    throw new HeroException(be.getMessage());
4519:                }
4520:                try {
4521:                    BnProjectLocal pl = pHome.findByNameVersion(projectName,
4522:                            version);
4523:                    String userName = mContext.getCallerPrincipal().getName();
4524:
4525:                    Collection ins = new ArrayList();
4526:                    if (pl.getType().equals(Constants.Pj.MODEL)) // is a projectModel
4527:                    {
4528:                        ins = this .getProjectInstances(pl.getName(), version);
4529:                        Iterator instances = ins.iterator();
4530:                        while (instances.hasNext()) {
4531:                            BnProjectValue pr = (BnProjectValue) instances
4532:                                    .next();
4533:                            if (!pr.getName().equals(pl.getName())
4534:                                    && pr.getState() != Constants.Pj.TERMINATED)
4535:                                throw new HeroException(
4536:                                        "Error in delete project: This Workflow model has running instances !!");
4537:                        }
4538:                    }
4539:
4540:                    if (!ins.isEmpty())
4541:                        this .deleteInstances(ins);
4542:                    try {
4543:                        if (pl.getType().equals(Constants.Pj.MODEL))
4544:                            BonitaProjectLocator.getInstance().cleanModelValue(
4545:                                    projectName, version);
4546:                    } catch (BonitaServiceException se) {
4547:                        throw new HeroException(se.getMessage());
4548:                    }
4549:
4550:                    pl.remove();
4551:                    if (jms != null)
4552:                        jms.sendProjectEvent(DELETEPROJECT, projectName);
4553:
4554:                } catch (javax.ejb.FinderException fe) {
4555:                    fe.printStackTrace();
4556:                    trace.error("Error while deleting the process "
4557:                            + projectName);
4558:                    throw new HeroException("Error while deleting the process "
4559:                            + projectName);
4560:
4561:                } catch (RemoveException re) {
4562:
4563:                    trace.error("Error in delete project " + re.getMessage());
4564:                    throw new HeroException("Error in delete project");
4565:                }
4566:            }
4567:
4568:            private void deleteInstance(String projectName)
4569:                    throws HeroException {
4570:                BnProjectLocalHome pHome;
4571:                this .synchronizeUser();
4572:                try {
4573:                    pHome = hero.interfaces.BnProjectUtil.getLocalHome();
4574:                } catch (javax.naming.NamingException be) {
4575:
4576:                    trace.error(be.getMessage());
4577:                    throw new HeroException(be.getMessage());
4578:                }
4579:                try {
4580:                    BnProjectLocal pl = pHome.findByName(projectName);
4581:                    String userName = mContext.getCallerPrincipal().getName();
4582:                    if (pl.getParent().equals(pl.getName())) {
4583:                        Collection nodes = pl.getBnNodes();
4584:                        Iterator nds = nodes.iterator();
4585:                        while (nds.hasNext()) // Verifies if the project has any subProcesses
4586:                        {
4587:                            BnNodeLocal nd = (BnNodeLocal) nds.next();
4588:                            if (nd.getType() == Constants.Nd.SUB_PROCESS_NODE) {
4589:                                BnProjectLocal subProcess = pHome.findByName(nd
4590:                                        .getReference());
4591:                                subProcess.remove();
4592:                                if (jms != null)
4593:                                    jms.sendProjectEvent(DELETEPROJECT, nd
4594:                                            .getReference());
4595:                                //this.deleteSubProcesses(nd.getVersion());
4596:                            }
4597:                        }
4598:                        pl.remove();
4599:                        if (jms != null)
4600:                            jms.sendProjectEvent(DELETEPROJECT, projectName);
4601:                    } else
4602:                        throw new HeroException(
4603:                                "Error in delete project: You must delete subProcess activity of this project !!");
4604:                } catch (javax.ejb.FinderException fe) {
4605:
4606:                    trace.error("User does not exist " + fe.getMessage());
4607:                    throw new HeroException("User does not exist");
4608:                } catch (RemoveException re) {
4609:
4610:                    trace.error("Error in delete project " + re.getMessage());
4611:                    throw new HeroException("Error in delete project");
4612:                }
4613:            }
4614:
4615:            private void historicAction(String projectName, String version)
4616:                    throws HeroException {
4617:                this .synchronizeUser();
4618:                if (this .getProjectConfigHistoric().equals(Constants.TRANSFER))
4619:                    BonitaTransfer.TransferFile(projectName);
4620:            }
4621:
4622:            private String getNodeName(String nodeName) {
4623:                int i = nodeName.indexOf("_instance");
4624:                return (nodeName.substring(0, i));
4625:            }
4626:
4627:            // Get the name of the subProcesses
4628:            private String getSubProcessName(String name) {
4629:                int i = name.indexOf("_version");
4630:                return (name.substring(0, i));
4631:            }
4632:
4633:            /**
4634:             * Internal Enterprise Java Beans method. 
4635:             **/
4636:
4637:            public void setSessionContext(final javax.ejb.SessionContext context) {
4638:                mContext = context;
4639:                try {
4640:                    bonitaConfig = BonitaConfig.getInstance();
4641:                    if (bonitaConfig.getJms()) {
4642:                        JMSServicesSessionLocalHome home = JMSServicesSessionUtil
4643:                                .getLocalHome();
4644:                        this .jms = home.create();
4645:                    }
4646:                } catch (Exception e) {
4647:                    throw new EJBException(e.getMessage());
4648:                }
4649:            }
4650:
4651:            /**
4652:             * Internal Enterprise Java Beans method. 
4653:             **/
4654:            public void ejbRemove() {
4655:            }
4656:
4657:            /**
4658:             * Internal Enterprise Java Beans method. 
4659:             **/
4660:            public void ejbActivate() {
4661:            }
4662:
4663:            /**
4664:             * Internal Enterprise Java Beans method. 
4665:             **/
4666:            public void ejbPassivate() {
4667:            }
4668:
4669:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.