0

我正在尝试在 alfresco 社区版中构建自定义工作流程。基本上我正在尝试修改名为生命周期过程的现有工作流程。我已经能够使用工作流控制台部署流程而不会出错。但是我根本无法对工作流表单进行任何更改。我的工作流程称为 leaveprocess,我有以下代码:

路径:alfresco/tomcat/shared/classes/alfresco/extension/

离开流程-bpmn20.xml

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

<definitions id="leave-definitions"
             typeLanguage="http://www.w3.org/2001/XMLSchema"
             expressionLanguage="http://www.w3.org/1999/XPath"
             targetNamespace="http://activiti.org/bpmn20" 
             xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:activiti="http://activiti.org/bpmn">

    <process id="activitileaveApproval" name="Leave Process">
        <extensionElements>
             <!-- When process is deleted/cancelled, status should be set to draft -->
             <activiti:executionListener event="end" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
                <activiti:field name="script">
                     <activiti:string>
                        if(cancelled || deleted) {
                            for (var i = 0; i &lt; bpm_package.children.length; i++)
                            {
                               if (!bpm_package.children[i].hasAspect("wfl:status"))
                               {
                                    bpm_package.children[i].properties["wfl:status"] = "Draft";
                                    bpm_package.children[i].save();
                               }
                            }
                        }
                     </activiti:string>
                  </activiti:field>
            </activiti:executionListener>
         </extensionElements>
        <startEvent id="start"
            activiti:formKey="wf:submitReviewTask" />

        <sequenceFlow id='flow1' 
            sourceRef='start'
            targetRef='reviewTask'>
             <extensionElements>
                 <activiti:executionListener event="take" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
                    <activiti:field name="script">
                         <activiti:string>
                            for (var i = 0; i &lt; bpm_package.children.length; i++)
                            {
                               if (!bpm_package.children[i].hasAspect("wfl:status"))
                               {
                                  bpm_package.children[i].addAspect("wfl:status");
                               }
                            }
                         </activiti:string>
                      </activiti:field>
                </activiti:executionListener>
             </extensionElements>
        </sequenceFlow>

        <userTask id="reviewTask" name="Review Task"
            activiti:formKey="wf:activitiReviewTask">
           <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.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);

                         for (var i = 0; i &lt; bpm_package.children.length; i++)
                         {
                            if (bpm_package.children[0].hasAspect("wfl:status")) {
                                bpm_package.children[i].properties["wfl:status"] = "In Review";
                                bpm_package.children[i].save();
                            }
                         }
                     </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('wf_reviewOutcome', task.getVariable('wf_reviewOutcome'));
                     </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">${wf_reviewOutcome == 'Approve'}</conditionExpression>
        </sequenceFlow>

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

       <userTask id="approved" name="Document Approved"
            activiti:formKey="wf:approvedTask" >
            <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>
                        if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);

                        for (var i = 0; i &lt; bpm_package.children.length; i++)
                        {
                           if (bpm_package.children[0].hasAspect("wfl:status")) {
                               bpm_package.children[i].properties["wfl:status"] = "Approved";
                               bpm_package.children[i].save();
                           }
                        }
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
            </extensionElements>
            <humanPerformer>
                <resourceAssignmentExpression>
                    <formalExpression>${initiator.properties.userName}</formalExpression>
                </resourceAssignmentExpression>
            </humanPerformer>
        </userTask>

        <userTask id="rejected" name="Document Rejected"
            activiti:formKey="wf:rejectedTask" >
            <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>
                        if (typeof bpm_workflowDueDate != 'undefined') task.setVariableLocal('bpm_dueDate', bpm_workflowDueDate);

                        for (var i = 0; i &lt; bpm_package.children.length; i++)
                        {
                           if (bpm_package.children[0].hasAspect("wfl:status"))
                           {
                              bpm_package.children[i].properties["wfl:status"] = "Draft";
                              bpm_package.children[i].save();
                           }
                        }
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
            </extensionElements>
            <humanPerformer>
                <resourceAssignmentExpression>
                    <formalExpression>${initiator.properties.userName}</formalExpression>
                </resourceAssignmentExpression>
            </humanPerformer>
        </userTask>

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

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

        <endEvent id="end" />



    </process>

</definitions>

离开messages.properties

# For JBPM leave Workflow Example
wfl_leaveapproval.workflow.title=Leave Application
wfl_leaveapproval.workflow.description=Leave Application (Auto updates document status)
wfl_leaveapproval.node.review.transition.reject.title=Reject
wfl_leaveapproval.node.review.transition.reject.description=Reject
wfl_leaveapproval.node.review.transition.approve.title=Approve
wfl_leaveapproval.node.review.transition.approve.description=Approve

# For Activiti leave Workflow Example
activitileaveApproval=Leave Application
activitileaveApproval=Leave Application workflow Activiti (Auto updates document status)

