Alfresco Activiti任务分配回发起人

时间:2013-12-26 08:32:08

标签: alfresco activiti

我已经在露天创建了一个3级激活工作流程,其中发起人启动了大头钉&它转到level1批准者。如果level1批准该任务,则转到level2批准者。如果level2批准任务,它将进入2级&不久。它还有定时器,在到期后将任务分配到下一级别。

enter image description here

同样,如果第3级拒绝任务,则转到level2。如果级别2拒绝,则转到level1,但如果level1拒绝该任务,则它不会返回到initiator.Except,它正常工作。 XML如下所示。

 <?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="alfrescoThreeLevelFullWF" name="Alfresco Three Level Full Workflow">
   <startEvent id="alfrescoStartevent1" name="Alfresco start" activiti:formKey="wf:submitGroupReviewTask" activiti:initiator="${initiator.properties.userName}"></startEvent>
<userTask id="level1ApprovalTask" name="Level 1 Approval" activiti:candidateGroups="GROUP_Group1" activiti:formKey="wf:activitiReviewTask">
  <extensionElements>
    <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
      <activiti:field name="script">
        <activiti:string>execution.setVariable('wf_reviewOutcome', task.getVariable('wf_reviewOutcome'));</activiti:string>
      </activiti:field>
    </activiti:taskListener>
  </extensionElements>
</userTask>
<boundaryEvent id="level1ApprovalTimer" name="Level 1 Approval Timer" cancelActivity="true" attachedToRef="level1ApprovalTask">
  <timerEventDefinition>
    <timeDuration>PT1M</timeDuration>
  </timerEventDefinition>
</boundaryEvent>
<exclusiveGateway id="gotLevel1Approval" name="Level 1 Approval Check"></exclusiveGateway>
<userTask id="level2ApprovalTask" name="Level 2 Approval" activiti:candidateGroups="GROUP_Group2" activiti:formKey="wf:activitiReviewTask">
  <extensionElements>
    <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
      <activiti:field name="script">
        <activiti:string>execution.setVariable('wf_reviewOutcome', task.getVariable('wf_reviewOutcome'));</activiti:string>
      </activiti:field>
    </activiti:taskListener>
  </extensionElements>
</userTask>
<boundaryEvent id="level2ApprovalTimer" name="Level 2 Approval Timer" cancelActivity="true" attachedToRef="level2ApprovalTask">
  <timerEventDefinition>
    <timeDuration>PT1M</timeDuration>
  </timerEventDefinition>
</boundaryEvent>
<exclusiveGateway id="gotLevel2Approval" name="Level 2 Approval Check"></exclusiveGateway>
<userTask id="level3ApprovalTask" name="Level 3 Approval" activiti:candidateGroups="GROUP_Group3" activiti:formKey="wf:activitiReviewTask">
  <extensionElements>
    <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
      <activiti:field name="script">
        <activiti:string>execution.setVariable('wf_reviewOutcome', task.getVariable('wf_reviewOutcome'));</activiti:string>
      </activiti:field>
    </activiti:taskListener>
  </extensionElements>
</userTask>
<exclusiveGateway id="gotLevel3Approval" name="Level3 Approval Check"></exclusiveGateway>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow1" name="" sourceRef="alfrescoStartevent1" targetRef="level1ApprovalTask"></sequenceFlow>
<sequenceFlow id="flow2" name="" sourceRef="level1ApprovalTask" targetRef="gotLevel1Approval"></sequenceFlow>
<sequenceFlow id="level1Approved" name="Level 1 Approved" sourceRef="gotLevel1Approval" targetRef="level2ApprovalTask">
  <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf_reviewOutcome == 'Approve'}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow4" name="" sourceRef="level2ApprovalTask" targetRef="gotLevel2Approval"></sequenceFlow>
<sequenceFlow id="level2Approved" name="Level2 Approved" sourceRef="gotLevel2Approval" targetRef="level3ApprovalTask">
  <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf_reviewOutcome == 'Approve'}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow6" name="" sourceRef="level3ApprovalTask" targetRef="gotLevel3Approval"></sequenceFlow>
