Completed!!  Below is the testCase that I created (modified from the 
workflowpattern#14.)

This test case shows the creation of tasks (from Wfp#14) based on the number of 
users that need to be assigned the task.  The task node IS NOT complete, until 
everyone completes their own assigned tasks.

Thanks Ronald, for your feedback.


  | public class Wfp14WithAssignment extends TestCase {
  |               
  |               public static class CreateTasks implements ActionHandler {
  |                 private static final long serialVersionUID = 1L;
  |                 public void execute(ExecutionContext executionContext) 
throws Exception {
  |                   TaskMgmtDefinition tmd = (TaskMgmtDefinition) 
executionContext.getDefinition(TaskMgmtDefinition.class);
  |                   Task task = tmd.getTask("watch movie amadeus");
  |                   
  |                   // This creates the tasks, and assigns an actor to it
  |                   TaskMgmtInstance tmi = 
executionContext.getTaskMgmtInstance();
  |                   for (int i = 0; i<userListing.size(); i++) {
  |                       TaskInstance taskInstance = 
tmi.createTaskInstance(task, executionContext.getToken());
  |                   taskInstance.setActorId((String)userListing.get(i));
  |                   }
  |                 }
  |               }
  | 
  |               public static ProcessDefinition processDefinition = 
ProcessDefinition.parseXmlString(
  |                 "<process-definition>" +
  |                 "  <start-state name='a'>" +
  |                 "    <transition to='b' />" +
  |                 "  </start-state>" +
  |                 "  <state name='b'>" +
  |                 "    <transition to='t' />" +
  |                 "  </state>" +
  |                 "  <task-node name='t' create-tasks='false'>" +
  |                 "    <event type='node-enter'>" +
  |                 "      <action 
class='org.thepaxson5.jbpm.Wfp14WithAssignment$CreateTasks' />" +
  |                 "    </event>" +
  |                 "    <task name='watch movie amadeus' />" +
  |                 "    <transition to='c' />" +
  |                 "  </task-node>" +
  |                 "  <state name='c' />" +
  |                 "</process-definition>"
  |               );
  |               
  |               public static Node t = processDefinition.getNode("t");
  |               public static Node c = processDefinition.getNode("c");
  |               public static List userListing = new ArrayList();
  |               
  |               public void testAprioriRuntimeKnowledgeScenario4() {
  |                       // 3 Users have been assigned to this task.
  |                       // All 3 users MUST complete their assignments before
  |                       // processing can continue
  |                         userListing.add("user1");
  |                         userListing.add("user2");
  |                         userListing.add("user3");
  |                         
  |                         ProcessInstance processInstance = new 
ProcessInstance(processDefinition);
  |                         Token token = processInstance.getRootToken();
  |                         processInstance.signal();
  |                         processInstance.signal();
  |                         
  |                         assertSame(t, token.getNode());
  |                         //End the task for user1
  |                         endOneTask(token,"user1");
  |                         //Are we still on the node 't'
  |                         assertSame(t, token.getNode());
  |                         
  |                         //End the task for user2
  |                         endOneTask(token, "user2");
  |                         //Are we still on the node 't'
  |                         assertSame(t, token.getNode());
  |                         
  |                         //End the task for user3
  |                         endOneTask(token, "user3");
  |                         //We should now be on node 'c'
  |                         assertSame(c, token.getNode());
  | 
  |                       }
  |                       
  |                       public static void endOneTask(Token token, String 
actorId) {
  |                               TaskMgmtInstance tmi = 
(TaskMgmtInstance)token.getProcessInstance().getInstance(TaskMgmtInstance.class);
  |                               Iterator allTasks = 
tmi.getUnfinishedTasks(token).iterator();
  |                               while (allTasks.hasNext()){
  |                                       TaskInstance taskInstance = 
(TaskInstance)allTasks.next();
  |                                       if (taskInstance.getActorId() == 
actorId) {
  |                                               taskInstance.end();
  |                                       }
  |                               }
  |                       }
  | 
  | }
  | 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3940424#3940424

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3940424


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to