Source Code Cross Referenced for BonitaActivityExecutor.java in  » Workflow-Engines » bonita-v3.1 » mc » formgenerator » bonita » 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 » bonita v3.1 » mc.formgenerator.bonita 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on 3 mai 2004
003:         *
004:         */
005:        package mc.formgenerator.bonita;
006:
007:        import hero.interfaces.ProjectSession;
008:        import hero.interfaces.ProjectSessionHome;
009:        import hero.interfaces.ProjectSessionUtil;
010:        import hero.interfaces.UserSession;
011:        import hero.interfaces.UserSessionHome;
012:        import hero.interfaces.UserSessionUtil;
013:
014:        import java.util.*;
015:
016:        import org.w3c.dom.Document;
017:
018:        import hero.util.HeroException;
019:
020:        /**
021:         * Given instance document with properties, starts and ends an activity
022:         */
023:        public class BonitaActivityExecutor {
024:
025:            /**
026:             * Default constructor
027:             */
028:            public BonitaActivityExecutor() {
029:
030:            }
031:
032:            /**
033:             * Allows to find, initialise and terminate an activity.
034:             * @param document Document with the activity information (name, attributes and project name).
035:             * @param mode the application mode: consumer or exploitant
036:             * @throws LoginException
037:             */
038:            public void actOnActivity(Document document, Vector req_parameters,
039:                    boolean formsExists, String mode, String version)
040:                    throws HeroException {
041:
042:                //'parse' transforms a Document
043:                DocumentParser parse = new DocumentParser();
044:
045:                DataActivity data = parse.parseActivity(document,
046:                        req_parameters, formsExists);
047:
048:                //get the project name to wich it belongs
049:                String projectName = data.getProjectName();
050:
051:                //get the activity name	
052:                String activityName = data.getActivityName();
053:
054:                //get the process properties
055:                HashMap projectTable = data.getProjectProperties();
056:
057:                //get activity properties
058:                HashMap activityTable = data.getActivityProperties();
059:
060:                //terminate the activity thanks to its name and properties
061:                this .startActivity(projectName, activityName, projectTable,
062:                        activityTable, mode, version);
063:            }
064:
065:            /**
066:             * Thanks to its name, the activity is found and stopped. 
067:             * Before, its attributes are set with the HashMap values.
068:             * @param activityName Name of the activity to stop.
069:             * @param projectName Name of the project to which it belongs.
070:             * @param table HashMap with the activity attributes associated to their values
071:             * @param mode the application mode: consumer or exploitant
072:             * @throws LoginException
073:             */
074:            private void startActivity(String projectName, String activityName,
075:                    HashMap projectTable, HashMap activityTable, String mode,
076:                    String version) throws HeroException {
077:
078:                //The local home
079:                ProjectSessionHome projecth = null;
080:
081:                //The bean
082:                ProjectSession project = null;
083:
084:                //All the keys will be saved in a set
085:                Set collec;
086:
087:                try {
088:                    //Getting local home by using JNDI
089:                    projecth = ProjectSessionUtil.getHome();
090:
091:                    //Creation of the project
092:                    project = projecth.create();
093:
094:                    //project.initProjectWithVersion(projectName,version);
095:                    project.initProject(projectName);
096:
097:                    //**************************************************************************
098:                    //					SET THE PROJECT PROPERTIES
099:                    //**************************************************************************
100:
101:                    collec = projectTable.keySet();
102:
103:                    //Set properties if they exist
104:                    if (collec.size() > 0) {
105:
106:                        //For all the keys we have to retrieve the associated value
107:                        Iterator it = collec.iterator();
108:
109:                        //variable which will stock the property name
110:                        String cle = "";
111:
112:                        while (it.hasNext()) {
113:
114:                            //Getting the values
115:                            cle = (String) it.next();
116:                            //Set the current process property
117:                            project.setProperty(cle, (String) projectTable
118:                                    .get(cle));
119:                        }
120:                    }
121:
122:                    //**************************************************************************
123:                    //					SET ACTIVITY PROPERTIES
124:                    //**************************************************************************
125:
126:                    collec = activityTable.keySet();
127:
128:                    //Set properties if they exist
129:                    if (collec.size() > 0) {
130:
131:                        //For all the keys we have to retrieve the associated value
132:                        Iterator it = collec.iterator();
133:
134:                        //variable which will stock the property name
135:                        String cle = "";
136:
137:                        while (it.hasNext()) {
138:
139:                            //Getting the values
140:                            cle = (String) it.next();
141:                            //Set the current process property
142:                            project.setNodeProperty(activityName, cle,
143:                                    (String) activityTable.get(cle));
144:                        }
145:                    }
146:
147:                    //**************************************************************************
148:                    //					START THE ACTIVITY
149:                    //**************************************************************************
150:
151:                    //The local home
152:                    UserSessionHome userh = UserSessionUtil.getHome();
153:                    //The bean
154:                    UserSession user = userh.create();
155:                    //the session starts the activity
156:                    user.startActivity(projectName, activityName);
157:                    //the session terminate the activity
158:                    user.terminateActivity(projectName, activityName);
159:
160:                    //**************************************************************************
161:                    //					STOP THE ACTIVITY
162:                    //**************************************************************************	
163:
164:                    //if(mode.equals("consumer"))
165:                    //this.endActivity(activityName, projectName);
166:                    project.remove();
167:                } catch (Exception e) {
168:                    try {
169:                        if (project != null)
170:                            project.remove();
171:                    } catch (Exception re) {
172:                        System.out.println(re + " " + e.getMessage());
173:                    }
174:                    //System.out.println(e.getMessage());
175:                    throw new HeroException(e.getMessage());
176:                }
177:            }
178:
179:            public void endActivity(String activityName, String projectName) {
180:                try {
181:
182:                    //The local home
183:                    UserSessionHome userh = UserSessionUtil.getHome();
184:
185:                    //The bean
186:                    UserSession user = userh.create();
187:
188:                    //the session terminates the activity
189:                    user.terminateActivity(projectName, activityName);
190:
191:                } catch (Exception e) {
192:                    System.out.println(e.getMessage());
193:                }
194:            }
195:
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.