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