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


001:        /**
002:         *
003:         * Bonita
004:         * Copyright (C) 1999 Bull S.A.
005:         * Bull 68 route de versailles  78434 Louveciennes Cedex France
006:         * Further information: bonita@objectweb.org
007:         *
008:         * This library is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU Lesser General Public
010:         * License as published by the Free Software Foundation; either
011:         * version 2.1 of the License, or any later version.
012:         *
013:         * This library is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:         * Lesser General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU Lesser General Public
019:         * License along with this library; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
021:         * USA
022:         *
023:         *
024:        --------------------------------------------------------------------------
025:         * $Id: Sample1CreateProcessModel.java,v 1.3 2004/11/10 17:10:50 mvaldes Exp $
026:         *
027:        --------------------------------------------------------------------------
028:         */package hero.client.samples;
029:
030:        import javax.security.auth.login.LoginContext;
031:        import hero.client.test.SimpleCallbackHandler;
032:
033:        import hero.interfaces.ProjectSession;
034:        import hero.interfaces.ProjectSessionHome;
035:        import hero.interfaces.ProjectSessionUtil;
036:
037:        import hero.interfaces.Constants;
038:
039:        public class Sample1CreateProcessModel {
040:
041:            static public void main(String[] args) throws Exception {
042:                // User Admin login
043:                char[] password = { 't', 'o', 't', 'o' };
044:                SimpleCallbackHandler handler = new SimpleCallbackHandler(
045:                        "admin", password);
046:                LoginContext lc = new LoginContext("TestClient", handler);
047:                lc.login();
048:
049:                // Creation of Bonita Project "Order Processing " 
050:
051:                // Collaboration Project Session Bean Creation using Remote Interface
052:                ProjectSessionHome prjHome = (ProjectSessionHome) ProjectSessionUtil
053:                        .getHome();
054:                ProjectSession prjSession = prjHome.create();
055:
056:                // Order Service project creation
057:
058:                prjSession.initModel("Order Processing");
059:
060:                //Process Model creation by user admin	  
061:                // Activities creation : non anticipative : traditional execution mode)
062:
063:                // First activity is created : Receive Order
064:                prjSession.addNode("Receive Order", Constants.Nd.AND_JOIN_NODE);
065:                prjSession.setNodeTraditional("Receive Order");
066:
067:                // Set node properties : customer_name, product_name, items
068:                prjSession.setNodeProperty("Receive Order", "once_more", "OK",
069:                        true);
070:                prjSession.setNodeProperty("Receive Order", "customer_name",
071:                        "", true);
072:                prjSession.setNodeProperty("Receive Order", "product_name", "",
073:                        true);
074:                prjSession.setNodeProperty("Receive Order", "items", "", true);
075:
076:                // Second Activity creation : Check Stock AutomaticAndJoin activity
077:                prjSession.addNode("Check Stock",
078:                        Constants.Nd.AND_JOIN_AUTOMATIC_NODE);
079:                prjSession.setNodeTraditional("Check Stock");
080:
081:                // Activities connection : Set edges between nodes
082:                prjSession.addEdge("Receive Order", "Check Stock");
083:
084:                // Set node hook
085:                // This hook (Check Stock Hook)verifies if the user has sent a correct order and set a new property "stock_status" with the value ok or nok
086:                String scriptHook = "import hero.interfaces.*;\n"
087:                        + "import hero.interfaces.BnNodeLocal;\n"
088:                        + "beforeTerminate (Object b,Object n) {\n"
089:                        + "hero.interfaces.ProjectSessionLocalHome pHome = (hero.interfaces.ProjectSessionLocalHome) hero.interfaces.ProjectSessionUtil.getLocalHome(); \n"
090:                        + "hero.interfaces.ProjectSessionLocal subProcess = pHome.create(); \n"
091:                        + "subProcess.initModel(n.getBnProject().getName()); \n"
092:                        + "if (customer_name != null && product_name != null && items != null) \n"
093:                        + "{ System.out.println(\"(Order Processing : Check Stock) Stock Status = OK\"); \n"
094:                        + " subProcess.setNodeProperty(n.getName(), \"stock_status\",\"ok\",true);\n "
095:                        + "	}\n"
096:                        + " else \n"
097:                        + "{ System.out.println(\"(Order Processing : Check Stock) Stock Status = NOK\");\n "
098:                        + "subProcess.setNodeProperty(n.getName(), \"stock_status\",\"nok\",true); \n"
099:                        + " }\n" + "}";
100:
101:                prjSession.addNodeInterHook("Check Stock", "Check Stock Hook",
102:                        Constants.Nd.BEFORETERMINATE,
103:                        Constants.Hook.BSINTERACTIVE, scriptHook);
104:
105:                // "Accept Order" subProcess activity creation, attached to "Customer Service" project
106:                prjSession
107:                        .addNodeSubProcess("Accept Order", "Customer Service");
108:
109:                // Adds Edge between "Check Stock" and "Accept Order"
110:                // and adds a condition to this new edge
111:                String edgeStockOrder = prjSession.addEdge("Check Stock",
112:                        "Accept Order");
113:                String condition = "stock_status.equals(\"ok\")";
114:                prjSession.setEdgeCondition(edgeStockOrder, condition);
115:
116:                // Add two activities connected with "Accept Order", once selected depending on the edge conditions
117:                // First
118:                prjSession.addNode("Ship & Report",
119:                        Constants.Nd.AND_JOIN_AUTOMATIC_NODE);
120:                prjSession.setNodeTraditional("Ship & Report");
121:
122:                // Set node hook
123:                // This hook (Ship & Report Hook)just print a message
124:                String scriptHookSR = "import hero.interfaces.*;\n"
125:                        + "import hero.interfaces.BnNodeLocal;\n"
126:                        + "beforeTerminate (Object b,Object n) {\n"
127:                        + "hero.interfaces.ProjectSessionLocalHome pHome = (hero.interfaces.ProjectSessionLocalHome) hero.interfaces.ProjectSessionUtil.getLocalHome(); \n"
128:                        + "hero.interfaces.ProjectSessionLocal subProcess = pHome.create(); \n"
129:                        + "subProcess.initModel(n.getBnProject().getName()); \n"
130:                        + "System.out.println(\"(Order Processing : Ship & Report) That's OK\"); \n"
131:                        + "}";
132:
133:                prjSession.addNodeInterHook("Ship & Report",
134:                        "Ship Report Hook", Constants.Nd.BEFORETERMINATE,
135:                        Constants.Hook.BSINTERACTIVE, scriptHookSR);
136:
137:                String edgeOrderReport = prjSession.addEdge("Accept Order",
138:                        "Ship & Report");
139:                String condition1 = "partial_sales_status.equals(\"ok\")";
140:                prjSession.setEdgeCondition(edgeOrderReport, condition1);
141:
142:                // second
143:                prjSession.addNode("Cancel Order",
144:                        Constants.Nd.AND_JOIN_AUTOMATIC_NODE);
145:                prjSession.setNodeTraditional("Cancel Order");
146:
147:                // Set node hook
148:                // This hook (Cancel Order Hook)just print a message
149:                String scriptHookCO = "import hero.interfaces.*;\n"
150:                        + "import hero.interfaces.BnNodeLocal;\n"
151:                        + "beforeTerminate (Object b,Object n) {\n"
152:                        + "hero.interfaces.ProjectSessionLocalHome pHome = (hero.interfaces.ProjectSessionLocalHome) hero.interfaces.ProjectSessionUtil.getLocalHome(); \n"
153:                        + "hero.interfaces.ProjectSessionLocal subProcess = pHome.create(); \n"
154:                        + "subProcess.initModel(n.getBnProject().getName()); \n"
155:                        + "System.out.println(\"(Order Processing : Cancel Order) That's NOT OK\"); \n"
156:                        + "}";
157:
158:                prjSession.addNodeInterHook("Cancel Order",
159:                        "Cancel Order Hook", Constants.Nd.BEFORETERMINATE,
160:                        Constants.Hook.BSINTERACTIVE, scriptHookCO);
161:
162:                String edgeOrderCancel = prjSession.addEdge("Accept Order",
163:                        "Cancel Order");
164:                String condition2 = "partial_sales_status.equals(\"nok\")";
165:                prjSession.setEdgeCondition(edgeOrderCancel, condition2);
166:
167:                // Creates two roles for this process : agent and customer 
168:                prjSession.addRole("agent", "Customer Service agent");
169:                prjSession.addRole("customer", "Sales order customer");
170:
171:                // set roles for activities
172:                prjSession.setNodeRole("Accept Order", "agent");
173:                prjSession.setNodeRole("Check Stock", "agent");
174:                prjSession.setNodeRole("Ship & Report", "agent");
175:                prjSession.setNodeRole("Cancel Order", "agent");
176:                prjSession.setNodeRole("Receive Order", "customer");
177:
178:                // Adding iteration from Receive Order and Ship & report
179:                // note : this is just as a sample : it is not a good design 
180:                // when an iteration includes nodes
181:                // with many output nodes, as Accept Order is
182:                String iterCondition = "once_more.equals(\"OK\")";
183:                prjSession.addIteration("Ship & Report", "Receive Order",
184:                        iterCondition);
185:            }
186:
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.