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 03 : Synchronization
24: * Author : Jordi Anguela
25: * Date : 2006/03/01
26: --------------------------------------------------------------------------
27: * Example
28: * Activity archive is enabled after the completion of both activity
29: * send_tickets and activity receive_payment.
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 Pattern03Synchronization {
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 03 - Synchronization");
58: prjSession.initModel("Pattern 03 - Synchronization");
59:
60: // Add activities and set them to Non anticipable
61: prjSession.addNode("send_tickets",
62: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
63: prjSession.addNode("receive_payment",
64: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
65: prjSession.addNode("archive",
66: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
67: prjSession.setNodeTraditional("send_tickets");
68: prjSession.setNodeTraditional("receive_payment");
69: prjSession.setNodeTraditional("archive");
70:
71: // Add transitions between activities
72: prjSession.addEdge("send_tickets", "archive");
73: prjSession.addEdge("receive_payment", "archive");
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("send_tickets", "Executor");
80: prjSession.setNodeRole("receive_payment", "Executor");
81: prjSession.setNodeRole("archive", "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: }
|