<sequenceFlow id="level3Approved" name="Level 3 Approved" sourceRef="gotLevel3Approval" targetRef="endevent1">
  <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf_reviewOutcome == 'Approve'}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="level1Unapproved" name="Level 1 Unapproved" sourceRef="gotLevel1Approval" targetRef="alfrescoStartevent1">
  <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf_reviewOutcome == 'Reject'}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="level2Unapproved" name="Level 2 Unapproved" sourceRef="gotLevel2Approval" targetRef="level1ApprovalTask">
  <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf_reviewOutcome == 'Reject'}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="level3Unapproved" name="Level 3 unapproved" sourceRef="gotLevel3Approval" targetRef="level2ApprovalTask">
  <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wf_reviewOutcome == 'Reject'}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow8" name="" sourceRef="level1ApprovalTimer" targetRef="level2ApprovalTask"></sequenceFlow>
<sequenceFlow id="flow9" name="" sourceRef="level2ApprovalTimer" targetRef="level3ApprovalTask"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_alfrescoThreeLevelFullWF">
    <bpmndi:BPMNPlane bpmnElement="alfrescoThreeLevelFullWF" id="BPMNPlane_alfrescoThreeLevelFullWF">
  <bpmndi:BPMNShape bpmnElement="alfrescoStartevent1" id="BPMNShape_alfrescoStartevent1">
    <omgdc:Bounds height="35" width="35" x="20" y="200"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="level1ApprovalTask" id="BPMNShape_level1ApprovalTask">
    <omgdc:Bounds height="55" width="105" x="110" y="190"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="level1ApprovalTimer" id="BPMNShape_level1ApprovalTimer">
    <omgdc:Bounds height="30" width="30" x="150" y="230"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="gotLevel1Approval" id="BPMNShape_gotLevel1Approval">
    <omgdc:Bounds height="40" width="40" x="252" y="197"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="level2ApprovalTask" id="BPMNShape_level2ApprovalTask">
    <omgdc:Bounds height="55" width="105" x="370" y="190"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="level2ApprovalTimer" id="BPMNShape_level2ApprovalTimer">
    <omgdc:Bounds height="30" width="30" x="440" y="230"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="gotLevel2Approval" id="BPMNShape_gotLevel2Approval">
    <omgdc:Bounds height="40" width="40" x="540" y="197"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="level3ApprovalTask" id="BPMNShape_level3ApprovalTask">
    <omgdc:Bounds height="55" width="105" x="640" y="190"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="gotLevel3Approval" id="BPMNShape_gotLevel3Approval">
    <omgdc:Bounds height="40" width="40" x="810" y="197"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
    <omgdc:Bounds height="35" width="35" x="920" y="200"></omgdc:Bounds>
  </bpmndi:BPMNShape>
  <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
    <omgdi:waypoint x="55" y="217"></omgdi:waypoint>
    <omgdi:waypoint x="110" y="217"></omgdi:waypoint>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
    <omgdi:waypoint x="215" y="217"></omgdi:waypoint>
    <omgdi:waypoint x="252" y="217"></omgdi:waypoint>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="level1Approved" id="BPMNEdge_level1Approved">
    <omgdi:waypoint x="292" y="217"></omgdi:waypoint>
    <omgdi:waypoint x="370" y="217"></omgdi:waypoint>
    <bpmndi:BPMNLabel>
      <omgdc:Bounds height="14" width="100" x="-40" y="7"></omgdc:Bounds>
    </bpmndi:BPMNLabel>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
    <omgdi:waypoint x="475" y="217"></omgdi:waypoint>
    <omgdi:waypoint x="540" y="217"></omgdi:waypoint>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="level2Approved" id="BPMNEdge_level2Approved">
    <omgdi:waypoint x="580" y="217"></omgdi:waypoint>
    <omgdi:waypoint x="640" y="217"></omgdi:waypoint>
    <bpmndi:BPMNLabel>
      <omgdc:Bounds height="14" width="100" x="-40" y="7"></omgdc:Bounds>
    </bpmndi:BPMNLabel>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
    <omgdi:waypoint x="745" y="217"></omgdi:waypoint>
    <omgdi:waypoint x="810" y="217"></omgdi:waypoint>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="level3Approved" id="BPMNEdge_level3Approved">
    <omgdi:waypoint x="850" y="217"></omgdi:waypoint>
    <omgdi:waypoint x="920" y="217"></omgdi:waypoint>
    <bpmndi:BPMNLabel>
      <omgdc:Bounds height="14" width="100" x="-45" y="7"></omgdc:Bounds>
    </bpmndi:BPMNLabel>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="level1Unapproved" id="BPMNEdge_level1Unapproved">
    <omgdi:waypoint x="272" y="237"></omgdi:waypoint>
    <omgdi:waypoint x="272" y="339"></omgdi:waypoint>
    <omgdi:waypoint x="155" y="339"></omgdi:waypoint>
    <omgdi:waypoint x="37" y="339"></omgdi:waypoint>
    <omgdi:waypoint x="37" y="235"></omgdi:waypoint>
    <bpmndi:BPMNLabel>
      <omgdc:Bounds height="42" width="100" x="-335" y="-94"></omgdc:Bounds>
    </bpmndi:BPMNLabel>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="level2Unapproved" id="BPMNEdge_level2Unapproved">
    <omgdi:waypoint x="560" y="197"></omgdi:waypoint>
    <omgdi:waypoint x="559" y="102"></omgdi:waypoint>
    <omgdi:waypoint x="422" y="102"></omgdi:waypoint>
    <omgdi:waypoint x="162" y="102"></omgdi:waypoint>
    <omgdi:waypoint x="162" y="190"></omgdi:waypoint>
    <bpmndi:BPMNLabel>
      <omgdc:Bounds height="42" width="100" x="-53" y="-12"></omgdc:Bounds>
    </bpmndi:BPMNLabel>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="level3Unapproved" id="BPMNEdge_level3Unapproved">
    <omgdi:waypoint x="830" y="237"></omgdi:waypoint>
    <omgdi:waypoint x="830" y="342"></omgdi:waypoint>
    <omgdi:waypoint x="692" y="342"></omgdi:waypoint>
    <omgdi:waypoint x="422" y="342"></omgdi:waypoint>
    <omgdi:waypoint x="422" y="245"></omgdi:waypoint>
    <bpmndi:BPMNLabel>
      <omgdc:Bounds height="42" width="100" x="-54" y="-32"></omgdc:Bounds>
    </bpmndi:BPMNLabel>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
    <omgdi:waypoint x="165" y="260"></omgdi:waypoint>
    <omgdi:waypoint x="164" y="278"></omgdi:waypoint>
    <omgdi:waypoint x="422" y="278"></omgdi:waypoint>
    <omgdi:waypoint x="422" y="245"></omgdi:waypoint>
  </bpmndi:BPMNEdge>
  <bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
    <omgdi:waypoint x="455" y="260"></omgdi:waypoint>
    <omgdi:waypoint x="454" y="299"></omgdi:waypoint>
    <omgdi:waypoint x="692" y="299"></omgdi:waypoint>
    <omgdi:waypoint x="692" y="245"></omgdi:waypoint>
  </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
    </definitions>

有没有人知道如何将此任务重新分配给发起人?

1 个答案:

答案 0 :(得分:2)

您需要将审批流程设置为子流程。如果级别1拒绝任务,则设置过程变量(即approved = false)并退出。现在,设置退出批准子流程的简单条件,以检查活动是否被批准。如果没有,请处理(即返回发起人),继续进行处理。

还有其他处理方式,即抛出一个将您发送回发起人的异常,但上述内容将是最容易阅读的,因此将来会保留。

将此设置为子流程的另一个好处是,您可以在需要此类批准的其他流程中重用逻辑。

希望这有帮助。