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 08 : Multi Merge
024: * Author : Jordi Anguela
025: * Date : 2006/03/01
026: --------------------------------------------------------------------------
027: * Example
028: * Two activities audit_application and process_application running in
029: * parallel which are both followed by an activity close_case. Use of
030: * SubProcesses to do the same activities multiple times.
031: --------------------------------------------------------------------------
032: */package hero.client.samples.patterns.src;
033:
034: import hero.client.test.SimpleCallbackHandler;
035: import hero.interfaces.Constants;
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 Pattern08MultiMerge {
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.print("\n Pattern 08 - Multi Merge");
060: prjSession.initModel("Pattern 08 - Multi Merge");
061:
062: // Add activities and set them to Non anticipable
063: prjSession.addNode("audit_application",
064: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
065: prjSession.addNode("process_aplication",
066: hero.interfaces.Constants.Nd.AND_JOIN_NODE);
067: prjSession.setNodeTraditional("audit_application");
068: prjSession.setNodeTraditional("process_aplication");
069:
070: // SubProcess definition
071: ProjectSession prjSession2 = prjHome.create();
072: prjSession2.initModel("Close case (SubProcess)");
073: prjSession2.addNode("prepare_report",
074: Constants.Nd.AND_JOIN_NODE);
075: prjSession2.addNode("archive_case",
076: Constants.Nd.AND_JOIN_NODE);
077: prjSession2.setNodeTraditional("prepare_report");
078: prjSession2.setNodeTraditional("archive_case");
079: prjSession2.addEdge("prepare_report", "archive_case");
080: prjSession2
081: .addRole("Executor",
082: "Rol that enables to execute the activities inside the SubProcess");
083: prjSession2.setUserRole("admin", "Executor");
084: prjSession2.setNodeRole("prepare_report", "Executor");
085: prjSession2.setNodeRole("archive_case", "Executor");
086: prjSession2.remove();
087:
088: // SubProcess instantiation (one instance for each path)
089: prjSession.addNodeSubProcess("close_case1",
090: "Close case (SubProcess)");
091: prjSession.addNodeSubProcess("close_case2",
092: "Close case (SubProcess)");
093:
094: // Add transitions between activities
095: prjSession.addEdge("audit_application", "close_case1");
096: prjSession.addEdge("process_aplication", "close_case2");
097:
098: // Add and set a role for the user admin to execute the activities
099: prjSession.addRole("Executor",
100: "Rol that enables to execute the activities");
101: prjSession.setUserRole("admin", "Executor");
102: prjSession.setNodeRole("audit_application", "Executor");
103: prjSession.setNodeRole("process_aplication", "Executor");
104: prjSession.setNodeRole("close_case1", "Executor");
105: prjSession.setNodeRole("close_case2", "Executor");
106:
107: // Check model definition
108: prjSession.checkModelDefinition();
109:
110: System.out.println(" [ OK ]");
111: } catch (Exception e) {
112: System.out.println("\n\n [ ERROR ] : " + e);
113: e.printStackTrace();
114: } // Maybe something is wrong
115: }
116: }
|