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


001:        package org.emforge.jbpm;
002:
003:        import java.util.Date;
004:
005:        import org.apache.commons.collections.Transformer;
006:        import org.apache.commons.lang.StringUtils;
007:        import org.emforge.jbpm.web.bean.WorkflowController;
008:        import org.emforge.xfer.WorkflowTO;
009:        import org.jbpm.JbpmContext;
010:        import org.jbpm.graph.def.ProcessDefinition;
011:
012:        import ru.emdev.EmForge.wiki.WikiTextToXHTMLConverter;
013:
014:        import com.ecyrd.jspwiki.WikiEngine;
015:
016:        /** Transformer for converting jBPM Process Definitions to Workflows
017:         * 
018:         * @author akakunin
019:         *
020:         */
021:        public class ProcessDefTransformer implements  Transformer {
022:            private WikiEngine wikiEngine;
023:            private JbpmContext jbpmContext;
024:
025:            public ProcessDefTransformer(WikiEngine wikiEngine,
026:                    JbpmContext jbpmContext) {
027:                this .wikiEngine = wikiEngine;
028:                this .jbpmContext = jbpmContext;
029:            }
030:
031:            public WorkflowTO transform(Object i_input) {
032:                ProcessDefinition processDef = (ProcessDefinition) i_input;
033:
034:                WorkflowTO workflow = new WorkflowTO();
035:                workflow.setId(processDef.getId());
036:                workflow.setName(processDef.getName());
037:                workflow.setVersion(processDef.getVersion());
038:                workflow.setStartName(processDef.getStartState().getName());
039:                workflow.setIconLink(getWorkflowIconLink(processDef));
040:
041:                String comment = null;
042:                Date date = null;
043:                String userName = null;
044:                String commentText = null;
045:
046:                try {
047:                    comment = new String(processDef.getFileDefinition()
048:                            .getBytes(BpmServiceImpl.COMMENT_FILENAME));
049:                    date = new Date(Long.parseLong(StringUtils
050:                            .substringBetween(comment,
051:                                    BpmServiceImpl.DATE_SEPARATOR,
052:                                    BpmServiceImpl.USER_SEPARATOR)));
053:                    userName = StringUtils.substringBetween(comment,
054:                            BpmServiceImpl.USER_SEPARATOR,
055:                            BpmServiceImpl.MESSAGE_SEPARATOR);
056:                    commentText = StringUtils.substringAfter(comment,
057:                            BpmServiceImpl.MESSAGE_SEPARATOR);
058:                } catch (Exception ex) {
059:                    // just ignore it here - comment not specified
060:                }
061:
062:                workflow.setDeployedBy(userName);
063:                workflow.setDeployedAt(date);
064:
065:                // convert comment to html
066:                if (commentText != null) {
067:                    WikiTextToXHTMLConverter converter = new WikiTextToXHTMLConverter(
068:                            wikiEngine, processDef.getName());
069:
070:                    // convert page to HTML
071:                    String htmlComment = converter.getAsString(null, null,
072:                            commentText);
073:                    workflow.setDeployComment(htmlComment);
074:                }
075:
076:                if (jbpmContext.getGraphSession().findLatestProcessDefinition(
077:                        processDef.getName()).getId() == processDef.getId()) {
078:                    workflow.setObsolete(false);
079:                } else {
080:                    workflow.setObsolete(true);
081:                }
082:
083:                return workflow;
084:            }
085:
086:            /** Returns contents of process icon (as byte array)
087:             * 
088:             * @param processDef
089:             * @return
090:             */
091:            protected static byte[] getWorkflowIcon(ProcessDefinition processDef) {
092:                try {
093:                    byte[] bytes = processDef.getFileDefinition().getBytes(
094:                            "processicon.png");
095:
096:                    return bytes;
097:                } catch (RuntimeException e) {
098:                    return null;
099:                }
100:
101:            }
102:
103:            /** Returns link to process definition icon
104:             * 
105:             * @param processDef
106:             * @return
107:             */
108:            protected static String getWorkflowIconLink(
109:                    ProcessDefinition processDef) {
110:                try {
111:                    byte[] bytes = getWorkflowIcon(processDef);
112:                    if (bytes == null || bytes.length == 0) {
113:                        return null;
114:                    }
115:                } catch (RuntimeException e) {
116:                    return null;
117:                }
118:
119:                return "processicon?" + WorkflowController.WORKFLOW_ID_ATTR
120:                        + "=" + processDef.getId();
121:            }
122:
123:            /** Returns contents of process image as byte array (in jpeg format)
124:             * 
125:             * @param processDef
126:             * @return
127:             */
128:            protected static byte[] getWorkflowImage(
129:                    ProcessDefinition processDef) {
130:                try {
131:                    byte[] bytes = processDef.getFileDefinition().getBytes(
132:                            "processimage.jpg");
133:
134:                    return bytes;
135:                } catch (RuntimeException e) {
136:                    return null;
137:                }
138:
139:            }
140:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.