离开工作流上下文.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="leave.workflowBootstrap" parent="workflowDeployer">
        <property name="workflowDefinitions">
            <list>
                <!-- JBPM version of leave process -->
                <props>
                    <prop key="engineId">jbpm</prop>
                    <prop key="location">alfresco/extension/leave_processdefinition.xml</prop>
                    <prop key="mimetype">text/xml</prop>
                    <prop key="redeploy">false</prop>
                </props>
                <!-- Activiti version of leave process -->
                <props>
                    <prop key="engineId">activiti</prop>
                    <prop key="location">alfresco/extension/leave-process.bpmn20.xml</prop>
                    <prop key="mimetype">text/xml</prop>
                    <prop key="redeploy">false</prop>
                </props>
            </list>
        </property>
        <property name="models">
            <list>
                <value>alfresco/extension/leaveModel.xml</value>
            </list>
        </property>
        <property name="labels">
            <list>
                <value>alfresco/extension/leave-messages</value>
            </list>
        </property>
    </bean>

</beans>

leave_processdefinition.xml

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

<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wfl:leaveapproval">

    <swimlane name="initiator" />

    <start-state name="start">
        <task name="wf:submitReviewTask" swimlane="initiator" />

        <event type="node-leave">
            <!-- Call script once the workflow package exists i.e. on node-leave -->
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                <!-- Apply the Workflow leave Aspect (wfl:status) if not set already. Note: The default wfl:status property is draft -->
                <script>
                    for (var i = 0; i &lt; bpm_package.children.length; i++)
                    {
                       if (!bpm_package.children[i].hasAspect("wfl:status"))
                       {
                          bpm_package.children[i].addAspect("wfl:status");
                       }
                    }
                </script>
            </action>
        </event>

        <transition name="" to="review" />
    </start-state>

    <swimlane name="reviewer">
       <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
          <actor>#{bpm_assignee}</actor>
       </assignment>
    </swimlane>

    <task-node name="review">
        <event type="node-enter">
            <!-- Update the status to In Review when we enter this task -->
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                <script>
                    for (var i = 0; i &lt; bpm_package.children.length; i++)
                    {
                       bpm_package.children[i].properties["wfl:status"] = "In Review";
                       bpm_package.children[i].save();
                    }
                </script>
            </action>
        </event>

        <task name="wf:reviewTask" swimlane="reviewer">
            <event type="task-create">
                <script>
                    if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
                    if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
                </script>
            </event>
        </task>

        <transition name="approve" to="approved" />
        <transition name="reject" to="rejected" />
    </task-node>

    <task-node name="rejected">
        <event type="node-enter">
            <!-- Update the status to Draft when we enter this task -->
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                <script>
                    for (var i = 0; i &lt; bpm_package.children.length; i++)
                    {
                       bpm_package.children[i].properties["wfl:status"] = "Draft";
                       bpm_package.children[i].save();
                    }
                </script>
            </action>
        </event>

        <task name="wf:rejectedTask" swimlane="initiator" />
        <transition name="" to="end" />
    </task-node>

    <task-node name="approved">
        <event type="node-enter">
            <!-- Update the status to Approved when we enter this task -->
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                <script>
                    for (var i = 0; i &lt; bpm_package.children.length; i++)
                    {
                       bpm_package.children[i].properties["wfl:status"] = "Approved";
                       bpm_package.children[i].save();
                    }
                </script>
            </action>
        </event>

        <task name="wf:approvedTask" swimlane="initiator" />
        <transition name="" to="end" />
    </task-node>

    <end-state name="end" />

    <event type="process-end">
        <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
                if (cancelled)
                {
                    for (var i = 0; i &lt; bpm_package.children.length; i++)
                    {
                       if (bpm_package.children[0].hasAspect("wfl:status"))
                       {
                          bpm_package.children[i].properties["wfl:status"] = "Draft";
                          bpm_package.children[i].save();
                       }
                    }
                    if (logger.isLoggingEnabled()) logger.log("Workflow cancelled, status reset to Draft");
                } 
                else                
                {
                    if (logger.isLoggingEnabled()) logger.log("Workflow completed");
                } 
            </script>
        </action>
    </event>

</process-definition> 

离开模型.xml

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

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

    <!-- Optional meta-data about the model -->
    <description>Workflow leave Model</description>
    <author></author>
    <version>1.0</version>

    <!-- Imports are required to allow references to definitions in other models -->
    <imports>
        <!-- Import Alfresco Dictionary Definitions -->
        <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
        <!-- Import Alfresco Content Domain Model Definitions -->
        <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
    </imports>

    <namespaces>
        <namespace uri="wfl.model" prefix="wfl" />
    </namespaces>

    <constraints>
        <constraint name="wfl:status" type="LIST">
            <parameter name="allowedValues">
                <list>
                    <value>Draft</value>
                    <value>In Review</value>
                    <value>Approved</value>
                </list>
            </parameter>
        </constraint>
    </constraints>

    <aspects>

        <!-- Status property is used to manage workflow approval -->
        <aspect name="wfl:status">
            <title>Status</title>
            <properties>
                <property name="wfl:status">
                    <title>Status</title>
                    <type>d:text</type>
                    <default>Draft</default>
                    <constraints>
                        <constraint ref="wfl:status" />
                    </constraints>
                </property>
            </properties>
        </aspect>

    </aspects>

