<startEvent id="startevent1" name="Start" activiti:initiator="applyUserId"></startEvent>
其中applyUserId 可以看做是一个变量。
利用下面代码,来设置发起人的值:
identityService.setAuthenticatedUserId("Malt");
作用:
如果我们想在某个流程节点自动驳回给发起人Malt,那么我们可以在节点中配置:
<usertask id="fanhuishenqingzhe" name="返回申请者" activiti:assignee="${applyUserId}"></usertask>
activiti:assignee 指定任务处理人
也就是说申请者变成动态的了, 方便我们驳回时使用。
<?xml version="1.0" encoding="UTF-8"?> <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test"> <process id="myProcess" name="My process" isExecutable="true"> <startEvent id="startevent1" name="Start" activiti:initiator="applyUserId"></startEvent> <userTask id="usertask1" name="User Task1" activiti:assignee="applyUserId"></userTask> <userTask id="usertask2" name="User Task2"></userTask> <sequenceFlow id="flow2" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow> <sequenceFlow id="flow3" sourceRef="usertask2" targetRef="endevent1"></sequenceFlow> <sequenceFlow id="flow5" sourceRef="startevent1" targetRef="endevent1"></sequenceFlow> <sequenceFlow id="flow7" sourceRef="usertask2" targetRef="usertask1"></sequenceFlow> <endEvent id="endevent1" name="End"></endEvent> </process> <bpmndi:BPMNDiagram id="BPMNDiagram_myProcess"> <bpmndi:BPMNPlane bpmnElement="myProcess" id="BPMNPlane_myProcess"> <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1"> <omgdc:Bounds height="55.0" width="105.0" x="288.0" y="80.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2"> <omgdc:Bounds height="55.0" width="105.0" x="288.0" y="161.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1"> <omgdc:Bounds height="35.0" width="35.0" x="323.0" y="250.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1"> <omgdc:Bounds height="35.0" width="35.0" x="323.0" y="20.0"></omgdc:Bounds> </bpmndi:BPMNShape> <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2"> <omgdi:waypoint x="340.0" y="135.0"></omgdi:waypoint> <omgdi:waypoint x="340.0" y="161.0"></omgdi:waypoint> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3"> <omgdi:waypoint x="340.0" y="216.0"></omgdi:waypoint> <omgdi:waypoint x="340.0" y="250.0"></omgdi:waypoint> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5"> <omgdi:waypoint x="340.0" y="55.0"></omgdi:waypoint> <omgdi:waypoint x="340.0" y="250.0"></omgdi:waypoint> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7"> <omgdi:waypoint x="393.0" y="188.0"></omgdi:waypoint> <omgdi:waypoint x="494.0" y="161.0"></omgdi:waypoint> <omgdi:waypoint x="340.0" y="135.0"></omgdi:waypoint> </bpmndi:BPMNEdge> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </definitions>