[jboss-user] [JBoss jBPM] - Even though the task is not for that actor i get that task u

csplrj do-not-reply at jboss.com
Wed Jun 4 03:02:50 EDT 2008


Below is the code for the experiment
I have assigned the process to pool of actors
After that task there is another task which is assigned to a single actor 
on reaching that task Node I try to get the remaining tasks for c but when i try the following code
System.out.println("c1 "+ taskMgmtSession.findPooledTaskInstances("c").size());

it gives output as 1 and it reaches stage task2 even though through the assignment of task 2 its only applicable to actor "a".

System.out.println("c2 "+ ((TaskInstance)taskMgmtSession.findPooledTaskInstances("c").get(0)).getToken().getNode().getName());

gives output as task2

Thanks in advance

CSJakharia


processdefinition.xml

<?xml version="1.0" encoding="UTF-8"?>
  | 
  | <process-definition  xmlns="urn:jbpm.org:jpdl-3.2"  name="authoring">
  | 	<start-state name="start-state1">
  | 		<task>
  | 		</task>
  | 		<transition to="task1"></transition>
  | 	</start-state>
  | 
  | 
  | 	<task-node name="task1">
  | 		<description>
  | 			task1
  | 		</description>
  | 		<task>
  | 			<assignment class="com.workflow.AssignTask"></assignment>
  | 		</task>
  | 		<transition to="task2"></transition>
  | 	</task-node>
  | 
  | 	<task-node name="task2">
  | 		<description>
  | 			task2
  | 		</description>
  | 		<task>
  | 			<assignment class="com.workflow.AssignTask1"></assignment>
  | 		</task>
  | 		<transition to="end"></transition>
  | 	</task-node>
  | 
  | 	<node name="end">
  | 		<action class="com.workflow.HandleAction"> </action>
  | 		<transition to="end-state1"></transition>
  | 	</node>
  | 
  | 
  | 	<end-state name="end-state1">
  | 		
  | 	</end-state>
  | 
  | 
  | </process-definition>



AssignTask.java
public class AssignTask implements AssignmentHandler {
  | 
  | 	public void assign(Assignable assignable, ExecutionContext executionContext)
  | 			throws Exception {
  | 		// TODO Auto-generated method stub
  | 		String actors[]=new String[]{"a","b","c"};
  | 		assignable.setPooledActors(actors);
  | 	}
  | 
  | }

AssignTask1.java
public class AssignTask1 implements AssignmentHandler {
  | 
  | 	public void assign(Assignable assignable, ExecutionContext executionContext)
  | 			throws Exception {
  | 		// TODO Auto-generated method stub
  | 		assignable.setActorId("a");
  | 	}
  | 
  | }

Test.java

  | public class Test {
  | 	 static JbpmConfiguration jbpmConfiguration = null; 
  | 
  | 	 public static void deployProcessDefinition()
  | 	 {
  | 		try {
  | 			ProcessDefinition processDefinition = ProcessDefinition.parseXmlInputStream(new FileInputStream("D:\\WorkFlowAuthoringPOC\\src\\main\\jpdl\\a\\processdefinition.xml"));
  | 			JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
  | 			jbpmContext.deployProcessDefinition(processDefinition);
  | 			jbpmContext.close();
  | 		} catch (FileNotFoundException e) {
  | 			// TODO Auto-generated catch block
  | 			e.printStackTrace();
  | 		}
  | 	 }
  | 	public static void main(String[] args) {
  | 		try {
  | 			jbpmConfiguration = JbpmConfiguration.parseInputStream(new FileInputStream("D:\\Cobra\\workspace\\WorkFlowAuthoringPOC\\src\\main\\config\\jbpm.cfg.xml"));
  | 			jbpmConfiguration.createSchema();
  | 			deployProcessDefinition();
  | 			JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
  | 			System.out.println("jbpmContext.getActorId() "+jbpmContext.getActorId());
  | 			GraphSession graphSession = jbpmContext.getGraphSession();
  | 		      ProcessDefinition processDefinition = 
  | 		          graphSession.findLatestProcessDefinition("authoring");
  | 			ProcessInstance processInstance = new ProcessInstance(processDefinition);
  | 			Token token=processInstance.getRootToken();
  | 			  // Let's start the process execution, leaving the start-state 
  | 			  // over its default transition.
  | 			  token.signal();
  | 			  TaskInstance taskInstance = (TaskInstance)  
  | 		      processInstance
  | 		        .getTaskMgmtInstance()
  | 		        .getTaskInstances()
  | 		        .iterator().next();
  | 			  
  | 			  System.out.println("size "+processInstance.getTaskMgmtInstance().getTaskInstances().size());
  | 			  System.out.println("taskInstance.getActorId() " +taskInstance.getActorId());
  | 			  System.out.println("taskInstance.getPooledActors() " +taskInstance.getPooledActors());
  | 			  TaskMgmtSession taskMgmtSession= jbpmContext.getTaskMgmtSession();
  | 			  System.out.println(taskMgmtSession.findPooledTaskInstances("a").size());
  | 			  System.out.println(taskMgmtSession.findPooledTaskInstances("b").size());
  | 			  ((TaskInstance)taskMgmtSession.findPooledTaskInstances("a").get(0)).getToken().signal();
  | 			  
  | 			  System.out.println("a1 "+ taskMgmtSession.findPooledTaskInstances("a").size());
  | 			  System.out.println("b1 "+ taskMgmtSession.findPooledTaskInstances("b").size());
  | 			  System.out.println("c1 "+ taskMgmtSession.findPooledTaskInstances("c").size());
  | 			  System.out.println("a1 "+ ((TaskInstance)taskMgmtSession.findPooledTaskInstances("a").get(0)).getToken().getNode().getName());
  | 			  System.out.println("c2 "+ ((TaskInstance)taskMgmtSession.findPooledTaskInstances("c").get(0)).getToken().getNode().getName());
  | 			  System.out.println("a1 "+ taskMgmtSession.findTaskInstances("a").size());
  | 			  System.out.println("b1 "+ taskMgmtSession.findTaskInstances("b").size());
  | 			  System.out.println("c1 "+ taskMgmtSession.findTaskInstances("c").size());
  | 			  
  | 			  
  | 		} catch (FileNotFoundException e) {
  | 			// TODO Auto-generated catch block
  | 			e.printStackTrace();
  | 		}
  | 	}
  | 
  | }
  | 

part of Sysout output
a1 1
b1 1
c1 1
a1 task2
c2 task2
a1 1
b1 0
c1 0



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

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



More information about the jboss-user mailing list