Source Code Cross Referenced for WorkflowController.java in  » Project-Management » EmForce » org » emforge » jbpm » web » bean » 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 » Project Management » EmForce » org.emforge.jbpm.web.bean 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.emforge.jbpm.web.bean;
002:
003:        import javax.faces.context.ExternalContext;
004:        import javax.faces.context.FacesContext;
005:        import javax.servlet.http.HttpServletRequest;
006:
007:        import org.apache.commons.lang.StringUtils;
008:        import org.apache.commons.logging.Log;
009:        import org.apache.commons.logging.LogFactory;
010:        import org.emforge.BpmService;
011:        import org.emforge.EmForgeException;
012:        import org.emforge.xfer.AttachmentTO;
013:        import org.emforge.xfer.HistoryTO;
014:        import org.emforge.xfer.WorkflowTO;
015:
016:        import ru.emdev.EmForge.security.web.SiteRole;
017:        import ru.emdev.EmForge.web.bean.BaseControllerImpl;
018:        import ru.emdev.EmForge.web.bean.MainMenuController.MainMenuItem;
019:        import ru.emdev.EmForge.wiki.web.bean.Crumb;
020:
021:        import com.ecyrd.jspwiki.WikiPage;
022:
023:        /** Workflow controller is used for processing workflow page
024:         * 
025:         */
026:        public class WorkflowController extends BaseControllerImpl {
027:            public static final String WORKFLOW_PAGE_NAME = "workflow";
028:            public static final String WORKFLOW_ID_ATTR = "workflowid";
029:            public static final String WORKFLOW_PAGE_ATTR = "page";
030:            public static final String WORKFLOW_VERSION_ATTR = "version";
031:
032:            protected final Log logger = LogFactory.getLog(getClass());
033:
034:            /** Processed Workflow*/
035:            private WorkflowTO m_workflow;
036:
037:            /** BPM Context */
038:            BpmService m_bpmService;
039:
040:            /** Task Controller
041:             * 
042:             * Used to start new process 
043:             */
044:            NewTaskController m_newTaskController;
045:
046:            private String m_pageName;
047:            private WikiPage m_wikiPage;
048:
049:            public void setBpmService(BpmService i_bpmService) {
050:                m_bpmService = i_bpmService;
051:            }
052:
053:            public void setNewTaskController(
054:                    NewTaskController i_newTaskController) {
055:                m_newTaskController = i_newTaskController;
056:            }
057:
058:            @Override
059:            public MainMenuItem getSelectionItemOnMainMenu() {
060:                return MainMenuItem.TASKS;
061:            }
062:
063:            @Override
064:            public Crumb getTrailCrumbInfo() {
065:                if (m_workflow == null) {
066:                    return null;
067:                }
068:                String displayName;
069:                String url;
070:                try {
071:                    displayName = m_workflow.getName();
072:                    url = WORKFLOW_PAGE_NAME + "/" + displayName;
073:                } catch (Exception ex) {
074:                    logger.debug("Cannot get trail crumb info: ", ex);
075:                    return null;
076:                }
077:
078:                return new Crumb(displayName, url);
079:            }
080:
081:            public String getTitleImpl() {
082:                if (m_workflow != null) {
083:                    return "Workflow: " + m_workflow.getName();
084:                } else {
085:                    return "Unknown Workflow";
086:                }
087:            }
088:
089:            public void init() {
090:                try {
091:                    if (m_bpmService != null) {
092:                        //get milestone by id
093:                        // moved initialization here - so, hibernate session is available
094:                        ExternalContext context = FacesContext
095:                                .getCurrentInstance().getExternalContext();
096:                        HttpServletRequest request = (HttpServletRequest) context
097:                                .getRequest();
098:
099:                        // get id
100:                        String idStr = request.getParameter(WORKFLOW_ID_ATTR);
101:                        if (StringUtils.isNotEmpty(idStr)) {
102:                            long id = Long.valueOf(idStr).longValue();
103:
104:                            // get process definition by id
105:                            WorkflowTO workflow = m_bpmService
106:                                    .getWorkflowById(id);
107:                            setWorkflow(workflow);
108:                            m_pageName = workflow.getName();
109:                        } else {
110:                            m_pageName = request
111:                                    .getParameter(WORKFLOW_PAGE_ATTR);
112:
113:                            String versionStr = request
114:                                    .getParameter(WORKFLOW_VERSION_ATTR);
115:                            Integer version = null;
116:                            try {
117:                                version = Integer.valueOf(versionStr);
118:                            } catch (Exception ex) {
119:                                // ignore any exception here
120:                            }
121:
122:                            if (version != null) {
123:                                // read workflow by pageName and version
124:                                setWorkflow(m_bpmService.getWorkflowByName(
125:                                        m_pageName, version));
126:                            } else {
127:                                // read workflow by pageName
128:                                setWorkflow(m_bpmService.getWorkflowByName(
129:                                        m_pageName,
130:                                        BpmService.WORKFLOW_LAST_VERSION));
131:                            }
132:                        }
133:
134:                        if (m_pageName != null) {
135:                            m_wikiPage = m_wikiEngine.getPage(m_pageName);
136:                        }
137:
138:                    }
139:                } catch (EmForgeException ex) {
140:                    logger.error("Cannot read workflow", ex);
141:                }
142:            }
143:
144:            public WorkflowTO getWorkflow() {
145:                return m_workflow;
146:            }
147:
148:            public void setWorkflow(WorkflowTO i_workflow) {
149:                m_workflow = i_workflow;
150:            }
151:
152:            /** Starts new process
153:             * 
154:             * @return
155:             */
156:            public String startNewProcess() {
157:                m_newTaskController.clean();
158:
159:                m_newTaskController.setWorkflow(m_workflow);
160:
161:                return "newtask";
162:            }
163:
164:            public String getPageName() {
165:                return m_pageName;
166:            }
167:
168:            public void setPageName(String pageName) {
169:                m_pageName = pageName;
170:            }
171:
172:            public boolean isPageExists() {
173:                return m_wikiPage != null;
174:            }
175:
176:            @SuppressWarnings("unchecked")
177:            public AttachmentTO[] getAttachments() {
178:                if (m_wikiPage != null) {
179:                    try {
180:                        return m_attachmentService.getAttachments(m_wikiPage
181:                                .getName());
182:                    } catch (EmForgeException ex) {
183:                        logger.error("Cannot get attachments", ex);
184:                    }
185:                }
186:
187:                return new AttachmentTO[0];
188:            }
189:
190:            public HistoryTO[] getWorkflowHistory() throws EmForgeException {
191:                if (m_workflow != null) {
192:                    return m_bpmService.getWorkflowHistory(
193:                            m_workflow.getName(), m_workflow.getVersion());
194:                } else {
195:                    return new HistoryTO[0];
196:                }
197:            }
198:
199:            public WorkflowTO[] getUsedWorkflows() throws EmForgeException {
200:                if (m_workflow != null) {
201:                    return m_bpmService.getUsedWorkflows(m_workflow.getName(),
202:                            m_workflow.getVersion());
203:                } else {
204:                    return new WorkflowTO[0];
205:                }
206:            }
207:
208:            public boolean isCanStartProcess() {
209:                return !getCurrentUser().isAnonymous();
210:            }
211:
212:            public boolean isCanAddAttachment() {
213:                return getCurrentUser().hasRole(SiteRole.ADMIN.getId());
214:            }
215:
216:            public boolean isCanEditDescription() {
217:                return getCurrentUser().hasRole(SiteRole.ADMIN.getId());
218:            }
219:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.