close

Filter

loading table of contents...

Workflow Manual / Version 2210

Table Of Contents

5.6 Programming Performer Policies

Performer policies control to which users a task instance should be offered. A performers policy calculates this set of users based on the users which have permission to accept the task instance defined by the rights policy. The performer policy is called by the CoreMedia Workflow Server.

A performers policy may optionally support:

  • Users who must be excluded from the offer (determined by the ExcludePerformer or ExcludeUser action).

  • Users who may be preferred (determined by the PreferPerformer action).

  • Groups which may be preferred.

  • Users who actively reject the offered task instance.

  • A single user who must perform the task (which will force an accept of the instance as soon as the user logs on to the workflow server, determined by the ForceUser action)

The DefaultPerformersPolicy supports all options.

Note

Note

There is no automatic recalculation of the user sets if there are changes in the user management. This may cause the following effects:

  • New users or users assigned to new groups won't see any offers already pending.

  • Users removed from groups won't see already offered task disappear from their task lists. This is not a security problem, since the rights are checked on every access on the server.

Interface to implement

Own performer policies must implement the interface com.coremedia.workflow.WfPerformersPolicy. The important method is calculateAssignment(WfTaskInstance taskInstance, WfUser[] permittedUsers) which is called by the CoreMedia Workflow Server. It returns a WfUserAssignment object (see the Workflow API documentation for details).

Default implementation

If you only want to adapt the default performer policy to your needs it would be easier to subclass the default performer policy DefaultPerformersPolicy and to override the appropriate methods.

Defining the policy in the workflow definition

In Example 5.12, “Defining a performer policy in the workflow definition” you see how to define your own performer policy in the workflow definition.

<Workflow>
    <Process name="PerformerTest" startTask="One">
    .
    .
    <UserTask name="One" final="true">
        <Performers policyClass=
                 "com.coremedia.example.DemoPerformersPolicy"/>
        <Rights>
            <Grant group="composer-role" 
                   rights="read, accept, complete"/>
        </Rights>
    </UserTask>
    .
    .
    </Process>
</Workflow>

Example 5.12. Defining a performer policy in the workflow definition


Customize the performer policy

See Example 5.13, “Invoking a performer policy” for a customization of the default performer policy which performs a very simple task. It calls the default performer policy and cuts off the last user from the result.

1:  package com.coremedia.example.policy;
2:  
3:  import com.coremedia.workflow.*;
4:  import com.coremedia.workflow.common.policies.
     DefaultPerformersPolicy;
5:  
6:  public class DemoPerformersPolicy 
     extends DefaultPerformersPolicy {
7:    
8:    public String toString() {
9:      return "DemoPerformersPolicy()";
10:   } 
11:   
12:   public String getName() {
13:     return "DemoPerformersPolicy";
14:   }
15:   
16:   public String getDescription() {
17:     return "quite simple policy implementation";
18:   } 
19:   
20:   public WfUserAssignment 
21:   calculateAssignment(WfTaskInstance taskInstance, 
         WfUser[] permittedUsers) throws WfException {
22:     WfUserAssignment userAssignment = 
23:     super.calculateAssignment(taskInstance, permittedUsers);
24: 
25:     WfUser[] users = userAssignment.getUsers();
26:     WfUser[] result = new WfUser[users.length-1];
27:     if (result.length < 1) {
28:       result = users;
29:     } else {
30:       System.arraycopy(users, 0, result, 0, result.length);
31:     }
32:     return new WfUserAssignment(result, false);
33:   } 
34: } 

Example 5.13. Invoking a performer policy


Line 1 - 4: Your package and the packages to import.

Line 6: You subclass DefaultPerformersPolicy for convenience.

Line 12 -14: Return the name of the policy.

Line 16 - 18: Return a description of the policy.

Line 20 - 33: The most important method which is called by the workflow server.

Line 20- 21: On call, the workflow server passes a WfTaskInstance and the WfUsers to the method. WfUsers contains all users which are allowed to accept the task.

Line 22 -23: At first you call the method calculateAssignment method of the super class, because the aim of this example policy is to modify the default result.

Line 25: Prepare the manipulation of the result by getting the WfUser from the WfUserAssignment.

Line 26: Prepare a new WfUser array which should keep the resulting users. Remember, you only want to get rid of the last user, so the length of the array is users.length-1.

Line 27 - 29: If the result contains no user, this result is returned.

Line 30: Otherwise, all users but the last are copied from the default result array to the returned array.

Line 32: The result array is returned to the workflow server. The second parameter determines that the selected user is not forced to accept the task.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.