01: /**
02: * Bonita
03: * Copyright (C) 1999 Bull S.A.
04: * Bull 68 route de versailles 78434 Louveciennes Cedex France
05: * Further information: bonita@objectweb.org
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation; either
10: * version 2.1 of the License, or any later version.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this library; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20: * USA
21: --------------------------------------------------------------------------
22: * BONITA Workflow Patterns sample
23: * Pattern 09 : Discriminator
24: * Author : Jordi Anguela
25: * Date : 2006/03/01
26: --------------------------------------------------------------------------
27: * Example
28: * Two activities audit_application and process_application running in
29: * parallel which are both followed by an activity close_case. Use of
30: * SubProcesses to do the same activities multiple times.
31: --------------------------------------------------------------------------
32: */package hero.client.samples.patterns.src;
33:
34: import hero.client.test.SimpleCallbackHandler;
35: import hero.interfaces.ProjectSession;
36: import hero.interfaces.ProjectSessionHome;
37: import hero.interfaces.ProjectSessionUtil;
38:
39: import javax.security.auth.login.LoginContext;
40:
41: public class Pattern09Discriminator {
42:
43: public static void main(String[] args) {
44: try {
45: // User Admin login
46: char[] password = { 't', 'o', 't', 'o' };
47: SimpleCallbackHandler handler = new SimpleCallbackHandler(
48: "admin", password);
49: LoginContext lc = new LoginContext("TestClient", handler);
50: lc.login();
51:
52: // Project Session Bean creation
53: ProjectSessionHome prjHome = (ProjectSessionHome) ProjectSessionUtil
54: .getHome();
55: ProjectSession prjSession = prjHome.create();
56:
57: // Model creation
58: System.out.print("\n Pattern 09 - Discriminator");
59: prjSession.initModel("Pattern 09 - Discriminator");
60:
61: // Add activities and set them to Non anticipable
62: prjSession.addNode("create_request",
63: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
64: prjSession.addNode("consult_db1",
65: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
66: prjSession.addNode("consult_db2",
67: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
68: prjSession.addNode("process_answer",
69: hero.interfaces.Constants.Nd.OR_JOIN_NODE);
70: prjSession.setNodeTraditional("create_request");
71: prjSession.setNodeTraditional("consult_db1");
72: prjSession.setNodeTraditional("consult_db2");
73: prjSession.setNodeTraditional("process_answer");
74:
75: // Add transitions between activities
76: prjSession.addEdge("create_request", "consult_db1");
77: prjSession.addEdge("create_request", "consult_db2");
78: prjSession.addEdge("consult_db1", "process_answer");
79: prjSession.addEdge("consult_db2", "process_answer");
80:
81: // Add and set a role for the user admin to execute the activities
82: prjSession.addRole("Executor",
83: "Rol that enables to execute the activities");
84: prjSession.setUserRole("admin", "Executor");
85: prjSession.setNodeRole("create_request", "Executor");
86: prjSession.setNodeRole("consult_db1", "Executor");
87: prjSession.setNodeRole("consult_db2", "Executor");
88: prjSession.setNodeRole("process_answer", "Executor");
89:
90: // Check model definition
91: prjSession.checkModelDefinition();
92:
93: System.out.println(" [ OK ]");
94: } catch (Exception e) {
95: System.out.println("\n\n [ ERROR ] : " + e);
96: e.printStackTrace();
97: } // Maybe something is wrong
98: }
99: }
|