Source Code Cross Referenced for TaskTransformer.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.Collection;
004:        import java.util.LinkedList;
005:        import java.util.List;
006:
007:        import org.apache.commons.collections.Transformer;
008:        import org.apache.commons.logging.Log;
009:        import org.apache.commons.logging.LogFactory;
010:        import org.emforge.projectmanager.ProjectService;
011:        import org.emforge.projectmanager.base.MilestoneDO;
012:        import org.emforge.projectmanager.base.ProjectDO;
013:        import org.emforge.xfer.StepTO;
014:        import org.emforge.xfer.VariableTO;
015:        import org.jbpm.context.def.VariableAccess;
016:        import org.jbpm.taskmgmt.def.TaskController;
017:        import org.jbpm.taskmgmt.exe.TaskInstance;
018:
019:        import ru.emdev.EmForge.security.UserFactory;
020:
021:        /** Trasformer for converting jBPM TaskInstances into StepTO 
022:         */
023:        public class TaskTransformer implements  Transformer {
024:            protected final Log logger = LogFactory.getLog(getClass());
025:
026:            private ProjectService projectService;
027:            private UserFactory userFactory;
028:
029:            public TaskTransformer(ProjectService projectService,
030:                    UserFactory userFactory) {
031:                this .projectService = projectService;
032:                this .userFactory = userFactory;
033:            }
034:
035:            public StepTO transform(Object i_input) {
036:                TaskInstance task = (TaskInstance) i_input;
037:
038:                if (task.getToken().getProcessInstance() == null) {
039:                    logger.error("Cannot get process for task instance #"
040:                            + task.getId());
041:                }
042:
043:                StepTO step = new StepTO();
044:                step.setId(task.getId());
045:                step.setTaskId(task.getToken().getProcessInstance().getId());
046:                step.setActor(task.getActorId());
047:
048:                if (task.getSwimlaneInstance() != null) {
049:                    step.setSwimlane(task.getSwimlaneInstance().getName());
050:                }
051:
052:                String title = null;
053:                if (task.hasVariable(BpmVariable.TITLE.getVariable())
054:                        && task.getVariable(BpmVariable.TITLE.getVariable()) != null) {
055:                    title = task.getVariable(BpmVariable.TITLE.getVariable())
056:                            .toString();
057:                }
058:                step.setTitle(title);
059:
060:                step.setName(task.getName());
061:
062:                step.setPriority(new PriorityTransformer()
063:                        .transform(new Integer(task.getPriority())));
064:
065:                step.setPlannedStartTime(task.getStart());
066:                step.setActualStartTime(task.getCreate());
067:                step.setDueDate(task.getDueDate());
068:                step.setHasEnded(task.hasEnded());
069:                step.setTaskHelp(task.getDescription());
070:                step.setWritableVariables(getStepVariables(task));
071:
072:                // get Project
073:                ProjectDO project = ProcessTransformer.getProject(task
074:                        .getToken().getProcessInstance());
075:                if (project != null) {
076:                    step.setProjectName(project.getName());
077:
078:                    // get milestone
079:                    MilestoneDO milestone = getMilestone(task);
080:                    if (milestone != null) {
081:                        step.setMilestoneName(milestone.getName());
082:                    }
083:                }
084:                step.setWorkflowName(task.getToken().getProcessInstance()
085:                        .getProcessDefinition().getName());
086:                step.setWorkflowVersion(task.getToken().getProcessInstance()
087:                        .getProcessDefinition().getVersion());
088:                step.setWorkflowIconLink(ProcessDefTransformer
089:                        .getWorkflowIconLink(task.getToken()
090:                                .getProcessInstance().getProcessDefinition()));
091:                step.setTaskOwner(ProcessTransformer.getOwner(task.getToken()
092:                        .getProcessInstance()));
093:
094:                // set transitions
095:                step.setTransitions(TaskDefinitionTransformer
096:                        .getTransitions(task.getTask()));
097:
098:                return step;
099:            }
100:
101:            /** Create array of writtable Variables for Step
102:             * 
103:             * @param i_step
104:             * @return
105:             */
106:            @SuppressWarnings("unchecked")
107:            private VariableTO[] getStepVariables(TaskInstance task) {
108:
109:                List<VariableTO> result = new LinkedList<VariableTO>();
110:
111:                // get task controller
112:                TaskController taskController = task.getTask()
113:                        .getTaskController();
114:                if (taskController != null) {
115:                    Collection<VariableAccess> variableAccesses = taskController
116:                            .getVariableAccesses();
117:
118:                    VariableTransformer variableTransformer = new VariableTransformer(
119:                            projectService, userFactory, task.getToken()
120:                                    .getProcessInstance(), null);
121:
122:                    // fill the list of variables
123:                    for (VariableAccess variableAccess : variableAccesses) {
124:                        String mappedName = variableAccess.getMappedName();
125:
126:                        if (variableAccess.isReadable()
127:                                && variableAccess.isWritable()) {
128:                            Object value = task.getVariable(mappedName);
129:                            VariableTO tfp = variableTransformer.transform(
130:                                    variableAccess, value);
131:                            result.add(tfp);
132:                        }
133:                    }
134:                }
135:
136:                return result.toArray(new VariableTO[result.size()]);
137:            }
138:
139:            private MilestoneDO getMilestone(TaskInstance task) {
140:                MilestoneDO value = (MilestoneDO) task
141:                        .getVariable(BpmVariable.MILESTONE.getVariable());
142:
143:                return value;
144:            }
145:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.