AnsweredAssumed Answered

Setting variables in workflow AFTER start from Java?

Question asked by joko71 on Oct 7, 2010
Latest reply on Oct 23, 2010 by joko71
I created serial workflow which works perfectly in Alfresco web client: initiator selects actor next in line to perform task, selected actor upon receiving task selects another, another actor selects another… you get the picture… :)

I tried to replicate this behavior in Java. I can select task, but I'm unable to pass next actor to workflow. I tried to use updateTask method from workflow services, but task is not updated with next actor, so I get error that task variable is not defined.

workflow model:
   <types>
      <type name="sdzwf:ulazniRacuniStartTask">
         <parent>bpm:startTask</parent>
         <overrides>
            <property name="bpm:packageActionGroup">
               <default>add_package_item_actions</default>
            </property>
            <property name="bpm:packageItemActionGroup">
               <default>edit_package_item_actions</default>
            </property>
         </overrides>
         <mandatory-aspects>
            <aspect>sdzwf:referent2</aspect>
         </mandatory-aspects>
      </type>
            
      <type name="sdzwf:ulazniRacuniReferent2Task">
         <parent>bpm:workflowTask</parent>
         <overrides>
            <property name="bpm:packageActionGroup">
               <default>add_package_item_actions</default>
            </property>
            <property name="bpm:packageItemActionGroup">
               <default>edit_package_item_actions</default>
            </property>
         </overrides>
         <mandatory-aspects>
            <aspect>sdzwf:procelnik</aspect>
         </mandatory-aspects>
      </type>
      
      <type name="sdzwf:ulazniRacuniProcelnikTask">
         <parent>bpm:workflowTask</parent>
         <overrides>
            <property name="bpm:packageActionGroup">
               <default>add_package_item_actions</default>
            </property>
            <property name="bpm:packageItemActionGroup">
               <default>edit_package_item_actions</default>
            </property>
         </overrides>
         <mandatory-aspects>
            <aspect>sdzwf:likvidator</aspect>
         </mandatory-aspects>
      </type>
      
      <type name="sdzwf:ulazniRacuniLikvidatorTask">
         <parent>bpm:workflowTask</parent>
         <overrides>
            <property name="bpm:packageActionGroup">
               <default>add_package_item_actions</default>
            </property>
            <property name="bpm:packageItemActionGroup">
               <default>edit_package_item_actions</default>
            </property>
         </overrides>
      </type>
      
   </types>

   <aspects>
         
   <aspect name="sdzwf:referent2">
      <associations>
         <association name="sdzwf:referent2">
            <source>
               <mandatory>false</mandatory>
               <many>false</many>
            </source>
            <target>
               <class>cm:person</class>
               <mandatory>false</mandatory>
               <many>false</many>
            </target>
         </association>
      </associations>
   </aspect>
   
   <aspect name="sdzwf:procelnik">
      <associations>
         <association name="sdzwf:procelnik">
            <source>
               <mandatory>false</mandatory>
               <many>false</many>
            </source>
            <target>
               <class>cm:person</class>
               <mandatory>false</mandatory>
               <many>false</many>
            </target>
         </association>
      </associations>
   </aspect>
   
   <aspect name="sdzwf:likvidator">
      <associations>
         <association name="sdzwf:likvidator">
            <source>
               <mandatory>false</mandatory>
               <many>false</many>
            </source>
            <target>
               <class>cm:person</class>
               <mandatory>false</mandatory>
               <many>false</many>
            </target>
         </association>
      </associations>
   </aspect>

   </aspects>

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

<process-definition
  xmlns="urn:jbpm.org:jpdl-3.1"  name="sdzwf:ulazniRacuni">
 
   <swimlane name="initiator" />
        
   <swimlane name="referent2">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <actor>#{sdzwf_referent2}</actor>
      </assignment>
   </swimlane>
   
   <swimlane name="procelnik">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <actor>#{sdzwf_procelnik}</actor>
      </assignment>
   </swimlane>
   
   <swimlane name="likvidator">
      <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
         <actor>#{sdzwf_likvidator}</actor>
      </assignment>
   </swimlane>                  
 
   <start-state name="start">
      <task name="sdzwf:ulazniRacuniStartTask" swimlane="initiator" />      
      <transition name="" to="referent2Task"></transition>
   </start-state>
        
   <task-node name="referent2Task">
      <task name="sdzwf:ulazniRacuniReferent2Task" swimlane="referent2"></task>
      <transition to="procelnikTask" name="Odobri"></transition>
   </task-node>

   <task-node name="procelnikTask">
      <task name="sdzwf:ulazniRacuniProcelnikTask" swimlane="procelnik"></task>
      <transition to="likvidatorTask" name="Odobri"></transition>
      <transition to="referent2Task" name="Vrati"></transition>
   </task-node>

   <task-node name="likvidatorTask">
      <task name="sdzwf:ulazniRacuniLikvidatorTask" swimlane="likvidator"></task>            
      <transition to="procelnikTask" name="Vrati"></transition>
      <transition to="end" name="Odobri"></transition>
   </task-node>
  
   <end-state name="end"></end-state>
  
</process-definition>

Outcomes