/**
*
* Bonita
* Copyright (C) 1999 Bull S.A.
* Bull 68 route de versailles 78434 Louveciennes Cedex France
* Further information: bonita@objectweb.org
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
*
--------------------------------------------------------------------------
* $Id: ProcessModel.java,v 1.4 2004/11/10 17:10:50 mvaldes Exp $
*
--------------------------------------------------------------------------
*/
package hero.client.samples;
import javax.security.auth.login.LoginContext;
import hero.client.test.SimpleCallbackHandler;
import hero.interfaces.ProjectSession;
import hero.interfaces.ProjectSessionHome;
import hero.interfaces.ProjectSessionUtil;
import hero.interfaces.Constants;
public class ProcessModel {
static public void main(String[] args) throws Exception{
// Admin login
char[] password={'t','o','t','o'};
SimpleCallbackHandler handler = new SimpleCallbackHandler("admin",password);
LoginContext lc = new LoginContext("TestClient", handler);
lc.login();
// Process Model creation by user admin
ProjectSessionHome lHome=ProjectSessionUtil.getHome();
ProjectSession lProject = lHome.create();
lProject.initModel("e-citizen");
// Activities creation (traditional execution mode)
lProject.addNode("Subscription order",Constants.Nd.AND_JOIN_NODE);
lProject.setNodeTraditional("Subscription order");
lProject.addNode("Verify order",Constants.Nd.AND_JOIN_NODE);
lProject.setNodeTraditional("Verify order");
lProject.addNode("Modify order",Constants.Nd.AND_JOIN_NODE);
lProject.setNodeTraditional("Modify order");
lProject.addNode("Verify changes",Constants.Nd.AND_JOIN_NODE);
lProject.setNodeTraditional("Verify changes");
lProject.addNode("Card order",Constants.Nd.OR_JOIN_AUTOMATIC_NODE);
lProject.setNodeTraditional("Card order");
lProject.addNode("Receive card",Constants.Nd.AND_JOIN_NODE);
lProject.setNodeTraditional("Receive card");
lProject.addNode("Send card",Constants.Nd.AND_JOIN_NODE);
lProject.setNodeTraditional("Send card");
// Set edges between nodes
lProject.addEdge("Subscription order","Verify order");
String inst_mod=lProject.addEdge("Verify order","Modify order");
lProject.addEdge("Modify order","Verify changes");
String inst_dem=lProject.addEdge("Verify order","Card order");
lProject.addEdge("Verify changes","Card order");
lProject.addEdge("Card order","Receive card");
lProject.addEdge("Receive card","Send card");
// Add iteration between Verify changes and Modify order
lProject.addIteration("Verify changes","Modify order","correct.equals(\"ok\")");
// Set process properties
lProject.setProperty("userId","");
lProject.setProperty("recordId","");
lProject.setProperty("orderId","");
// Set node property
lProject.setNodeProperty("Verify order","correct","",false);
// Set edge conditions
lProject.setEdgeCondition(inst_mod,"correct.equals(\"nok\")");
lProject.setEdgeCondition(inst_dem,"correct.equals(\"ok\")");
// Set node hook
String script =
"import hero.interfaces.BnProjectLocal;\n"
+ "import hero.interfaces.BnNodeLocal;\n"
+ "afterTerminate (Object b,Object n) {\n\n\n"
+ "System.out.println(\"Card order... \");"
+ "}";
lProject.addNodeInterHook("Card order","Card order",Constants.Nd.AFTERTERMINATE,Constants.Hook.BSINTERACTIVE,script);
// Creates two process roles
lProject.addRole("agent","agent");
lProject.addRole("preCitizen","preCitizen");
// Set role to activities
lProject.setNodeRole("Verify order","agent");
lProject.setNodeRole("Verify changes","agent");
lProject.setNodeRole("Receive card","agent");
lProject.setNodeRole("Send card","agent");
lProject.setNodeRole("Modify order","preCitizen");
}
}
|