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