001: /**
002: *
003: * Bonita
004: * Copyright (C) 1999 Bull S.A.
005: * Bull 68 route de versailles 78434 Louveciennes Cedex France
006: * Further information: bonita@objectweb.org
007: *
008: * This library is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Lesser General Public
010: * License as published by the Free Software Foundation; either
011: * version 2.1 of the License, or any later version.
012: *
013: * This library is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public
019: * License along with this library; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
021: * USA
022: *
023: *
024: --------------------------------------------------------------------------
025: * $Id: ProcessModel.java,v 1.4 2004/11/10 17:10:50 mvaldes Exp $
026: *
027: --------------------------------------------------------------------------
028: */package hero.client.samples;
029:
030: import javax.security.auth.login.LoginContext;
031: import hero.client.test.SimpleCallbackHandler;
032:
033: import hero.interfaces.ProjectSession;
034: import hero.interfaces.ProjectSessionHome;
035: import hero.interfaces.ProjectSessionUtil;
036:
037: import hero.interfaces.Constants;
038:
039: public class ProcessModel {
040:
041: static public void main(String[] args) throws Exception {
042: // Admin login
043: char[] password = { 't', 'o', 't', 'o' };
044: SimpleCallbackHandler handler = new SimpleCallbackHandler(
045: "admin", password);
046: LoginContext lc = new LoginContext("TestClient", handler);
047: lc.login();
048:
049: // Process Model creation by user admin
050: ProjectSessionHome lHome = ProjectSessionUtil.getHome();
051: ProjectSession lProject = lHome.create();
052: lProject.initModel("e-citizen");
053:
054: // Activities creation (traditional execution mode)
055: lProject.addNode("Subscription order",
056: Constants.Nd.AND_JOIN_NODE);
057: lProject.setNodeTraditional("Subscription order");
058:
059: lProject.addNode("Verify order", Constants.Nd.AND_JOIN_NODE);
060: lProject.setNodeTraditional("Verify order");
061:
062: lProject.addNode("Modify order", Constants.Nd.AND_JOIN_NODE);
063: lProject.setNodeTraditional("Modify order");
064:
065: lProject.addNode("Verify changes", Constants.Nd.AND_JOIN_NODE);
066: lProject.setNodeTraditional("Verify changes");
067:
068: lProject.addNode("Card order",
069: Constants.Nd.OR_JOIN_AUTOMATIC_NODE);
070: lProject.setNodeTraditional("Card order");
071:
072: lProject.addNode("Receive card", Constants.Nd.AND_JOIN_NODE);
073: lProject.setNodeTraditional("Receive card");
074:
075: lProject.addNode("Send card", Constants.Nd.AND_JOIN_NODE);
076: lProject.setNodeTraditional("Send card");
077:
078: // Set edges between nodes
079: lProject.addEdge("Subscription order", "Verify order");
080: String inst_mod = lProject.addEdge("Verify order",
081: "Modify order");
082: lProject.addEdge("Modify order", "Verify changes");
083: String inst_dem = lProject
084: .addEdge("Verify order", "Card order");
085: lProject.addEdge("Verify changes", "Card order");
086: lProject.addEdge("Card order", "Receive card");
087: lProject.addEdge("Receive card", "Send card");
088:
089: // Add iteration between Verify changes and Modify order
090: lProject.addIteration("Verify changes", "Modify order",
091: "correct.equals(\"ok\")");
092:
093: // Set process properties
094: lProject.setProperty("userId", "");
095: lProject.setProperty("recordId", "");
096: lProject.setProperty("orderId", "");
097:
098: // Set node property
099: lProject.setNodeProperty("Verify order", "correct", "", false);
100:
101: // Set edge conditions
102: lProject.setEdgeCondition(inst_mod, "correct.equals(\"nok\")");
103: lProject.setEdgeCondition(inst_dem, "correct.equals(\"ok\")");
104:
105: // Set node hook
106: String script = "import hero.interfaces.BnProjectLocal;\n"
107: + "import hero.interfaces.BnNodeLocal;\n"
108: + "afterTerminate (Object b,Object n) {\n\n\n"
109: + "System.out.println(\"Card order... \");" + "}";
110: lProject.addNodeInterHook("Card order", "Card order",
111: Constants.Nd.AFTERTERMINATE,
112: Constants.Hook.BSINTERACTIVE, script);
113:
114: // Creates two process roles
115: lProject.addRole("agent", "agent");
116: lProject.addRole("preCitizen", "preCitizen");
117:
118: // Set role to activities
119: lProject.setNodeRole("Verify order", "agent");
120: lProject.setNodeRole("Verify changes", "agent");
121: lProject.setNodeRole("Receive card", "agent");
122: lProject.setNodeRole("Send card", "agent");
123: lProject.setNodeRole("Modify order", "preCitizen");
124: }
125:
126: }
|