Source Code Cross Referenced for BonitaActivityAdapter.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 03 mai. 2004 by the Message Center Team
003:         *
004:         */
005:        package mc.formgenerator.bonita;
006:
007:        import java.io.IOException;
008:        import java.util.ArrayList;
009:        import java.util.Collection;
010:        import java.util.HashMap;
011:        import java.util.Iterator;
012:
013:        import org.w3c.dom.Document;
014:
015:        //Bonita imports
016:        import hero.interfaces.*;
017:        import hero.interfaces.ProjectSessionHome;
018:        import hero.interfaces.ProjectSession;
019:
020:        /**
021:         * The aim of this class is to transform Bonita activity data to a xml Document
022:         */
023:        public class BonitaActivityAdapter {
024:
025:            private ArrayList projectKeys;
026:            private ArrayList activityKeys;
027:
028:            /**
029:             * Default class constructor 
030:             */
031:            public BonitaActivityAdapter() {
032:            };
033:
034:            /**
035:             * Provides a Document output for Bonita data
036:             * @param theHashMap : The table containing the properties.
037:             * @param theProjectName : The project concerned.
038:             * @param theProjectName the activity concerned in the project
039:             * @return Document document with the activity information : project name & activity name & activity properties.
040:             * @throws IOExecption
041:             */
042:            private Document generateBonitaDataDocument(HashMap projectHashMap,
043:                    HashMap activityHashMap, String theProjectName,
044:                    String theActivityName) throws IOException {
045:
046:                //DOM
047:                Document document = null;
048:
049:                //a parser to generate the xml document from the dataProcess
050:                DocumentParser parser = new DocumentParser();
051:
052:                //Create the dataProcess structure with bonita key value
053:                DataActivity data = new DataActivity(theProjectName,
054:                        theActivityName, projectHashMap, activityHashMap);
055:
056:                //Generate the xml document representing the dataProcess
057:                if (data != null)
058:                    document = parser.createDocument(data, projectKeys,
059:                            activityKeys);
060:
061:                return document;
062:            }
063:
064:            /**
065:             * Get the Bonita activity data identified by its name and put them in a DOM 
066:             * @param theProjectName the name of the project we have to get process informations
067:             * @param theActivityName the name of the activityname concerned
068:             * @return the document that represents bonita activity data
069:             * @throws LoginException
070:             * @throws IOException
071:             */
072:            public Document getActivityData(String theProjectName,
073:                    String theActivityName, String theProjectVersion)
074:                    throws IOException {
075:
076:                //SET PROJECT AND ACTIVITY DATA IN HASHMAPS
077:
078:                //H map of project data where 'Bonita key - value' will be put
079:                HashMap projectMap = new HashMap();
080:
081:                //H map of activity data where 'Bonita key - value' will be put
082:                HashMap activityMap = new HashMap();
083:
084:                //The local home
085:                ProjectSessionHome projecth = null;
086:
087:                //The bean
088:                ProjectSession project = null;
089:                ProjectSession model = null;
090:
091:                //keys arrayLists
092:                projectKeys = new ArrayList();
093:                activityKeys = new ArrayList();
094:
095:                try {
096:                    //Getting local home by using JNDI
097:                    projecth = ProjectSessionUtil.getHome();
098:
099:                    //Project creation
100:                    project = projecth.create();
101:
102:                    model = projecth.create(); // isAdmin of the model ?
103:                    int i = theProjectName.indexOf("_instance");
104:                    model.initModelWithVersion(theProjectName.substring(0, i),
105:                            theProjectVersion);
106:                    //model.initProject(theProjectName.substring(0, i));
107:                    //ORIG: model.initProject(theProjectName.substring(0, i));
108:
109:                    //Project initialisation
110:                    project.initProject(theProjectName);
111:                    //ORIG: project.initProject(theProjectName);
112:
113:                    if (!project.isUserInNodeRole(theActivityName)
114:                            && !model.isAdminOfProject())
115:                        throw new Exception(
116:                                "You are not allowed to execute this activity ! ");
117:
118:                    //properties collection
119:                    Collection collectionProperties;
120:                    //colelction iterator
121:                    Iterator it;
122:                    //The current key of the property value object
123:                    String currentKey = "";
124:                    //The current value of the property value object
125:                    String currentValue = "";
126:                    String possibleValue = "";
127:
128:                    //GET PROJECT PROPERTIES
129:                    //Project Property value of Bonita
130:                    BnProjectPropertyValue pv = null;
131:                    collectionProperties = project.getProperties();
132:                    //For all the keys we have to retrieve the associated value
133:                    it = collectionProperties.iterator();
134:
135:                    while (it.hasNext()) {
136:                        //Getting the values
137:                        pv = (BnProjectPropertyValue) it.next();
138:
139:                        //Retrieve the key
140:                        currentKey = pv.getTheKey();
141:                        currentValue = pv.getTheValue();
142:                        if (currentValue == null)
143:                            currentValue = "";
144:                        //And the value or possible values
145:                        Collection possibleValues = pv.getPossibleValues();
146:                        if (possibleValues != null) {
147:                            //Pb with the StringTokenizer if ""
148:                            if (currentValue.equals(""))
149:                                currentValue = " ";
150:                            //For all the keys we have to retrieve the associated value
151:                            Iterator itValues = possibleValues.iterator();
152:                            // each possible values are added after the value
153:                            while (itValues.hasNext()) {
154:                                // we add a pipe | after each possible values
155:                                currentValue = currentValue + "|"
156:                                        + (String) itValues.next();
157:                            }
158:                        }
159:                        //Adding key to collection to mantain order
160:                        projectKeys.add(currentKey);
161:                        //Adding key and value in a hashMap
162:                        projectMap.put(currentKey, currentValue);
163:                    }
164:
165:                    //GET ACTIVITY PROPERTIES
166:                    //Project Property value of Bonita
167:                    BnNodePropertyValue npv = null;
168:                    collectionProperties = project
169:                            .getNodeProperties(theActivityName);
170:
171:                    //For all the keys we have to retrieve the associated value
172:                    it = collectionProperties.iterator();
173:
174:                    while (it.hasNext()) {
175:                        //Getting the values
176:                        npv = (BnNodePropertyValue) it.next();
177:
178:                        //Retrieve the key
179:                        currentKey = npv.getTheKey();
180:                        currentValue = npv.getTheValue();
181:                        if (currentValue == null)
182:                            currentValue = "";
183:                        //And the value or possible values
184:                        Collection possibleValues = npv.getPossibleValues();
185:                        if (possibleValues != null) {
186:                            //Pb with the StringTokenizer if ""
187:                            if (currentValue.equals(""))
188:                                currentValue = " ";
189:                            //For all the keys we have to retrieve the associated value
190:                            Iterator itValues = possibleValues.iterator();
191:                            // each possible values are added after the value
192:                            while (itValues.hasNext()) {
193:                                currentValue = currentValue + "|"
194:                                        + (String) itValues.next();
195:                            }
196:                        }
197:                        //Adding key to collection to mantain order
198:                        activityKeys.add(currentKey);
199:                        //Adding key and value in a hashMap
200:                        activityMap.put(currentKey, currentValue);
201:                        currentValue = "";
202:                    }
203:                    project.remove();
204:                    model.remove();
205:                } catch (Exception e) {
206:                    try {
207:                        if (project != null)
208:                            project.remove();
209:                    } catch (Exception re) {
210:                        System.out.println(re + " " + e.getMessage());
211:                    }
212:                    throw new IOException(e.getMessage());
213:                }
214:
215:                //Document generated
216:                return this.generateBonitaDataDocument(projectMap, activityMap,
217:                        theProjectName, theActivityName);
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.