cancel
Showing results for 
Search instead for 
Did you mean: 

Komisches Verhalten beim Erstellen von Activiti Workflows

dsoe
Champ in-the-making
Champ in-the-making
Hallo zusammen,

ich bin gerade dabei einen eigenen Workflow mit Activiti zu erstellen. Der Workflow soll quasi eine Erweiterung des Pooled Review & Approve Workflows darstellen. Dazu habe ich zunächst den original Pooled Review & Approve Workflow kopiert:

/shared/classes/alfresco/extension/custom-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="custom.workflowBootstrap" parent="workflowDeployer">
      <property name="workflowDefinitions">
         <list>
            <!– Activiti version of custom process –>
            <props>
               <prop key="engineId">activiti</prop>
               <prop key="location">alfresco/extension/custom-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/customModel.xml</value>
         </list>
      </property>
   </bean>

</beans>

/shared/classes/alfresco/extension/custom-process.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 isExecutable="true" id="activitiCustomProcess" name="Custom Activiti Process">

        <startEvent id="start"
            activiti:formKey="wf:customSubmitGroupReviewTask" />

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

        <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.setVariable('bpm_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('wf_reviewOutcome', task.getVariable('wf_reviewOutcome'));
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
             
           </extensionElements>
           <potentialOwner>
            <resourceAssignmentExpression>
              <formalExpression>${bpm_groupAssignee.properties.authorityName}</formalExpression>
            </resourceAssignmentExpression>
         </potentialOwner>
        </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.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('bpm_assignee', person);
                     </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="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.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('bpm_assignee', person);
                     </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_activitiReviewPooled">
      <bpmndi:BPMNPlane bpmnElement="activitiReviewPooled"
         id="BPMNPlane_activitiReviewPooled">
         <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>

/shared/classes/alfresco/extension/customModel.xml

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

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

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

    <!– Imports are required to allow references to definitions in other models –>
    <imports>
      <!– Import Alfresco BPM Definitions –>
      <import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm" />
    </imports>

    <namespaces>
        <namespace uri="http://www.alfresco.org/model/workflow/1.0" prefix="wf" />
    </namespaces>

    <types>
        <type name="wf:customSubmitGroupReviewTask">
            <parent>bpm:startTask</parent>
            <mandatory-aspects>
                <aspect>bpm:groupAssignee</aspect>
            </mandatory-aspects>
        </type>
    </types>

</model>

in /shared/classes/alfresco/web-extension/share-config-custom.xml folgenden Eintrag hinzugefügt:

   <config evaluator="task-type" condition="wf:customSubmitGroupReviewTask">
      <forms>
         <form id="workflow-details">
            <field-visibility>
               <show id="bpm:groupAssignee" />
               <show id="wf:requiredApprovePercent" />
               <show id="bpm:sendEMailNotifications" />
               <show id="packageItems" />
            </field-visibility>
            <appearance>
               <set id="" appearance="title" label-id="workflow.set.workflow.more_info" />
               <set id="items" appearance="title" label-id="workflow.set.items" />
              
               <field id="bpm:groupAssignee" label-id="workflow.field.review_group" />
               <field id="packageItems" set="items" />
            </appearance>
         </form>
        
         <form>
            <field-visibility>
               <show id="message" />
               <show id="taskOwner" />
               <show id="bpm:workflowPriority" />
               <show id="bpm:workflowDueDate" />
               <show id="bpm:taskId" />
               <show id="wf:requiredApprovePercent" />
               <show id="bpm:status" />
               <show id="packageItems" />
               <show id="bpm:sendEMailNotifications" />
            </field-visibility>
            <appearance>
               <set id="" appearance="title" label-id="workflow.set.task.info" />
               <set id="info" appearance="" template="/org/alfresco/components/form/3-column-set.ftl" />
               <set id="progress" appearance="title" label-id="workflow.set.task.progress" />
               <set id="items" appearance="title" label-id="workflow.set.items" />
               <set id="other" appearance="title" label-id="workflow.set.other" />
              
               <field id="message">
                  <control template="/org/alfresco/components/form/controls/info.ftl" />
               </field>
               <field id="taskOwner" set="info" />
               <field id="bpm:taskId" set="info">
                  <control template="/org/alfresco/components/form/controls/info.ftl" />
               </field>
               <field id="bpm:workflowPriority" label-id="workflow.field.priority" set="info" read-only="true">
                  <control template="/org/alfresco/components/form/controls/workflow/priority.ftl" />
               </field>
               <field id="bpm:workflowDueDate" set="info" label-id="workflow.field.due">
                  <control template="/org/alfresco/components/form/controls/info.ftl" />
               </field>
               <field id="wf:requiredApprovePercent" set="info" />
               <field id="bpm:status" set="progress" />
               <field id="packageItems" set="items" />
               <field id="bpm:sendEMailNotifications" set="other" />
            </appearance>
         </form>
      </forms>
   </config>

Nun müsste sich dieser Custom Workflow zunächst genau so verhalten wie der Pooled Review & Approve Workflow. Leider ist das aber nicht der Fall:

- Plötzlich andere Maske beim Starten des Workflows: es erscheint ein ausgegrautes Feld "Sprachumgebung" sowie die Felder "Kommentar" und "Beschreibung". Anstelle eines "Bevollmächtigter" Feldes gibt es ganz oben den Eintrag "Bevollmächtigter für die Gruppe der Workflows". Außerdem kann nur noch ein Bevollmächtigter ausgewählt werden.
- Das deployen des Custom Workflows hat einen Nebeneffekt auf die default Workflows - dort kann nun keine Gruppe bzw. Benutzer mehr ausgewählt werden.

Was ist da falsch gelaufen?
1 REPLY 1

jpfi_4454
Champ in-the-making
Champ in-the-making
Hi,
du solltest nicht das wf:workflowmodel überschreiben sondern einen eigenen namenspace wählen.
So hast Du das ContentModel von Alfresco überschrieben…
VG, jan
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.