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: * Class AbortSchema.java created by Jordi Anguela - June 2006
025: --------------------------------------------------------------------------
026: */package hero.client.samples.iterations.src;
027:
028: import hero.client.test.SimpleCallbackHandler;
029: import hero.interfaces.Constants;
030: import hero.interfaces.ProjectSession;
031: import hero.interfaces.ProjectSessionHome;
032: import hero.interfaces.ProjectSessionUtil;
033:
034: import javax.security.auth.login.LoginContext;
035:
036: public class AbortSchema {
037: static public void main(String[] args) throws Exception {
038: try {
039: // User Admin login
040: char[] password = { 't', 'o', 't', 'o' };
041: SimpleCallbackHandler handler = new SimpleCallbackHandler(
042: "admin", password);
043: LoginContext lc = new LoginContext("TestClient", handler);
044: lc.login();
045:
046: ProjectSessionHome projectSessionh = ProjectSessionUtil
047: .getHome();
048: ProjectSession ps = projectSessionh.create();
049: System.out.print("\n Creating AbortSchema model");
050: ps.initModel("AbortSchema");
051:
052: // Set Properties
053: ps.setProperty("abort", "false");
054:
055: // Set Nodes
056: ps.addNode("Start", Constants.Nd.AND_JOIN_NODE);
057: ps.addNode("A1", Constants.Nd.AND_JOIN_NODE);
058: ps.addNode("A2", Constants.Nd.AND_JOIN_NODE);
059: ps.addNode("B1", Constants.Nd.AND_JOIN_NODE);
060: ps.addNode("B2", Constants.Nd.AND_JOIN_NODE);
061: ps.addNode("Abort", Constants.Nd.OR_JOIN_NODE);
062:
063: ps.setNodeTraditional("Start");
064: ps.setNodeTraditional("A1");
065: ps.setNodeTraditional("A2");
066: ps.setNodeTraditional("B1");
067: ps.setNodeTraditional("B2");
068: ps.setNodeTraditional("Abort");
069:
070: // Set Edges
071: ps.addEdge("Start", "A1");
072: ps.addEdge("Start", "B1");
073: String fromA1toA2 = ps.addEdge("A1", "A2");
074: String fromB1toB2 = ps.addEdge("B1", "B2");
075: String fromA1toAbort = ps.addEdge("A1", "Abort");
076: String fromA2toAbort = ps.addEdge("A2", "Abort");
077: String fromB1toAbort = ps.addEdge("B1", "Abort");
078: String fromB2toAbort = ps.addEdge("B2", "Abort");
079:
080: // Set transition conditions
081: ps.setEdgeCondition(fromA1toA2, "abort.equals(\"false\")");
082: ps.setEdgeCondition(fromB1toB2, "abort.equals(\"false\")");
083: ps
084: .setEdgeCondition(fromA1toAbort,
085: "abort.equals(\"true\")");
086: ps
087: .setEdgeCondition(fromA2toAbort,
088: "abort.equals(\"true\")");
089: ps
090: .setEdgeCondition(fromB1toAbort,
091: "abort.equals(\"true\")");
092: ps
093: .setEdgeCondition(fromB2toAbort,
094: "abort.equals(\"true\")");
095:
096: // Iteration
097: ps.addIteration("Abort", "Start", "abort.equals(\"true\")");
098:
099: // Set activity roles
100: ps.addRole("Administrator", "The system administator role");
101: ps.setNodeRole("Start", "Administrator");
102: ps.setNodeRole("A1", "Administrator");
103: ps.setNodeRole("A2", "Administrator");
104: ps.setNodeRole("B1", "Administrator");
105: ps.setNodeRole("B2", "Administrator");
106: ps.setNodeRole("Abort", "Administrator");
107:
108: // Set role mapper
109: ps.addRoleMapper("Administrator", "AdministratorMapper",
110: Constants.Mapper.PROPERTIES);
111:
112: // Checks if the model is correctly defined
113: ps.checkModelDefinition();
114:
115: System.out.println(" [ OK ]");
116: } catch (Exception e) {
117: System.out.println("\n\n [ ERROR ] : " + e);
118: e.printStackTrace();
119: }
120: }
121: }
|