Source Code Cross Referenced for BonitaProjectAdapter.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 19 avr. 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:        import hero.interfaces.BnProjectPropertyValue;
016:        import hero.interfaces.ProjectSessionHome;
017:        import hero.interfaces.ProjectSession;
018:        import hero.interfaces.ProjectSessionUtil;
019:
020:        /**
021:         * The aim of this class is to transform data from a Bonita project to a xml Document
022:         */
023:        public class BonitaProjectAdapter {
024:
025:            private ArrayList keys;
026:
027:            /**
028:             * Default class constructor 
029:             */
030:            public BonitaProjectAdapter() {
031:            };
032:
033:            /**
034:             * Get the bonita properties as key value hash map
035:             * @param theProjectName : The project concerned.
036:             * @return HashMap the table containing the properties.
037:             */
038:            private HashMap getHBonitaData(String theProjectName,
039:                    String theProjectVersion) {
040:
041:                //Hash map where 'Bonita key - value' will be put
042:                HashMap hMap = new HashMap();
043:
044:                //The local home
045:                ProjectSessionHome projecth = null;
046:
047:                //The bean
048:                ProjectSession project = null;
049:
050:                //keys arrayList
051:                keys = new ArrayList();
052:
053:                try {
054:                    //Getting local home by using JNDI
055:                    projecth = ProjectSessionUtil.getHome();
056:
057:                    //Project creation
058:                    project = projecth.create();
059:
060:                    project.initModelWithVersion(theProjectName,
061:                            theProjectVersion);
062:                    project.executeProcessHook();
063:
064:                    //We are now able to acess Bonita api and get properties
065:                    Collection collectionProperties = project.getProperties();
066:
067:                    //Number of bean instances responding
068:
069:                    //Property value of Bonita
070:                    BnProjectPropertyValue pv = null;
071:
072:                    //The current key of the property value object
073:                    String currentKey = "";
074:
075:                    //The current value of the property value object
076:                    String currentValue = "";
077:                    String possibleValue = "";
078:
079:                    //For all the keys we have to retrieve the associated value
080:                    Iterator it = collectionProperties.iterator();
081:
082:                    while (it.hasNext()) {
083:                        //Getting the values
084:                        pv = (BnProjectPropertyValue) it.next();
085:
086:                        //Retrieve the key
087:                        currentKey = pv.getTheKey();
088:                        currentValue = pv.getTheValue();
089:                        if (currentValue == null)
090:                            currentValue = "";
091:                        //And the value or possible values
092:                        Collection possibleValues = pv.getPossibleValues();
093:                        if (possibleValues != null) {
094:                            //Pb with the StringTokenizer if ""
095:                            if (currentValue.equals(""))
096:                                currentValue = " ";
097:                            //For all the keys we have to retrieve the associated value
098:                            Iterator itValues = possibleValues.iterator();
099:                            // each possible values are added after the value
100:                            while (itValues.hasNext()) {
101:                                // we add a pipe | after each possible values
102:                                currentValue = currentValue + "|"
103:                                        + (String) itValues.next();
104:                            }
105:                        }
106:                        //Adding key to collection to mantain order
107:                        keys.add(currentKey);
108:                        //Adding key and value in a hashMap
109:                        hMap.put(currentKey, currentValue);
110:                    }
111:                    project.remove();
112:                    //Returns the hash map
113:                    return hMap;
114:                } catch (Exception e) {
115:                    try {
116:                        if (project != null)
117:                            project.remove();
118:                    } catch (Exception re) {
119:                        System.out.println(re + " " + e.getMessage());
120:                    }
121:                    System.out.println(e + " " + e.getMessage());
122:                    return null;
123:                }
124:            }
125:
126:            /**
127:             * Provides a Document output for Bonita data
128:             * @param theHashMap : The table containing the properties.
129:             * @param theProjectName : The project concerned.
130:             * @return Document document with the process information : name & properties.
131:             * @throws IOExecption
132:             */
133:            private Document generateBonitaDataDocument(HashMap theHashMap,
134:                    String theProjectName) throws IOException {
135:
136:                //DOM
137:                Document document = null;
138:
139:                //a parser to generate the xml document from the dataProcess
140:                DocumentParser parser = new DocumentParser();
141:
142:                //Create the dataProcess structure with bonita key value
143:                DataProject data = new DataProject(theProjectName, theHashMap);
144:
145:                //Generate the xml document representing the dataProcess
146:                if (data != null)
147:                    document = parser.createDocument(data, keys);
148:
149:                return document;
150:            }
151:
152:            /**
153:             * Get the Bonita project data identified by its name and put them in a DOM 
154:             * @param theProjectName : The name of the project we have to get process informations
155:             * @return the document that represents bonita data
156:             * @throws LoginException
157:             * @throws IOException
158:             */
159:            public Document getProjectData(String theProjectName,
160:                    String theProjectVersion) throws IOException {
161:
162:                //H map of Bonita data
163:                HashMap bonitaMap = new HashMap();
164:
165:                //Set Bonita data in H map
166:                bonitaMap = this .getHBonitaData(theProjectName,
167:                        theProjectVersion);
168:
169:                //Document generated
170:                return this.generateBonitaDataDocument(bonitaMap,
171:                        theProjectName);
172:            }
173:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.