Source Code Cross Referenced for ParticipantService.java in  » Workflow-Engines » wilos » wilos » business » services » misc » wilosuser » 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 » wilos » wilos.business.services.misc.wilosuser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Wilos Is a cLever process Orchestration Software - http://www.wilos-project.org
003:         * Copyright (C) 2006-2007 Paul Sabatier University, IUP ISI (Toulouse, France) <massie@irit.fr>
004:         * Copyright (C) 2007 Mathieu BENOIT <mathieu-benoit@hotmail.fr>
005:         * Copyright (C) 2007 Sebastien BALARD <sbalard@wilos-project.org>
006:         *
007:         * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
008:         * General Public License as published by the Free Software Foundation; either version 2 of the License,
009:         * or (at your option) any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
012:         * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013:         * GNU General Public License for more details.
014:         *
015:         * You should have received a copy of the GNU General Public License along with this program; if not,
016:         * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
017:         */
018:
019:        package wilos.business.services.misc.wilosuser;
020:
021:        import java.util.ArrayList;
022:        import java.util.HashMap;
023:        import java.util.HashSet;
024:        import java.util.List;
025:        import java.util.Map;
026:        import java.util.Set;
027:
028:        import org.springframework.transaction.annotation.Propagation;
029:        import org.springframework.transaction.annotation.Transactional;
030:
031:        import wilos.business.services.misc.concreterole.ConcreteRoleDescriptorService;
032:        import wilos.business.services.misc.concreteworkproduct.ConcreteWorkProductDescriptorService;
033:        import wilos.business.services.misc.project.ProjectService;
034:        import wilos.business.webservices.transfertobject.ParticipantTO;
035:        import wilos.hibernate.misc.wilosuser.ParticipantDao;
036:        import wilos.model.misc.concreterole.ConcreteRoleDescriptor;
037:        import wilos.model.misc.concreteworkproduct.ConcreteWorkProductDescriptor;
038:        import wilos.model.misc.project.Project;
039:        import wilos.model.misc.wilosuser.Participant;
040:        import wilos.utils.Security;
041:
042:        /**
043:         * The services associated to the Participant
044:         * 
045:         */
046:        @Transactional(readOnly=false,propagation=Propagation.REQUIRED)
047:        public class ParticipantService {
048:
049:            private ParticipantDao participantDao;
050:
051:            private ProjectService projectService;
052:
053:            private ConcreteRoleDescriptorService concreteRoleDescriptorService;
054:
055:            private ConcreteWorkProductDescriptorService concreteWorkProductDescriptorService;
056:
057:            /**
058:             * Allows to get the concreteRoleDescriptorService
059:             * 
060:             * @return the concreteRoleDescriptorService
061:             */
062:            public ConcreteRoleDescriptorService getConcreteRoleDescriptorService() {
063:                return this .concreteRoleDescriptorService;
064:            }
065:
066:            /**
067:             * Allows to set the concreteRoleDescriptorService
068:             * 
069:             * @param _concreteRoleDescriptorService
070:             */
071:            public void setConcreteRoleDescriptorService(
072:                    ConcreteRoleDescriptorService _concreteRoleDescriptorService) {
073:                this .concreteRoleDescriptorService = _concreteRoleDescriptorService;
074:            }
075:
076:            /**
077:             * Allows to get the participantDao
078:             * 
079:             * @return the ParticipantDao
080:             */
081:            public ParticipantDao getParticipantDao() {
082:                return this .participantDao;
083:            }
084:
085:            /**
086:             * Allows to set the participantDao
087:             * 
088:             * @param _participantDao
089:             */
090:            public void setParticipantDao(ParticipantDao _participantDao) {
091:                this .participantDao = _participantDao;
092:            }
093:
094:            /**
095:             * Allows to get the projectService
096:             * 
097:             * @return the projectService
098:             */
099:            public ProjectService getProjectService() {
100:                return this .projectService;
101:            }
102:
103:            /**
104:             * Allows to get the projectService
105:             * 
106:             * @param _projectService
107:             * 
108:             */
109:            public void setProjectService(ProjectService _projectService) {
110:                this .projectService = _projectService;
111:            }
112:
113:            /**
114:             * Allows to get the set of concreteRoleDescriptor for a participant and a
115:             * project
116:             * 
117:             * @return the set of concreteRoleDescriptor
118:             */
119:            public Set<ConcreteRoleDescriptor> getConcreteRoleDescriptorsForAParticipantAndForAProject(
120:                    String _participantId, String _projectId) {
121:
122:                Set<ConcreteRoleDescriptor> concreteRolesList = new HashSet<ConcreteRoleDescriptor>();
123:                Set<ConcreteRoleDescriptor> participantConcreteRolesList = this 
124:                        .getParticipant(_participantId)
125:                        .getConcreteRoleDescriptors();
126:                List<ConcreteRoleDescriptor> projectConcreteRolesList = this .concreteRoleDescriptorService
127:                        .getAllConcreteRoleDescriptorsForProject(_projectId);
128:                if (projectConcreteRolesList != null) {
129:
130:                    for (ConcreteRoleDescriptor projectConcreteRole : projectConcreteRolesList) {
131:                        for (ConcreteRoleDescriptor concreteRoleDescriptor : participantConcreteRolesList) {
132:                            if (projectConcreteRole.getId().equals(
133:                                    concreteRoleDescriptor.getId()))
134:                                concreteRolesList.add(concreteRoleDescriptor);
135:                        }
136:                    }
137:                }
138:                return concreteRolesList;
139:            }
140:
141:            /**
142:             * Allows to get the list of participants
143:             * 
144:             * @return the list of participants
145:             */
146:            public List<Participant> getParticipants() {
147:                return this .participantDao.getAllParticipants();
148:            }
149:
150:            /**
151:             * Allows to get the participant with its id
152:             * 
153:             * @return the participant
154:             */
155:            public Participant getParticipant(String _id) {
156:                return this .participantDao.getParticipantById(_id);
157:            }
158:
159:            /**
160:             * Allows to save the participant
161:             * 
162:             * @param _participant
163:             */
164:            public void saveParticipant(Participant _participant) {
165:                _participant.setPassword(Security.encode(_participant
166:                        .getPassword()));
167:                participantDao.saveOrUpdateParticipant(_participant);
168:            }
169:
170:            /**
171:             * Allows to save the participant without encryption of the password
172:             * 
173:             * @param _participant
174:             */
175:            public void saveParticipantWithoutEncryption(
176:                    Participant _participant) {
177:                participantDao.saveOrUpdateParticipant(_participant);
178:            }
179:
180:            /**
181:             * Allows to delete a participant
182:             * 
183:             * @param participantId
184:             */
185:            public void deleteParticipant(String participantId) {
186:                Participant participant = this .getParticipant(participantId);
187:                this .participantDao.deleteParticipant(participant);
188:            }
189:
190:            /**
191:             * 
192:             * Allows to get the list of projects for a participant
193:             * 
194:             * @param participant
195:             * @return list of projects where the participant is affected to
196:             */
197:            public HashMap<Project, Boolean> getProjectsForAParticipant(
198:                    Participant _participant) {
199:
200:                this .participantDao.getSessionFactory().getCurrentSession()
201:                        .saveOrUpdate(_participant);
202:
203:                HashMap<Project, Boolean> affectedProjectList = new HashMap<Project, Boolean>();
204:                HashSet<Project> allProjectList = new HashSet<Project>();
205:                // Participant loadedParticipant = new Participant();
206:
207:                // chargement du participant et des projets
208:                // String login = loadedParticipant.getLogin();
209:                // loadedParticipant = this.participantDao.getParticipant(login);
210:                allProjectList = (HashSet<Project>) this .projectService
211:                        .getUnfinishedProjects();
212:
213:                for (Project p : allProjectList) {
214:                    Set<Project> tmp = _participant.getAffectedProjectList();
215:                    if (tmp.contains(p)) {
216:                        affectedProjectList.put(p, true);
217:                    } else {
218:                        affectedProjectList.put(p, false);
219:                    }
220:                }
221:                return affectedProjectList;
222:            }
223:
224:            /**
225:             * 
226:             * Allows to get the list of project where a participant is affected to
227:             * 
228:             * @param participant
229:             * @return list of project where the participant is affected to
230:             */
231:            public List<Project> getAllAffectedProjectsForParticipant(
232:                    Participant participant) {
233:                List<Project> affectedProjectList = new ArrayList<Project>();
234:                HashSet<Project> allProjectList = new HashSet<Project>();
235:                Participant chargedParticipant = new Participant();
236:
237:                // chargement du participant et des projets
238:                String login = participant.getLogin();
239:                chargedParticipant = this .participantDao.getParticipant(login);
240:                allProjectList = (HashSet<Project>) this .projectService
241:                        .getUnfinishedProjects();
242:
243:                for (Project p : allProjectList) {
244:                    if (chargedParticipant.getAffectedProjectList().contains(p)) {
245:                        affectedProjectList.add(p);
246:                    }
247:                }
248:                return affectedProjectList;
249:            }
250:
251:            /**
252:             * Allows to save projects for a participant
253:             * 
254:             * @param participant
255:             * @param affectedProjects
256:             */
257:            public void saveProjectsForAParticipant(Participant participant,
258:                    Map<String, Boolean> affectedProjects) {
259:                Participant currentParticipant = this .getParticipantDao()
260:                        .getParticipant(participant.getLogin());
261:                Project currentProject;
262:
263:                // for every project
264:                for (String projectId : affectedProjects.keySet()) {
265:
266:                    currentProject = this .projectService.getProject(projectId);
267:
268:                    // if this is an affectation
269:                    if (Boolean.valueOf(affectedProjects.get(projectId)) == true) {
270:                        currentParticipant.addAffectedProject(currentProject);
271:                    }
272:                    // if this is an unaffectation
273:                    else {
274:                        // removing the participant from the project
275:                        currentParticipant
276:                                .removeAffectedProject(currentProject);
277:
278:                        // if the project have a project manager
279:                        if (currentProject.getProjectManager() != null) {
280:                            // if the project manager is the current participant
281:                            if (currentProject.getProjectManager().getId()
282:                                    .equals(currentParticipant.getId())) {
283:                                currentParticipant
284:                                        .removeManagedProject(currentProject);
285:                                this .projectService.saveProject(currentProject);
286:                            }
287:                        }
288:                    }
289:                }
290:                this .participantDao.saveOrUpdateParticipant(currentParticipant);
291:            }
292:
293:            /**
294:             * Allows to save a project for a projectManager
295:             * 
296:             * @param _participantId
297:             * @param _projectId
298:             * @param _isForAssignment
299:             */
300:            public void saveProjectForAProjectManager(String _participantId,
301:                    String _projectId, boolean _isForAssignment) {
302:                Participant currentParticipant = this .getParticipantDao()
303:                        .getParticipantById(_participantId);
304:                Project currentProject = this .projectService
305:                        .getProject(_projectId);
306:
307:                if (_isForAssignment) {
308:                    currentParticipant.addManagedProject(currentProject);
309:                } else {
310:                    // removing the participant from the project.
311:                    currentParticipant.removeManagedProject(currentProject);
312:                }
313:                this .projectService.saveProject(currentProject);
314:                this .participantDao.saveOrUpdateParticipant(currentParticipant);
315:            }
316:
317:            /**
318:             * 
319:             * Allows to get the list of projects without project manager for a
320:             * participant
321:             * 
322:             * @param participant
323:             * @return HashMap with couples of this form : (Project,ProjectManager) or
324:             *         (Project,null)
325:             */
326:            public HashMap<Project, Participant> getManageableProjectsForAParticipant(
327:                    Participant participant) {
328:                HashMap<Project, Boolean> affectedProjectList = new HashMap<Project, Boolean>();
329:                HashMap<Project, Participant> manageableProjectList = new HashMap<Project, Participant>();
330:
331:                // chargement des projets
332:                affectedProjectList = this 
333:                        .getProjectsForAParticipant(participant);
334:
335:                // for every project
336:                for (Project project : affectedProjectList.keySet()) {
337:                    // if the project is affected to the participant
338:                    if (affectedProjectList.get(project).booleanValue() == true) {
339:                        // if there is no projectManager -> the project is manageable
340:                        if (project.getProjectManager() == null) {
341:                            manageableProjectList.put(project, null);
342:                        }
343:                        // if there is a projectManager -> the project is not manageable
344:                        else {
345:                            manageableProjectList.put(project, project
346:                                    .getProjectManager());
347:                        }
348:                    }
349:                }
350:                return manageableProjectList;
351:            }
352:
353:            /**
354:             * Allows to save managed projects for a participant
355:             * 
356:             * @param participant
357:             * @param managedProjects
358:             */
359:            public void saveManagedProjectsForAParticipant(
360:                    Participant participant,
361:                    Map<String, Boolean> managedProjects) {
362:                Participant currentParticipant = this .getParticipantDao()
363:                        .getParticipant(participant.getLogin());
364:                Project currentProject;
365:
366:                for (String projectId : managedProjects.keySet()) {
367:                    // loading the current project from database
368:                    currentProject = this .projectService.getProject(projectId);
369:                    if ((Boolean) managedProjects.get(projectId))
370:                        currentParticipant.addManagedProject(currentProject);
371:                    else
372:                        currentParticipant.removeManagedProject(currentProject);
373:                }
374:                this .participantDao.saveOrUpdateParticipant(currentParticipant);
375:            }
376:
377:            /**
378:             * Allows to get the participantTO with the login
379:             * 
380:             * @param _login
381:             * @return the participantTO
382:             */
383:            public ParticipantTO getParticipantTO(String _login) {
384:                return new ParticipantTO(participantDao.getParticipant(_login));
385:            }
386:
387:            /**
388:             * Allows to get a participant's login
389:             * 
390:             * @param participant
391:             * @return the participant's login
392:             */
393:            public String getParticipantLogin(Participant participant) {
394:                this .participantDao.getSessionFactory().getCurrentSession()
395:                        .saveOrUpdate(participant);
396:                return participant.getLogin();
397:            }
398:
399:            /**
400:             * Allows to get the concreteWorkProductDescriptorService
401:             * 
402:             * @return the concreteWorkProductDescriptorService
403:             */
404:            public ConcreteWorkProductDescriptorService getConcreteWorkProductDescriptorService() {
405:                return this .concreteWorkProductDescriptorService;
406:            }
407:
408:            /**
409:             * Allows to set the concreteWorkProductDescriptorService
410:             * 
411:             * @param _concreteWorkProductDescriptorService
412:             */
413:            public void setConcreteWorkProductDescriptorService(
414:                    ConcreteWorkProductDescriptorService _concreteWorkProductDescriptorService) {
415:                this .concreteWorkProductDescriptorService = _concreteWorkProductDescriptorService;
416:            }
417:
418:            /**
419:             * Allows to save the concreteWorkProductDescriptor for a participant
420:             * 
421:             * @param _participant
422:             * @param _concreteWorkProductDescriptor
423:             */
424:            public void saveConcreteWorkProductDescriptorForAParticipant(
425:                    Participant _participant,
426:                    ConcreteWorkProductDescriptor _concreteWorkProductDescriptor) {
427:
428:                Participant currentParticipant = this.getParticipantDao()
429:                        .getParticipant(_participant.getLogin());
430:
431:                currentParticipant
432:                        .addConcreteWorkProductDescriptor(_concreteWorkProductDescriptor);
433:
434:                this.participantDao.saveOrUpdateParticipant(currentParticipant);
435:
436:            }
437:
438:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.