</model>

路径:alfresco/tomcat/webapps/share/WEB-INF/classes/alfresco/

共享工作流-form-config.xml

<!-- Leave Workflow Definition -->
   <config evaluator="string-compare" condition="jbpm$wfl:leaveApproval">
      <forms>
         <form>
            <field-visibility>
               <show id="bpm:workflowDescription" />
               <show id="bpm:workflowDueDate" />
               <show id="bpm:workflowPriority" />
               <show id="bpm:assignee" />
               <show id="packageItems" />
               <show id="bpm:sendEMailNotifications" />
            </field-visibility>
            <appearance>
               <set id="" appearance="title" label-id="workflow.set.general" />
               <set id="info" appearance="" template="/org/alfresco/components/form/2-column-set.ftl" />
               <set id="assignee" appearance="title" label-id="workflow.set.assignee" />
               <set id="items" appearance="title" label-id="workflow.set.items" />
               <set id="other" appearance="title" label-id="workflow.set.other" />

               <field id="bpm:workflowDescription" label-id="workflow.field.message">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl">
                     <control-param name="style">width: 95%</control-param>
                  </control>
               </field>
               <field id="bpm:workflowDueDate" label-id="workflow.field.due" set="info" />
               <field id="bpm:workflowPriority" label-id="workflow.field.priority" set="info">
                  <control template="/org/alfresco/components/form/controls/workflow/priority.ftl" />
               </field>
               <field id="bpm:assignee" label-id="workflow.field.reviewer" set="assignee" />
               <field id="packageItems" set="items" />
               <field id="bpm:sendEMailNotifications" set="other">
                  <control template="/org/alfresco/components/form/controls/workflow/email-notification.ftl" />
               </field>
            </appearance>
         </form>
      </forms>
   </config>

    <config evaluator="string-compare" condition="activiti$activitileaveApproval">
      <forms>
         <form>
            <field-visibility>
               <show id="bpm:workflowDescription" />
               <show id="bpm:workflowDueDate" />
               <show id="bpm:workflowPriority" />
               <show id="bpm:assignee" />
               <show id="packageItems" />
               <show id="bpm:sendEMailNotifications" />
            </field-visibility>
            <appearance>
               <set id="" appearance="title" label-id="workflow.set.general" />
               <set id="info" appearance="" template="/org/alfresco/components/form/2-column-set.ftl" />
               <set id="assignee" appearance="title" label-id="workflow.set.assignee" />
               <set id="items" appearance="title" label-id="workflow.set.items" />
               <set id="other" appearance="title" label-id="workflow.set.other" />

               <field id="bpm:workflowDescription" label-id="workflow.field.message">
                  <control template="/org/alfresco/components/form/controls/textarea.ftl">
                     <control-param name="style">width: 95%</control-param>
                  </control>
               </field>
               <field id="bpm:workflowDueDate" label-id="workflow.field.due" set="info">
                  <control template="/org/alfresco/components/form/controls/date.ftl">
                      <control-param name="showTime">false</control-param>
                      <control-param name="submitTime">false</control-param>
                  </control>
               </field>
               <field id="bpm:workflowPriority" label-id="workflow.field.priority" set="info">
                  <control template="/org/alfresco/components/form/controls/workflow/priority.ftl" />
               </field>
               <field id="bpm:assignee" label-id="workflow.field.reviewer" set="assignee" />
               <field id="packageItems" set="items" />
               <field id="bpm:sendEMailNotifications" set="other">
                  <control template="/org/alfresco/components/form/controls/workflow/email-notification.ftl" />
               </field>
            </appearance>
         </form>
      </forms>
   </config>

我无法理解,无论我在此代码中对 share-workflow-form-config.xml 进行什么更改,它都不会反映何时转到 Share->Workflows I've started->select Leave Process。它总是在那里显示默认表单。有人请指导我在这里做错了什么。

4

2 回答 2

3

你需要更换这个

 <form>

与以下行

 <form id="workflow-details">

意味着在您的表单标签中添加属性“id”

于 2013-10-29T14:04:42.680 回答
0

进行更改后,share-config您必须重新启动 alfresco :)

部署工作流(通过workflow console)只重新部署工作流定义(也像部署模型,..)

   <config evaluator="string-compare" condition="jbpm$wfl:leaveApproval">

应该可以工作:D,不知道为什么不工作..

于 2015-06-02T12:24:48.790 回答