01: package client.Java_client;
02:
03: import javax.security.auth.login.LoginContext;
04: import hero.client.test.SimpleCallbackHandler;
05:
06: import hero.interfaces.*;
07:
08: import java.util.*;
09:
10: public class ApprovalWorkflow {
11:
12: static public void main(String[] args) throws Exception {
13:
14: char[] password = { 'b', 's', 'o', 'a' };
15: SimpleCallbackHandler handler = new SimpleCallbackHandler(
16: "bsoa", password);
17: LoginContext lc = new LoginContext("TestClient", handler);
18: lc.login();
19:
20: ProjectSessionHome projectSessionh = ProjectSessionUtil
21: .getHome();
22: ProjectSession pss = projectSessionh.create();
23:
24: pss.initModel("Approval_workflow");
25:
26: // Set project properties
27: pss.setProperty("User_name", "");
28: pss.setProperty("Phone_number", "");
29: pss.setProperty("Email_address", "");
30:
31: Collection applications = new ArrayList();
32: applications.add("application1");
33: applications.add("application2");
34: applications.add("application3");
35: pss.setPropertyPossibleValues("Available_applications",
36: applications);
37: pss.setProperty("Available_applications", "application1");
38:
39: // Set activities
40: pss.addNode("Approval", Constants.Nd.AND_JOIN_NODE);
41: pss.addNode("Acceptance", Constants.Nd.AND_JOIN_AUTOMATIC_NODE);
42: pss.addNode("Reject", Constants.Nd.AND_JOIN_AUTOMATIC_NODE);
43: pss.setNodeTraditional("Approval");
44: pss.setNodeTraditional("Acceptance");
45: pss.setNodeTraditional("Reject");
46:
47: // Set node properties
48: Collection possible_decision = new ArrayList();
49: possible_decision.add("grant");
50: possible_decision.add("reject");
51: pss.setNodePropertyPossibleValues("Approval", "decision",
52: possible_decision);
53: pss.setNodeProperty("Approval", "decision", "reject", true);
54:
55: // Set transitions
56: String approval_acceptance = pss.addEdge("Approval",
57: "Acceptance");
58: String approval_reject = pss.addEdge("Approval", "Reject");
59: pss.setEdgeCondition(approval_acceptance,
60: "decision.equals(\"grant\")");
61: pss.setEdgeCondition(approval_reject,
62: "decision.equals(\"reject\")");
63:
64: // Set activity roles
65: pss.addRole("Administrator", "The system administator role");
66: pss.setNodeRole("Approval", "Administrator");
67:
68: // Set role mapper
69: pss.addRoleMapper("Administrator",
70: "hero.mapper.AdministratorMapper",
71: Constants.Mapper.PROPERTIES);
72:
73: // Check the defition model
74: pss.checkModelDefinition();
75: }
76: }
|