Source Code Cross Referenced for ProjectService.java in  » Workflow-Engines » wilos » wilos » business » services » misc » project » 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.project 
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 Sebastien BALARD <sbalard@wilos-project.org>
005:         * Copyright (C) 2007 Emilien PERICO <eperico@wilos-project.org>
006:         * Copyright (C) 2007-2008 Paul Sabatier University, IUP ISI (Toulouse, France) <massie@irit.fr>
007:         *
008:         * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
009:         * General Public License as published by the Free Software Foundation; either version 2 of the License,
010:         * or (at your option) any later version.
011:         * 
012:         * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
013:         * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014:         * GNU General Public License for more details.
015:         * 
016:         * You should have received a copy of the GNU General Public License along with this program; if not,
017:         * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 
018:         */
019:        package wilos.business.services.misc.project;
020:
021:        import java.util.ArrayList;
022:        import java.util.Arrays;
023:        import java.util.Comparator;
024:        import java.util.HashMap;
025:        import java.util.HashSet;
026:        import java.util.List;
027:        import java.util.Set;
028:
029:        import org.apache.commons.logging.Log;
030:        import org.apache.commons.logging.LogFactory;
031:        import org.springframework.transaction.annotation.Propagation;
032:        import org.springframework.transaction.annotation.Transactional;
033:
034:        import wilos.business.services.misc.concreteactivity.ConcreteActivityService;
035:        import wilos.business.services.misc.concreteworkbreakdownelement.ConcreteWorkBreakdownElementService;
036:        import wilos.business.services.misc.stateservice.StateService;
037:        import wilos.business.services.spem2.process.ProcessService;
038:        import wilos.hibernate.misc.concreteactivity.ConcreteActivityDao;
039:        import wilos.hibernate.misc.concreterole.ConcreteRoleDescriptorDao;
040:        import wilos.hibernate.misc.concretetask.ConcreteTaskDescriptorDao;
041:        import wilos.hibernate.misc.project.ProjectDao;
042:        import wilos.hibernate.misc.wilosuser.ParticipantDao;
043:        import wilos.hibernate.spem2.activity.ActivityDao;
044:        import wilos.hibernate.spem2.role.RoleDescriptorDao;
045:        import wilos.hibernate.spem2.task.TaskDescriptorDao;
046:        import wilos.model.misc.concreteactivity.ConcreteActivity;
047:        import wilos.model.misc.concretebreakdownelement.ConcreteBreakdownElement;
048:        import wilos.model.misc.concretemilestone.ConcreteMilestone;
049:        import wilos.model.misc.concreterole.ConcreteRoleDescriptor;
050:        import wilos.model.misc.concretetask.ConcreteTaskDescriptor;
051:        import wilos.model.misc.concreteworkproduct.ConcreteWorkProductDescriptor;
052:        import wilos.model.misc.project.Project;
053:        import wilos.model.misc.wilosuser.Participant;
054:        import wilos.model.spem2.activity.Activity;
055:        import wilos.model.spem2.breakdownelement.BreakdownElement;
056:        import wilos.model.spem2.process.Process;
057:        import wilos.model.spem2.role.RoleDescriptor;
058:        import wilos.model.spem2.task.TaskDescriptor;
059:        import wilos.model.spem2.workproduct.WorkProductDescriptor;
060:        import wilos.presentation.web.utils.WebSessionService;
061:        import wilos.utils.Constantes.State;
062:
063:        /**
064:         * The services associated to the Project
065:         * 
066:         */
067:        @Transactional(readOnly=false,propagation=Propagation.REQUIRED)
068:        public class ProjectService {
069:
070:            private ProjectDao projectDao;
071:
072:            private ParticipantDao participantDao;
073:
074:            private ActivityDao activityDao;
075:
076:            private StateService stateService;
077:
078:            private ConcreteWorkBreakdownElementService concreteWorkBreakdownElementService;
079:
080:            private ConcreteActivityDao concreteActivityDao;
081:
082:            private ConcreteActivityService concreteActivityService;
083:
084:            private ConcreteTaskDescriptorDao concreteTaskDescriptorDao;
085:
086:            private ConcreteRoleDescriptorDao concreteRoleDescriptorDao;
087:
088:            private TaskDescriptorDao taskDescriptorDao;
089:
090:            private RoleDescriptorDao roleDescriptorDao;
091:
092:            private ProcessService processService;
093:
094:            public final Log logger = LogFactory.getLog(this .getClass());
095:
096:            private Project[] projects;
097:
098:            /**
099:             * Allows to create a taskDescriptor
100:             * 
101:             * @param _presentationName
102:             * @param _description
103:             * @param _mainRole
104:             * @param _guid
105:             * @return the taskDescriptor if it's created, null in the other case
106:             */
107:            public TaskDescriptor createTaskDescriptor(
108:                    String _presentationName, String _description,
109:                    RoleDescriptor _mainRole, String _guid) {
110:                TaskDescriptor taskDesc = new TaskDescriptor();
111:                taskDesc.setPresentationName(_presentationName);
112:                taskDesc.setDescription(_description);
113:                taskDesc.setGuid(_guid);
114:                taskDesc.setPrefix("");
115:                taskDesc.setIsPlanned(true);
116:                taskDesc.setHasMultipleOccurrences(false);
117:                taskDesc.setIsOptional(false);
118:                taskDesc.setIsRepeatable(true);
119:                taskDesc.setIsOngoing(false);
120:                taskDesc.setIsEvenDriven(false);
121:                _mainRole.addPrimaryTask(taskDesc);
122:
123:                this .taskDescriptorDao.saveOrUpdateTaskDescriptor(taskDesc);
124:                System.out.println("### TaskDescriptor sauve");
125:                if (taskDesc.getId() != null)
126:                    return taskDesc;
127:                else
128:                    return null;
129:            }
130:
131:            /**
132:             * Allows to create a concreteTaskDescriptor
133:             * 
134:             * @param _concreteName
135:             * @param _project
136:             * @param _td
137:             * @param _cact
138:             * @return true if the concreteTaskDescriptor is created, false in the other
139:             *         case
140:             */
141:            public boolean createConcreteTaskDescriptor(String _concreteName,
142:                    Project _project, TaskDescriptor _td, ConcreteActivity _cact) {
143:                ConcreteTaskDescriptor concTaskDesc = new ConcreteTaskDescriptor();
144:
145:                // this variable is used to generate a random number for the
146:                // instanciationOrder in order to correct the tree problem
147:                int i = Math.abs((int) System.currentTimeMillis());
148:
149:                concTaskDesc.setConcreteName(_concreteName);
150:                concTaskDesc.setProject(_project);
151:                concTaskDesc.setInstanciationOrder(i);
152:                concTaskDesc.addSuperConcreteActivity(_cact);
153:
154:                concTaskDesc.setTaskDescriptor(_td);
155:                concTaskDesc.setBreakdownElement(_td);
156:                concTaskDesc.setWorkBreakdownElement(_td);
157:
158:                this .concreteTaskDescriptorDao
159:                        .saveOrUpdateConcreteTaskDescriptor(concTaskDesc);
160:                System.out.println("### ConcreteTaskDescriptor sauve");
161:                this .concreteActivityDao.saveOrUpdateConcreteActivity(_cact);
162:                System.out.println("### ConcreteActivity sauve");
163:
164:                return (concTaskDesc.getId() != null);
165:
166:            }
167:
168:            /**
169:             * Allows to create a task
170:             * 
171:             * @param _taskName
172:             * @param _taskDescription
173:             * @param _project
174:             * @param _role
175:             * @param _cact
176:             * @param recursive
177:             * @return true if the task is created, false in the other case
178:             */
179:            public boolean createTask(String _taskName,
180:                    String _taskDescription, Project _project,
181:                    RoleDescriptor _role, ConcreteActivity _cact,
182:                    boolean recursive) {
183:
184:                this .roleDescriptorDao.getSessionFactory().getCurrentSession()
185:                        .saveOrUpdate(_role);
186:                this .concreteActivityDao.getSessionFactory()
187:                        .getCurrentSession().saveOrUpdate(_cact);
188:                this .concreteActivityDao.getSessionFactory()
189:                        .getCurrentSession().saveOrUpdate(_project);
190:
191:                TaskDescriptor td = this .createTaskDescriptor(_taskName,
192:                        _taskDescription, _role, _taskName);
193:
194:                if (td == null) {
195:                    return false;
196:                }
197:
198:                if (recursive) {
199:                    for (ConcreteBreakdownElement cbe : _cact
200:                            .getConcreteBreakdownElements()) {
201:                        if (cbe instanceof  ConcreteActivity) {
202:                            if (!(this .createConcreteTaskDescriptor(_taskName,
203:                                    _project, td, (ConcreteActivity) cbe)))
204:                                return false;
205:                        }
206:                    }
207:                }
208:                if (!(this .createConcreteTaskDescriptor(_taskName, _project,
209:                        td, _cact)))
210:                    return false;
211:                else
212:                    return true;
213:            }
214:
215:            /**
216:             * Save processManager
217:             * 
218:             * @param _processmanager
219:             */
220:            public void saveProject(Project _project) {
221:                this .projectDao.saveOrUpdateProject(_project);
222:            }
223:
224:            /**
225:             * Delete a participant
226:             * 
227:             * @param participantId
228:             */
229:            public boolean deleteProject(String projectId) {
230:                boolean ok = false;
231:                Project project = this .getProject(projectId);
232:                if (project.getProcess() == null
233:                        && project.getParticipants().size() == 0
234:                        && project.getProjectManager() == null) {
235:                    this .projectDao.deleteProject(project);
236:                    ok = true;
237:                }
238:                return ok;
239:
240:            }
241:
242:            /**
243:             * Check if the project already exist
244:             * 
245:             * @param _projectName
246:             * @return True is the _projectName is already present
247:             */
248:            public boolean projectExist(String _projectName) {
249:                boolean found = false;
250:                String projectName;
251:                List<Project> projects = this .projectDao.getAllProjects();
252:                for (Project project : projects) {
253:                    projectName = project.getConcreteName().toUpperCase();
254:                    if (projectName.equals(_projectName.toUpperCase())) {
255:                        return true;
256:                    }
257:                }
258:                return found;
259:            }
260:
261:            /**
262:             * Gets the sorted project data.
263:             * 
264:             * @return table of sorted project data
265:             */
266:            public List<Project> getAllSortedProjects() {
267:                List<Project> projectList = new ArrayList<Project>();
268:                projectList = this .projectDao.getAllProjects();
269:                projects = projectList.toArray(new Project[projectList.size()]);
270:                sortProject();
271:                return Arrays.asList(projects);
272:            }
273:
274:            /**
275:             * Sorts the list of project data.
276:             */
277:            @SuppressWarnings("unchecked")
278:            protected void sortProject() {
279:                Comparator comparator = new Comparator() {
280:                    public int compare(Object o1, Object o2) {
281:                        Project p1 = (Project) o1;
282:                        Project p2 = (Project) o2;
283:                        return p1.getConcreteName().compareTo(
284:                                p2.getConcreteName());
285:                    }
286:                };
287:                Arrays.sort(projects, comparator);
288:            }
289:
290:            // =================================== getters & setters
291:            // ========================================
292:
293:            /**
294:             * This method returns the list of the projects that aren't yet finished
295:             * 
296:             * @return a set of Projects
297:             */
298:            public Set<Project> getUnfinishedProjects() {
299:                Set<Project> unfinishedP = new HashSet<Project>();
300:                List<Project> projects = this .projectDao.getAllProjects();
301:
302:                for (Project project : projects) {
303:                    if (!(project.getIsFinished())) {
304:                        unfinishedP.add(project);
305:                    }
306:                }
307:                return unfinishedP;
308:            }
309:
310:            /**
311:             * Allows to get the set of concreteBreakdownElements for a project
312:             * 
313:             * @param project
314:             * @return the set of concreteBreakdownElements
315:             */
316:            public Set<ConcreteBreakdownElement> getConcreteBreakdownElementsFromProject(
317:                    Project _project) {
318:                Set<ConcreteBreakdownElement> tmp = new HashSet<ConcreteBreakdownElement>();
319:
320:                this .getProjectDao().getSessionFactory().getCurrentSession()
321:                        .saveOrUpdate(_project);
322:                this .getProjectDao().getSessionFactory().getCurrentSession()
323:                        .refresh(_project);
324:
325:                for (ConcreteBreakdownElement element : _project
326:                        .getConcreteBreakdownElements()) {
327:                    tmp.add(element);
328:                }
329:                return tmp;
330:            }
331:
332:            /**
333:             * Allows to get the set of concreteRoleDescriptors from a project for a
334:             * concreteActivity
335:             * 
336:             * @param _project
337:             * @return the set of concreteRoleDescriptors
338:             */
339:            public Set<ConcreteRoleDescriptor> getConcreteRoleDescriptorsFromProject(
340:                    ConcreteActivity _cact) {
341:                Set<ConcreteRoleDescriptor> tmp = new HashSet<ConcreteRoleDescriptor>();
342:
343:                this .activityDao.getSessionFactory().getCurrentSession()
344:                        .saveOrUpdate(_cact);
345:                for (ConcreteBreakdownElement element : _cact
346:                        .getConcreteBreakdownElements()) {
347:                    if (element instanceof  ConcreteRoleDescriptor) {
348:                        ConcreteRoleDescriptor crd = (ConcreteRoleDescriptor) element;
349:                        tmp.add(crd);
350:                    } else if (!(element instanceof  ConcreteTaskDescriptor)
351:                            && !(element instanceof  ConcreteWorkProductDescriptor)
352:                            && !(element instanceof  ConcreteMilestone)) {
353:                        ConcreteActivity cact = (ConcreteActivity) element;
354:                        tmp.addAll(this 
355:                                .getConcreteRoleDescriptorsFromProject(cact));
356:                    }
357:                }
358:                return tmp;
359:            }
360:
361:            /**
362:             * Getter of projectDao.
363:             * 
364:             * @return the projectDao.
365:             */
366:            public ProjectDao getProjectDao() {
367:                return this .projectDao;
368:            }
369:
370:            /**
371:             * Setter of projectDao.
372:             * 
373:             * @param _projectDao
374:             *            The projectDao to set.
375:             */
376:            public void setProjectDao(ProjectDao _projectDao) {
377:                this .projectDao = _projectDao;
378:            }
379:
380:            /**
381:             * This method returns all the projects.
382:             * 
383:             * @return A set of Project
384:             */
385:            public List<Project> getAllProjects() {
386:                List<Project> projectList = new ArrayList<Project>();
387:                projectList = this .projectDao.getAllProjects();
388:                return projectList;
389:            }
390:
391:            /**
392:             * This method returns all the projects with no process.
393:             * 
394:             * @return A set of Project
395:             */
396:            public Set<Project> getAllProjectsWithNoProcess() {
397:                Set<Project> projectList = new HashSet<Project>();
398:                List<Project> tmpList = new ArrayList<Project>();
399:                tmpList = this .projectDao.getAllProjects();
400:                for (Project project : tmpList) {
401:                    if (project.getProcess() == null)
402:                        projectList.add(project);
403:                }
404:                return projectList;
405:            }
406:
407:            /**
408:             * Returns the projects that aren't associated to a process.
409:             * 
410:             * @return A set of Project
411:             */
412:            public Set<Project> getAllProjectsWithProcess() {
413:                Set<Project> projectList = new HashSet<Project>();
414:                List<Project> tmpList = new ArrayList<Project>();
415:                tmpList = this .projectDao.getAllProjects();
416:                for (Project project : tmpList) {
417:                    if (project.getProcess() != null)
418:                        projectList.add(project);
419:                }
420:                return projectList;
421:            }
422:
423:            /**
424:             * 
425:             * Getter of project
426:             * 
427:             * @param _id
428:             * @return the project
429:             */
430:            public Project getProject(String _id) {
431:                return this .projectDao.getProject(_id);
432:            }
433:
434:            /*
435:             * public String getProjectName(String _projectId) { return
436:             * this.projectDao.getProjectName(_projectId); }
437:             */
438:
439:            /**
440:             * Getter of participantDao.
441:             * 
442:             * @return the participantDao.
443:             */
444:            public ParticipantDao getParticipantDao() {
445:                return this .participantDao;
446:            }
447:
448:            /**
449:             * 
450:             * Getter of processService
451:             * 
452:             * @return processService
453:             */
454:            public ProcessService getProcessService() {
455:                return this .processService;
456:            }
457:
458:            /**
459:             * 
460:             * Setter of processService
461:             * 
462:             * @param _processService
463:             */
464:            public void setProcessService(ProcessService _processService) {
465:                this .processService = _processService;
466:            }
467:
468:            /**
469:             * Setter of participantDao.
470:             * 
471:             * @param _participantDao
472:             *            The participantDao to set.
473:             */
474:            public void setParticipantDao(ParticipantDao _participantDao) {
475:                this .participantDao = _participantDao;
476:            }
477:
478:            /**
479:             * 
480:             * Return the participants affected to the project
481:             * 
482:             * @param project
483:             * @return the set of participants affected to the project parameter
484:             */
485:            public Set<Participant> getAllParticipants(Project project) {
486:                return project.getParticipants();
487:            }
488:
489:            /**
490:             * Allows to get the process for a project
491:             * 
492:             * @param _project
493:             * @return the process
494:             */
495:            public Process getProcessFromProject(Project _project) {
496:                this .projectDao.getSessionFactory().getCurrentSession()
497:                        .saveOrUpdate(_project);
498:                return _project.getProcess();
499:            }
500:
501:            /**
502:             * Allows to get all projects
503:             * 
504:             * @return projects
505:             */
506:            public Project[] getProjects() {
507:                return projects;
508:            }
509:
510:            /**
511:             * Allows to set a list of projects
512:             * 
513:             * @param projects
514:             */
515:            public void setProjects(Project[] projects) {
516:                this .projects = projects;
517:            }
518:
519:            /**
520:             * Allows to get the activityDao
521:             * 
522:             * @return the activityDao
523:             */
524:            public ActivityDao getActivityDao() {
525:                return this .activityDao;
526:            }
527:
528:            /**
529:             * Allows to set the activityDao
530:             * 
531:             * @param _activityDao
532:             */
533:            public void setActivityDao(ActivityDao _activityDao) {
534:                this .activityDao = _activityDao;
535:            }
536:
537:            /**
538:             * Allows to get the list of different paths of a roleDescriptor in process
539:             * 
540:             * @param _process
541:             * @param _roleName
542:             * @return the list of different paths
543:             */
544:            public List<HashMap<String, Object>> getDifferentPathsOfRoleDescriptorInProcess(
545:                    Process _process, String _roleName) {
546:                this .processService.getProcessDao().getSessionFactory()
547:                        .getCurrentSession().saveOrUpdate(_process);
548:
549:                Project project = this .getProject((String) WebSessionService
550:                        .getAttribute(WebSessionService.PROJECT_ID));
551:
552:                List<HashMap<String, Object>> lines = new ArrayList<HashMap<String, Object>>();
553:                String path = _process.getPresentationName();
554:
555:                return this .giveRoleDescriptorsPathName(project, _process,
556:                        path, _roleName, lines);
557:            }
558:
559:            /**
560:             * Allows to give the list of roleDescriptors path name
561:             * 
562:             * @param _process
563:             * @param path
564:             * @return the list of roleDescriptors path name
565:             */
566:            private List<HashMap<String, Object>> giveRoleDescriptorsPathName(
567:                    Project _project, Activity _act, String path,
568:                    String _roleName, List<HashMap<String, Object>> lines) {
569:
570:                final String TABLE_LEAF = "images/expandableTable/leaf.gif";
571:
572:                for (BreakdownElement bde : _act.getBreakdownElements()) {
573:                    if (bde instanceof  RoleDescriptor) {
574:                        if (bde.getPresentationName().equals(_roleName)) {
575:                            path += " / " + bde.getPresentationName();
576:
577:                            HashMap<String, Object> hm = new HashMap<String, Object>();
578:                            hm.put("nodeType", "leaf");
579:                            hm.put("expansionImage", TABLE_LEAF);
580:                            hm.put("id", bde.getId());
581:                            hm.put("name", path);
582:                            int nbcrd = this 
583:                                    .getConcreteRoleDescriptorsFromProject(
584:                                            _project).size();
585:                            if (nbcrd > 0) {
586:                                hm.put("nbOccurences", new Integer(0));
587:                            } else {
588:                                hm.put("nbOccurences", new Integer(1));
589:                            }
590:                            hm.put("parentId", _roleName);
591:                            lines.add(hm);
592:                        }
593:                    } else if ((bde instanceof  Activity)) {
594:                        Activity act = (Activity) bde;
595:                        String newPath = path + " / "
596:                                + act.getPresentationName();
597:                        lines = this .giveRoleDescriptorsPathName(_project, act,
598:                                newPath, _roleName, lines);
599:                    }
600:                }
601:                return lines;
602:            }
603:
604:            /**
605:             * Allows to get the concreteActivityDao
606:             * 
607:             * @return the concreteActivityDao
608:             */
609:            public ConcreteActivityDao getConcreteActivityDao() {
610:                return concreteActivityDao;
611:            }
612:
613:            /**
614:             * Allows to set the concreteActivityDao
615:             * 
616:             * @param _concreteActivityDao
617:             */
618:            public void setConcreteActivityDao(
619:                    ConcreteActivityDao _concreteActivityDao) {
620:                concreteActivityDao = _concreteActivityDao;
621:            }
622:
623:            /**
624:             * Allows to get the concreteTaskDescriptorDao
625:             * 
626:             * @return the concreteTaskDescriptorDao
627:             */
628:            public ConcreteTaskDescriptorDao getConcreteTaskDescriptorDao() {
629:                return concreteTaskDescriptorDao;
630:            }
631:
632:            /**
633:             * Allows to set the concreteTaskDescriptorDao
634:             * 
635:             * @param _concreteTaskDescriptorDao
636:             */
637:            public void setConcreteTaskDescriptorDao(
638:                    ConcreteTaskDescriptorDao _concreteTaskDescriptorDao) {
639:                concreteTaskDescriptorDao = _concreteTaskDescriptorDao;
640:            }
641:
642:            /**
643:             * Allows to get the set of concreteWorkProductDescriptors from a project
644:             * for a concreteActivity
645:             * 
646:             * @param _cact
647:             * @return the set of concreteWorkProductDescriptors
648:             */
649:            public Set<ConcreteWorkProductDescriptor> getConcreteWorkProductDescriptorsFromProject(
650:                    ConcreteActivity _cact) {
651:
652:                Set<ConcreteWorkProductDescriptor> tmp = new HashSet<ConcreteWorkProductDescriptor>();
653:
654:                this .activityDao.getSessionFactory().getCurrentSession()
655:                        .saveOrUpdate(_cact);
656:                for (ConcreteBreakdownElement element : _cact
657:                        .getConcreteBreakdownElements()) {
658:                    if (element instanceof  ConcreteWorkProductDescriptor) {
659:
660:                        ConcreteWorkProductDescriptor cwpd = (ConcreteWorkProductDescriptor) element;
661:                        tmp.add(cwpd);
662:                    } else if (!(element instanceof  ConcreteTaskDescriptor)
663:                            && !(element instanceof  ConcreteRoleDescriptor)
664:                            && !(element instanceof  ConcreteMilestone)) {
665:                        ConcreteActivity cact = (ConcreteActivity) element;
666:                        tmp
667:                                .addAll(this 
668:                                        .getConcreteWorkProductDescriptorsFromProject(cact));
669:                    }
670:                }
671:                return tmp;
672:            }
673:
674:            /**
675:             * Allows to get the list of different paths of a workProductDescriptor in
676:             * process
677:             * 
678:             * @param _process
679:             * @param _workProductName
680:             * @return the list of different paths
681:             */
682:            public List<HashMap<String, Object>> getDifferentPathsOfWorkProductDescriptorInProcess(
683:                    Process _process, String _workProductName) {
684:                this .processService.getProcessDao().getSessionFactory()
685:                        .getCurrentSession().saveOrUpdate(_process);
686:
687:                Project project = this .getProject((String) WebSessionService
688:                        .getAttribute(WebSessionService.PROJECT_ID));
689:
690:                List<HashMap<String, Object>> lines = new ArrayList<HashMap<String, Object>>();
691:                String path = _process.getPresentationName();
692:
693:                return this .giveWorkProductDescriptorsPathName(project,
694:                        _process, path, _workProductName, lines);
695:            }
696:
697:            /**
698:             * Allows to get the list of workProductDescriptors path name
699:             * 
700:             * @param _project
701:             * @param _act
702:             * @param _path
703:             * @param _workProductName
704:             * @param _lines
705:             * @return the list of workProductDescriptors path name
706:             */
707:            private List<HashMap<String, Object>> giveWorkProductDescriptorsPathName(
708:                    Project _project, Activity _act, String _path,
709:                    String _workProductName,
710:                    List<HashMap<String, Object>> _lines) {
711:
712:                final String TABLE_LEAF = "images/expandableTable/leaf.gif";
713:
714:                for (BreakdownElement bde : _act.getBreakdownElements()) {
715:                    if (bde instanceof  WorkProductDescriptor) {
716:                        if (bde.getPresentationName().equals(_workProductName)) {
717:                            _path += " / " + bde.getPresentationName();
718:
719:                            HashMap<String, Object> hm = new HashMap<String, Object>();
720:                            hm.put("nodeType", "leaf");
721:                            hm.put("expansionImage", TABLE_LEAF);
722:                            hm.put("id", bde.getId());
723:                            hm.put("name", _path);
724:                            int nbcwpd = this 
725:                                    .getConcreteWorkProductDescriptorsFromProject(
726:                                            _project).size();
727:                            if (nbcwpd > 0) {
728:                                hm.put("nbOccurences", new Integer(0));
729:                            } else {
730:                                hm.put("nbOccurences", new Integer(1));
731:                            }
732:                            hm.put("parentId", _workProductName);
733:                            _lines.add(hm);
734:                        }
735:                    } else if ((bde instanceof  Activity)) {
736:                        Activity act = (Activity) bde;
737:                        String newPath = _path + " / "
738:                                + act.getPresentationName();
739:                        _lines = this .giveWorkProductDescriptorsPathName(
740:                                _project, act, newPath, _workProductName,
741:                                _lines);
742:                    }
743:                }
744:                return _lines;
745:            }
746:
747:            /**
748:             * Allows to update the concreteActivity's state for a project
749:             * 
750:             * @param _project
751:             */
752:            public void updateConcreteActivitiesStateFromProject(
753:                    Project _project) {
754:                this .projectDao.getSessionFactory().getCurrentSession()
755:                        .saveOrUpdate(_project);
756:                this .projectDao.getSessionFactory().getCurrentSession()
757:                        .refresh(_project);
758:                this .stateService.updateStateTo(_project, State.READY);
759:            }
760:
761:            /**
762:             * Allows to get the concreteActivityService
763:             * 
764:             * @return the concreteActivityService
765:             */
766:            public ConcreteActivityService getConcreteActivityService() {
767:                return concreteActivityService;
768:            }
769:
770:            /**
771:             * Allows to set the concreteActivityService
772:             * 
773:             * @param _concreteActivityService
774:             */
775:            public void setConcreteActivityService(
776:                    ConcreteActivityService _concreteActivityService) {
777:                concreteActivityService = _concreteActivityService;
778:            }
779:
780:            /**
781:             * Allows to get the concreteRoleDescriptorDao
782:             * 
783:             * @return the concreteRoleDescriptorDao
784:             */
785:            public ConcreteRoleDescriptorDao getConcreteRoleDescriptorDao() {
786:                return concreteRoleDescriptorDao;
787:            }
788:
789:            /**
790:             * Allows to set the concreteRoleDescriptorDao
791:             * 
792:             * @param concreteRoleDescriptorDao
793:             */
794:            public void setConcreteRoleDescriptorDao(
795:                    ConcreteRoleDescriptorDao concreteRoleDescriptorDao) {
796:                this .concreteRoleDescriptorDao = concreteRoleDescriptorDao;
797:            }
798:
799:            /**
800:             * Allows to get the taskDescriptorDao
801:             * 
802:             * @return the taskDescriptorDao
803:             */
804:            public TaskDescriptorDao getTaskDescriptorDao() {
805:                return taskDescriptorDao;
806:            }
807:
808:            /**
809:             * Allows to set the taskDescriptorDao
810:             * 
811:             * @param taskDescriptorDao
812:             */
813:            public void setTaskDescriptorDao(TaskDescriptorDao taskDescriptorDao) {
814:                this .taskDescriptorDao = taskDescriptorDao;
815:            }
816:
817:            /**
818:             * Allows to get the roleDescriptorDao
819:             * 
820:             * @return the roleDescriptorDao
821:             */
822:            public RoleDescriptorDao getRoleDescriptorDao() {
823:                return roleDescriptorDao;
824:            }
825:
826:            /**
827:             * Allows to set the roleDescriptorDao
828:             * 
829:             * @param roleDescriptorDao
830:             */
831:            public void setRoleDescriptorDao(RoleDescriptorDao roleDescriptorDao) {
832:                this .roleDescriptorDao = roleDescriptorDao;
833:            }
834:
835:            /**
836:             * Allows to create a role
837:             * 
838:             * @param _roleName
839:             * @param _roleDescription
840:             * @param _project
841:             * @param _task
842:             * @param _cact
843:             * @return true if the role is created, false in the other case
844:             */
845:            public boolean createRole(String _roleName,
846:                    String _roleDescription, Project _project,
847:                    TaskDescriptor _task, ConcreteActivity _cact) {
848:                if (_task != null) {
849:                    this .taskDescriptorDao.getSessionFactory()
850:                            .getCurrentSession().saveOrUpdate(_task);
851:                }
852:                this .concreteActivityDao.getSessionFactory()
853:                        .getCurrentSession().saveOrUpdate(_cact);
854:
855:                // create role descriptor
856:                RoleDescriptor rd = this .createRoleDescriptor(_roleName,
857:                        _roleDescription, _task, _roleName);
858:
859:                if (rd == null) {
860:                    return false;
861:                }
862:
863:                // create BreakDownElement
864:
865:                for (ConcreteBreakdownElement cbe : _cact
866:                        .getConcreteBreakdownElements()) {
867:                    if (cbe instanceof  ConcreteActivity) {
868:                        if (!(this .createConcreteRoleDescriptor(_roleName,
869:                                _project, rd, (ConcreteActivity) cbe)))
870:                            return false;
871:                    }
872:                }
873:
874:                if (!(this .createConcreteRoleDescriptor(_roleName, _project,
875:                        rd, _cact)))
876:                    return false;
877:                else
878:                    return true;
879:            }
880:
881:            /**
882:             * Allows to create a roleDescriptor
883:             * 
884:             * @param _presentationName
885:             * @param _description
886:             * @param _mainTask
887:             * @param _guid
888:             * @return the roleDescriptor created, null in the other case
889:             */
890:            public RoleDescriptor createRoleDescriptor(
891:                    String _presentationName, String _description,
892:                    TaskDescriptor _mainTask, String _guid) {
893:
894:                RoleDescriptor roleDesc = new RoleDescriptor();
895:                roleDesc.setIsOutOfProcess(true);
896:                roleDesc.setPresentationName(_presentationName);
897:                roleDesc.setDescription(_description);
898:                roleDesc.setGuid(_guid);
899:                roleDesc.setPrefix("");
900:                roleDesc.setIsPlanned(true);
901:                roleDesc.setHasMultipleOccurrences(false);
902:                roleDesc.setIsOptional(false);
903:
904:                if (_mainTask != null) {
905:                    _mainTask.addMainRole(roleDesc);
906:                }
907:
908:                this .roleDescriptorDao.saveOrUpdateRoleDescriptor(roleDesc);
909:
910:                System.out
911:                        .println("\n*********\nRoleDescriptor sauve\n***********\n");
912:
913:                if (roleDesc.getId() != null)
914:                    return roleDesc;
915:                else
916:                    return null;
917:            }
918:
919:            /**
920:             * Allows to create a concreteRoleDescriptor
921:             * 
922:             * @param _concreteName
923:             * @param _project
924:             * @param _rd
925:             * @param _cact
926:             * @return true if the concreteRoleDescriptor is created, false in the other
927:             *         case
928:             */
929:            public boolean createConcreteRoleDescriptor(String _concreteName,
930:                    Project _project, RoleDescriptor _rd, ConcreteActivity _cact) {
931:                ConcreteRoleDescriptor concRoleDesc = new ConcreteRoleDescriptor();
932:
933:                concRoleDesc.setConcreteName(_concreteName);
934:                concRoleDesc.setProject(_project);
935:                concRoleDesc.setInstanciationOrder(1);
936:                concRoleDesc.addSuperConcreteActivity(_cact);
937:
938:                concRoleDesc.setRoleDescriptor(_rd);
939:                concRoleDesc.setBreakdownElement(_rd);
940:
941:                this .concreteRoleDescriptorDao
942:                        .saveOrUpdateConcreteRoleDescriptor(concRoleDesc);
943:
944:                return (concRoleDesc.getId() != null);
945:
946:            }
947:
948:            /**
949:             * Allows to get the concreteWorkBreakdownElementService
950:             * 
951:             * @return the concreteWorkBreakdownElementService
952:             */
953:            public ConcreteWorkBreakdownElementService getConcreteWorkBreakdownElementService() {
954:                return this .concreteWorkBreakdownElementService;
955:            }
956:
957:            /**
958:             * Allows to set the concreteWorkBreakdownElementService
959:             * 
960:             * @param _concreteWorkBreakdownElementService
961:             */
962:            public void setConcreteWorkBreakdownElementService(
963:                    ConcreteWorkBreakdownElementService _concreteWorkBreakdownElementService) {
964:                this .concreteWorkBreakdownElementService = _concreteWorkBreakdownElementService;
965:            }
966:
967:            /**
968:             * Allows to get the service's state
969:             * 
970:             * @return the stateService
971:             */
972:            public StateService getStateService() {
973:                return this .stateService;
974:            }
975:
976:            /**
977:             * Allows to set the service's state
978:             * 
979:             * @param _stateService
980:             */
981:            public void setStateService(StateService _stateService) {
982:                this.stateService = _stateService;
983:            }
984:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.