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 02 : Parallel Split
24: * Author : Jordi Anguela
25: * Date : 2006/03/01
26: --------------------------------------------------------------------------
27: * Example
28: * The execution of the activity payment enables the execution of the
29: * activities ship_goods and inform_customer.
30: --------------------------------------------------------------------------
31: */package hero.client.samples.patterns.src;
32:
33: import hero.client.test.SimpleCallbackHandler;
34: import hero.interfaces.ProjectSession;
35: import hero.interfaces.ProjectSessionHome;
36: import hero.interfaces.ProjectSessionUtil;
37:
38: import javax.security.auth.login.LoginContext;
39:
40: public class Pattern02ParallelSplit {
41:
42: public static void main(String[] args) {
43: try {
44: // User Admin login
45: char[] password = { 't', 'o', 't', 'o' };
46: SimpleCallbackHandler handler = new SimpleCallbackHandler(
47: "admin", password);
48: LoginContext lc = new LoginContext("TestClient", handler);
49: lc.login();
50:
51: // Project Session Bean creation
52: ProjectSessionHome prjHome = (ProjectSessionHome) ProjectSessionUtil
53: .getHome();
54: ProjectSession prjSession = prjHome.create();
55:
56: // Model creation
57: System.out.print("\n Pattern 02 - Parallel Split");
58: prjSession.initModel("Pattern 02 - Parallel Split");
59:
60: // Add activities and set them to Non anticipable
61: prjSession.addNode("payment",
62: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
63: prjSession.addNode("ship_goods",
64: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
65: prjSession.addNode("inform_costumer",
66: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
67: prjSession.setNodeTraditional("payment");
68: prjSession.setNodeTraditional("ship_goods");
69: prjSession.setNodeTraditional("inform_costumer");
70:
71: // Add transitions between activities
72: prjSession.addEdge("payment", "ship_goods");
73: prjSession.addEdge("payment", "inform_costumer");
74:
75: // Add and set a role for the user admin to execute the activities
76: prjSession.addRole("Executor",
77: "Rol that enables to execute the activities");
78: prjSession.setUserRole("admin", "Executor");
79: prjSession.setNodeRole("payment", "Executor");
80: prjSession.setNodeRole("ship_goods", "Executor");
81: prjSession.setNodeRole("inform_costumer", "Executor");
82:
83: // Check model definition
84: prjSession.checkModelDefinition();
85:
86: System.out.println(" [ OK ]");
87: } catch (Exception e) {
88: System.out.println("\n\n [ ERROR ] : " + e);
89: e.printStackTrace();
90: } // Maybe something is wrong
91: }
92: }
|