[JBoss jBPM] - Re: ProcessState getSubProcessDefinition is null
by don_t
I tried without late binding and got same result. However after looking at the unit test it seems the subprocess need to be set explicitly and the superprocess then persisted in the database.
| // create the subprocess
| ProcessDefinition subProcessDefinition = new ProcessDefinition("sub");
| // store the subprocess in the database
| graphSession.saveProcessDefinition(subProcessDefinition);
|
| // create the super process
| ProcessDefinition superProcessDefinition = ProcessDefinition.parseXmlString(
| "<process-definition name='super'>" +
| " <process-state name='subprocess' />" +
| "</process-definition>");
| // resolve the reference to the subprocess
| ProcessState processState = (ProcessState) superProcessDefinition.getNode("subprocess");
| processState.setSubProcessDefinition(subProcessDefinition);
|
| // save and reload the superprocess
| superProcessDefinition = saveAndReload(superProcessDefinition);
|
| processState = (ProcessState) superProcessDefinition.getNode("subprocess");
| assertNotNull("sub", processState.getSubProcessDefinition().getName());
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4192292#4192292
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4192292
17 years, 4 months
[JBoss jBPM] - Does AssignmentHandler work within the start node??
by ardavan
Hi,
I can't assign the actorid that I want for a simple start node:
As a test case I am using a simple processdefinition:
| <?xml version="1.0" encoding="UTF-8"?>
| <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="test">
|
| <start-state name="Submission">
| <task name="taskSubmission">
| <assignment class="jbpm.taskmgmt.EmiliAssignmentHandler"></assignment>
| </task>
| <transition to="Evaluate" name="trEvaluate"></transition>
| </start-state>
|
| <task-node name="Evaluate">
| <task name="evaluateTask">
| <assignment class="jbpm.taskmgmt.ManagerAssignmentHandler"></assignment>
| <controller></controller>
| </task>
| <transition to="end" name="trAbort"></transition>
| </task-node>
|
| <end-state name="end">
| <event type=""></event>
| </end-state>
| </process-definition>
|
My issue is within the task: "taskSubmission" f the start node and the class "EmiliAssignmentHandler":
| package jbpm.taskmgmt;
| import org.jbpm.graph.exe.*;
| import org.jbpm.taskmgmt.def.*;
| import org.jbpm.taskmgmt.exe.Assignable;
|
| public class EmiliAssignmentHandler implements AssignmentHandler {
|
| private static final long serialVersionUID = 1L;
| public void assign(Assignable assignable, ExecutionContext executionContext) {
| assignable.setActorId("emili");
| }
| }
|
I run the JUNIT test:
| + the correct imports...
|
| public class TestCase2 extends junit.framework.TestCase {
|
| static JbpmConfiguration jbpmConfiguration =
| JbpmConfiguration.parseResource("jbpm.cfg.xml");
|
| ... variables ...
| public void setUp() {
| ... same as in jbpm examples
| }
|
| public void tearDown() {
| ... same as in jbpm examples
| }
|
| private void newTransaction() {
| ... same as in jbpm examples
| }
|
| private void deployProcess() {
| ... same as in jbpm examples
| }
|
| private TaskInstance createNewProcessInstance() {
| GraphSession graphSession = jbpmContext.getGraphSession();
| ProcessDefinition processDefinition =
| graphSession.findLatestProcessDefinition("test");
| processInstance =
| new ProcessInstance(processDefinition);
| processInstanceId = processInstance.getId();
| contextInstance = processInstance.getContextInstance();
| taskMgmtInstance = processInstance.getTaskMgmtInstance();
| return processInstance.getTaskMgmtInstance().createStartTaskInstance();
| }
|
| public void testStartSubmissionParameters() {
| TaskInstance taskInstance = createNewProcessInstance();
| assertEquals("taskSubmission", taskInstance.getName());
| assertEquals(0, taskInstance.getVariables().size());
| }
|
| public void testSubmissionTask(){
| TaskInstance taskInstance = createNewProcessInstance();
| taskInstance.setActorId("emili");
| taskInstance.end();
| assertEquals("emili", taskInstance.getActorId()); <----WORKS
| List emiliTasks = jbpmContext.getTaskMgmtSession().findTaskInstances("emili");
| assertEquals(0, emiliTasks.size()); <----WORKS
| }
|
| public void testSubmissionNotWorking(){
| // create a task to start the test process
| TaskInstance taskInstance = createNewProcessInstance();
| assertEquals("emili", taskInstance.getActorId()); <----PROBLEM
| taskInstance.end();
| }
| }
|
Why does taskInstance.getActorId() in method testSubmissionTask() equal null where it should be equal to "emili" because of the EmiliAssignmentHandler class in the "taskSubmission" start node ????
thank you for your help
Ardavan
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4192287#4192287
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4192287
17 years, 4 months