작업 흐름 UserTask 사용

6015 단어 user
작업 흐름 도표:
 
 
작업 흐름 설정:
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions" 
  xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
  xmlns:activiti="http://activiti.org/bpmn"
  targetNamespace="Examples">
  <process id="executionAndTaskListenerDelegation">
  <!--     -->
  <extensionElements> 
      <activiti:executionListener class="com.easyway.activiti.servicetask.FieldInjectedExecutionListener" event="start"> 
        <activiti:field name="fixedValue" stringValue="Yes, I am " /> 
        <activiti:field name="dynamicValue" expression="${sentenceGenerator.getSentence()}" /> 
      </activiti:executionListener> 
    </extensionElements> 
  
   <startEvent id="start" />
    <sequenceFlow id="flow1" sourceRef="start" targetRef="userTask" />
    <!--                         -->
    <userTask id="userTask" name="Schedule meeting">
      <extensionElements>
        <activiti:executionListener event="start" delegateExpression="${myExecutionListenerBean}" />
        <activiti:taskListener event="create" delegateExpression="${myTaskListenerBean}" />
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow3" sourceRef="userTask" targetRef="userTask3" />
    <!--                -->
    <userTask id="userTask3">
      <extensionElements> 
      <activiti:executionListener expression="${myPojo.myMethod(execution.event)}" event="end" /> 
    </extensionElements> 
    </userTask> 
    
     <sequenceFlow id="flow4" sourceRef="userTask3" targetRef="end" />
   
   
    
    <endEvent id="end" />
    
  </process>

</definitions>

 
 
코드:
package com.easyway.activiti.servicetask;

import org.activiti.engine.runtime.ProcessInstance;


/**
 * 1.    :
 *    <!--     -->
  <extensionElements> 
      <activiti:executionListener class="com.easyway.activiti.servicetask.FieldInjectedExecutionListener" event="start"> 
        <activiti:field name="fixedValue" stringValue="Yes, I am " /> 
        <activiti:field name="dynamicValue" expression="${sentenceGenerator.getSentence()}" /> 
      </activiti:executionListener> 
    </extensionElements> 
    
    2.
        <userTask id="userTask" name="Schedule meeting">
      <extensionElements>
        <activiti:executionListener event="start" delegateExpression="${myExecutionListenerBean}" />
        <activiti:taskListener event="create" delegateExpression="${myTaskListenerBean}" />
      </extensionElements>
    </userTask>
    
    3.
        <userTask id="userTask3">
		      <extensionElements> 
		      <activiti:executionListener expression="${myPojo.myMethod(execution.event)}" event="end" /> 
		    </extensionElements> 
		</userTask> 
 * @author longgangbai
 * 
 * 2011-12-20    09:30:42
 */
@ContextConfiguration("classpath:servicetaskSpringTest-context.xml")
public class ExecutionAndTaskListenerDelegationExpressionTest extends SpringActivitiTestCase {
  

  @Deployment(resources={"diagrams/userTaskexecutionAndTaskListenerDelegationExpression.bpmn20.xml"})
  public void testExecutionAndTaskListenerDelegationExpression() {
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("executionAndTaskListenerDelegation");
    assertEquals("working", runtimeService.getVariable(processInstance.getId(), "executionListenerVar"));
    assertEquals("working", runtimeService.getVariable(processInstance.getId(), "taskListenerVar"));
  }
  
  
}

 
 
 
package com.easyway.activiti.servicetask;

import org.activiti.engine.delegate.DelegateExecution;

/**
 * @author longgangbai
 * 
 * 2011-12-20    10:55:06
 */
public class FieldInjectedExecutionListener implements ExecutionListener { 
	 
	  private Expression fixedValue; 
	 
	  private Expression dynamicValue; 
	 

	/* (non-Javadoc)
	 * @see org.activiti.engine.delegate.ExecutionListener#notify(org.activiti.engine.delegate.DelegateExecution)
	 */
	@Override
	public void notify(DelegateExecution execution) throws Exception {
	    execution.setVariable("var", fixedValue.getValue(execution).toString() + dynamicValue.getValue(execution).toString()); 
	} 
	} 

 
 
 
package com.easyway.activiti.servicetask;

import org.activiti.engine.delegate.DelegateExecution;

/**
 * 
 * @author longgangbai
 * 
 * 2011-12-20    09:32:45
 */
public class ActivitiExecutionListenerBean implements ExecutionListener {
  
  public void notify(DelegateExecution execution) throws Exception {
    execution.setVariable("executionListenerVar", "working");
  }

}

좋은 웹페이지 즐겨찾기