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 01 : Sequence
24: * Author : Jordi Anguela
25: * Date : 2006/03/01
26: --------------------------------------------------------------------------
27: * Example
28: * Activity send_bill is executed after the execution of activity
29: * send_goods.
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 Pattern01Sequence {
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 01 - Sequence");
58: prjSession.initModel("Pattern 01 - Sequence");
59:
60: // Add activities and set them to Non anticipable
61: prjSession.addNode("send_goods",
62: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
63: prjSession.addNode("send_bill",
64: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
65: prjSession.setNodeTraditional("send_goods");
66: prjSession.setNodeTraditional("send_bill");
67:
68: // Add transitions between activities
69: prjSession.addEdge("send_goods", "send_bill");
70:
71: // Add and set a role for the user admin to execute the activities
72: prjSession.addRole("Executor",
73: "Rol that enables to execute the activities");
74: prjSession.setUserRole("admin", "Executor");
75: prjSession.setNodeRole("send_goods", "Executor");
76: prjSession.setNodeRole("send_bill", "Executor");
77:
78: // Check model definition
79: prjSession.checkModelDefinition();
80:
81: System.out.println(" [ OK ]");
82: } catch (Exception e) {
83: System.out.println("\n\n [ ERROR ] : " + e);
84: e.printStackTrace();
85: } // Maybe something is wrong
86: }
87: }
|