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