AnsweredAssumed Answered

Task re-assignment

Question asked by fufler on Oct 27, 2010
I want to implement following workflow: user1 submits task to user2, if time expired and user2 didn't change status of task (it's still "Not Yet Started"), then task should be reassigned to user1. I wrote content and workflow models, process definition, but i need help with timer. When timer fires in my workflow task within timer was created becomes completed regardless on its current state. It's not behaviour i want to see, please help my to fix this issue.

My workflow files:

web-client-config-custom.xml
<alfresco-config>

   <!–  add types to add content list –>
   <config evaluator="string-compare" condition="Content Wizards">
      <content-types>
         <type name="x:doc" />
      </content-types>
   </config>

   <!–  workflow property sheets –>

   <config evaluator="node-type" condition="xwf:submitTask" replace="true">
      <property-sheet>
         <separator name="sep1" display-label-id="general" component-generator="HeaderSeparatorGenerator" />
      <show-property name="bpm:workflowDescription" component-generator="TextAreaGenerator" />
      <show-association name="bpm:assignee" />     
      </property-sheet>
   </config>

   <config evaluator="node-type" condition="xwf:slaveTask" replace="true">
      <property-sheet>
         <separator name="sep1" display-label-id="general" component-generator="HeaderSeparatorGenerator" />
         <show-property name="bpm:description" component-generator="TextAreaGenerator" read-only="true"/>
      <show-property name="bpm:comment" component-generator="TextAreaGenerator" />      
      <show-property name="bpm:status" />     
      </property-sheet>
   </config>

   <config evaluator="node-type" condition="xwf:masterTask" replace="true">
      <property-sheet>
         <separator name="sep1" display-label-id="general" component-generator="HeaderSeparatorGenerator" />
         <show-property name="bpm:description" component-generator="TextAreaGenerator" read-only="true"/>
         <show-property name="bpm:comment" component-generator="TextAreaGenerator" />      
      </property-sheet>
   </config>
</alfresco-config>

x-model-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>
    <!– Registration of new models
    <bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/xModel.xml</value>
                <value>alfresco/extension/xWorkflowModel.xml</value>
            </list>
        </property>
    </bean –>
   
   <!– Registration of resource bundles –>
    <bean id="extension.workflowBootstrap" parent="workflowDeployer">
      <property name="workflowDefinitions">
        <list>
          <props>
            <prop key="engineId">jbpm</prop>
            <prop key="location">alfresco/extension/workflows/MasterSlaveProcess.xml</prop>
            <prop key="mimetype">text/xml</prop>
            <prop key="redeploy">true</prop>
          </props>
        </list>
      </property>
      <property name="labels">
        <list>
          <value>alfresco.extension.xWorkflow</value>
        </list>
      </property>
      <property name="models">
          <list>
              <value>alfresco/extension/xModel.xml</value>
              <value>alfresco/extension/xWorkflowModel.xml</value>
          </list>
      </property>
    </bean>
   
</beans>

xModel.xml
<?xml version="1.0" encoding="UTF-8"?>
<!– Definition of new Model –>
<model name="x:somemodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– 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" />
      <!– import uri="http://www.alfresco.org/model/system/1.0" prefix="sys" / –>
   </imports>

   <!– Introduction of new namespaces defined by this model –>
   <namespaces>
      <namespace uri="http://www.someco.com/model/content/1.0" prefix="x" />
   </namespaces>

   <types>
      <type name="x:doc">
         <title>Some Document</title>
         <parent>cm:content</parent>
    </type>
  </types>
      
</model>
xWorkflowModel.xml
<?xml version="1.0" encoding="UTF-8"?>
<!– Definition of new Model –>
<model name="xwf:workflowmodel"   xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– Imports are required to allow references to definitions in other models –>
   <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>

   <!– Introduction of new namespaces defined by this model –>
   <namespaces>
      <namespace uri="http://www.someco.com/model/workflow/1.0"   prefix="xwf" />
   </namespaces>

   <types>

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

      <type name="xwf:slaveTask">
         <parent>bpm:workflowTask</parent>
         <overrides>
            <property name="bpm:packageItemActionGroup">
               <default>read_package_item_actions</default>
            </property>
         </overrides>
      </type>

      <type name="xwf:masterTask">
         <parent>bpm:workflowTask</parent>
         <overrides>
            <property name="bpm:packageItemActionGroup">
               <default>read_package_item_actions</default>
            </property>
         </overrides>
      </type>

      
  </types>

</model>
workflows/MasterSlaveProcess.xml
<?xml version="1.0" encoding="UTF-8"?>


<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="xwf:makesmth">
 
  <swimlane name="initiator" />

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

  <start-state name="Start">
    <task name="xwf:submitTask" swimlane="initiator" />
    <transition name="1" to="Submit" />
  </start-state>

  <node name="Submit">
    <transition name="2" to="Task"/>
  </node>

  <task-node name="Task">
    <task name="xwf:slaveTask" swimlane="slave" >
      <timer name="ReassignTimer" duedate="30 seconds">
        <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
          <script>
            if (taskInstance.getVariable("bpm_status") == "Not Yet Started")
              logger.log("REASSIGN!!!");
          </script>
        </action>
      </timer>
    </task>
    <transition name="accept" to="Done" />
    <transition name="decline" to="ReassignTask" />
  </task-node>

  <task-node name="ReassignTask">
    <task name="xwf:masterTask" swimlane="initiator" />
    <transition name="master_accept" to="Done" />
    <transition name="master_decline" to="End" />
  </task-node>

  <node name="Done">
    <transition name="3" to="End"/>
  </node>

  <end-state name="End"/>
 
</process-definition>

Outcomes