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 MultiIterationsNode.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 MultiIterationsNode {
037: static public void main(String[] args) throws Exception {
038:
039: System.out.println(" **** MultiIterationsNode **** ");
040: System.out.println(" * * ");
041: System.out.println(" * path=A * ");
042: System.out.println(" * - - - - - - - - * ");
043: System.out.println(" * | path=B | * ");
044: System.out.println(" * | - - - - | * ");
045: System.out.println(" * | | ||path=D * ");
046: System.out.println(" * A----->B----->C----->D * ");
047: System.out.println(" * |_| * ");
048: System.out.println(" * path=C * ");
049: System.out.println(" * * ");
050: System.out.println(" ********************************** ");
051:
052: // User Admin login
053: char[] password = { 't', 'o', 't', 'o' };
054: SimpleCallbackHandler handler = new SimpleCallbackHandler(
055: "admin", password);
056: LoginContext lc = new LoginContext("TestClient", handler);
057: lc.login();
058:
059: // Project Session Bean Creation using Remote Interface
060: ProjectSessionHome prjHome = (ProjectSessionHome) ProjectSessionUtil
061: .getHome();
062: ProjectSession prjSession = prjHome.create();
063:
064: // Process creation by user admin
065: System.out.println("\nMultiIterationsNode model creation");
066: prjSession.initModel("MultiIterationsNode");
067:
068: System.out.println("\nActivities creation");
069: try {
070: prjSession.addNode("A",
071: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
072: prjSession.addNode("B",
073: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
074: prjSession.addNode("C",
075: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
076: prjSession.addNode("D",
077: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
078: } catch (Exception e) {
079: System.out.println(" --> " + e);
080: }
081:
082: System.out.println("Setting Activities types");
083: try {
084: prjSession.setNodeTraditional("A");
085: prjSession.setNodeTraditional("B");
086: prjSession.setNodeTraditional("C");
087: prjSession.setNodeTraditional("D");
088: } catch (Exception e) {
089: System.out.println(" --> " + e);
090: }
091:
092: System.out.println("Adding project properties");
093: try {
094: prjSession.setProperty("path", "A"); // Decides which iteration we have to take
095: } catch (Exception e) {
096: System.out.println(e);
097: }
098:
099: System.out.println("Adding edges between activities");
100: String fromCtoD = ""; // Exit conditions from the iterations
101: try {
102: prjSession.addEdge("A", "B");
103: prjSession.addEdge("B", "C");
104: fromCtoD = prjSession.addEdge("C", "D");
105: } catch (Exception e) {
106: System.out.println(" --> " + e);
107: }
108:
109: System.out.println("Adding 'C' edge condition");
110: try {
111: prjSession.setEdgeCondition(fromCtoD,
112: "path.equals(\"D\") || path.equals(\"d\")");
113: } catch (Exception e) {
114: System.out.println(" --> " + e);
115: }
116:
117: System.out
118: .println("Adding iterations: between C--->A & C--->B & C--->C");
119: try {
120: prjSession.addIteration("C", "A",
121: "path.equals(\"A\") || path.equals(\"a\")");
122: prjSession.addIteration("C", "B",
123: "path.equals(\"B\") || path.equals(\"b\")");
124: prjSession.addIteration("C", "C",
125: "path.equals(\"C\") || path.equals(\"c\")");
126: } catch (Exception e) {
127: System.out.println(" --> " + e);
128: }
129:
130: System.out
131: .println("Settind activity roles and the role mapper");
132: try {
133: prjSession.addRole("Administrator",
134: "The system administator role");
135: prjSession.setNodeRole("A", "Administrator");
136: prjSession.setNodeRole("B", "Administrator");
137: prjSession.setNodeRole("C", "Administrator");
138: prjSession.setNodeRole("D", "Administrator");
139:
140: prjSession.addRoleMapper("Administrator",
141: "AdministratorMapper", Constants.Mapper.PROPERTIES);
142: } catch (Exception e) {
143: System.out.println(" --> " + e);
144: }
145:
146: System.out.println("Checking model definition");
147: try {
148: prjSession.checkModelDefinition();
149: } catch (Exception e) {
150: System.out.println(" --> " + e);
151: }
152:
153: System.out.println(" --- FINISHED! ---");
154: }
155: }
|