通过激活将工作流程分配给Alfresco中的组

时间:2019-04-30 09:57:25

标签: workflow alfresco activiti

我想创建一个自定义工作流,以便由包含两个用户的组审阅文档,这两个用户应该能够并行审阅该文档。我该怎么办?

我要做的就是由一个用户审阅文档(请参阅附件代码),为了将审阅任务分配给一个组,我需要更改什么?

activiti-demand-workflow-context.xml

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
    <bean id="lifecycle.workflowaBootstrap" parent="workflowDeployer">
        <property name="workflowDefinitions">
            <list>
                <props>
                    <prop key="engineId">activiti</prop>
                    <prop key="location">alfresco/extension/activiti-demand.bpmn20.xml</prop>
                    <prop key="mimetype">text/xml</prop>
                    <prop key="redeploy">false</prop>
                </props>
            </list>
        </property>
        <property name="models">         
            <list>        
                <value>alfresco/extension/workflowdemandModel.xml</value>
            </list>      
         </property>
        <property name="labels">
            <list>
                <value>alfresco/extension/activiti-demand-messages</value>
            </list>
        </property>
    </bean>
</beans>

activiti-demand-messages.properties

activitiDemand.workflow.title=Demand
activitiDemand.workflow.description=Process of demand validation
wfa_workflowmodelk.type.wfa_submitReviewTaskk.title=review demand
wfa_workflowmodelk.type.wfa_submitReviewTaskk.description=review demand

workflowdemandModel.xml

<?xml version="1.0" encoding="UTF-8"?>

