cancel
Showing results for 
Search instead for 
Did you mean: 

Pass 'Claimed' Task Process to other Task Process in Model

scscott
Champ in-the-making
Champ in-the-making
I am new to Activiti and still trying to figure this all out.
I am creating a QA workflow for reports. Its pretty simple workflow:

Create Report -> QA Report -> Approve/Reject -> Submit Report.

My issue is that each report is not assigned to a user but is to be Claimed. If the report is rejected it goes back to "Create Report". I am not sure how to set the "Create Report", "Submit Report" to the user that claimed the workflow. Any help would be great.

<process id="ScheduleReview" name="Schedule Review" isExecutable="true">
     <userTask id="sid-A3C9124A-222E-4549-8B1A-9E0ABE84EE20" name="QA Schedule Review" activiti:candidateGroups="qa">
          <extensionElements>
               <activiti:formProperty id="reviseReview" name="Revise the Schedule Review?" type="enum" required="true">
                    <activiti:value id="true" name="Yes"/>
                    <activiti:value id="false" name="No"/>
               </activiti:formProperty>
          </extensionElements>
     </userTask>
     <endEvent id="sid-96A146C1-74CD-42E0-98E1-A44D1F5AF20F" name="End"/>
      <userTask id="sid-6B2CB8BF-5E8A-4E7C-B2E4-0322B7BE162E" name="Finalize Report/Exhibits" activiti:candidateGroups="reviewer"/>
          <exclusiveGateway id="sid-8E221FC1-1E87-46C4-9870-BE8831F01B5A" name="Revise?"/>
     <userTask id="sid-0EB55542-5AC4-400B-BB73-B7A1E7FABA4C" name="Start Schedule Review" activiti:candidateGroups="reviewer">
          <documentation>
Project: ${projName} Update ${updateNumber} is due ${dueDate} and is ready for review.
          </documentation>
     </userTask>
     <startEvent id="sid-A8C30A8D-E9C6-498D-BCAE-DB8F287B818C">
          <extensionElements>
          <activiti:formProperty id="projName" name="Project Name:" type="string" required="true"/>
               <activiti:formProperty id="updateNumber" name="Update:" type="string" required="true"/>
               <activiti:formProperty id="dueDate" name="Due Date" type="date" datePattern="MMM-dd-yy" required="true"/>
          </extensionElements>
     </startEvent>
     <sequenceFlow id="Flow1" sourceRef="sid-A8C30A8D-E9C6-498D-BCAE-DB8F287B818C" targetRef="sid-0EB55542-5AC4-400B-BB73-B7A1E7FABA4C"/>
     <sequenceFlow id="Flow2" sourceRef="sid-0EB55542-5AC4-400B-BB73-B7A1E7FABA4C" targetRef="sid-A3C9124A-222E-4549-8B1A-9E0ABE84EE20"/>
     <sequenceFlow id="Flow3" sourceRef="sid-A3C9124A-222E-4549-8B1A-9E0ABE84EE20" targetRef="sid-8E221FC1-1E87-46C4-9870-BE8831F01B5A"/>
     <sequenceFlow id="Flow4" sourceRef="sid-6B2CB8BF-5E8A-4E7C-B2E4-0322B7BE162E" targetRef="sid-96A146C1-74CD-42E0-98E1-A44D1F5AF20F"/>
     <sequenceFlow id="FlowNo" name="No" sourceRef="sid-8E221FC1-1E87-46C4-9870-BE8831F01B5A" targetRef="sid-6B2CB8BF-5E8A-4E7C-B2E4-0322B7BE162E">
          <conditionExpression xsi:type="tFormalExpression">
               <![CDATA[ ${reviseReview == 'false'} ]]>
          </conditionExpression>
     </sequenceFlow>
     <sequenceFlow id="FlowYes" name="Yes" sourceRef="sid-8E221FC1-1E87-46C4-9870-BE8831F01B5A" targetRef="sid-0EB55542-5AC4-400B-BB73-B7A1E7FABA4C">
          <conditionExpression xsi:type="tFormalExpression">
               <![CDATA[ ${reviseReview == 'true'} ]]>
          </conditionExpression>
     </sequenceFlow>
</process>

2 REPLIES 2

hari
Star Contributor
Star Contributor
Hi Scott,

As per your description I understood that a user will claim the Create Report task from a group and completes it. when it gets rejected, the task has to go back to the user who had claimed it initially.

You will have to write a create task listener on Create Report and assign it to user or group based on some condition (Refer to: http://activiti.org/userguide/index.html#bpmnUserTaskUserCustomAssignmentTaskListeners) . Ex: Check if a process instance variable with name 'user' has any value in it. If it doesn't then consider that it is the first time its getting executed and assign it to the group which ever was defined. Now when the user claims the task and completes it, have a complete task listener and set the process instance variable 'user' to store the user who has completed it.
<code>
public class SetCompletionUser implements TaskListener{
public void notify(DelegateTask delegateTask) {
  String user = delegateTask.getAssignee();
  delegateTask.getExecution().setVariable("user", user);
}
}
</code>

If the task gets rejected, flow goes back to Create Report's create task listener where it checks if user is present in the flow. Since the user exists now, Instead of assigning the task to the group, assign it to the user.

scscott
Champ in-the-making
Champ in-the-making
You are correct that I want "Start Schedule Review" and "Finalize Report/Exhibits" to be the user who claims the workflow. This will be the same for the user who claims the "QA Schedule Review" if there are multiple QA reviews.

Adding the task listener seems pretty straight forward. My issue is adding a custom class. I am having trouble locating documentation on how to do that. I am fumbling through java and all the components you need to put together. If you could point me in the correct direction that would be much appreciated. Also, delegateTask is a variable?