001: /**
002: * Bonita
003: * Copyright (C) 1999 Bull S.A.
004: * Bull 68 route de versailles 78434 Louveciennes Cedex France
005: * Further information: bonita@objectweb.org
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
020: * USA
021: --------------------------------------------------------------------------
022: * BONITA Workflow Patterns sample
023: * Pattern Extra 01 : Explicit Termination
024: * Author : Jordi Anguela
025: * Date : 2006/03/01
026: --------------------------------------------------------------------------
027: * Example
028: * This example uses a special activity called 'BonitaEnd' that
029: * terminates explicitly the execution of the process when it is reached.
030: * We will use the same example as in pattern05 - Simple Merge but now
031: * it is not necessary to execute both paths to terminate.
032: --------------------------------------------------------------------------
033: */package hero.client.samples.patterns.src;
034:
035: import hero.client.test.SimpleCallbackHandler;
036: import hero.interfaces.ProjectSession;
037: import hero.interfaces.ProjectSessionHome;
038: import hero.interfaces.ProjectSessionUtil;
039:
040: import javax.security.auth.login.LoginContext;
041:
042: public class PatternExtra1ExplicitTermination {
043:
044: public static void main(String[] args) {
045: try {
046: // User Admin login
047: char[] password = { 't', 'o', 't', 'o' };
048: SimpleCallbackHandler handler = new SimpleCallbackHandler(
049: "admin", password);
050: LoginContext lc = new LoginContext("TestClient", handler);
051: lc.login();
052:
053: // Project Session Bean creation
054: ProjectSessionHome prjHome = (ProjectSessionHome) ProjectSessionUtil
055: .getHome();
056: ProjectSession prjSession = prjHome.create();
057:
058: // Model creation
059: System.out
060: .print("\n Pattern Extra 1 - Explicit Termination");
061: prjSession
062: .initModel("Pattern Extra 1 - Explicit Termination");
063:
064: // Add activities and set them to Non anticipable
065: prjSession.addNode("pay_damage",
066: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
067: prjSession.addNode("contact_customer",
068: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
069: prjSession.addNode("archive_claim",
070: hero.interfaces.Constants.Nd.OR_JOIN_NODE);
071: prjSession.addNode("after_archive",
072: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
073: prjSession
074: .addNode(
075: "BonitaEnd",
076: hero.interfaces.Constants.Nd.AND_JOIN_AUTOMATIC_NODE);
077: prjSession.setNodeTraditional("pay_damage");
078: prjSession.setNodeTraditional("contact_customer");
079: prjSession.setNodeTraditional("archive_claim");
080: prjSession.setNodeTraditional("after_archive");
081: prjSession.setNodeTraditional("BonitaEnd");
082:
083: // Add transitions between activities
084: prjSession.addEdge("pay_damage", "archive_claim");
085: prjSession.addEdge("contact_customer", "archive_claim");
086: prjSession.addEdge("archive_claim", "after_archive");
087: prjSession.addEdge("after_archive", "BonitaEnd");
088:
089: // Add and set a role for the user admin to execute the activities
090: prjSession.addRole("Executor",
091: "Rol that enables to execute the activities");
092: prjSession.setUserRole("admin", "Executor");
093: prjSession.setNodeRole("pay_damage", "Executor");
094: prjSession.setNodeRole("contact_customer", "Executor");
095: prjSession.setNodeRole("archive_claim", "Executor");
096: prjSession.setNodeRole("after_archive", "Executor");
097:
098: // Check model definition
099: prjSession.checkModelDefinition();
100:
101: System.out.println(" [ OK ]");
102: } catch (Exception e) {
103: System.out.println("\n\n [ ERROR ] : " + e);
104: e.printStackTrace();
105: } // Maybe something is wrong
106: }
107: }
|