<model name="wfa:workflowmodelk" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm"/>
   </imports>

   <namespaces>
      <namespace uri="wfa.workflow.model" prefix="wfa"/>
   </namespaces>

   <types>

      <!--                               -->
      <!--  Basic Review & Approve Tasks -->               
      <!--                               -->

      <type name="wfa:submitReviewTaskk">
         <parent>bpm:startTask</parent>
         <mandatory-aspects>
            <aspect>bpm:assignee</aspect>
         </mandatory-aspects>
      </type>

        <type name="wfa:activitiReviewTaskk">
            <parent>bpm:activitiOutcomeTask</parent>
            <properties>
                <property name="wfa:reviewOutcome">
                    <type>d:text</type>
                    <default>Reject</default>
                    <constraints>
                        <constraint name="wfa:reviewOutcomeOptions" type="LIST">
                            <parameter name="allowedValues">
                                <list>
                                    <value>Approve</value>
                                    <value>Reject</value>
                                </list>
                            </parameter>
                        </constraint>
                    </constraints>
                </property>
            </properties>
            <overrides>
                <property name="bpm:packageItemActionGroup">
                    <default>edit_package_item_actions</default>
                </property>
                <property name="bpm:outcomePropertyName">
                    <default>{http://www.alfresco.org/model/workflow/1.0}reviewOutcome</default>
                </property>
            </overrides>
        </type>

      <type name="wfa:approvedTaskk">
         <parent>bpm:workflowTask</parent>

      </type>

      <type name="wfa:rejectedTaskk">
         <parent>bpm:workflowTask</parent>

      </type>
   </types>

</model>

activiti-demand.bpmn20.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://alfresco.org">

    <process id="activitiDemand" name="review process">

        <startEvent id="start" name="Submit Review Task"
            activiti:formKey="wfa:submitReviewTaskk" />

        <sequenceFlow id='flow1' 
            sourceRef='start'
            targetRef='reviewTask' />

        <userTask id="reviewTask" name="Review Task"
            activiti:formKey="wfa:activitiReviewTaskk">
           <extensionElements>
               <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                        if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
               <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                        execution.setVariable('wfa_reviewOutcome', task.getVariable('wfa_reviewOutcome'));

                        if (task.getVariable('wfa_reviewOutcome') == 'Approve')
                               {

                           bpm_package.children[0].addTag("Approved_demand");
                        }
                            else
                            {
                                if (task.getVariable('wfa_reviewOutcome') == 'Reject')
                                {

                                bpm_package.children[0].addTag("Rejected_demand");
                                }
                        }
                     </activiti:string>
                  </activiti:field>
                  <activiti:field name="runAs">  
                     <activiti:string>admin</activiti:string>  
                  </activiti:field> 
               </activiti:taskListener>
           </extensionElements>
            <humanPerformer>
                <resourceAssignmentExpression>
                    <formalExpression>${bpm_assignee.properties.userName}</formalExpression>
                </resourceAssignmentExpression>
            </humanPerformer>
        </userTask>

   <!--      <sequenceFlow id='flow2' 
        sourceRef='reviewTask'
            targetRef='reviewDecision' /> -->

     <!--   <exclusiveGateway  id="reviewDecision" name="Review Decision" /> -->

   <!--     <sequenceFlow id='flow3' sourceRef='reviewDecision' targetRef='approved' >
            <conditionExpression xsi:type="tFormalExpression">${wfa_reviewOutcome == 'Approve'}</conditionExpression>
        </sequenceFlow>

        <sequenceFlow id='flow4' 
        sourceRef='reviewDecision'
            targetRef='rejected' />-->

      <!-- <userTask id="approved" name="Document Approved"
            activiti:formKey="wfa:approvedTaskk" >
            <documentation>
                The document was reviewed and approved.
            </documentation>
            <extensionElements>
               <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                        execution.setVariable("bpm_assignee", task.getVariable("bpm_assignee"));
                        if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;



                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
            </extensionElements>
            <humanPerformer>
                <resourceAssignmentExpression>
                    <formalExpression>${initiator.exists() ? initiator.properties.userName : 'admin'}</formalExpression>
                </resourceAssignmentExpression>
            </humanPerformer>
        </userTask>-->

      <!--  <userTask id="rejected" name="Document Rejected"
            activiti:formKey="wfa:rejectedTaskk" >
            <documentation>
                The document was reviewed and rejected.
            </documentation>
            <extensionElements>
               <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                        execution.setVariable("bpm_assignee", task.getVariable("bpm_assignee"));
                        if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;

                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
            </extensionElements>
            <humanPerformer>
                <resourceAssignmentExpression>
                    <formalExpression>${initiator.exists() ? initiator.properties.userName : 'admin'}</formalExpression>
                </resourceAssignmentExpression>
            </humanPerformer>
        </userTask>-->

   <!--     <sequenceFlow id='flow5' sourceRef='approved'
            targetRef='end' />

        <sequenceFlow id='flow6' sourceRef='rejected'
            targetRef='end' />-->

        <endEvent id="end" />

    </process>

   <!-- Graphical representaion of diagram -->
   <bpmndi:BPMNDiagram id="BPMNDiagram_activitiReview">
      <bpmndi:BPMNPlane bpmnElement="activitiReview"
         id="BPMNPlane_activitiReview">
         <bpmndi:BPMNShape bpmnElement="start"
            id="BPMNShape_start">
            <omgdc:Bounds height="35" width="35" x="30" y="200"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="reviewTask"
            id="BPMNShape_reviewTask">
            <omgdc:Bounds height="55" width="105" x="125"
               y="190"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="reviewDecision"
            id="BPMNShape_reviewDecision">
            <omgdc:Bounds height="40" width="40" x="290" y="197"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="approved"
            id="BPMNShape_approved">
            <omgdc:Bounds height="55" width="105" x="390"
               y="97"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="rejected"
            id="BPMNShape_rejected">
            <omgdc:Bounds height="55" width="105" x="390"
               y="297"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="end" id="BPMNShape_end">
            <omgdc:Bounds height="35" width="35" x="555" y="307"></omgdc:Bounds>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
            <omgdi:waypoint x="65" y="217"></omgdi:waypoint>
            <omgdi:waypoint x="125" y="217"></omgdi:waypoint>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
            <omgdi:waypoint x="230" y="217"></omgdi:waypoint>
            <omgdi:waypoint x="290" y="217"></omgdi:waypoint>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
            <omgdi:waypoint x="310" y="197"></omgdi:waypoint>
            <omgdi:waypoint x="310" y="124"></omgdi:waypoint>
            <omgdi:waypoint x="390" y="124"></omgdi:waypoint>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
            <omgdi:waypoint x="310" y="237"></omgdi:waypoint>
            <omgdi:waypoint x="310" y="324"></omgdi:waypoint>
            <omgdi:waypoint x="390" y="324"></omgdi:waypoint>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
            <omgdi:waypoint x="495" y="124"></omgdi:waypoint>
            <omgdi:waypoint x="572" y="124"></omgdi:waypoint>
            <omgdi:waypoint x="572" y="307"></omgdi:waypoint>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
            <omgdi:waypoint x="495" y="324"></omgdi:waypoint>
            <omgdi:waypoint x="555" y="324"></omgdi:waypoint>
         </bpmndi:BPMNEdge>
      </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>

</definitions>

2 个答案:

答案 0 :(得分:0)

您不能将任务分配给组。但是您可以有一个任务的多个实例。

将您的审核任务定义为多实例任务。

<userTask id="reviewTask" name="Review Task" activiti:formKey="wfa:activitiReviewTaskk">
<multiInstanceLoopCharacteristics isSequential="false">
<loopDataInputRef>assigneeList</loopDataInputRef>
<inputDataItem name="assignee" />
</multiInstanceLoopCharacteristics>
...
</userTask>

要为审阅者组的每个用户创建一个实例,可以在工作流程启动时将assigneeList设置为该组中的用户列表。

您还应该定义任务在何时完成。完成了两个或更多审阅任务的实例?

<completionCondition>${nrOfCompletedInstances >= 2 }</completionCondition>

还是全部?

<completionCondition>${nrOfCompletedInstances==nrOfInstances}</completionCondition>

最后,您还应该考虑总体审查结果应该是什么。是否所有用户都必须批准该文档才能将其视为已批准?两个或更多?至少50%? 一种实现上述目的的方法是,只要审阅任务的实例以批准结束就增加计数器的值,并在任务完成后检查该值。

另请参阅Multi-instance tasksXml representation of multi-instance tasks

答案 1 :(得分:0)

您可以在userTask标记内使用此属性将任务分配给组:

activiti:candidateGroups="GROUP_development"

您可以用逗号分隔的值格式添加多个组,并且每个组名必须以“ GROUP_”为前缀。

请记住,通过这种方式可以将任务转换为共享任务,这意味着完成任务的第一个用户可以完成任务。