Source Code Cross Referenced for ProcessBean.java in  » Workflow-Engines » wilos » wilos » presentation » web » process » 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.presentation.web.process 
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-2008 Paul Sabatier University, IUP ISI (Toulouse, France) <massie@irit.fr>
005:         * 
006:         * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
007:         * General Public License as published by the Free Software Foundation; either version 2 of the License,
008:         * or (at your option) any later version.
009:         *
010:         * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
011:         * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012:         * GNU General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU General Public License along with this program; if not,
015:         * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 
016:         */
017:
018:        package wilos.presentation.web.process;
019:
020:        import java.util.ArrayList;
021:        import java.util.HashMap;
022:        import java.util.List;
023:        import java.util.Map;
024:
025:        import javax.faces.context.FacesContext;
026:        import javax.faces.event.ActionEvent;
027:        import javax.faces.event.ValueChangeEvent;
028:        import javax.faces.model.SelectItem;
029:
030:        import org.apache.commons.logging.Log;
031:        import org.apache.commons.logging.LogFactory;
032:
033:        import wilos.business.services.misc.project.ProjectService;
034:        import wilos.business.services.misc.wilosuser.ProcessManagerService;
035:        import wilos.business.services.spem2.process.ProcessManagementService;
036:        import wilos.business.services.spem2.process.ProcessService;
037:        import wilos.model.misc.project.Project;
038:        import wilos.model.spem2.process.Process;
039:        import wilos.presentation.web.expandabletable.RolesExpTableBean;
040:        import wilos.presentation.web.expandabletable.TasksExpTableBean;
041:        import wilos.presentation.web.expandabletable.WorkProductsExpTableBean;
042:        import wilos.presentation.web.utils.WebCommonService;
043:        import wilos.presentation.web.utils.WebSessionService;
044:        import wilos.resources.WilosBundle;
045:
046:        public class ProcessBean {
047:
048:            private ProcessService processService;
049:
050:            private ProjectService projectService;
051:
052:            private ProcessManagerService processManagerService;
053:
054:            private List<HashMap<String, Object>> processesList;
055:
056:            private String processesListView;
057:
058:            private static final String VIEW_NULL = "processesManagement_null";
059:
060:            private static final String VIEW_NOT_NULL = "processesManagementPanelGroup_not_null";
061:
062:            protected final Log logger = LogFactory.getLog(this .getClass());
063:
064:            private ProcessManagementService processManagementService;
065:
066:            private boolean visiblePopup = false;
067:
068:            private String processId;
069:
070:            /* fields for ExpandableTable management */
071:
072:            private Project project;
073:
074:            private String selectedProcessId = "default";
075:
076:            private boolean instanciateDependenciesWithProcess = false;
077:
078:            private boolean readOnly = false;
079:
080:            private boolean isVisibleExpTable = false;
081:
082:            private boolean isProjectManager = false;
083:
084:            /* field for dependencies view management */
085:
086:            // TODO utile ?
087:            private String instanciationDependenciesView = "view_instanciation_panelGroup";
088:
089:            /* Manage the popup. */
090:
091:            /**
092:             * This method allow to print the right message 
093:             * when an user want to delete the selected process 
094:             * 
095:             * @param event
096:             */
097:            public void confirmDelete(ActionEvent event) {
098:                if (this .processManagementService
099:                        .hasBeenInstanciated(this .processId)) {
100:                    WebCommonService
101:                            .addErrorMessage(WilosBundle
102:                                    .getText("component.process.management.deletionforbidden"));
103:                } else {
104:                    this .processManagementService.removeProcess(this .processId);
105:                    WebCommonService
106:                            .addErrorMessage(WilosBundle
107:                                    .getText("component.process.management.deletiondone"));
108:                }
109:
110:                this .visiblePopup = false;
111:            }
112:
113:            /**
114:             * This method fixed the visiblePopup boolean attribute 
115:             * to false
116:             * 
117:             * @param event
118:             */
119:            public void cancelDelete(ActionEvent event) {
120:                this .visiblePopup = false;
121:            }
122:
123:            /* Others for Process management */
124:
125:            /**
126:             * 
127:             * Deletes selected process from the database
128:             * 
129:             * @param e
130:             *                event received when a user clicks on suppress button in
131:             *                the datatable
132:             */
133:            public void deleteProcess(ActionEvent e) {
134:                FacesContext context = FacesContext.getCurrentInstance();
135:                Map map = context.getExternalContext().getRequestParameterMap();
136:                this .processId = (String) map.get("processId");
137:
138:                this .visiblePopup = true;
139:            }
140:
141:            /**
142:             * Getter of processesList.
143:             * 
144:             * @return the processesList.
145:             */
146:            public List<HashMap<String, Object>> getProcessesList() {
147:                if (this .processesList == null
148:                        || this .processesList.size() != this .processService
149:                                .getAllProcesses().size()) {
150:
151:                    this .processesList = new ArrayList<HashMap<String, Object>>();
152:                    for (Process process : this .processService
153:                            .getAllProcesses()) {
154:                        HashMap<String, Object> processDescription = new HashMap<String, Object>();
155:                        processDescription.put("presentationName", process
156:                                .getPresentationName());
157:                        processDescription.put("id", process.getId());
158:                        processDescription
159:                                .put("isEditable", new Boolean(false));
160:
161:                        if (process.getProcessManager() != null) {
162:                            process
163:                                    .setProcessManager(this .processManagerService
164:                                            .getProcessManager(process
165:                                                    .getProcessManager()
166:                                                    .getId()));
167:                            processDescription.put("owner", process
168:                                    .getProcessManager().getFirstname()
169:                                    + " "
170:                                    + process.getProcessManager().getName());
171:                        }
172:
173:                        this .processesList.add(processDescription);
174:                    }
175:                    return this .processesList;
176:                }
177:                return this .processesList;
178:            }
179:
180:            /**
181:             * 
182:             * Editing process name
183:             * 
184:             * @param e
185:             *                event received when a user clicks on edit button in the
186:             *                datatable
187:             */
188:            public void editName(ActionEvent e) {
189:                String processId = (String) FacesContext.getCurrentInstance()
190:                        .getExternalContext().getRequestParameterMap().get(
191:                                "processEditId");
192:                for (HashMap<String, Object> processDescription : this .processesList) {
193:                    if (((String) processDescription.get("id"))
194:                            .equals(processId)) {
195:                        processDescription.put("isEditable", new Boolean(true));
196:                    }
197:                }
198:            }
199:
200:            /**
201:             * 
202:             * Saving new process name
203:             * 
204:             * @param e
205:             *                event received when a user clicks on save button in the
206:             *                datatable
207:             */
208:            public void saveName(ActionEvent e) {
209:                String processId = (String) FacesContext.getCurrentInstance()
210:                        .getExternalContext().getRequestParameterMap().get(
211:                                "processSaveId");
212:                Process process = this .processService.getProcessDao()
213:                        .getProcess(processId);
214:                for (HashMap<String, Object> processDescription : this 
215:                        .getProcessesList()) {
216:                    if (((String) processDescription.get("id"))
217:                            .equals(processId)) {
218:                        String presentationName = (String) processDescription
219:                                .get("presentationName");
220:
221:                        if (presentationName.trim().length() == 0) {
222:                            processDescription.put("presentationName", process
223:                                    .getPresentationName());
224:
225:                            // Error message.
226:                            WebCommonService
227:                                    .addInfoMessage(WilosBundle
228:                                            .getText("component.process.management.message.invalidName"));
229:                        } else if (this .presentationNameAlreadyExists(
230:                                presentationName, processId)) {
231:                            processDescription.put("presentationName", process
232:                                    .getPresentationName());
233:
234:                            // Error message.
235:                            WebCommonService
236:                                    .addInfoMessage(WilosBundle
237:                                            .getText("component.process.management.message.nameAlreadyExists"));
238:                        } else {
239:                            process.setPresentationName(presentationName);
240:                            this .processService.getProcessDao()
241:                                    .saveOrUpdateProcess(process);
242:                            processDescription.put("isEditable", new Boolean(
243:                                    false));
244:                        }
245:                        break;
246:                    }
247:                }
248:            }
249:
250:            /**
251:             * this method allow to search if the given presentationName 
252:             * for the given Process is already existing in the database
253:             * 
254:             * @param _presentationName
255:             * @param _processId
256:             * @return boolean
257:             */
258:            private boolean presentationNameAlreadyExists(
259:                    String _presentationName, String _processId) {
260:                for (Process process : this .processService.getAllProcesses())
261:                    if ((process.getPresentationName()
262:                            .equals(_presentationName))
263:                            && (!_processId.equals(process.getId())))
264:                        return true;
265:                return false;
266:            }
267:
268:            /* Others for ExpandableTable management */
269:
270:            /**
271:             * Give all the processes save in the database
272:             * 
273:             * @return the processes list
274:             */
275:            public List<SelectItem> getProcesses() {
276:
277:                List<SelectItem> processesList = new ArrayList<SelectItem>();
278:
279:                processesList
280:                        .add(new SelectItem(
281:                                "default",
282:                                WilosBundle
283:                                        .getText("component.combobox.processchoice.defaultlabel")));
284:
285:                List<Process> processes = this .processService.getProcessDao()
286:                        .getAllProcesses();
287:                for (Process process : processes) {
288:                    processesList.add(new SelectItem(process.getId(), process
289:                            .getPresentationName()));
290:                }
291:                return processesList;
292:            }
293:
294:            /**
295:             * 
296:             * listener on the processes selection combobox
297:             */
298:            public void changeProcessSelectionListener(ValueChangeEvent evt) {
299:
300:                TasksExpTableBean tasksExpTableBean = (TasksExpTableBean) WebCommonService
301:                        .getBean("TasksExpTableBean");
302:                RolesExpTableBean rolesExpTableBean = (RolesExpTableBean) WebCommonService
303:                        .getBean("RolesExpTableBean");
304:                WorkProductsExpTableBean workproductsExpTableBean = (WorkProductsExpTableBean) WebCommonService
305:                        .getBean("WorkProductsExpTableBean");
306:
307:                this .selectedProcessId = (String) evt.getNewValue();
308:                tasksExpTableBean.setSelectedProcessId((String) evt
309:                        .getNewValue());
310:                rolesExpTableBean.setSelectedProcessId((String) evt
311:                        .getNewValue());
312:                workproductsExpTableBean.setSelectedProcessId((String) evt
313:                        .getNewValue());
314:                if (this .selectedProcessId.equals("default")) {
315:                    this .isVisibleExpTable = false;
316:                } else {
317:                    this .isVisibleExpTable = true;
318:                }
319:            }
320:
321:            /**
322:             * getter of selectedProcessId String attribute
323:             * 
324:             * @return the processGuid
325:             */
326:            public String getSelectedProcessId() {
327:                return this .selectedProcessId;
328:            }
329:
330:            /**
331:             * setter of selectedProcessId String attribute
332:             * 
333:             * @param _processGuid
334:             *                the processGuid to set
335:             */
336:            public void setSelectedProcessId(String _processGuid) {
337:                this .selectedProcessId = _processGuid;
338:            }
339:
340:            /**
341:             * getter of isVisibleExpTable boolean attribute
342:             * 
343:             * @return the isVisibleExpTable
344:             */
345:            public boolean getIsVisibleExpTable() {
346:                return this .isVisibleExpTable;
347:            }
348:
349:            /**
350:             * setter of isVisibleExpTable boolean attribute
351:             * 
352:             * @param _isVisibleExpTable
353:             *                the isVisibleExpTable to set
354:             */
355:            public void setIsVisibleExpTable(boolean _isVisibleExpTable) {
356:                this .isVisibleExpTable = _isVisibleExpTable;
357:            }
358:
359:            /**
360:             * getter of readOnly boolean attribute
361:             * 
362:             * @return the readOnly
363:             */
364:            public boolean getReadOnly() {
365:
366:                String projectId = (String) WebSessionService
367:                        .getAttribute(WebSessionService.PROJECT_ID);
368:                Project project = this .projectService.getProject(projectId);
369:
370:                if (project.getProcess() == null) {
371:                    this .readOnly = false;
372:
373:                } else {
374:                    this .readOnly = true;
375:                }
376:
377:                return this .readOnly;
378:            }
379:
380:            /**
381:             * setter of readOnly boolean attribute
382:             * 
383:             * @param _readOnly
384:             *                the readOnly to set
385:             */
386:            public void setReadOnly(boolean _readOnly) {
387:                this .readOnly = _readOnly;
388:            }
389:
390:            /**
391:             * getter of isProjectManager boolean attribute
392:             * 
393:             * @return the isProjectManager
394:             */
395:            public boolean getIsProjectManager() {
396:
397:                String user_id = (String) WebSessionService
398:                        .getAttribute(WebSessionService.WILOS_USER_ID);
399:                String projectId = (String) WebSessionService
400:                        .getAttribute(WebSessionService.PROJECT_ID);
401:                String role = (String) WebSessionService
402:                        .getAttribute(WebSessionService.ROLE_TYPE);
403:                if (projectId == null) {
404:                    this .isProjectManager = false;
405:                    return false;
406:                }
407:
408:                this .project = this .projectService.getProject(projectId);
409:                if (project == null) {
410:                    this .isProjectManager = false;
411:                    return false;
412:                }
413:
414:                this .isProjectManager = false;
415:                if (this .project.getProjectManager() != null) {
416:                    if (this .project.getProjectManager().getId()
417:                            .equals(user_id)) {
418:                        this .isProjectManager = true;
419:                    }
420:                    if (role.equals("projectDirector")) {
421:                        this .isProjectManager = true;
422:                    }
423:                }
424:
425:                return this .isProjectManager;
426:            }
427:
428:            /**
429:             * setter of isProjectManager boolean attribute
430:             * 
431:             * @param _isProjectManager
432:             *                the isProjectManager to set
433:             */
434:            public void setIsProjectManager(boolean _isProjectManager) {
435:                this .isProjectManager = _isProjectManager;
436:            }
437:
438:            /* Getters & Setters */
439:
440:            /**
441:             * Setter of processesList.
442:             * 
443:             * @param _processesList
444:             *                The processesList to set.
445:             */
446:            public void setProcessesList(
447:                    List<HashMap<String, Object>> _processesList) {
448:                this .processesList = _processesList;
449:            }
450:
451:            /**
452:             * Getter of processesListView.
453:             * 
454:             * @return the processesListView.
455:             */
456:            public String getProcessesListView() {
457:                if (this .getProcessesList().size() == 0) {
458:                    this .processesListView = VIEW_NULL;
459:                } else {
460:                    this .processesListView = VIEW_NOT_NULL;
461:                }
462:                return this .processesListView;
463:            }
464:
465:            /**
466:             * Setter of processesListView.
467:             * 
468:             * @param _processesListView
469:             *                The processesListView to set.
470:             */
471:            public void setProcessesListView(String _processesListView) {
472:                this .processesListView = _processesListView;
473:            }
474:
475:            /**
476:             * Getter of processService.
477:             * 
478:             * @return the processService.
479:             */
480:            public ProcessService getProcessService() {
481:                return this .processService;
482:            }
483:
484:            /**
485:             * Setter of processService.
486:             * 
487:             * @param _processService
488:             *                The processService to set.
489:             */
490:            public void setProcessService(ProcessService _processService) {
491:                this .processService = _processService;
492:            }
493:
494:            /**
495:             * Getter of projectService.
496:             * 
497:             * @return the projectService.
498:             */
499:            public ProjectService getProjectService() {
500:                return this .projectService;
501:            }
502:
503:            /**
504:             * Setter of projectService.
505:             * 
506:             * @param _projectService
507:             *                The projectService to set.
508:             */
509:            public void setProjectService(ProjectService _projectService) {
510:                this .projectService = _projectService;
511:            }
512:
513:            /**
514:             * this method allow to return the current Instance of
515:             * ProcessManagementService
516:             * 
517:             * @return ProcessManagementService
518:             */
519:
520:            public ProcessManagementService getProcessManagementService() {
521:                return processManagementService;
522:            }
523:
524:            /**
525:             * this method allow to set the current Instance of
526:             * ProcessManagementService
527:             * 
528:             * @param processManagementService
529:             */
530:
531:            public void setProcessManagementService(
532:                    ProcessManagementService processManagementService) {
533:                this .processManagementService = processManagementService;
534:            }
535:
536:            /**
537:             * this method allow to return the current Instance of
538:             * ProcessManagerService
539:             * 
540:             * @return ProcessManagerService
541:             */
542:
543:            public ProcessManagerService getProcessManagerService() {
544:                return processManagerService;
545:            }
546:
547:            /**
548:             * this method allow to set the current Instance of
549:             * ProcessManagerService
550:             * 
551:             * @param processManagerService
552:             */
553:
554:            public void setProcessManagerService(
555:                    ProcessManagerService processManagerService) {
556:                this .processManagerService = processManagerService;
557:            }
558:
559:            /**
560:             * getter of visiblePopup boolean attribute
561:             * 
562:             * @return the visiblePopup
563:             */
564:            public boolean getVisiblePopup() {
565:                return this .visiblePopup;
566:            }
567:
568:            /**
569:             * setter of visiblePopup boolean attribute
570:             * 
571:             * @param visiblePopup
572:             *                the visiblePopup to set
573:             */
574:            public void setVisiblePopup(boolean _visiblePopup) {
575:                this .visiblePopup = _visiblePopup;
576:            }
577:
578:            /**
579:             * getter of instanciationDependenciesView String attribute
580:             * 
581:             * @return the instanciationDependenciesView
582:             */
583:            public String getInstanciationDependenciesView() {
584:                return this .instanciationDependenciesView;
585:            }
586:
587:            /**
588:             * setter of instanciationDependenciesView String attribute
589:             * 
590:             * @param _instanciationDependenciesView
591:             *                the instanciationDependenciesView to set
592:             */
593:            public void setInstanciationDependenciesView(
594:                    String _instanciationDependenciesView) {
595:                this .instanciationDependenciesView = _instanciationDependenciesView;
596:            }
597:
598:            /**
599:             * getter of instanciateDependenciesWithProcess boolean attribute
600:             * 
601:             * @return the instanciateDependenciesWithProcess
602:             */
603:            public boolean getInstanciateDependenciesWithProcess() {
604:                return instanciateDependenciesWithProcess;
605:            }
606:
607:            /**
608:             * setter of instanciateDependenciesWithProcess boolean attribute
609:             * 
610:             * @param instanciateDependenciesWithProcess
611:             *                the instanciateDependenciesWithProcess to set
612:             */
613:            public void setInstanciateDependenciesWithProcess(
614:                    boolean _instanciateDependenciesWithProcess) {
615:                this.instanciateDependenciesWithProcess = _instanciateDependenciesWithProcess;
616:            }
617:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.